mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge commit '5597eacb4eaeb0cd55cea0dfa8a0259c3a7febf1'
This commit is contained in:
commit
c2ef0d70a7
@ -41,6 +41,7 @@ public class ActionSheetPeerItem: ActionSheetItem {
|
||||
}
|
||||
|
||||
node.setItem(self)
|
||||
node.requestLayoutUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,8 +133,6 @@ public class ActionSheetPeerItemNode: ActionSheetItemNode {
|
||||
}
|
||||
self.accessibilityArea.accessibilityTraits = accessibilityTraits
|
||||
self.accessibilityArea.accessibilityLabel = item.title
|
||||
|
||||
self.setNeedsLayout()
|
||||
}
|
||||
|
||||
public override func updateLayout(constrainedSize: CGSize, transition: ContainedViewLayoutTransition) -> CGSize {
|
||||
@ -155,7 +154,7 @@ public class ActionSheetPeerItemNode: ActionSheetItemNode {
|
||||
|
||||
self.accessibilityArea.frame = CGRect(origin: CGPoint(), size: size)
|
||||
|
||||
self.updateInternalLayout(size)
|
||||
self.updateInternalLayout(size, constrainedSize: constrainedSize)
|
||||
return size
|
||||
}
|
||||
|
||||
|
@ -133,6 +133,7 @@ public class BotCheckoutPaymentMethodItem: ActionSheetItem {
|
||||
}
|
||||
|
||||
node.setItem(self)
|
||||
node.requestLayoutUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
@ -209,8 +210,6 @@ public class BotCheckoutPaymentMethodItemNode: ActionSheetItemNode {
|
||||
} else {
|
||||
self.checkNode.isHidden = true
|
||||
}
|
||||
|
||||
self.setNeedsLayout()
|
||||
}
|
||||
|
||||
public override func updateLayout(constrainedSize: CGSize, transition: ContainedViewLayoutTransition) -> CGSize {
|
||||
@ -237,7 +236,7 @@ public class BotCheckoutPaymentMethodItemNode: ActionSheetItemNode {
|
||||
self.checkNode.frame = CGRect(origin: CGPoint(x: floor((44.0 - image.size.width) / 2.0), y: floor((size.height - image.size.height) / 2.0)), size: image.size)
|
||||
}
|
||||
|
||||
self.updateInternalLayout(size)
|
||||
self.updateInternalLayout(size, constrainedSize: constrainedSize)
|
||||
return size
|
||||
}
|
||||
|
||||
|
@ -109,6 +109,7 @@ public class BotCheckoutPaymentShippingOptionItem: ActionSheetItem {
|
||||
}
|
||||
|
||||
node.setItem(self)
|
||||
node.requestLayoutUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,8 +187,6 @@ public class BotCheckoutPaymentShippingOptionItemNode: ActionSheetItemNode {
|
||||
} else {
|
||||
self.checkNode.isHidden = true
|
||||
}
|
||||
|
||||
self.setNeedsLayout()
|
||||
}
|
||||
|
||||
public override func updateLayout(constrainedSize: CGSize, transition: ContainedViewLayoutTransition) -> CGSize {
|
||||
@ -209,7 +208,7 @@ public class BotCheckoutPaymentShippingOptionItemNode: ActionSheetItemNode {
|
||||
self.checkNode.frame = CGRect(origin: CGPoint(x: floor((44.0 - image.size.width) / 2.0), y: floor((size.height - image.size.height) / 2.0)), size: image.size)
|
||||
}
|
||||
|
||||
self.updateInternalLayout(size)
|
||||
self.updateInternalLayout(size, constrainedSize: constrainedSize)
|
||||
return size
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ private final class DateSelectionActionSheetItemNode: ActionSheetItemNode {
|
||||
|
||||
self.pickerView.frame = CGRect(origin: CGPoint(), size: size)
|
||||
|
||||
self.updateInternalLayout(size)
|
||||
self.updateInternalLayout(size, constrainedSize: constrainedSize)
|
||||
return size
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ private final class DeleteChatPeerActionSheetItemNode: ActionSheetItemNode {
|
||||
let size = CGSize(width: constrainedSize.width, height: topInset + avatarSize + textSpacing + textSize.height + bottomInset)
|
||||
self.accessibilityArea.frame = CGRect(origin: CGPoint(), size: size)
|
||||
|
||||
self.updateInternalLayout(size)
|
||||
self.updateInternalLayout(size, constrainedSize: constrainedSize)
|
||||
return size
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ public class ActionSheetButtonItem: ActionSheetItem {
|
||||
}
|
||||
|
||||
node.setItem(self)
|
||||
node.requestLayoutUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,8 +149,6 @@ public class ActionSheetButtonNode: ActionSheetItemNode {
|
||||
accessibilityTraits.insert(.notEnabled)
|
||||
}
|
||||
self.accessibilityArea.accessibilityTraits = accessibilityTraits
|
||||
|
||||
self.setNeedsLayout()
|
||||
}
|
||||
|
||||
public override func updateLayout(constrainedSize: CGSize, transition: ContainedViewLayoutTransition) -> CGSize {
|
||||
@ -161,7 +160,7 @@ public class ActionSheetButtonNode: ActionSheetItemNode {
|
||||
self.label.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((size.width - labelSize.width) / 2.0), y: floorToScreenPixels((size.height - labelSize.height) / 2.0)), size: labelSize)
|
||||
self.accessibilityArea.frame = CGRect(origin: CGPoint(), size: size)
|
||||
|
||||
self.updateInternalLayout(size)
|
||||
self.updateInternalLayout(size, constrainedSize: constrainedSize)
|
||||
return size
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@ public class ActionSheetCheckboxItem: ActionSheetItem {
|
||||
}
|
||||
|
||||
node.setItem(self)
|
||||
node.requestLayoutUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,8 +133,6 @@ public class ActionSheetCheckboxItemNode: ActionSheetItemNode {
|
||||
accessibilityTraits.insert(.selected)
|
||||
}
|
||||
self.accessibilityArea.accessibilityTraits = accessibilityTraits
|
||||
|
||||
self.setNeedsLayout()
|
||||
}
|
||||
|
||||
public override func updateLayout(constrainedSize: CGSize, transition: ContainedViewLayoutTransition) -> CGSize {
|
||||
@ -159,7 +158,7 @@ public class ActionSheetCheckboxItemNode: ActionSheetItemNode {
|
||||
|
||||
self.accessibilityArea.frame = CGRect(origin: CGPoint(), size: size)
|
||||
|
||||
self.updateInternalLayout(size)
|
||||
self.updateInternalLayout(size, constrainedSize: constrainedSize)
|
||||
return size
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,9 @@ final class ActionSheetItemGroupsContainerNode: ASDisplayNode {
|
||||
var theme: ActionSheetControllerTheme {
|
||||
didSet {
|
||||
self.setGroups(self.groups)
|
||||
self.setNeedsLayout()
|
||||
if let size = self.validSize {
|
||||
let _ = self.updateLayout(constrainedSize: size, transition: .immediate)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,6 +18,8 @@ final class ActionSheetItemGroupsContainerNode: ASDisplayNode {
|
||||
|
||||
var requestLayout: (() -> Void)?
|
||||
|
||||
private var validSize: CGSize?
|
||||
|
||||
init(theme: ActionSheetControllerTheme) {
|
||||
self.theme = theme
|
||||
|
||||
@ -46,6 +50,8 @@ final class ActionSheetItemGroupsContainerNode: ASDisplayNode {
|
||||
}
|
||||
|
||||
func updateLayout(constrainedSize: CGSize, transition: ContainedViewLayoutTransition) -> CGSize {
|
||||
self.validSize = constrainedSize
|
||||
|
||||
var groupsHeight: CGFloat = 0.0
|
||||
|
||||
var calculatedSizes: [CGSize] = []
|
||||
|
@ -11,6 +11,8 @@ open class ActionSheetItemNode: ASDisplayNode {
|
||||
|
||||
public var requestLayout: (() -> Void)?
|
||||
|
||||
private var validSize: CGSize?
|
||||
|
||||
public init(theme: ActionSheetControllerTheme) {
|
||||
self.theme = theme
|
||||
|
||||
@ -28,13 +30,21 @@ open class ActionSheetItemNode: ASDisplayNode {
|
||||
|
||||
open func updateLayout(constrainedSize: CGSize, transition: ContainedViewLayoutTransition) -> CGSize {
|
||||
let size = CGSize(width: constrainedSize.width, height: 57.0)
|
||||
self.updateInternalLayout(size)
|
||||
self.updateInternalLayout(size, constrainedSize: constrainedSize)
|
||||
return size
|
||||
}
|
||||
|
||||
public func updateInternalLayout(_ calculatedSize: CGSize) {
|
||||
public func updateInternalLayout(_ calculatedSize: CGSize, constrainedSize: CGSize) {
|
||||
self.validSize = constrainedSize
|
||||
|
||||
self.backgroundNode.frame = CGRect(origin: CGPoint(), size: calculatedSize)
|
||||
self.overflowSeparatorNode.frame = CGRect(origin: CGPoint(x: 0.0, y: calculatedSize.height), size: CGSize(width: calculatedSize.width, height: UIScreenPixel))
|
||||
self.overflowSeparatorNode.isHidden = !self.hasSeparator
|
||||
}
|
||||
|
||||
public func requestLayoutUpdate() {
|
||||
if let size = self.validSize {
|
||||
let _ = self.updateLayout(constrainedSize: size, transition: .immediate)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ public class ActionSheetSwitchItem: ActionSheetItem {
|
||||
}
|
||||
|
||||
node.setItem(self)
|
||||
node.requestLayoutUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,8 +100,6 @@ public class ActionSheetSwitchNode: ActionSheetItemNode {
|
||||
accessibilityTraits.insert(.selected)
|
||||
}
|
||||
self.accessibilityArea.accessibilityTraits = accessibilityTraits
|
||||
|
||||
self.setNeedsLayout()
|
||||
}
|
||||
|
||||
public override func updateLayout(constrainedSize: CGSize, transition: ContainedViewLayoutTransition) -> CGSize {
|
||||
@ -116,7 +115,7 @@ public class ActionSheetSwitchNode: ActionSheetItemNode {
|
||||
|
||||
self.accessibilityArea.frame = CGRect(origin: CGPoint(), size: size)
|
||||
|
||||
self.updateInternalLayout(size)
|
||||
self.updateInternalLayout(size, constrainedSize: constrainedSize)
|
||||
return size
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ public class ActionSheetTextItem: ActionSheetItem {
|
||||
}
|
||||
|
||||
node.setItem(self)
|
||||
node.requestLayoutUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,8 +66,6 @@ public class ActionSheetTextNode: ActionSheetItemNode {
|
||||
|
||||
self.label.attributedText = NSAttributedString(string: item.title, font: defaultFont, textColor: self.theme.secondaryTextColor, paragraphAlignment: .center)
|
||||
self.accessibilityArea.accessibilityLabel = item.title
|
||||
|
||||
self.setNeedsLayout()
|
||||
}
|
||||
|
||||
public override func updateLayout(constrainedSize: CGSize, transition: ContainedViewLayoutTransition) -> CGSize {
|
||||
@ -77,7 +76,7 @@ public class ActionSheetTextNode: ActionSheetItemNode {
|
||||
|
||||
self.accessibilityArea.frame = CGRect(origin: CGPoint(), size: size)
|
||||
|
||||
self.updateInternalLayout(size)
|
||||
self.updateInternalLayout(size, constrainedSize: constrainedSize)
|
||||
return size
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ private final class OpenInActionSheetItemNode: ActionSheetItemNode {
|
||||
}
|
||||
}
|
||||
|
||||
self.updateInternalLayout(size)
|
||||
self.updateInternalLayout(size, constrainedSize: constrainedSize)
|
||||
return size
|
||||
}
|
||||
}
|
||||
|
@ -151,15 +151,15 @@ private enum ChannelBlacklistEntry: ItemListNodeEntry {
|
||||
func item(presentationData: ItemListPresentationData, arguments: Any) -> ListViewItem {
|
||||
let arguments = arguments as! ChannelBlacklistControllerArguments
|
||||
switch self {
|
||||
case let .add(theme, text):
|
||||
case let .add(_, text):
|
||||
return ItemListActionItem(presentationData: presentationData, title: text, kind: .generic, alignment: .natural, sectionId: self.section, style: .blocks, action: {
|
||||
arguments.addPeer()
|
||||
})
|
||||
case let .addInfo(theme, text):
|
||||
case let .addInfo(_, text):
|
||||
return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section)
|
||||
case let .bannedHeader(theme, text):
|
||||
case let .bannedHeader(_, text):
|
||||
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
|
||||
case let .peerItem(theme, strings, dateTimeFormat, nameDisplayOrder, _, participant, editing, enabled):
|
||||
case let .peerItem(_, strings, dateTimeFormat, nameDisplayOrder, _, participant, editing, enabled):
|
||||
var text: ItemListPeerItemText = .none
|
||||
switch participant.participant {
|
||||
case let .member(_, _, _, banInfo, _):
|
||||
|
@ -107,7 +107,7 @@ private final class ChannelDiscussionGroupActionSheetItemNode: ActionSheetItemNo
|
||||
|
||||
let size = CGSize(width: constrainedSize.width, height: topInset + avatarSize + textSpacing + textSize.height + bottomInset)
|
||||
|
||||
self.updateInternalLayout(size)
|
||||
self.updateInternalLayout(size, constrainedSize: constrainedSize)
|
||||
return size
|
||||
}
|
||||
}
|
||||
|
@ -327,81 +327,81 @@ private enum ChannelInfoEntry: ItemListNodeEntry {
|
||||
func item(presentationData: ItemListPresentationData, arguments: Any) -> ListViewItem {
|
||||
let arguments = arguments as! ChannelInfoControllerArguments
|
||||
switch self {
|
||||
case let .info(theme, strings, dateTimeFormat, peer, cachedData, state, updatingAvatar):
|
||||
case let .info(_, _, dateTimeFormat, peer, cachedData, state, updatingAvatar):
|
||||
return ItemListAvatarAndNameInfoItem(accountContext: arguments.context, presentationData: presentationData, dateTimeFormat: dateTimeFormat, mode: .generic, peer: peer, presence: nil, cachedData: cachedData, state: state, sectionId: self.section, style: .plain, editingNameUpdated: { editingName in
|
||||
arguments.updateEditingName(editingName)
|
||||
}, avatarTapped: {
|
||||
arguments.tapAvatarAction()
|
||||
}, context: arguments.avatarAndNameInfoContext, updatingImage: updatingAvatar)
|
||||
case let .about(theme, text, value):
|
||||
case let .about(_, text, value):
|
||||
return ItemListTextWithLabelItem(presentationData: presentationData, label: text, text: foldMultipleLineBreaks(value), enabledEntityTypes: [.allUrl, .mention, .hashtag], multiline: true, sectionId: self.section, action: nil, longTapAction: {
|
||||
arguments.displayContextMenu(ChannelInfoEntryTag.about, value)
|
||||
}, linkItemAction: { action, itemLink in
|
||||
arguments.aboutLinkAction(action, itemLink)
|
||||
}, tag: ChannelInfoEntryTag.about)
|
||||
case let .addressName(theme, text, value):
|
||||
case let .addressName(_, text, value):
|
||||
return ItemListTextWithLabelItem(presentationData: presentationData, label: text, text: "https://t.me/\(value)", textColor: .accent, enabledEntityTypes: [], multiline: false, sectionId: self.section, action: {
|
||||
arguments.displayAddressNameContextMenu("https://t.me/\(value)")
|
||||
}, longTapAction: {
|
||||
arguments.displayContextMenu(ChannelInfoEntryTag.link, "https://t.me/\(value)")
|
||||
}, tag: ChannelInfoEntryTag.link)
|
||||
case let .channelPhotoSetup(theme, text):
|
||||
case let .channelPhotoSetup(_, text):
|
||||
return ItemListActionItem(presentationData: presentationData, title: text, kind: .generic, alignment: .natural, sectionId: self.section, style: .plain, action: {
|
||||
arguments.changeProfilePhoto()
|
||||
})
|
||||
case let .channelTypeSetup(theme, text, value):
|
||||
case let .channelTypeSetup(_, text, value):
|
||||
return ItemListDisclosureItem(presentationData: presentationData, title: text, label: value, sectionId: self.section, style: .plain, action: {
|
||||
arguments.openChannelTypeSetup()
|
||||
})
|
||||
case let .discussionGroupSetup(theme, text, value):
|
||||
case let .discussionGroupSetup(_, text, value):
|
||||
return ItemListDisclosureItem(presentationData: presentationData, title: text, label: value, sectionId: self.section, style: .plain, action: {
|
||||
arguments.openDiscussionGroupSetup()
|
||||
})
|
||||
case let .discussionGroupSetupInfo(theme, text):
|
||||
case let .discussionGroupSetupInfo(_, text):
|
||||
return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section)
|
||||
case let .channelDescriptionSetup(theme, placeholder, value):
|
||||
case let .channelDescriptionSetup(_, placeholder, value):
|
||||
return ItemListMultilineInputItem(presentationData: presentationData, text: value, placeholder: placeholder, maxLength: ItemListMultilineInputItemTextLimit(value: 255, display: true), sectionId: self.section, style: .plain, textUpdated: { updatedText in
|
||||
arguments.updateEditingDescriptionText(updatedText)
|
||||
})
|
||||
case let .admins(theme, text, value):
|
||||
case let .admins(_, text, value):
|
||||
return ItemListDisclosureItem(presentationData: presentationData, title: text, label: value, sectionId: self.section, style: .plain, action: {
|
||||
arguments.openAdmins()
|
||||
})
|
||||
case let .members(theme, text, value):
|
||||
case let .members(_, text, value):
|
||||
return ItemListDisclosureItem(presentationData: presentationData, title: text, label: value, sectionId: self.section, style: .plain, action: {
|
||||
arguments.openMembers()
|
||||
})
|
||||
case let .banned(theme, text, value):
|
||||
case let .banned(_, text, value):
|
||||
return ItemListDisclosureItem(presentationData: presentationData, title: text, label: value, sectionId: self.section, style: .plain, action: {
|
||||
arguments.openBanned()
|
||||
})
|
||||
case let .signMessages(theme, text, value):
|
||||
case let .signMessages(_, text, value):
|
||||
return ItemListSwitchItem(presentationData: presentationData, title: text, value: value, sectionId: self.section, style: .plain, updated: { updated in
|
||||
arguments.toggleSignatures(updated)
|
||||
})
|
||||
case let .signInfo(theme, text):
|
||||
case let .signInfo(_, text):
|
||||
return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section, style: .plain)
|
||||
case let .sharedMedia(theme, text):
|
||||
case let .sharedMedia(_, text):
|
||||
return ItemListDisclosureItem(presentationData: presentationData, title: text, label: "", sectionId: self.section, style: .plain, action: {
|
||||
arguments.openSharedMedia()
|
||||
})
|
||||
case let .stats(theme, text):
|
||||
case let .stats(_, text):
|
||||
return ItemListDisclosureItem(presentationData: presentationData, title: text, label: "", sectionId: self.section, style: .plain, action: {
|
||||
arguments.openStats()
|
||||
})
|
||||
case let .notifications(theme, text, value):
|
||||
case let .notifications(_, text, value):
|
||||
return ItemListDisclosureItem(presentationData: presentationData, title: text, label: value, sectionId: self.section, style: .plain, action: {
|
||||
arguments.changeNotificationMuteSettings()
|
||||
})
|
||||
case let .report(theme, text):
|
||||
case let .report(_, text):
|
||||
return ItemListActionItem(presentationData: presentationData, title: text, kind: .generic, alignment: .natural, sectionId: self.section, style: .plain, action: {
|
||||
arguments.reportChannel()
|
||||
})
|
||||
case let .leave(theme, text):
|
||||
case let .leave(_, text):
|
||||
return ItemListActionItem(presentationData: presentationData, title: text, kind: .destructive, alignment: .natural, sectionId: self.section, style: .plain, action: {
|
||||
arguments.leaveChannel()
|
||||
})
|
||||
case let .deleteChannel(theme, text):
|
||||
case let .deleteChannel(_, text):
|
||||
return ItemListActionItem(presentationData: presentationData, title: text, kind: .destructive, alignment: .natural, sectionId: self.section, style: .plain, action: {
|
||||
arguments.deleteChannel()
|
||||
})
|
||||
@ -529,7 +529,7 @@ private func channelInfoEntries(account: Account, presentationData: Presentation
|
||||
}
|
||||
}
|
||||
|
||||
if let _ = state.editingState, let adminRights = peer.adminRights {
|
||||
if let _ = state.editingState, let _ = peer.adminRights {
|
||||
let discussionGroupTitle: String?
|
||||
if let cachedData = view.cachedData as? CachedChannelData {
|
||||
if case let .known(maybeLinkedDiscussionPeerId) = cachedData.linkedDiscussionPeerId, let linkedDiscussionPeerId = maybeLinkedDiscussionPeerId, let peer = view.peers[linkedDiscussionPeerId] {
|
||||
@ -935,22 +935,13 @@ public func channelInfoController(context: AccountContext, peerId: PeerId) -> Vi
|
||||
}
|
||||
}
|
||||
|
||||
var canManageChannel = false
|
||||
if let peer = peer as? TelegramChannel {
|
||||
if peer.flags.contains(.isCreator) {
|
||||
canManageChannel = true
|
||||
} else if let adminRights = peer.adminRights {
|
||||
canManageChannel = true
|
||||
}
|
||||
}
|
||||
|
||||
var canEditChannel = false
|
||||
var hasSomethingToEdit = false
|
||||
if let peer = view.peers[view.peerId] as? TelegramChannel {
|
||||
canEditChannel = peer.hasPermission(.changeInfo)
|
||||
if canEditChannel {
|
||||
hasSomethingToEdit = true
|
||||
} else if let adminRights = peer.adminRights {
|
||||
} else if let _ = peer.adminRights {
|
||||
if let cachedData = view.cachedData as? CachedChannelData, case let .known(maybeLinkedDiscussionPeerId) = cachedData.linkedDiscussionPeerId, let _ = maybeLinkedDiscussionPeerId {
|
||||
hasSomethingToEdit = true
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ private enum GroupStickerPackEntry: ItemListNodeEntry {
|
||||
func item(presentationData: ItemListPresentationData, arguments: Any) -> ListViewItem {
|
||||
let arguments = arguments as! GroupStickerPackSetupControllerArguments
|
||||
switch self {
|
||||
case let .search(theme, strings, prefix, placeholder, value):
|
||||
case let .search(theme, _, prefix, placeholder, value):
|
||||
return ItemListSingleLineInputItem(presentationData: presentationData, title: NSAttributedString(string: prefix, textColor: theme.list.itemPrimaryTextColor), text: value, placeholder: placeholder, type: .regular(capitalization: false, autocorrection: false), spacing: 0.0, clearType: .always, tag: nil, sectionId: self.section, textUpdated: { value in
|
||||
arguments.updateSearchText(value)
|
||||
}, processPaste: { text in
|
||||
@ -223,11 +223,11 @@ private enum GroupStickerPackEntry: ItemListNodeEntry {
|
||||
}
|
||||
return text
|
||||
}, action: {})
|
||||
case let .searchInfo(theme, text):
|
||||
case let .searchInfo(_, text):
|
||||
return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section, linkAction: nil)
|
||||
case let .packsTitle(theme, text):
|
||||
case let .packsTitle(_, text):
|
||||
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
|
||||
case let .pack(_, theme, strings, info, topItem, count, playAnimatedStickers, selected):
|
||||
case let .pack(_, _, _, info, topItem, count, playAnimatedStickers, selected):
|
||||
return ItemListStickerPackItem(presentationData: presentationData, account: arguments.account, packInfo: info, itemCount: count, topItem: topItem, unread: false, control: selected ? .selection : .none, editing: ItemListStickerPackItemEditing(editable: false, editing: false, revealed: false, reorderable: false), enabled: true, playAnimatedStickers: playAnimatedStickers, sectionId: self.section, action: {
|
||||
if selected {
|
||||
arguments.openStickerPack(info)
|
||||
|
@ -116,7 +116,7 @@ private final class PeerBanTimeoutActionSheetItemNode: ActionSheetItemNode {
|
||||
|
||||
self.pickerView.frame = CGRect(origin: CGPoint(), size: size)
|
||||
|
||||
self.updateInternalLayout(size)
|
||||
self.updateInternalLayout(size, constrainedSize: constrainedSize)
|
||||
return size
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ private final class ReportPeerDetailsActionSheetItemNode: ActionSheetItemNode {
|
||||
|
||||
let size = CGSize(width: constrainedSize.width, height: inputHeight)
|
||||
|
||||
self.updateInternalLayout(size)
|
||||
self.updateInternalLayout(size, constrainedSize: constrainedSize)
|
||||
return size
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ private final class ReportPeerHeaderActionSheetItemNode: ActionSheetItemNode {
|
||||
let size = CGSize(width: constrainedSize.width, height: topInset + iconSize.height + textSpacing + textSize.height + bottomInset)
|
||||
self.accessibilityArea.frame = CGRect(origin: CGPoint(), size: size)
|
||||
|
||||
self.updateInternalLayout(size)
|
||||
self.updateInternalLayout(size, constrainedSize: constrainedSize)
|
||||
return size
|
||||
}
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ private final class ProxyServerInfoItemNode: ActionSheetItemNode {
|
||||
offset += 36.0
|
||||
}
|
||||
|
||||
self.updateInternalLayout(size)
|
||||
self.updateInternalLayout(size, constrainedSize: constrainedSize)
|
||||
return size
|
||||
}
|
||||
}
|
||||
@ -368,7 +368,7 @@ private final class ProxyServerActionItemNode: ActionSheetItemNode {
|
||||
self.titleNode.frame = titleFrame
|
||||
self.activityIndicator.frame = CGRect(origin: CGPoint(x: 14.0, y: titleFrame.minY - 0.0), size: activitySize)
|
||||
|
||||
self.updateInternalLayout(size)
|
||||
self.updateInternalLayout(size, constrainedSize: constrainedSize)
|
||||
return size
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ private final class ThemeAutoNightTimeSelectionActionSheetItemNode: ActionSheetI
|
||||
|
||||
self.pickerView.frame = CGRect(origin: CGPoint(), size: size)
|
||||
|
||||
self.updateInternalLayout(size)
|
||||
self.updateInternalLayout(size, constrainedSize: constrainedSize)
|
||||
return size
|
||||
}
|
||||
|
||||
|
@ -15,11 +15,11 @@ public struct PixelDimensions: Equatable {
|
||||
#if os(iOS)
|
||||
|
||||
public extension PixelDimensions {
|
||||
public init(_ size: CGSize) {
|
||||
init(_ size: CGSize) {
|
||||
self.init(width: Int32(size.width), height: Int32(size.height))
|
||||
}
|
||||
|
||||
public var cgSize: CGSize {
|
||||
var cgSize: CGSize {
|
||||
return CGSize(width: CGFloat(self.width), height: CGFloat(self.height))
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ public class LocationBroadcastActionSheetItem: ActionSheetItem {
|
||||
}
|
||||
|
||||
node.setItem(self)
|
||||
node.requestLayoutUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,8 +109,6 @@ public class LocationBroadcastActionSheetItemNode: ActionSheetItemNode {
|
||||
self.avatarNode.setPeer(context: item.context, theme: (item.context.sharedContext.currentPresentationData.with { $0 }).theme, peer: item.peer)
|
||||
|
||||
self.timerNode.update(backgroundColor: self.theme.controlAccentColor.withAlphaComponent(0.4), foregroundColor: self.theme.controlAccentColor, textColor: self.theme.controlAccentColor, beginTimestamp: item.beginTimestamp, timeout: item.timeout, strings: item.strings)
|
||||
|
||||
self.setNeedsLayout()
|
||||
}
|
||||
|
||||
public override func updateLayout(constrainedSize: CGSize, transition: ContainedViewLayoutTransition) -> CGSize {
|
||||
@ -128,7 +127,7 @@ public class LocationBroadcastActionSheetItemNode: ActionSheetItemNode {
|
||||
let timerSize = CGSize(width: 28.0, height: 28.0)
|
||||
self.timerNode.frame = CGRect(origin: CGPoint(x: size.width - 16.0 - timerSize.width, y: floorToScreenPixels((size.height - timerSize.height) / 2.0)), size: timerSize)
|
||||
|
||||
self.updateInternalLayout(size)
|
||||
self.updateInternalLayout(size, constrainedSize: constrainedSize)
|
||||
return size
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ public class CallRouteActionSheetItem: ActionSheetItem {
|
||||
}
|
||||
|
||||
node.setItem(self)
|
||||
node.requestLayoutUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,8 +133,6 @@ public class CallRouteActionSheetItemNode: ActionSheetItemNode {
|
||||
}
|
||||
self.accessibilityArea.accessibilityTraits = accessibilityTraits
|
||||
self.accessibilityArea.accessibilityLabel = item.title
|
||||
|
||||
self.setNeedsLayout()
|
||||
}
|
||||
|
||||
public override func updateLayout(constrainedSize: CGSize, transition: ContainedViewLayoutTransition) -> CGSize {
|
||||
@ -152,7 +151,7 @@ public class CallRouteActionSheetItemNode: ActionSheetItemNode {
|
||||
self.checkNode.frame = CGRect(origin: CGPoint(x: size.width - image.size.width - 13.0, y: floor((size.height - image.size.height) / 2.0)), size: image.size)
|
||||
}
|
||||
|
||||
self.updateInternalLayout(size)
|
||||
self.updateInternalLayout(size, constrainedSize: constrainedSize)
|
||||
return size
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ import SwiftSignalKit
|
||||
|
||||
public func forwardGameWithScore(account: Account, messageId: MessageId, to peerId: PeerId) -> Signal<Void, NoError> {
|
||||
return account.postbox.transaction { transaction -> Signal<Void, NoError> in
|
||||
if let message = transaction.getMessage(messageId), let fromPeer = transaction.getPeer(messageId.peerId), let fromInputPeer = apiInputPeer(fromPeer), let toPeer = transaction.getPeer(peerId), let toInputPeer = apiInputPeer(toPeer) {
|
||||
if let _ = transaction.getMessage(messageId), let fromPeer = transaction.getPeer(messageId.peerId), let fromInputPeer = apiInputPeer(fromPeer), let toPeer = transaction.getPeer(peerId), let toInputPeer = apiInputPeer(toPeer) {
|
||||
return account.network.request(Api.functions.messages.forwardMessages(flags: 1 << 8, fromPeer: fromInputPeer, id: [messageId.id], randomId: [arc4random64()], toPeer: toInputPeer, scheduleDate: nil))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.Updates?, NoError> in
|
||||
|
@ -79,7 +79,7 @@ extension InstantPageTableRow {
|
||||
extension InstantPageRelatedArticle {
|
||||
convenience init(apiRelatedArticle: Api.PageRelatedArticle) {
|
||||
switch apiRelatedArticle {
|
||||
case let .pageRelatedArticle(flags, url, webpageId, title, description, photoId, author, publishedDate):
|
||||
case let .pageRelatedArticle(_, url, webpageId, title, description, photoId, author, publishedDate):
|
||||
var posterPhotoId: MediaId?
|
||||
if let photoId = photoId {
|
||||
posterPhotoId = MediaId(namespace: Namespaces.Media.CloudImage, id: photoId)
|
||||
@ -177,14 +177,14 @@ extension InstantPage {
|
||||
let url: String
|
||||
let views: Int32?
|
||||
switch apiPage {
|
||||
case let .page(page):
|
||||
url = page.url
|
||||
blocks = page.blocks
|
||||
photos = page.photos
|
||||
files = page.documents
|
||||
isComplete = (page.flags & (1 << 0)) == 0
|
||||
rtl = (page.flags & (1 << 1)) != 0
|
||||
views = page.views
|
||||
case let .page(flags, pageUrl, pageBlocks, pagePhotos, pageDocuments, pageViews):
|
||||
url = pageUrl
|
||||
blocks = pageBlocks
|
||||
photos = pagePhotos
|
||||
files = pageDocuments
|
||||
isComplete = (flags & (1 << 0)) == 0
|
||||
rtl = (flags & (1 << 1)) != 0
|
||||
views = pageViews
|
||||
}
|
||||
var media: [MediaId: Media] = [:]
|
||||
for photo in photos {
|
||||
|
@ -584,8 +584,6 @@ private func decryptedAttributes73(_ attributes: [TelegramMediaFileAttribute], t
|
||||
break
|
||||
case .hintIsValidated:
|
||||
break
|
||||
case .hintIsValidated:
|
||||
break
|
||||
}
|
||||
}
|
||||
return result
|
||||
|
@ -99,7 +99,7 @@ public func preloadedFeaturedStickerSet(network: Network, postbox: Postbox, id:
|
||||
if let result = result {
|
||||
return postbox.transaction { transaction -> Void in
|
||||
if let pack = transaction.getOrderedItemListItem(collectionId: Namespaces.OrderedItemList.CloudFeaturedStickerPacks, itemId: FeaturedStickerPackItemId(id.id).rawValue)?.contents as? FeaturedStickerPackItem {
|
||||
var items = result.items.map({ $0 as? StickerPackItem }).flatMap({ $0 })
|
||||
var items = result.items.map({ $0 as? StickerPackItem }).compactMap({ $0 })
|
||||
if items.count > 5 {
|
||||
items.removeSubrange(5 ..< items.count)
|
||||
}
|
||||
|
@ -88,10 +88,10 @@ public func stickerPacksAttachedToMedia(account: Account, media: AnyMediaReferen
|
||||
|> mapToSignal { reference -> Signal<[Api.StickerSetCovered], MTRpcError> in
|
||||
let inputMedia: Api.InputStickeredMedia
|
||||
if let resource = reference.updatedResource as? TelegramCloudMediaResourceWithFileReference, let updatedReference = resource.fileReference {
|
||||
if let imageReference = media.concrete(TelegramMediaImage.self), let reference = imageReference.media.reference, case let .cloud(imageId, accessHash, fileReference) = reference, let representation = largestImageRepresentation(imageReference.media.representations) {
|
||||
inputMedia = .inputStickeredMediaPhoto(id: Api.InputPhoto.inputPhoto(id: imageId, accessHash: accessHash, fileReference: Buffer(data: updatedReference ?? Data())))
|
||||
if let imageReference = media.concrete(TelegramMediaImage.self), let reference = imageReference.media.reference, case let .cloud(imageId, accessHash, _) = reference, let representation = largestImageRepresentation(imageReference.media.representations) {
|
||||
inputMedia = .inputStickeredMediaPhoto(id: Api.InputPhoto.inputPhoto(id: imageId, accessHash: accessHash, fileReference: Buffer(data: updatedReference)))
|
||||
} else if let fileReference = media.concrete(TelegramMediaFile.self), let resource = fileReference.media.resource as? CloudDocumentMediaResource {
|
||||
inputMedia = .inputStickeredMediaDocument(id: Api.InputDocument.inputDocument(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: updatedReference ?? Data())))
|
||||
inputMedia = .inputStickeredMediaDocument(id: Api.InputDocument.inputDocument(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: updatedReference)))
|
||||
} else {
|
||||
return .single([])
|
||||
}
|
||||
|
@ -120,13 +120,13 @@ func apiMessagePeerId(_ messsage: Api.Message) -> PeerId? {
|
||||
case let .message(message):
|
||||
let chatPeerId = message.peerId
|
||||
return chatPeerId.peerId
|
||||
case let .messageEmpty(_, id, peerId):
|
||||
case let .messageEmpty(_, _, peerId):
|
||||
if let peerId = peerId {
|
||||
return peerId.peerId
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
case let .messageService(flags, _, fromId, chatPeerId, _, _, _, _):
|
||||
case let .messageService(_, _, _, chatPeerId, _, _, _, _):
|
||||
return chatPeerId.peerId
|
||||
}
|
||||
}
|
||||
@ -185,7 +185,7 @@ func apiMessagePeerIds(_ message: Api.Message) -> [PeerId] {
|
||||
return result
|
||||
case .messageEmpty:
|
||||
return []
|
||||
case let .messageService(flags, _, fromId, chatPeerId, _, _, action, _):
|
||||
case let .messageService(_, _, fromId, chatPeerId, _, _, action, _):
|
||||
let peerId: PeerId = chatPeerId.peerId
|
||||
var result = [peerId]
|
||||
|
||||
|
@ -54,9 +54,8 @@ public func deviceContactsImportedByCount(postbox: Postbox, contacts: [(String,
|
||||
for (id, numbers) in contacts {
|
||||
var maxCount: Int32 = 0
|
||||
for number in numbers {
|
||||
if let value = transaction.getDeviceContactImportInfo(TelegramDeviceContactImportIdentifier.phoneNumber(number).key) as? TelegramDeviceContactImportedData, case let .imported(imported) = value {
|
||||
|
||||
maxCount = max(maxCount, imported.importedByCount)
|
||||
if let value = transaction.getDeviceContactImportInfo(TelegramDeviceContactImportIdentifier.phoneNumber(number).key) as? TelegramDeviceContactImportedData, case let .imported(_, importedByCount) = value {
|
||||
maxCount = max(maxCount, importedByCount)
|
||||
}
|
||||
}
|
||||
if maxCount != 0 {
|
||||
|
@ -7,8 +7,8 @@ import SyncCore
|
||||
extension TelegramMediaWebFile {
|
||||
convenience init(_ document: Api.WebDocument) {
|
||||
switch document {
|
||||
case let .webDocument(data):
|
||||
self.init(resource: WebFileReferenceMediaResource(url: data.url, size: data.size, accessHash: data.accessHash), mimeType: data.mimeType, size: data.size, attributes: telegramMediaFileAttributesFromApiAttributes(data.attributes))
|
||||
case let .webDocument(url, accessHash, size, mimeType, attributes):
|
||||
self.init(resource: WebFileReferenceMediaResource(url: url, size: size, accessHash: accessHash), mimeType: mimeType, size: size, attributes: telegramMediaFileAttributesFromApiAttributes(attributes))
|
||||
case let .webDocumentNoProxy(url, size, mimeType, attributes):
|
||||
self.init(resource: HttpReferenceMediaResource(url: url, size: Int(size)), mimeType: mimeType, size: size, attributes: telegramMediaFileAttributesFromApiAttributes(attributes))
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import SyncCore
|
||||
|
||||
func telegramMediaWebpageAttributeFromApiWebpageAttribute(_ attribute: Api.WebPageAttribute) -> TelegramMediaWebpageAttribute? {
|
||||
switch attribute {
|
||||
case let .webPageAttributeTheme(flags, documents, settings):
|
||||
case let .webPageAttributeTheme(_, documents, settings):
|
||||
var files: [TelegramMediaFile] = []
|
||||
if let documents = documents {
|
||||
files = documents.compactMap { telegramMediaFileFromApiDocument($0) }
|
||||
|
@ -59,7 +59,7 @@ func managedTermsOfServiceUpdates(postbox: Postbox, network: Network, stateManag
|
||||
switch result {
|
||||
case let .termsOfServiceUpdate(_, termsOfService):
|
||||
updated = TermsOfServiceUpdate(apiTermsOfService: termsOfService)
|
||||
case let .termsOfServiceUpdateEmpty(expires):
|
||||
case .termsOfServiceUpdateEmpty:
|
||||
break
|
||||
}
|
||||
stateManager?.modifyTermsOfServiceUpdate { _ in
|
||||
|
@ -10,8 +10,6 @@ extension TelegramTheme {
|
||||
switch apiTheme {
|
||||
case let .theme(flags, id, accessHash, slug, title, document, settings, installCount):
|
||||
self.init(id: id, accessHash: accessHash, slug: slug, title: title, file: document.flatMap(telegramMediaFileFromApiDocument), settings: settings.flatMap(TelegramThemeSettings.init(apiThemeSettings:)), isCreator: (flags & 1 << 0) != 0, isDefault: (flags & 1 << 1) != 0, installCount: installCount)
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -49,14 +47,12 @@ extension TelegramBaseTheme {
|
||||
extension TelegramThemeSettings {
|
||||
convenience init?(apiThemeSettings: Api.ThemeSettings) {
|
||||
switch apiThemeSettings {
|
||||
case let .themeSettings(flags, baseTheme, accentColor, messageTopColor, messageBottomColor, wallpaper):
|
||||
case let .themeSettings(_, baseTheme, accentColor, messageTopColor, messageBottomColor, wallpaper):
|
||||
var messageColors: (UInt32, UInt32)?
|
||||
if let messageTopColor = messageTopColor, let messageBottomColor = messageBottomColor {
|
||||
messageColors = (UInt32(bitPattern: messageTopColor), UInt32(bitPattern: messageBottomColor))
|
||||
}
|
||||
self.init(baseTheme: TelegramBaseTheme(apiBaseTheme: baseTheme) ?? .classic, accentColor: UInt32(bitPattern: accentColor), messageColors: messageColors, wallpaper: wallpaper.flatMap(TelegramWallpaper.init(apiWallpaper:)))
|
||||
default:
|
||||
return nil
|
||||
self.init(baseTheme: TelegramBaseTheme(apiBaseTheme: baseTheme), accentColor: UInt32(bitPattern: accentColor), messageColors: messageColors, wallpaper: wallpaper.flatMap(TelegramWallpaper.init(apiWallpaper:)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ private final class ChatDateSelectorItemNode: ActionSheetItemNode {
|
||||
|
||||
self.pickerView.frame = CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: 180.0))
|
||||
|
||||
self.updateInternalLayout(size)
|
||||
self.updateInternalLayout(size, constrainedSize: constrainedSize)
|
||||
return size
|
||||
}
|
||||
|
||||
|
@ -590,7 +590,7 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState
|
||||
f(.default)
|
||||
})))
|
||||
|
||||
if isSpeakSelectionEnabled() {
|
||||
if isSpeakSelectionEnabled() && !message.text.isEmpty {
|
||||
actions.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.Conversation_ContextMenuSpeak, icon: { theme in
|
||||
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Message"), color: theme.actionSheet.primaryTextColor)
|
||||
}, action: { _, f in
|
||||
|
@ -179,7 +179,7 @@ private final class AutoremoveTimeoutSelectorItemNode: ActionSheetItemNode, UIPi
|
||||
|
||||
self.pickerView.frame = CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: 180.0))
|
||||
|
||||
self.updateInternalLayout(size)
|
||||
self.updateInternalLayout(size, constrainedSize: constrainedSize)
|
||||
return size
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user