diff --git a/Widget/PeerNode.swift b/Widget/PeerNode.swift index ccc57c330a..82e9f95362 100644 --- a/Widget/PeerNode.swift +++ b/Widget/PeerNode.swift @@ -135,9 +135,13 @@ final class PeerView: UIView { title.append("\n") title.append(lastName) } + + let systemFontSize = UIFont.preferredFont(forTextStyle: .body).pointSize + let fontSize = floor(systemFontSize * 11.0 / 17.0) + self.titleLabel.text = title self.titleLabel.textColor = primaryColor - self.titleLabel.font = UIFont.systemFont(ofSize: 11.0) + self.titleLabel.font = UIFont.systemFont(ofSize: fontSize) self.titleLabel.lineBreakMode = .byTruncatingTail self.titleLabel.numberOfLines = 2 self.titleLabel.textAlignment = .center diff --git a/Widget/TodayViewController.swift b/Widget/TodayViewController.swift index e18ee5af81..c1edbafbca 100644 --- a/Widget/TodayViewController.swift +++ b/Widget/TodayViewController.swift @@ -54,10 +54,12 @@ class TodayViewController: UIViewController, NCWidgetProviding { presentationData = WidgetPresentationData(applicationLockedString: "Unlock the app to use widget") } + let fontSize = UIFont.preferredFont(forTextStyle: .body).pointSize + if let data = try? Data(contentsOf: URL(fileURLWithPath: appLockStatePath(rootPath: rootPath))), let state = try? JSONDecoder().decode(LockState.self, from: data), isAppLocked(state: state) { let appLockedLabel = UILabel() appLockedLabel.textColor = self.primaryColor - appLockedLabel.font = UIFont.systemFont(ofSize: 16.0) + appLockedLabel.font = UIFont.systemFont(ofSize: fontSize) appLockedLabel.text = presentationData.applicationLockedString appLockedLabel.sizeToFit() self.appLockedLabel = appLockedLabel diff --git a/submodules/ActionSheetPeerItem/Sources/ActionSheetPeerItem.swift b/submodules/ActionSheetPeerItem/Sources/ActionSheetPeerItem.swift index d3e81caa6a..b227f15efb 100644 --- a/submodules/ActionSheetPeerItem/Sources/ActionSheetPeerItem.swift +++ b/submodules/ActionSheetPeerItem/Sources/ActionSheetPeerItem.swift @@ -48,7 +48,7 @@ private let avatarFont = avatarPlaceholderFont(size: 15.0) public class ActionSheetPeerItemNode: ActionSheetItemNode { private let theme: ActionSheetControllerTheme - public static let defaultFont: UIFont = Font.regular(20.0) + private let defaultFont: UIFont private var item: ActionSheetPeerItem? @@ -62,6 +62,8 @@ public class ActionSheetPeerItemNode: ActionSheetItemNode { override public init(theme: ActionSheetControllerTheme) { self.theme = theme + self.defaultFont = Font.regular(floor(theme.baseFontSize * 20.0 / 17.0)) + self.button = HighlightTrackingButton() self.button.isAccessibilityElement = false @@ -114,8 +116,10 @@ public class ActionSheetPeerItemNode: ActionSheetItemNode { func setItem(_ item: ActionSheetPeerItem) { self.item = item + let defaultFont = Font.regular(floor(theme.baseFontSize * 20.0 / 17.0)) + let textColor: UIColor = self.theme.primaryTextColor - self.label.attributedText = NSAttributedString(string: item.title, font: ActionSheetButtonNode.defaultFont, textColor: textColor) + self.label.attributedText = NSAttributedString(string: item.title, font: defaultFont, textColor: textColor) self.avatarNode.setPeer(account: item.account, theme: item.theme, peer: item.peer) diff --git a/submodules/BotPaymentsUI/Sources/BotCheckoutPaymentMethodSheet.swift b/submodules/BotPaymentsUI/Sources/BotCheckoutPaymentMethodSheet.swift index f67d0f2c32..58d07f8c43 100644 --- a/submodules/BotPaymentsUI/Sources/BotCheckoutPaymentMethodSheet.swift +++ b/submodules/BotPaymentsUI/Sources/BotCheckoutPaymentMethodSheet.swift @@ -42,11 +42,11 @@ final class BotCheckoutPaymentMethodSheetController: ActionSheetController { let theme = presentationData.theme let strings = presentationData.strings - super.init(theme: ActionSheetControllerTheme(presentationTheme: theme)) + super.init(theme: ActionSheetControllerTheme(presentationData: presentationData)) self.presentationDisposable = context.sharedContext.presentationData.start(next: { [weak self] presentationData in if let strongSelf = self { - strongSelf.theme = ActionSheetControllerTheme(presentationTheme: presentationData.theme) + strongSelf.theme = ActionSheetControllerTheme(presentationData: presentationData) } }) @@ -137,7 +137,7 @@ public class BotCheckoutPaymentMethodItem: ActionSheetItem { } public class BotCheckoutPaymentMethodItemNode: ActionSheetItemNode { - public static let defaultFont: UIFont = Font.regular(20.0) + private let defaultFont: UIFont private let theme: ActionSheetControllerTheme @@ -150,6 +150,7 @@ public class BotCheckoutPaymentMethodItemNode: ActionSheetItemNode { public override init(theme: ActionSheetControllerTheme) { self.theme = theme + self.defaultFont = Font.regular(floor(theme.baseFontSize * 20.0 / 17.0)) self.button = HighlightTrackingButton() @@ -201,7 +202,7 @@ public class BotCheckoutPaymentMethodItemNode: ActionSheetItemNode { func setItem(_ item: BotCheckoutPaymentMethodItem) { self.item = item - self.titleNode.attributedText = NSAttributedString(string: item.title, font: BotCheckoutPaymentMethodItemNode.defaultFont, textColor: self.theme.primaryTextColor) + self.titleNode.attributedText = NSAttributedString(string: item.title, font: self.defaultFont, textColor: self.theme.primaryTextColor) self.iconNode.image = item.icon if let value = item.value { self.checkNode.isHidden = !value diff --git a/submodules/BotPaymentsUI/Sources/BotCheckoutPaymentShippingOptionSheetController.swift b/submodules/BotPaymentsUI/Sources/BotCheckoutPaymentShippingOptionSheetController.swift index 5150821641..495a5e674d 100644 --- a/submodules/BotPaymentsUI/Sources/BotCheckoutPaymentShippingOptionSheetController.swift +++ b/submodules/BotPaymentsUI/Sources/BotCheckoutPaymentShippingOptionSheetController.swift @@ -16,11 +16,11 @@ final class BotCheckoutPaymentShippingOptionSheetController: ActionSheetControll let theme = presentationData.theme let strings = presentationData.strings - super.init(theme: ActionSheetControllerTheme(presentationTheme: theme)) + super.init(theme: ActionSheetControllerTheme(presentationData: presentationData)) self.presentationDisposable = context.sharedContext.presentationData.start(next: { [weak self] presentationData in if let strongSelf = self { - strongSelf.theme = ActionSheetControllerTheme(presentationTheme: presentationData.theme) + strongSelf.theme = ActionSheetControllerTheme(presentationData: presentationData) } }) @@ -113,7 +113,7 @@ public class BotCheckoutPaymentShippingOptionItem: ActionSheetItem { } public class BotCheckoutPaymentShippingOptionItemNode: ActionSheetItemNode { - public static let defaultFont: UIFont = Font.regular(20.0) + private let defaultFont: UIFont private let theme: ActionSheetControllerTheme @@ -126,6 +126,7 @@ public class BotCheckoutPaymentShippingOptionItemNode: ActionSheetItemNode { public override init(theme: ActionSheetControllerTheme) { self.theme = theme + self.defaultFont = Font.regular(floor(theme.baseFontSize * 20.0 / 17.0)) self.button = HighlightTrackingButton() @@ -178,8 +179,8 @@ public class BotCheckoutPaymentShippingOptionItemNode: ActionSheetItemNode { func setItem(_ item: BotCheckoutPaymentShippingOptionItem) { self.item = item - self.titleNode.attributedText = NSAttributedString(string: item.title, font: BotCheckoutPaymentShippingOptionItemNode.defaultFont, textColor: self.theme.primaryTextColor) - self.labelNode.attributedText = NSAttributedString(string: item.label, font: BotCheckoutPaymentShippingOptionItemNode.defaultFont, textColor: self.theme.primaryTextColor) + self.titleNode.attributedText = NSAttributedString(string: item.title, font: self.defaultFont, textColor: self.theme.primaryTextColor) + self.labelNode.attributedText = NSAttributedString(string: item.label, font: self.defaultFont, textColor: self.theme.primaryTextColor) if let value = item.value { self.checkNode.isHidden = !value } else { diff --git a/submodules/ChatListUI/Sources/ChatListController.swift b/submodules/ChatListUI/Sources/ChatListController.swift index 13e3c32b99..86bfd13c60 100644 --- a/submodules/ChatListUI/Sources/ChatListController.swift +++ b/submodules/ChatListUI/Sources/ChatListController.swift @@ -308,7 +308,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController, if case .root = groupId, checkProxy { if strongSelf.proxyUnavailableTooltipController == nil && !strongSelf.didShowProxyUnavailableTooltipController && strongSelf.isNodeLoaded && strongSelf.displayNode.view.window != nil { strongSelf.didShowProxyUnavailableTooltipController = true - let tooltipController = TooltipController(content: .text(strongSelf.presentationData.strings.Proxy_TooltipUnavailable), timeout: 60.0, dismissByTapOutside: true) + let tooltipController = TooltipController(content: .text(strongSelf.presentationData.strings.Proxy_TooltipUnavailable), baseFontSize: strongSelf.presentationData.fontSize.baseDisplaySize, timeout: 60.0, dismissByTapOutside: true) strongSelf.proxyUnavailableTooltipController = tooltipController tooltipController.dismissed = { [weak tooltipController] _ in if let strongSelf = self, let tooltipController = tooltipController, strongSelf.proxyUnavailableTooltipController === tooltipController { @@ -588,7 +588,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController, self.chatListDisplayNode.requestOpenRecentPeerOptions = { [weak self] peer in if let strongSelf = self { strongSelf.view.window?.endEditing(true) - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) actionSheet.setItemGroups([ ActionSheetItemGroup(items: [ @@ -669,12 +669,12 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController, case let .groupReference(groupReference): let chatListController = ChatListControllerImpl(context: strongSelf.context, groupId: groupReference.groupId, controlsHistoryPreload: false, hideNetworkActivityStatus: true, previewing: true, enableDebugActions: false) chatListController.navigationPresentation = .master - let contextController = ContextController(account: strongSelf.context.account, theme: strongSelf.presentationData.theme, strings: strongSelf.presentationData.strings, source: .controller(ContextControllerContentSourceImpl(controller: chatListController, sourceNode: node, navigationController: strongSelf.navigationController as? NavigationController)), items: archiveContextMenuItems(context: strongSelf.context, groupId: groupReference.groupId, chatListController: strongSelf), reactionItems: [], gesture: gesture) + let contextController = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: chatListController, sourceNode: node, navigationController: strongSelf.navigationController as? NavigationController)), items: archiveContextMenuItems(context: strongSelf.context, groupId: groupReference.groupId, chatListController: strongSelf), reactionItems: [], gesture: gesture) strongSelf.presentInGlobalOverlay(contextController) case let .peer(peer): let chatController = strongSelf.context.sharedContext.makeChatController(context: strongSelf.context, chatLocation: .peer(peer.peer.peerId), subject: nil, botStart: nil, mode: .standard(previewing: true)) chatController.canReadHistory.set(false) - let contextController = ContextController(account: strongSelf.context.account, theme: strongSelf.presentationData.theme, strings: strongSelf.presentationData.strings, source: .controller(ContextControllerContentSourceImpl(controller: chatController, sourceNode: node, navigationController: strongSelf.navigationController as? NavigationController)), items: chatContextMenuItems(context: strongSelf.context, peerId: peer.peer.peerId, source: .chatList, chatListController: strongSelf), reactionItems: [], gesture: gesture) + let contextController = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: chatController, sourceNode: node, navigationController: strongSelf.navigationController as? NavigationController)), items: chatContextMenuItems(context: strongSelf.context, peerId: peer.peer.peerId, source: .chatList, chatListController: strongSelf), reactionItems: [], gesture: gesture) strongSelf.presentInGlobalOverlay(contextController) } } @@ -687,7 +687,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController, let chatController = strongSelf.context.sharedContext.makeChatController(context: strongSelf.context, chatLocation: .peer(peer.id), subject: nil, botStart: nil, mode: .standard(previewing: true)) chatController.canReadHistory.set(false) - let contextController = ContextController(account: strongSelf.context.account, theme: strongSelf.presentationData.theme, strings: strongSelf.presentationData.strings, source: .controller(ContextControllerContentSourceImpl(controller: chatController, sourceNode: node, navigationController: strongSelf.navigationController as? NavigationController)), items: chatContextMenuItems(context: strongSelf.context, peerId: peer.id, source: .search(source), chatListController: strongSelf), reactionItems: [], gesture: gesture) + let contextController = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: chatController, sourceNode: node, navigationController: strongSelf.navigationController as? NavigationController)), items: chatContextMenuItems(context: strongSelf.context, peerId: peer.id, source: .search(source), chatListController: strongSelf), reactionItems: [], gesture: gesture) strongSelf.presentInGlobalOverlay(contextController) } @@ -798,7 +798,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController, if hasPasscode { let _ = ApplicationSpecificNotice.setPasscodeLockTips(accountManager: strongSelf.context.sharedContext.accountManager).start() - let tooltipController = TooltipController(content: .text(strongSelf.presentationData.strings.DialogList_PasscodeLockHelp), dismissByTapOutside: true) + let tooltipController = TooltipController(content: .text(strongSelf.presentationData.strings.DialogList_PasscodeLockHelp), baseFontSize: strongSelf.presentationData.fontSize.baseDisplaySize, dismissByTapOutside: true) strongSelf.present(tooltipController, in: .window(.root), with: TooltipControllerPresentationArguments(sourceViewAndRect: { [weak self] in if let strongSelf = self { return (strongSelf.titleView, lockViewFrame.offsetBy(dx: 4.0, dy: 14.0)) @@ -1199,7 +1199,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController, self?.donePressed() }) } else if case .right = action, !peerIds.isEmpty { - let actionSheet = ActionSheetController(presentationTheme: self.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: self.presentationData) var items: [ActionSheetItem] = [] items.append(ActionSheetButtonItem(title: self.presentationData.strings.ChatList_DeleteConfirmation(Int32(peerIds.count)), color: .destructive, action: { [weak self, weak actionSheet] in actionSheet?.dismissAnimated() @@ -1385,7 +1385,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController, if let user = chatPeer as? TelegramUser, user.botInfo == nil, canRemoveGlobally { strongSelf.maybeAskForPeerChatRemoval(peer: peer, completion: { _ in }, removed: {}) } else { - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) var items: [ActionSheetItem] = [] var canClear = true var canStop = false @@ -1468,7 +1468,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController, } if canRemoveGlobally { - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) var items: [ActionSheetItem] = [] items.append(DeleteChatPeerActionSheetItem(context: strongSelf.context, peer: mainPeer, chatPeer: chatPeer, action: .clearHistory, strings: strongSelf.presentationData.strings, nameDisplayOrder: strongSelf.presentationData.nameDisplayOrder)) @@ -1556,7 +1556,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController, } if canRemoveGlobally { - let actionSheet = ActionSheetController(presentationTheme: self.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: self.presentationData) var items: [ActionSheetItem] = [] items.append(DeleteChatPeerActionSheetItem(context: self.context, peer: mainPeer, chatPeer: chatPeer, action: .delete, strings: self.presentationData.strings, nameDisplayOrder: self.presentationData.nameDisplayOrder)) diff --git a/submodules/ChatListUI/Sources/Node/ChatListItem.swift b/submodules/ChatListUI/Sources/Node/ChatListItem.swift index f06e3fb0b5..83dc27d38a 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListItem.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListItem.swift @@ -774,7 +774,10 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { let enableChatListPhotos = item.context.sharedContext.immediateExperimentalUISettings.chatListPhotos - let leftInset: CGFloat = params.leftInset + 78.0 + let avatarDiameter = floor(item.presentationData.fontSize.baseDisplaySize * 60.0 / 17.0) + let avatarLeftInset = 18.0 + avatarDiameter + + let leftInset: CGFloat = params.leftInset + avatarLeftInset enum ContentData { case chat(itemPeer: RenderedPeer, peer: Peer?, hideAuthor: Bool, messageText: String) @@ -1337,7 +1340,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { transition.updateAlpha(node: strongSelf.statusNode, alpha: 1.0) } - let avatarFrame = CGRect(origin: CGPoint(x: leftInset - 78.0 + editingOffset + 10.0 + revealOffset, y: floor((layout.contentSize.height - 60.0) / 2.0)), size: CGSize(width: 60.0, height: 60.0)) + let avatarFrame = CGRect(origin: CGPoint(x: leftInset - avatarLeftInset + editingOffset + 10.0 + revealOffset, y: floor((layout.contentSize.height - avatarDiameter) / 2.0)), size: CGSize(width: avatarDiameter, height: avatarDiameter)) transition.updateFrame(node: strongSelf.avatarNode, frame: avatarFrame) let onlineFrame = CGRect(origin: CGPoint(x: avatarFrame.maxX - onlineLayout.width - 2.0, y: avatarFrame.maxY - onlineLayout.height - 2.0), size: onlineLayout) @@ -1417,7 +1420,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { strongSelf.secretIconNode = iconNode } iconNode.image = currentSecretIconImage - transition.updateFrame(node: iconNode, frame: CGRect(origin: CGPoint(x: contentRect.origin.x, y: contentRect.origin.y + 4.0), size: currentSecretIconImage.size)) + transition.updateFrame(node: iconNode, frame: CGRect(origin: CGPoint(x: contentRect.origin.x, y: contentRect.origin.y + floor((strongSelf.titleNode.frame.height - currentSecretIconImage.size.height) / 2.0)), size: currentSecretIconImage.size)) titleOffset += currentSecretIconImage.size.width + 3.0 } else if let secretIconNode = strongSelf.secretIconNode { strongSelf.secretIconNode = nil @@ -1616,7 +1619,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { override func updateRevealOffset(offset: CGFloat, transition: ContainedViewLayoutTransition) { super.updateRevealOffset(offset: offset, transition: transition) - if let _ = self.item, let params = self.layoutParams?.5, let countersSize = self.layoutParams?.6 { + if let item = self.item, let params = self.layoutParams?.5, let countersSize = self.layoutParams?.6 { let editingOffset: CGFloat if let selectableControlNode = self.selectableControlNode { editingOffset = selectableControlNode.bounds.size.width @@ -1635,14 +1638,17 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { transition.updateFrame(node: reorderControlNode, frame: reorderControlFrame) } - let leftInset: CGFloat = params.leftInset + 78.0 + let avatarDiameter = floor(item.presentationData.fontSize.baseDisplaySize * 60.0 / 17.0) + let avatarLeftInset = 18.0 + avatarDiameter + + let leftInset: CGFloat = params.leftInset + avatarLeftInset let rawContentRect = CGRect(origin: CGPoint(x: 2.0, y: layoutOffset + 8.0), size: CGSize(width: params.width - leftInset - params.rightInset - 10.0 - 1.0 - editingOffset, height: self.bounds.size.height - 12.0 - 9.0)) let contentRect = rawContentRect.offsetBy(dx: editingOffset + leftInset + offset, dy: 0.0) var avatarFrame = self.avatarNode.frame - avatarFrame.origin.x = leftInset - 78.0 + editingOffset + 10.0 + offset + avatarFrame.origin.x = leftInset - avatarLeftInset + editingOffset + 10.0 + offset transition.updateFrame(node: self.avatarNode, frame: avatarFrame) var onlineFrame = self.onlineNode.frame diff --git a/submodules/ChatListUI/Sources/Node/ChatListItemStrings.swift b/submodules/ChatListUI/Sources/Node/ChatListItemStrings.swift index d927b769f1..73d9d2f377 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListItemStrings.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListItemStrings.swift @@ -40,7 +40,9 @@ public func chatListItemStrings(strings: PresentationStrings, nameDisplayOrder: processed = true break inner case let .Audio(isVoice, _, title, performer, _): - if isVoice { + if !message.text.isEmpty { + messageText = "🎤 \(messageText)" + } else if isVoice { if message.text.isEmpty { messageText = strings.Message_Audio } else { diff --git a/submodules/ContactListUI/Sources/ContactsController.swift b/submodules/ContactListUI/Sources/ContactsController.swift index 7597864b6b..7dcfc4b716 100644 --- a/submodules/ContactListUI/Sources/ContactsController.swift +++ b/submodules/ContactListUI/Sources/ContactsController.swift @@ -495,7 +495,7 @@ public class ContactsController: ViewController { } } - let actionSheet = ActionSheetController(presentationTheme: self.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: self.presentationData) var items: [ActionSheetItem] = [] items.append(ActionSheetTextItem(title: self.presentationData.strings.Contacts_SortBy)) items.append(ActionSheetButtonItem(title: self.presentationData.strings.Contacts_SortByName, color: .accent, action: { [weak actionSheet] in diff --git a/submodules/ContactListUI/Sources/ContactsControllerNode.swift b/submodules/ContactListUI/Sources/ContactsControllerNode.swift index ee7fcb6e3f..d994543130 100644 --- a/submodules/ContactListUI/Sources/ContactsControllerNode.swift +++ b/submodules/ContactListUI/Sources/ContactsControllerNode.swift @@ -193,7 +193,7 @@ final class ContactsControllerNode: ASDisplayNode { } let chatController = self.context.sharedContext.makeChatController(context: self.context, chatLocation: .peer(peer.id), subject: nil, botStart: nil, mode: .standard(previewing: true)) chatController.canReadHistory.set(false) - let contextController = ContextController(account: self.context.account, theme: self.presentationData.theme, strings: self.presentationData.strings, source: .controller(ContextControllerContentSourceImpl(controller: chatController, sourceNode: node)), items: contactContextMenuItems(context: self.context, peerId: peer.id, contactsController: contactsController), reactionItems: [], gesture: gesture) + let contextController = ContextController(account: self.context.account, presentationData: self.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: chatController, sourceNode: node)), items: contactContextMenuItems(context: self.context, peerId: peer.id, contactsController: contactsController), reactionItems: [], gesture: gesture) contactsController.presentInGlobalOverlay(contextController) } diff --git a/submodules/ContactsPeerItem/Sources/ContactsPeerItem.swift b/submodules/ContactsPeerItem/Sources/ContactsPeerItem.swift index e12b099d7f..c8e3cd9323 100644 --- a/submodules/ContactsPeerItem/Sources/ContactsPeerItem.swift +++ b/submodules/ContactsPeerItem/Sources/ContactsPeerItem.swift @@ -435,7 +435,8 @@ public class ContactsPeerItemNode: ItemListRevealOptionsItemNode { let titleFont = Font.regular(item.presentationData.fontSize.itemListBaseFontSize) let titleBoldFont = Font.medium(item.presentationData.fontSize.itemListBaseFontSize) let statusFont = Font.regular(floor(item.presentationData.fontSize.itemListBaseFontSize * 13.0 / 17.0)) - let badgeFont = Font.regular(floor(item.presentationData.fontSize.itemListBaseFontSize * 14.0 / 17.0)) + let badgeFont = Font.regular(14.0) + let avatarDiameter = min(40.0, floor(item.presentationData.fontSize.itemListBaseFontSize * 40.0 / 17.0)) if currentItem?.presentationData.theme !== item.presentationData.theme { updatedTheme = item.presentationData.theme @@ -611,7 +612,8 @@ public class ContactsPeerItemNode: ItemListRevealOptionsItemNode { let (statusLayout, statusApply) = makeStatusLayout(TextNodeLayoutArguments(attributedString: statusAttributedString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: max(0.0, params.width - leftInset - rightInset - badgeSize), height: CGFloat.infinity), alignment: .natural, cutout: nil, insets: UIEdgeInsets())) - let verticalInset: CGFloat = statusAttributedString == nil ? 11.0 : 6.0 + let titleVerticalInset: CGFloat = statusAttributedString == nil ? 13.0 : 6.0 + let verticalInset: CGFloat = statusAttributedString == nil ? 13.0 : 6.0 let statusHeightComponent: CGFloat if statusAttributedString == nil { @@ -624,7 +626,7 @@ public class ContactsPeerItemNode: ItemListRevealOptionsItemNode { let titleFrame: CGRect if statusAttributedString != nil { - titleFrame = CGRect(origin: CGPoint(x: leftInset, y: verticalInset), size: titleLayout.size) + titleFrame = CGRect(origin: CGPoint(x: leftInset, y: titleVerticalInset), size: titleLayout.size) } else { titleFrame = CGRect(origin: CGPoint(x: leftInset, y: floor((nodeLayout.contentSize.height - titleLayout.size.height) / 2.0)), size: titleLayout.size) } @@ -707,7 +709,7 @@ public class ContactsPeerItemNode: ItemListRevealOptionsItemNode { strongSelf.highlightedBackgroundNode.backgroundColor = item.presentationData.theme.list.itemHighlightedBackgroundColor } - transition.updateFrame(node: strongSelf.avatarNode, frame: CGRect(origin: CGPoint(x: revealOffset + leftInset - 50.0, y: floor((nodeLayout.contentSize.height - 40.0) / 2.0)), size: CGSize(width: 40.0, height: 40.0))) + transition.updateFrame(node: strongSelf.avatarNode, frame: CGRect(origin: CGPoint(x: revealOffset + leftInset - 50.0, y: floor((nodeLayout.contentSize.height - avatarDiameter) / 2.0)), size: CGSize(width: avatarDiameter, height: avatarDiameter))) let _ = titleApply() transition.updateFrame(node: strongSelf.titleNode, frame: titleFrame.offsetBy(dx: revealOffset, dy: 0.0)) diff --git a/submodules/ContextUI/Sources/ContextActionNode.swift b/submodules/ContextUI/Sources/ContextActionNode.swift index 470101545a..60d6ec0573 100644 --- a/submodules/ContextUI/Sources/ContextActionNode.swift +++ b/submodules/ContextUI/Sources/ContextActionNode.swift @@ -3,8 +3,6 @@ import AsyncDisplayKit import Display import TelegramPresentationData -private let textFont = Font.regular(17.0) - enum ContextActionSibling { case none case item @@ -23,17 +21,19 @@ final class ContextActionNode: ASDisplayNode { private let iconNode: ASImageNode private let buttonNode: HighlightTrackingButtonNode - init(theme: PresentationTheme, action: ContextMenuActionItem, getController: @escaping () -> ContextController?, actionSelected: @escaping (ContextMenuActionResult) -> Void) { + init(presentationData: PresentationData, action: ContextMenuActionItem, getController: @escaping () -> ContextController?, actionSelected: @escaping (ContextMenuActionResult) -> Void) { self.action = action self.getController = getController self.actionSelected = actionSelected + let textFont = Font.regular(presentationData.fontSize.baseDisplaySize) + self.backgroundNode = ASDisplayNode() self.backgroundNode.isAccessibilityElement = false - self.backgroundNode.backgroundColor = theme.contextMenu.itemBackgroundColor + self.backgroundNode.backgroundColor = presentationData.theme.contextMenu.itemBackgroundColor self.highlightedBackgroundNode = ASDisplayNode() self.highlightedBackgroundNode.isAccessibilityElement = false - self.highlightedBackgroundNode.backgroundColor = theme.contextMenu.itemHighlightedBackgroundColor + self.highlightedBackgroundNode.backgroundColor = presentationData.theme.contextMenu.itemHighlightedBackgroundColor self.highlightedBackgroundNode.alpha = 0.0 self.textNode = ImmediateTextNode() @@ -43,9 +43,9 @@ final class ContextActionNode: ASDisplayNode { let textColor: UIColor switch action.textColor { case .primary: - textColor = theme.contextMenu.primaryColor + textColor = presentationData.theme.contextMenu.primaryColor case .destructive: - textColor = theme.contextMenu.destructiveColor + textColor = presentationData.theme.contextMenu.destructiveColor } self.textNode.attributedText = NSAttributedString(string: action.text, font: textFont, textColor: textColor) @@ -62,7 +62,7 @@ final class ContextActionNode: ASDisplayNode { statusNode.isAccessibilityElement = false statusNode.isUserInteractionEnabled = false statusNode.displaysAsynchronously = false - statusNode.attributedText = NSAttributedString(string: value, font: textFont, textColor: theme.contextMenu.secondaryColor) + statusNode.attributedText = NSAttributedString(string: value, font: textFont, textColor: presentationData.theme.contextMenu.secondaryColor) statusNode.maximumNumberOfLines = 1 self.statusNode = statusNode } @@ -72,7 +72,7 @@ final class ContextActionNode: ASDisplayNode { self.iconNode.displaysAsynchronously = false self.iconNode.displayWithoutProcessing = true self.iconNode.isUserInteractionEnabled = false - self.iconNode.image = action.icon(theme) + self.iconNode.image = action.icon(presentationData.theme) self.buttonNode = HighlightTrackingButtonNode() self.buttonNode.isAccessibilityElement = true @@ -149,27 +149,30 @@ final class ContextActionNode: ASDisplayNode { } } - func updateTheme(theme: PresentationTheme) { - self.backgroundNode.backgroundColor = theme.contextMenu.itemBackgroundColor - self.highlightedBackgroundNode.backgroundColor = theme.contextMenu.itemHighlightedBackgroundColor + func updateTheme(presentationData: PresentationData) { + self.backgroundNode.backgroundColor = presentationData.theme.contextMenu.itemBackgroundColor + self.highlightedBackgroundNode.backgroundColor = presentationData.theme.contextMenu.itemHighlightedBackgroundColor let textColor: UIColor switch action.textColor { case .primary: - textColor = theme.contextMenu.primaryColor + textColor = presentationData.theme.contextMenu.primaryColor case .destructive: - textColor = theme.contextMenu.destructiveColor + textColor = presentationData.theme.contextMenu.destructiveColor } + + let textFont = Font.regular(presentationData.fontSize.baseDisplaySize) + self.textNode.attributedText = NSAttributedString(string: self.action.text, font: textFont, textColor: textColor) switch self.action.textLayout { case let .secondLineWithValue(value): - self.statusNode?.attributedText = NSAttributedString(string: value, font: textFont, textColor: theme.contextMenu.secondaryColor) + self.statusNode?.attributedText = NSAttributedString(string: value, font: textFont, textColor: presentationData.theme.contextMenu.secondaryColor) default: break } - self.iconNode.image = self.action.icon(theme) + self.iconNode.image = self.action.icon(presentationData.theme) } @objc private func buttonPressed() { diff --git a/submodules/ContextUI/Sources/ContextActionsContainerNode.swift b/submodules/ContextUI/Sources/ContextActionsContainerNode.swift index 23e68aa31f..ebc6bf1d49 100644 --- a/submodules/ContextUI/Sources/ContextActionsContainerNode.swift +++ b/submodules/ContextUI/Sources/ContextActionsContainerNode.swift @@ -39,7 +39,7 @@ private enum ContextItemNode { } final class ContextActionsContainerNode: ASDisplayNode { - private let theme: PresentationTheme + private let presentationData: PresentationData private var effectView: UIVisualEffectView? private var itemNodes: [ContextItemNode] private let feedbackTap: () -> Void @@ -47,23 +47,23 @@ final class ContextActionsContainerNode: ASDisplayNode { private(set) var gesture: UIGestureRecognizer? private var currentHighlightedActionNode: ContextActionNode? - init(theme: PresentationTheme, items: [ContextMenuItem], getController: @escaping () -> ContextController?, actionSelected: @escaping (ContextMenuActionResult) -> Void, feedbackTap: @escaping () -> Void) { - self.theme = theme + init(presentationData: PresentationData, items: [ContextMenuItem], getController: @escaping () -> ContextController?, actionSelected: @escaping (ContextMenuActionResult) -> Void, feedbackTap: @escaping () -> Void) { + self.presentationData = presentationData self.feedbackTap = feedbackTap var itemNodes: [ContextItemNode] = [] for i in 0 ..< items.count { switch items[i] { case let .action(action): - itemNodes.append(.action(ContextActionNode(theme: theme, action: action, getController: getController, actionSelected: actionSelected))) + itemNodes.append(.action(ContextActionNode(presentationData: presentationData, action: action, getController: getController, actionSelected: actionSelected))) if i != items.count - 1, case .action = items[i + 1] { let separatorNode = ASDisplayNode() - separatorNode.backgroundColor = theme.contextMenu.itemSeparatorColor + separatorNode.backgroundColor = presentationData.theme.contextMenu.itemSeparatorColor itemNodes.append(.itemSeparator(separatorNode)) } case .separator: let separatorNode = ASDisplayNode() - separatorNode.backgroundColor = theme.contextMenu.sectionSeparatorColor + separatorNode.backgroundColor = presentationData.theme.contextMenu.sectionSeparatorColor itemNodes.append(.separator(separatorNode)) } } @@ -75,7 +75,7 @@ final class ContextActionsContainerNode: ASDisplayNode { self.clipsToBounds = true self.cornerRadius = 14.0 - self.backgroundColor = theme.contextMenu.backgroundColor + self.backgroundColor = presentationData.theme.contextMenu.backgroundColor self.itemNodes.forEach({ itemNode in switch itemNode { @@ -133,7 +133,7 @@ final class ContextActionsContainerNode: ASDisplayNode { if self.effectView == nil { let effectView: UIVisualEffectView if #available(iOS 13.0, *) { - if self.theme.overallDarkAppearance { + if self.presentationData.theme.overallDarkAppearance { effectView = UIVisualEffectView(effect: UIBlurEffect(style: .systemMaterialDark)) } else { effectView = UIVisualEffectView(effect: UIBlurEffect(style: .systemMaterialLight)) @@ -213,19 +213,19 @@ final class ContextActionsContainerNode: ASDisplayNode { return size } - func updateTheme(theme: PresentationTheme) { + func updateTheme(presentationData: PresentationData) { for itemNode in self.itemNodes { switch itemNode { case let .action(action): - action.updateTheme(theme: theme) + action.updateTheme(presentationData: presentationData) case let .separator(separator): - separator.backgroundColor = theme.contextMenu.sectionSeparatorColor + separator.backgroundColor = presentationData.theme.contextMenu.sectionSeparatorColor case let .itemSeparator(itemSeparator): - itemSeparator.backgroundColor = theme.contextMenu.itemSeparatorColor + itemSeparator.backgroundColor = presentationData.theme.contextMenu.itemSeparatorColor } } - self.backgroundColor = theme.contextMenu.backgroundColor + self.backgroundColor = presentationData.theme.contextMenu.backgroundColor } func actionNode(at point: CGPoint) -> ContextActionNode? { diff --git a/submodules/ContextUI/Sources/ContextController.swift b/submodules/ContextUI/Sources/ContextController.swift index 1b5b1bb37d..7a3ef594cf 100644 --- a/submodules/ContextUI/Sources/ContextController.swift +++ b/submodules/ContextUI/Sources/ContextController.swift @@ -60,8 +60,7 @@ private func convertFrame(_ frame: CGRect, from fromView: UIView, to toView: UIV } private final class ContextControllerNode: ViewControllerTracingNode, UIScrollViewDelegate { - private var theme: PresentationTheme - private var strings: PresentationStrings + private var presentationData: PresentationData private let source: ContextContentSource private var items: Signal<[ContextMenuItem], NoError> private let beginDismiss: (ContextMenuActionResult) -> Void @@ -108,9 +107,8 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi private let itemsDisposable = MetaDisposable() - init(account: Account, controller: ContextController, theme: PresentationTheme, strings: PresentationStrings, source: ContextContentSource, items: Signal<[ContextMenuItem], NoError>, reactionItems: [ReactionContextItem], beginDismiss: @escaping (ContextMenuActionResult) -> Void, recognizer: TapLongTapOrDoubleTapGestureRecognizer?, gesture: ContextGesture?, reactionSelected: @escaping (String) -> Void, beganAnimatingOut: @escaping () -> Void, attemptTransitionControllerIntoNavigation: @escaping () -> Void) { - self.theme = theme - self.strings = strings + init(account: Account, controller: ContextController, presentationData: PresentationData, source: ContextContentSource, items: Signal<[ContextMenuItem], NoError>, reactionItems: [ReactionContextItem], beginDismiss: @escaping (ContextMenuActionResult) -> Void, recognizer: TapLongTapOrDoubleTapGestureRecognizer?, gesture: ContextGesture?, reactionSelected: @escaping (String) -> Void, beganAnimatingOut: @escaping () -> Void, attemptTransitionControllerIntoNavigation: @escaping () -> Void) { + self.presentationData = presentationData self.source = source self.items = items self.beginDismiss = beginDismiss @@ -126,7 +124,7 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi self.effectView = UIVisualEffectView() if #available(iOS 9.0, *) { } else { - if theme.rootController.keyboardColor == .dark { + if presentationData.theme.rootController.keyboardColor == .dark { self.effectView.effect = UIBlurEffect(style: .dark) } else { self.effectView.effect = UIBlurEffect(style: .light) @@ -135,7 +133,7 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi } self.dimNode = ASDisplayNode() - self.dimNode.backgroundColor = theme.contextMenu.dimColor + self.dimNode.backgroundColor = presentationData.theme.contextMenu.dimColor self.dimNode.alpha = 0.0 self.withoutBlurDimNode = ASDisplayNode() @@ -159,7 +157,7 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi var feedbackTap: (() -> Void)? - self.actionsContainerNode = ContextActionsContainerNode(theme: theme, items: [], getController: { [weak controller] in + self.actionsContainerNode = ContextActionsContainerNode(presentationData: presentationData, items: [], getController: { [weak controller] in return controller }, actionSelected: { result in beginDismiss(result) @@ -168,7 +166,7 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi }) if !reactionItems.isEmpty { - let reactionContextNode = ReactionContextNode(account: account, theme: theme, items: reactionItems) + let reactionContextNode = ReactionContextNode(account: account, theme: presentationData.theme, items: reactionItems) self.reactionContextNode = reactionContextNode } else { self.reactionContextNode = nil @@ -966,7 +964,7 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi self.currentItems = items let previousActionsContainerNode = self.actionsContainerNode - self.actionsContainerNode = ContextActionsContainerNode(theme: self.theme, items: items, getController: { [weak self] in + self.actionsContainerNode = ContextActionsContainerNode(presentationData: self.presentationData, items: items, getController: { [weak self] in return self?.getController() }, actionSelected: { [weak self] result in self?.beginDismiss(result) @@ -988,11 +986,11 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi } } - func updateTheme(theme: PresentationTheme) { - self.theme = theme + func updateTheme(presentationData: PresentationData) { + self.presentationData = presentationData - self.dimNode.backgroundColor = theme.contextMenu.dimColor - self.actionsContainerNode.updateTheme(theme: theme) + self.dimNode.backgroundColor = presentationData.theme.contextMenu.dimColor + self.actionsContainerNode.updateTheme(presentationData: presentationData) if let validLayout = self.validLayout { self.updateLayout(layout: validLayout, transition: .immediate, previousActionsContainerNode: nil) @@ -1364,8 +1362,7 @@ public enum ContextContentSource { public final class ContextController: ViewController, StandalonePresentableController { private let account: Account - private var theme: PresentationTheme - private var strings: PresentationStrings + private var presentationData: PresentationData private let source: ContextContentSource private var items: Signal<[ContextMenuItem], NoError> private var reactionItems: [ReactionContextItem] @@ -1387,10 +1384,9 @@ public final class ContextController: ViewController, StandalonePresentableContr public var reactionSelected: ((String) -> Void)? - public init(account: Account, theme: PresentationTheme, strings: PresentationStrings, source: ContextContentSource, items: Signal<[ContextMenuItem], NoError>, reactionItems: [ReactionContextItem], recognizer: TapLongTapOrDoubleTapGestureRecognizer? = nil, gesture: ContextGesture? = nil) { + public init(account: Account, presentationData: PresentationData, source: ContextContentSource, items: Signal<[ContextMenuItem], NoError>, reactionItems: [ReactionContextItem], recognizer: TapLongTapOrDoubleTapGestureRecognizer? = nil, gesture: ContextGesture? = nil) { self.account = account - self.theme = theme - self.strings = strings + self.presentationData = presentationData self.source = source self.items = items self.reactionItems = reactionItems @@ -1407,7 +1403,7 @@ public final class ContextController: ViewController, StandalonePresentableContr } override public func loadDisplayNode() { - self.displayNode = ContextControllerNode(account: self.account, controller: self, theme: self.theme, strings: self.strings, source: self.source, items: self.items, reactionItems: self.reactionItems, beginDismiss: { [weak self] result in + self.displayNode = ContextControllerNode(account: self.account, controller: self, presentationData: self.presentationData, source: self.source, items: self.items, reactionItems: self.reactionItems, beginDismiss: { [weak self] result in self?.dismiss(result: result, completion: nil) }, recognizer: self.recognizer, gesture: self.gesture, reactionSelected: { [weak self] value in guard let strongSelf = self else { @@ -1464,10 +1460,10 @@ public final class ContextController: ViewController, StandalonePresentableContr } } - public func updateTheme(theme: PresentationTheme) { - self.theme = theme + public func updateTheme(presentationData: PresentationData) { + self.presentationData = presentationData if self.isNodeLoaded { - self.controllerNode.updateTheme(theme: theme) + self.controllerNode.updateTheme(presentationData: presentationData) } } diff --git a/submodules/DateSelectionUI/Sources/DateSelectionActionSheetController.swift b/submodules/DateSelectionUI/Sources/DateSelectionActionSheetController.swift index b11e3572ca..ee5ee5f509 100644 --- a/submodules/DateSelectionUI/Sources/DateSelectionActionSheetController.swift +++ b/submodules/DateSelectionUI/Sources/DateSelectionActionSheetController.swift @@ -20,11 +20,11 @@ public final class DateSelectionActionSheetController: ActionSheetController { let theme = presentationData.theme let strings = presentationData.strings - super.init(theme: ActionSheetControllerTheme(presentationTheme: theme)) + super.init(theme: ActionSheetControllerTheme(presentationData: presentationData)) self.presentationDisposable = context.sharedContext.presentationData.start(next: { [weak self] presentationData in if let strongSelf = self { - strongSelf.theme = ActionSheetControllerTheme(presentationTheme: presentationData.theme) + strongSelf.theme = ActionSheetControllerTheme(presentationData: presentationData) } }) diff --git a/submodules/DeleteChatPeerActionSheetItem/Sources/DeleteChatPeerActionSheetItem.swift b/submodules/DeleteChatPeerActionSheetItem/Sources/DeleteChatPeerActionSheetItem.swift index bbaefbcb19..0501a4e5bd 100644 --- a/submodules/DeleteChatPeerActionSheetItem/Sources/DeleteChatPeerActionSheetItem.swift +++ b/submodules/DeleteChatPeerActionSheetItem/Sources/DeleteChatPeerActionSheetItem.swift @@ -56,6 +56,8 @@ private final class DeleteChatPeerActionSheetItemNode: ActionSheetItemNode { self.theme = theme self.strings = strings + let peerFont = Font.regular(floor(theme.baseFontSize * 14.0 / 17.0)) + self.avatarNode = AvatarNode(font: avatarFont) self.avatarNode.isAccessibilityElement = false @@ -88,9 +90,9 @@ private final class DeleteChatPeerActionSheetItemNode: ActionSheetItemNode { case .clearCache, .clearCacheSuggestion: switch action { case .clearCache: - attributedText = NSAttributedString(string: strings.ClearCache_Description, font: Font.regular(14.0), textColor: theme.primaryTextColor) + attributedText = NSAttributedString(string: strings.ClearCache_Description, font: peerFont, textColor: theme.primaryTextColor) case .clearCacheSuggestion: - attributedText = NSAttributedString(string: strings.ClearCache_FreeSpaceDescription, font: Font.regular(14.0), textColor: theme.primaryTextColor) + attributedText = NSAttributedString(string: strings.ClearCache_FreeSpaceDescription, font: peerFont, textColor: theme.primaryTextColor) default: break } @@ -115,9 +117,9 @@ private final class DeleteChatPeerActionSheetItemNode: ActionSheetItemNode { break } if let text = text { - var formattedAttributedText = NSMutableAttributedString(attributedString: NSAttributedString(string: text.0, font: Font.regular(14.0), textColor: theme.primaryTextColor)) + var formattedAttributedText = NSMutableAttributedString(attributedString: NSAttributedString(string: text.0, font: peerFont, textColor: theme.primaryTextColor)) for (_, range) in text.1 { - formattedAttributedText.addAttribute(.font, value: Font.semibold(14.0), range: range) + formattedAttributedText.addAttribute(.font, value: peerFont, range: range) } attributedText = formattedAttributedText } diff --git a/submodules/Display/Display/ActionSheetButtonItem.swift b/submodules/Display/Display/ActionSheetButtonItem.swift index d5e66cb69e..89abbaf404 100644 --- a/submodules/Display/Display/ActionSheetButtonItem.swift +++ b/submodules/Display/Display/ActionSheetButtonItem.swift @@ -47,8 +47,8 @@ public class ActionSheetButtonItem: ActionSheetItem { public class ActionSheetButtonNode: ActionSheetItemNode { private let theme: ActionSheetControllerTheme - public static let defaultFont: UIFont = Font.regular(20.0) - public static let boldFont: UIFont = Font.medium(20.0) + private let defaultFont: UIFont + private let boldFont: UIFont private var item: ActionSheetButtonItem? @@ -59,6 +59,9 @@ public class ActionSheetButtonNode: ActionSheetItemNode { override public init(theme: ActionSheetControllerTheme) { self.theme = theme + self.defaultFont = Font.regular(floor(theme.baseFontSize * 20.0 / 17.0)) + self.boldFont = Font.medium(floor(theme.baseFontSize * 20.0 / 17.0)) + self.button = HighlightTrackingButton() self.button.isAccessibilityElement = false @@ -113,9 +116,9 @@ public class ActionSheetButtonNode: ActionSheetItemNode { } switch item.font { case .default: - textFont = ActionSheetButtonNode.defaultFont + textFont = Font.regular(floor(theme.baseFontSize * 20.0 / 17.0)) case .bold: - textFont = ActionSheetButtonNode.boldFont + textFont = Font.medium(floor(theme.baseFontSize * 20.0 / 17.0)) } self.label.attributedText = NSAttributedString(string: item.title, font: textFont, textColor: textColor) self.label.isAccessibilityElement = false diff --git a/submodules/Display/Display/ActionSheetCheckboxItem.swift b/submodules/Display/Display/ActionSheetCheckboxItem.swift index 7c4f7acfdc..a24220e064 100644 --- a/submodules/Display/Display/ActionSheetCheckboxItem.swift +++ b/submodules/Display/Display/ActionSheetCheckboxItem.swift @@ -39,7 +39,7 @@ public class ActionSheetCheckboxItem: ActionSheetItem { } public class ActionSheetCheckboxItemNode: ActionSheetItemNode { - public static let defaultFont: UIFont = Font.regular(20.0) + private let defaultFont: UIFont private let theme: ActionSheetControllerTheme @@ -54,6 +54,7 @@ public class ActionSheetCheckboxItemNode: ActionSheetItemNode { override public init(theme: ActionSheetControllerTheme) { self.theme = theme + self.defaultFont = Font.regular(floor(theme.baseFontSize * 20.0 / 17.0)) self.button = HighlightTrackingButton() self.button.isAccessibilityElement = false @@ -118,8 +119,10 @@ public class ActionSheetCheckboxItemNode: ActionSheetItemNode { func setItem(_ item: ActionSheetCheckboxItem) { self.item = item - self.titleNode.attributedText = NSAttributedString(string: item.title, font: ActionSheetCheckboxItemNode.defaultFont, textColor: self.theme.primaryTextColor) - self.labelNode.attributedText = NSAttributedString(string: item.label, font: ActionSheetCheckboxItemNode.defaultFont, textColor: self.theme.secondaryTextColor) + let defaultFont = Font.regular(floor(theme.baseFontSize * 20.0 / 17.0)) + + self.titleNode.attributedText = NSAttributedString(string: item.title, font: defaultFont, textColor: self.theme.primaryTextColor) + self.labelNode.attributedText = NSAttributedString(string: item.label, font: defaultFont, textColor: self.theme.secondaryTextColor) self.checkNode.isHidden = !item.value self.accessibilityArea.accessibilityLabel = item.title diff --git a/submodules/Display/Display/ActionSheetSwitchItem.swift b/submodules/Display/Display/ActionSheetSwitchItem.swift index 01eb3678de..7dddc07701 100644 --- a/submodules/Display/Display/ActionSheetSwitchItem.swift +++ b/submodules/Display/Display/ActionSheetSwitchItem.swift @@ -42,6 +42,7 @@ public class ActionSheetSwitchNode: ActionSheetItemNode { override public init(theme: ActionSheetControllerTheme) { self.theme = theme + let defaultFont = Font.regular(floor(theme.baseFontSize * 20.0 / 17.0)) self.button = HighlightTrackingButton() self.button.isAccessibilityElement = false @@ -85,7 +86,9 @@ public class ActionSheetSwitchNode: ActionSheetItemNode { func setItem(_ item: ActionSheetSwitchItem) { self.item = item - self.label.attributedText = NSAttributedString(string: item.title, font: ActionSheetButtonNode.defaultFont, textColor: self.theme.primaryTextColor) + let defaultFont = Font.regular(floor(theme.baseFontSize * 20.0 / 17.0)) + + self.label.attributedText = NSAttributedString(string: item.title, font: defaultFont, textColor: self.theme.primaryTextColor) self.label.isAccessibilityElement = false self.switchNode.isOn = item.isOn diff --git a/submodules/Display/Display/ActionSheetTextItem.swift b/submodules/Display/Display/ActionSheetTextItem.swift index 5102185f61..7b65015f8d 100644 --- a/submodules/Display/Display/ActionSheetTextItem.swift +++ b/submodules/Display/Display/ActionSheetTextItem.swift @@ -26,7 +26,7 @@ public class ActionSheetTextItem: ActionSheetItem { } public class ActionSheetTextNode: ActionSheetItemNode { - public static let defaultFont: UIFont = Font.regular(13.0) + private let defaultFont: UIFont private let theme: ActionSheetControllerTheme @@ -38,6 +38,7 @@ public class ActionSheetTextNode: ActionSheetItemNode { override public init(theme: ActionSheetControllerTheme) { self.theme = theme + self.defaultFont = Font.regular(floor(theme.baseFontSize * 13.0 / 17.0)) self.label = ASTextNode() self.label.isUserInteractionEnabled = false @@ -60,7 +61,9 @@ public class ActionSheetTextNode: ActionSheetItemNode { func setItem(_ item: ActionSheetTextItem) { self.item = item - self.label.attributedText = NSAttributedString(string: item.title, font: ActionSheetTextNode.defaultFont, textColor: self.theme.secondaryTextColor, paragraphAlignment: .center) + let defaultFont = Font.regular(floor(theme.baseFontSize * 20.0 / 17.0)) + + self.label.attributedText = NSAttributedString(string: item.title, font: defaultFont, textColor: self.theme.secondaryTextColor, paragraphAlignment: .center) self.accessibilityArea.accessibilityLabel = item.title self.setNeedsLayout() diff --git a/submodules/Display/Display/ActionSheetTheme.swift b/submodules/Display/Display/ActionSheetTheme.swift index 1911cb8b3d..89ef25d5f6 100644 --- a/submodules/Display/Display/ActionSheetTheme.swift +++ b/submodules/Display/Display/ActionSheetTheme.swift @@ -21,8 +21,9 @@ public final class ActionSheetControllerTheme: Equatable { public let switchFrameColor: UIColor public let switchContentColor: UIColor public let switchHandleColor: UIColor + public let baseFontSize: CGFloat - public init(dimColor: UIColor, backgroundType: ActionSheetControllerThemeBackgroundType, itemBackgroundColor: UIColor, itemHighlightedBackgroundColor: UIColor, standardActionTextColor: UIColor, destructiveActionTextColor: UIColor, disabledActionTextColor: UIColor, primaryTextColor: UIColor, secondaryTextColor: UIColor, controlAccentColor: UIColor, controlColor: UIColor, switchFrameColor: UIColor, switchContentColor: UIColor, switchHandleColor: UIColor) { + public init(dimColor: UIColor, backgroundType: ActionSheetControllerThemeBackgroundType, itemBackgroundColor: UIColor, itemHighlightedBackgroundColor: UIColor, standardActionTextColor: UIColor, destructiveActionTextColor: UIColor, disabledActionTextColor: UIColor, primaryTextColor: UIColor, secondaryTextColor: UIColor, controlAccentColor: UIColor, controlColor: UIColor, switchFrameColor: UIColor, switchContentColor: UIColor, switchHandleColor: UIColor, baseFontSize: CGFloat) { self.dimColor = dimColor self.backgroundType = backgroundType self.itemBackgroundColor = itemBackgroundColor @@ -37,6 +38,7 @@ public final class ActionSheetControllerTheme: Equatable { self.switchFrameColor = switchFrameColor self.switchContentColor = switchContentColor self.switchHandleColor = switchHandleColor + self.baseFontSize = min(26.0, baseFontSize) } public static func ==(lhs: ActionSheetControllerTheme, rhs: ActionSheetControllerTheme) -> Bool { @@ -82,6 +84,9 @@ public final class ActionSheetControllerTheme: Equatable { if lhs.switchHandleColor != rhs.switchHandleColor { return false } + if lhs.baseFontSize != rhs.baseFontSize { + return false + } return true } } diff --git a/submodules/Display/Display/ListView.swift b/submodules/Display/Display/ListView.swift index f730752bf7..eca0ee0c07 100644 --- a/submodules/Display/Display/ListView.swift +++ b/submodules/Display/Display/ListView.swift @@ -2413,7 +2413,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture //print("replay after \(self.itemNodes.map({"\($0.index) \(unsafeAddressOf($0))"}))") } - if let scrollToItem = scrollToItem, !self.areAllItemsOnScreen() { + if let scrollToItem = scrollToItem, !self.areAllItemsOnScreen() || updateSizeAndInsets == nil { self.stopScrolling() for itemNode in self.itemNodes { diff --git a/submodules/Display/Display/TooltipController.swift b/submodules/Display/Display/TooltipController.swift index 2b440b21b1..f1c103fbcb 100644 --- a/submodules/Display/Display/TooltipController.swift +++ b/submodules/Display/Display/TooltipController.swift @@ -62,6 +62,7 @@ open class TooltipController: ViewController, StandalonePresentableController { } public private(set) var content: TooltipControllerContent + private let baseFontSize: CGFloat open func updateContent(_ content: TooltipControllerContent, animated: Bool, extendTimer: Bool, arrowOnBottom: Bool = true) { if self.content != content { @@ -89,8 +90,9 @@ open class TooltipController: ViewController, StandalonePresentableController { public var dismissed: ((Bool) -> Void)? - public init(content: TooltipControllerContent, timeout: Double = 2.0, dismissByTapOutside: Bool = false, dismissByTapOutsideSource: Bool = false, dismissImmediatelyOnLayoutUpdate: Bool = false, arrowOnBottom: Bool = true) { + public init(content: TooltipControllerContent, baseFontSize: CGFloat, timeout: Double = 2.0, dismissByTapOutside: Bool = false, dismissByTapOutsideSource: Bool = false, dismissImmediatelyOnLayoutUpdate: Bool = false, arrowOnBottom: Bool = true) { self.content = content + self.baseFontSize = baseFontSize self.timeout = timeout self.dismissByTapOutside = dismissByTapOutside self.dismissByTapOutsideSource = dismissByTapOutsideSource @@ -111,7 +113,7 @@ open class TooltipController: ViewController, StandalonePresentableController { } override open func loadDisplayNode() { - self.displayNode = TooltipControllerNode(content: self.content, dismiss: { [weak self] tappedInside in + self.displayNode = TooltipControllerNode(content: self.content, baseFontSize: self.baseFontSize, dismiss: { [weak self] tappedInside in self?.dismiss(tappedInside: tappedInside) }, dismissByTapOutside: self.dismissByTapOutside, dismissByTapOutsideSource: self.dismissByTapOutsideSource) self.controllerNode.arrowOnBottom = self.initialArrowOnBottom diff --git a/submodules/Display/Display/TooltipControllerNode.swift b/submodules/Display/Display/TooltipControllerNode.swift index 3b39885dc0..62b790ca8f 100644 --- a/submodules/Display/Display/TooltipControllerNode.swift +++ b/submodules/Display/Display/TooltipControllerNode.swift @@ -3,6 +3,8 @@ import UIKit import AsyncDisplayKit final class TooltipControllerNode: ASDisplayNode { + private let baseFontSize: CGFloat + private let dismiss: (Bool) -> Void private var validLayout: ContainerViewLayout? @@ -19,7 +21,9 @@ final class TooltipControllerNode: ASDisplayNode { private var dismissedByTouchOutside = false private var dismissByTapOutsideSource = false - init(content: TooltipControllerContent, dismiss: @escaping (Bool) -> Void, dismissByTapOutside: Bool, dismissByTapOutsideSource: Bool) { + init(content: TooltipControllerContent, baseFontSize: CGFloat, dismiss: @escaping (Bool) -> Void, dismissByTapOutside: Bool, dismissByTapOutsideSource: Bool) { + self.baseFontSize = baseFontSize + self.dismissByTapOutside = dismissByTapOutside self.dismissByTapOutsideSource = dismissByTapOutsideSource @@ -33,7 +37,7 @@ final class TooltipControllerNode: ASDisplayNode { if case let .attributedText(text) = content { self.textNode.attributedText = text } else { - self.textNode.attributedText = NSAttributedString(string: content.text, font: Font.regular(14.0), textColor: .white, paragraphAlignment: .center) + self.textNode.attributedText = NSAttributedString(string: content.text, font: Font.regular(floor(baseFontSize * 14.0 / 17.0)), textColor: .white, paragraphAlignment: .center) } self.textNode.isUserInteractionEnabled = false self.textNode.displaysAsynchronously = false @@ -58,7 +62,7 @@ final class TooltipControllerNode: ASDisplayNode { }) self.textNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.12) } - self.textNode.attributedText = NSAttributedString(string: text, font: Font.regular(14.0), textColor: .white, paragraphAlignment: .center) + self.textNode.attributedText = NSAttributedString(string: text, font: Font.regular(floor(self.baseFontSize * 14.0 / 17.0)), textColor: .white, paragraphAlignment: .center) if let layout = self.validLayout { self.containerLayoutUpdated(layout, transition: transition) } diff --git a/submodules/Display/Display/ViewController.swift b/submodules/Display/Display/ViewController.swift index a350b1e101..454f764476 100644 --- a/submodules/Display/Display/ViewController.swift +++ b/submodules/Display/Display/ViewController.swift @@ -529,7 +529,11 @@ public enum ViewControllerNavigationPresentation { } open func dismiss(completion: (() -> Void)? = nil) { - (self.navigationController as? NavigationController)?.filterController(self, animated: true) + if let navigationController = self.navigationController as? NavigationController { + navigationController.filterController(self, animated: true) + } else { + self.presentingViewController?.dismiss(animated: false, completion: nil) + } } @available(iOSApplicationExtension 9.0, iOS 9.0, *) diff --git a/submodules/Display/Display/WindowContent.swift b/submodules/Display/Display/WindowContent.swift index 2a23c98239..dbea7fd16f 100644 --- a/submodules/Display/Display/WindowContent.swift +++ b/submodules/Display/Display/WindowContent.swift @@ -272,6 +272,8 @@ public class Window1 { public var previewThemeAccentColor: UIColor = .blue public var previewThemeDarkBlur: Bool = false + private var shouldNotAnimateLikelyKeyboardAutocorrectionSwitch: Bool = false + public private(set) var forceInCallStatusBarText: String? = nil public var inCallNavigate: (() -> Void)? { didSet { @@ -522,7 +524,15 @@ public class Window1 { transitionCurve = .easeInOut } - strongSelf.updateLayout { $0.update(inputHeight: keyboardHeight.isLessThanOrEqualTo(0.0) ? nil : keyboardHeight, transition: .animated(duration: duration, curve: transitionCurve), overrideTransition: false) } + var transition: ContainedViewLayoutTransition = .animated(duration: duration, curve: transitionCurve) + + if strongSelf.shouldNotAnimateLikelyKeyboardAutocorrectionSwitch, let inputHeight = strongSelf.windowLayout.inputHeight { + if abs(inputHeight - keyboardHeight) <= 44.1 { + transition = .immediate + } + } + + strongSelf.updateLayout { $0.update(inputHeight: keyboardHeight.isLessThanOrEqualTo(0.0) ? nil : keyboardHeight, transition: transition, overrideTransition: false) } } }) @@ -1203,4 +1213,11 @@ public class Window1 { } } } + + public func doNotAnimateLikelyKeyboardAutocorrectionSwitch() { + self.shouldNotAnimateLikelyKeyboardAutocorrectionSwitch = true + DispatchQueue.main.async { + self.shouldNotAnimateLikelyKeyboardAutocorrectionSwitch = false + } + } } diff --git a/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift b/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift index 6e5b4944a9..4c69e53910 100644 --- a/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift +++ b/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift @@ -106,6 +106,7 @@ class CaptionScrollWrapperNode: ASDisplayNode { final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScrollViewDelegate { private let context: AccountContext + private var presentationData: PresentationData private var theme: PresentationTheme private var strings: PresentationStrings private var nameOrder: PresentationPersonNameOrder @@ -243,6 +244,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll init(context: AccountContext, presentationData: PresentationData) { self.context = context + self.presentationData = presentationData self.theme = presentationData.theme self.strings = presentationData.strings self.nameOrder = presentationData.nameDisplayOrder @@ -757,7 +759,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll } } - let actionSheet = ActionSheetController(presentationTheme: presentationData.theme) + let actionSheet = ActionSheetController(presentationData: presentationData) let items: [ActionSheetItem] = [ ActionSheetButtonItem(title: singleText, color: .destructive, action: { [weak actionSheet] in actionSheet?.dismissAnimated() @@ -787,7 +789,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll private func commitDeleteMessages(_ messages: [Message], ask: Bool) { self.messageContextDisposable.set((self.context.sharedContext.chatAvailableMessageActions(postbox: self.context.account.postbox, accountPeerId: self.context.account.peerId, messageIds: Set(messages.map { $0.id })) |> deliverOnMainQueue).start(next: { [weak self] actions in if let strongSelf = self, let controllerInteration = strongSelf.controllerInteraction, !actions.options.isEmpty { - let actionSheet = ActionSheetController(presentationTheme: strongSelf.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) var items: [ActionSheetItem] = [] var personalPeerName: String? var isChannel = false @@ -947,7 +949,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll } } - let actionSheet = ActionSheetController(presentationTheme: presentationData.theme) + let actionSheet = ActionSheetController(presentationData: presentationData) let items: [ActionSheetItem] = [ ActionSheetButtonItem(title: singleText, color: .accent, action: { [weak actionSheet] in actionSheet?.dismissAnimated() diff --git a/submodules/GalleryUI/Sources/GalleryController.swift b/submodules/GalleryUI/Sources/GalleryController.swift index 9a0907491a..24ac0a6c2d 100644 --- a/submodules/GalleryUI/Sources/GalleryController.swift +++ b/submodules/GalleryUI/Sources/GalleryController.swift @@ -609,7 +609,7 @@ public class GalleryController: ViewController, StandalonePresentableController } else if canOpenIn { openText = strongSelf.presentationData.strings.Conversation_FileOpenIn } - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) var items: [ActionSheetItem] = [] items.append(ActionSheetTextItem(title: cleanUrl)) @@ -652,7 +652,7 @@ public class GalleryController: ViewController, StandalonePresentableController ])]) strongSelf.present(actionSheet, in: .window(.root)) case let .peerMention(peerId, mention): - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) var items: [ActionSheetItem] = [] if !mention.isEmpty { items.append(ActionSheetTextItem(title: mention)) @@ -677,7 +677,7 @@ public class GalleryController: ViewController, StandalonePresentableController ])]) strongSelf.present(actionSheet, in: .window(.root)) case let .textMention(mention): - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetTextItem(title: mention), ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_LinkDialogOpen, color: .accent, action: { [weak actionSheet] in @@ -698,7 +698,7 @@ public class GalleryController: ViewController, StandalonePresentableController ])]) strongSelf.present(actionSheet, in: .window(.root)) case let .botCommand(command): - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) var items: [ActionSheetItem] = [] items.append(ActionSheetTextItem(title: command)) items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_LinkDialogCopy, color: .accent, action: { [weak actionSheet] in @@ -712,7 +712,7 @@ public class GalleryController: ViewController, StandalonePresentableController ])]) strongSelf.present(actionSheet, in: .window(.root)) case let .hashtag(peerName, hashtag): - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetTextItem(title: hashtag), ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_LinkDialogOpen, color: .accent, action: { [weak actionSheet] in @@ -734,7 +734,7 @@ public class GalleryController: ViewController, StandalonePresentableController ]) strongSelf.present(actionSheet, in: .window(.root)) case let .timecode(timecode, text): - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetTextItem(title: text), ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_LinkDialogOpen, color: .accent, action: { [weak actionSheet] in diff --git a/submodules/InstantPageUI/Sources/InstantPageGalleryController.swift b/submodules/InstantPageUI/Sources/InstantPageGalleryController.swift index 8b5da25843..5015a0b383 100644 --- a/submodules/InstantPageUI/Sources/InstantPageGalleryController.swift +++ b/submodules/InstantPageUI/Sources/InstantPageGalleryController.swift @@ -260,7 +260,7 @@ public class InstantPageGalleryController: ViewController, StandalonePresentable if let strongSelf = self { let canOpenIn = availableOpenInOptions(context: context, item: .url(url: url.url)).count > 1 let openText = canOpenIn ? strongSelf.presentationData.strings.Conversation_FileOpenIn : strongSelf.presentationData.strings.Conversation_LinkDialogOpen - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetTextItem(title: url.url), ActionSheetButtonItem(title: openText, color: .accent, action: { [weak actionSheet] in diff --git a/submodules/InstantPageUI/Sources/InstantPageTheme.swift b/submodules/InstantPageUI/Sources/InstantPageTheme.swift index 495378975b..61352e34d6 100644 --- a/submodules/InstantPageUI/Sources/InstantPageTheme.swift +++ b/submodules/InstantPageUI/Sources/InstantPageTheme.swift @@ -323,7 +323,7 @@ func instantPageThemeForType(_ type: InstantPageThemeType, settings: InstantPage extension ActionSheetControllerTheme { convenience init(instantPageTheme: InstantPageTheme) { - self.init(dimColor: UIColor(white: 0.0, alpha: 0.4), backgroundType: instantPageTheme.type != .dark ? .light : .dark, itemBackgroundColor: instantPageTheme.overlayPanelColor, itemHighlightedBackgroundColor: instantPageTheme.panelHighlightedBackgroundColor, standardActionTextColor: instantPageTheme.panelAccentColor, destructiveActionTextColor: instantPageTheme.panelAccentColor, disabledActionTextColor: instantPageTheme.panelAccentColor, primaryTextColor: instantPageTheme.textCategories.paragraph.color, secondaryTextColor: instantPageTheme.textCategories.caption.color, controlAccentColor: instantPageTheme.panelAccentColor, controlColor: instantPageTheme.tableBorderColor, switchFrameColor: .white, switchContentColor: .white, switchHandleColor: .white) + self.init(dimColor: UIColor(white: 0.0, alpha: 0.4), backgroundType: instantPageTheme.type != .dark ? .light : .dark, itemBackgroundColor: instantPageTheme.overlayPanelColor, itemHighlightedBackgroundColor: instantPageTheme.panelHighlightedBackgroundColor, standardActionTextColor: instantPageTheme.panelAccentColor, destructiveActionTextColor: instantPageTheme.panelAccentColor, disabledActionTextColor: instantPageTheme.panelAccentColor, primaryTextColor: instantPageTheme.textCategories.paragraph.color, secondaryTextColor: instantPageTheme.textCategories.caption.color, controlAccentColor: instantPageTheme.panelAccentColor, controlColor: instantPageTheme.tableBorderColor, switchFrameColor: .white, switchContentColor: .white, switchHandleColor: .white, baseFontSize: 17.0) } } diff --git a/submodules/ItemListUI/Sources/ItemListItem.swift b/submodules/ItemListUI/Sources/ItemListItem.swift index d9f8746046..0054416f1b 100644 --- a/submodules/ItemListUI/Sources/ItemListItem.swift +++ b/submodules/ItemListUI/Sources/ItemListItem.swift @@ -178,22 +178,7 @@ public final class ItemListPresentationData: Equatable { public extension PresentationFontSize { var itemListBaseHeaderFontSize: CGFloat { - switch self { - case .extraSmall: - return 13.0 - case .small: - return 14.0 - case .medium: - return 15.0 - case .regular: - return 16.0 - case .large: - return 18.0 - case .extraLarge: - return 22.0 - case .extraLargeX2: - return 25.0 - } + return floor(self.itemListBaseFontSize * 13.0 / 17.0) } var itemListBaseFontSize: CGFloat { diff --git a/submodules/LegacyComponents/LegacyComponents/TGAttachmentCarouselItemView.m b/submodules/LegacyComponents/LegacyComponents/TGAttachmentCarouselItemView.m index 17318f32fd..ed98907ad2 100644 --- a/submodules/LegacyComponents/LegacyComponents/TGAttachmentCarouselItemView.m +++ b/submodules/LegacyComponents/LegacyComponents/TGAttachmentCarouselItemView.m @@ -257,7 +257,7 @@ const NSUInteger TGAttachmentDisplayedAssetLimit = 500; if (_cameraView) [_collectionView addSubview:_cameraView]; - _sendMediaItemView = [[TGMenuSheetButtonItemView alloc] initWithTitle:nil type:TGMenuSheetButtonTypeSend action:^ + _sendMediaItemView = [[TGMenuSheetButtonItemView alloc] initWithTitle:nil type:TGMenuSheetButtonTypeSend fontSize:20.0 action:^ { __strong TGAttachmentCarouselItemView *strongSelf = weakSelf; if (strongSelf != nil && strongSelf.sendPressed != nil) @@ -272,7 +272,7 @@ const NSUInteger TGAttachmentDisplayedAssetLimit = 500; if (!_document) { - _sendFileItemView = [[TGMenuSheetButtonItemView alloc] initWithTitle:nil type:TGMenuSheetButtonTypeDefault action:^ + _sendFileItemView = [[TGMenuSheetButtonItemView alloc] initWithTitle:nil type:TGMenuSheetButtonTypeDefault fontSize:20.0 action:^ { __strong TGAttachmentCarouselItemView *strongSelf = weakSelf; if (strongSelf != nil && strongSelf.sendPressed != nil) diff --git a/submodules/LegacyComponents/LegacyComponents/TGCameraController.m b/submodules/LegacyComponents/LegacyComponents/TGCameraController.m index 8bb1df16ee..33ae3c1bfa 100644 --- a/submodules/LegacyComponents/LegacyComponents/TGCameraController.m +++ b/submodules/LegacyComponents/LegacyComponents/TGCameraController.m @@ -1050,7 +1050,7 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus NSArray *items = @ [ - [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Camera.Discard") type:TGMenuSheetButtonTypeDefault action:^ + [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Camera.Discard") type:TGMenuSheetButtonTypeDefault fontSize:20.0 action:^ { __strong TGMenuSheetController *strongController = weakController; if (strongController == nil) @@ -1063,7 +1063,7 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus [strongController dismissAnimated:true manual:false completion:nil]; [strongSelf beginTransitionOutWithVelocity:0.0f]; }], - [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.Cancel") type:TGMenuSheetButtonTypeCancel action:^ + [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.Cancel") type:TGMenuSheetButtonTypeCancel fontSize:20.0 action:^ { __strong TGMenuSheetController *strongController = weakController; if (strongController != nil) diff --git a/submodules/LegacyComponents/LegacyComponents/TGClipboardMenu.m b/submodules/LegacyComponents/LegacyComponents/TGClipboardMenu.m index e61ce11057..7a3b0c3169 100644 --- a/submodules/LegacyComponents/LegacyComponents/TGClipboardMenu.m +++ b/submodules/LegacyComponents/LegacyComponents/TGClipboardMenu.m @@ -64,7 +64,7 @@ sendTitle = [NSString stringWithFormat:format, [NSString stringWithFormat:@"%ld", photosCount]]; } - TGMenuSheetButtonItemView *sendItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:sendTitle type:TGMenuSheetButtonTypeSend action:^ + TGMenuSheetButtonItemView *sendItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:sendTitle type:TGMenuSheetButtonTypeSend fontSize:20.0 action:^ { __strong TGClipboardPreviewItemView *strongPreviewItem = weakPreviewItem; completed(strongPreviewItem.selectionContext, strongPreviewItem.editingContext, nil); @@ -90,7 +90,7 @@ [strongPreviewItem setCollapsed:count == 0 animated:true]; }; - TGMenuSheetButtonItemView *cancelItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.Cancel") type:TGMenuSheetButtonTypeCancel action:^ + TGMenuSheetButtonItemView *cancelItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.Cancel") type:TGMenuSheetButtonTypeCancel fontSize:20.0 action:^ { __strong TGMenuSheetController *strongController = weakController; [strongController dismissAnimated:true]; diff --git a/submodules/LegacyComponents/LegacyComponents/TGLocationLiveSessionItemView.m b/submodules/LegacyComponents/LegacyComponents/TGLocationLiveSessionItemView.m index 4e4bb3530c..98d3bfc810 100644 --- a/submodules/LegacyComponents/LegacyComponents/TGLocationLiveSessionItemView.m +++ b/submodules/LegacyComponents/LegacyComponents/TGLocationLiveSessionItemView.m @@ -23,7 +23,7 @@ { bool isUser = [peer isKindOfClass:[TGUser class]]; NSString *title = isUser ? ((TGUser *)peer).displayName : ((TGConversation *)peer).chatTitle; - self = [super initWithTitle:@"" type:TGMenuSheetButtonTypeDefault action:action]; + self = [super initWithTitle:@"" type:TGMenuSheetButtonTypeDefault fontSize:20.0 action:action]; if (self != nil) { _label = [[UILabel alloc] init]; diff --git a/submodules/LegacyComponents/LegacyComponents/TGLocationMapViewController.m b/submodules/LegacyComponents/LegacyComponents/TGLocationMapViewController.m index 6703d330d7..3a02f3c329 100644 --- a/submodules/LegacyComponents/LegacyComponents/TGLocationMapViewController.m +++ b/submodules/LegacyComponents/LegacyComponents/TGLocationMapViewController.m @@ -491,7 +491,7 @@ const CGFloat TGLocationMapInset = 100.0f; [itemViews addObject:titleItem]; __weak TGMenuSheetController *weakController = controller; - TGMenuSheetButtonItemView *for15MinutesItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Map.LiveLocationFor15Minutes") type:TGMenuSheetButtonTypeDefault action:^ + TGMenuSheetButtonItemView *for15MinutesItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Map.LiveLocationFor15Minutes") type:TGMenuSheetButtonTypeDefault fontSize:20.0 action:^ { __strong TGLocationMapViewController *strongSelf = weakSelf; if (strongSelf == nil) @@ -508,7 +508,7 @@ const CGFloat TGLocationMapInset = 100.0f; }]; [itemViews addObject:for15MinutesItem]; - TGMenuSheetButtonItemView *for1HourItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Map.LiveLocationFor1Hour") type:TGMenuSheetButtonTypeDefault action:^ + TGMenuSheetButtonItemView *for1HourItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Map.LiveLocationFor1Hour") type:TGMenuSheetButtonTypeDefault fontSize:20.0 action:^ { __strong TGLocationMapViewController *strongSelf = weakSelf; if (strongSelf == nil) @@ -525,7 +525,7 @@ const CGFloat TGLocationMapInset = 100.0f; }]; [itemViews addObject:for1HourItem]; - TGMenuSheetButtonItemView *for8HoursItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Map.LiveLocationFor8Hours") type:TGMenuSheetButtonTypeDefault action:^ + TGMenuSheetButtonItemView *for8HoursItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Map.LiveLocationFor8Hours") type:TGMenuSheetButtonTypeDefault fontSize:20.0 action:^ { __strong TGLocationMapViewController *strongSelf = weakSelf; if (strongSelf == nil) @@ -542,7 +542,7 @@ const CGFloat TGLocationMapInset = 100.0f; }]; [itemViews addObject:for8HoursItem]; - TGMenuSheetButtonItemView *cancelItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.Cancel") type:TGMenuSheetButtonTypeCancel action:^ + TGMenuSheetButtonItemView *cancelItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.Cancel") type:TGMenuSheetButtonTypeCancel fontSize:20.0 action:^ { __strong TGMenuSheetController *strongController = weakController; if (strongController == nil) diff --git a/submodules/LegacyComponents/LegacyComponents/TGLocationViewController.m b/submodules/LegacyComponents/LegacyComponents/TGLocationViewController.m index 67ba7e72b3..97489ab445 100644 --- a/submodules/LegacyComponents/LegacyComponents/TGLocationViewController.m +++ b/submodules/LegacyComponents/LegacyComponents/TGLocationViewController.m @@ -742,7 +742,7 @@ NSMutableArray *itemViews = [[NSMutableArray alloc] init]; __weak TGMenuSheetController *weakController = controller; - TGMenuSheetButtonItemView *openItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Map.OpenInMaps") type:TGMenuSheetButtonTypeDefault action:^ + TGMenuSheetButtonItemView *openItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Map.OpenInMaps") type:TGMenuSheetButtonTypeDefault fontSize:20.0 action:^ { __strong TGLocationViewController *strongSelf = weakSelf; if (strongSelf == nil) @@ -757,7 +757,7 @@ }]; [itemViews addObject:openItem]; - TGMenuSheetButtonItemView *shareItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Conversation.ContextMenuShare") type:TGMenuSheetButtonTypeDefault action:^ + TGMenuSheetButtonItemView *shareItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Conversation.ContextMenuShare") type:TGMenuSheetButtonTypeDefault fontSize:20.0 action:^ { __strong TGMenuSheetController *strongController = weakController; if (strongController == nil) @@ -770,7 +770,7 @@ }]; [itemViews addObject:shareItem]; - TGMenuSheetButtonItemView *cancelItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.Cancel") type:TGMenuSheetButtonTypeCancel action:^ + TGMenuSheetButtonItemView *cancelItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.Cancel") type:TGMenuSheetButtonTypeCancel fontSize:20.0 action:^ { __strong TGMenuSheetController *strongController = weakController; if (strongController == nil) @@ -870,7 +870,7 @@ __weak TGMenuSheetController *weakController = controller; NSArray *items = @ [ - [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Map.GetDirections") type:TGMenuSheetButtonTypeDefault action:^ + [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Map.GetDirections") type:TGMenuSheetButtonTypeDefault fontSize:20.0 action:^ { __strong TGMenuSheetController *strongController = weakController; if (strongController == nil) @@ -879,7 +879,7 @@ [strongController dismissAnimated:true]; block(); }], - [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.Cancel") type:TGMenuSheetButtonTypeCancel action:^ + [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.Cancel") type:TGMenuSheetButtonTypeCancel fontSize:20.0 action:^ { __strong TGMenuSheetController *strongController = weakController; if (strongController != nil) diff --git a/submodules/LegacyComponents/LegacyComponents/TGMediaAvatarMenuMixin.m b/submodules/LegacyComponents/LegacyComponents/TGMediaAvatarMenuMixin.m index b43bcd9353..ed292c996e 100644 --- a/submodules/LegacyComponents/LegacyComponents/TGMediaAvatarMenuMixin.m +++ b/submodules/LegacyComponents/LegacyComponents/TGMediaAvatarMenuMixin.m @@ -128,7 +128,7 @@ }; [itemViews addObject:carouselItem]; - TGMenuSheetButtonItemView *galleryItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.ChoosePhoto") type:TGMenuSheetButtonTypeDefault action:^ + TGMenuSheetButtonItemView *galleryItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.ChoosePhoto") type:TGMenuSheetButtonTypeDefault fontSize:20.0 action:^ { __strong TGMediaAvatarMenuMixin *strongSelf = weakSelf; if (strongSelf == nil) @@ -145,7 +145,7 @@ if (_hasSearchButton) { - TGMenuSheetButtonItemView *viewItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"AttachmentMenu.WebSearch") type:TGMenuSheetButtonTypeDefault action:^ + TGMenuSheetButtonItemView *viewItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"AttachmentMenu.WebSearch") type:TGMenuSheetButtonTypeDefault fontSize:20.0 action:^ { __strong TGMediaAvatarMenuMixin *strongSelf = weakSelf; if (strongSelf == nil) @@ -164,7 +164,7 @@ if (_hasViewButton) { - TGMenuSheetButtonItemView *viewItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Settings.ViewPhoto") type:TGMenuSheetButtonTypeDefault action:^ + TGMenuSheetButtonItemView *viewItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Settings.ViewPhoto") type:TGMenuSheetButtonTypeDefault fontSize:20.0 action:^ { __strong TGMediaAvatarMenuMixin *strongSelf = weakSelf; if (strongSelf == nil) @@ -182,7 +182,7 @@ if (_hasDeleteButton) { - TGMenuSheetButtonItemView *deleteItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"GroupInfo.SetGroupPhotoDelete") type:TGMenuSheetButtonTypeDestructive action:^ + TGMenuSheetButtonItemView *deleteItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"GroupInfo.SetGroupPhotoDelete") type:TGMenuSheetButtonTypeDestructive fontSize:20.0 action:^ { __strong TGMediaAvatarMenuMixin *strongSelf = weakSelf; if (strongSelf == nil) @@ -198,7 +198,7 @@ [itemViews addObject:deleteItem]; } - TGMenuSheetButtonItemView *cancelItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.Cancel") type:TGMenuSheetButtonTypeCancel action:^ + TGMenuSheetButtonItemView *cancelItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.Cancel") type:TGMenuSheetButtonTypeCancel fontSize:20.0 action:^ { __strong TGMediaAvatarMenuMixin *strongSelf = weakSelf; if (strongSelf == nil) diff --git a/submodules/LegacyComponents/LegacyComponents/TGMediaPickerGalleryInterfaceView.m b/submodules/LegacyComponents/LegacyComponents/TGMediaPickerGalleryInterfaceView.m index c94f055775..7bcdea25b5 100644 --- a/submodules/LegacyComponents/LegacyComponents/TGMediaPickerGalleryInterfaceView.m +++ b/submodules/LegacyComponents/LegacyComponents/TGMediaPickerGalleryInterfaceView.m @@ -609,7 +609,7 @@ NSArray *items = @ [ - [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Camera.Discard") type:TGMenuSheetButtonTypeDefault action:^ + [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Camera.Discard") type:TGMenuSheetButtonTypeDefault fontSize:20.0 action:^ { __strong TGMenuSheetController *strongController = weakController; if (strongController == nil) @@ -624,7 +624,7 @@ [strongController dismissAnimated:true manual:false completion:nil]; }], - [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.Cancel") type:TGMenuSheetButtonTypeCancel action:^ + [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.Cancel") type:TGMenuSheetButtonTypeCancel fontSize:20.0 action:^ { __strong TGMenuSheetController *strongController = weakController; if (strongController != nil) diff --git a/submodules/LegacyComponents/LegacyComponents/TGMenuSheetButtonItemView.h b/submodules/LegacyComponents/LegacyComponents/TGMenuSheetButtonItemView.h index 610e8925cd..730f304e2f 100644 --- a/submodules/LegacyComponents/LegacyComponents/TGMenuSheetButtonItemView.h +++ b/submodules/LegacyComponents/LegacyComponents/TGMenuSheetButtonItemView.h @@ -21,7 +21,7 @@ typedef enum @property (nonatomic, copy) void (^action)(void); @property (nonatomic, assign) bool thickDivider; -- (instancetype)initWithTitle:(NSString *)title type:(TGMenuSheetButtonType)type action:(void (^)(void))action; +- (instancetype)initWithTitle:(NSString *)title type:(TGMenuSheetButtonType)type fontSize:(CGFloat)fontSize action:(void (^)(void))action; @property (nonatomic, assign) bool collapsed; - (void)setCollapsed:(bool)collapsed animated:(bool)animated; diff --git a/submodules/LegacyComponents/LegacyComponents/TGMenuSheetButtonItemView.m b/submodules/LegacyComponents/LegacyComponents/TGMenuSheetButtonItemView.m index e6c781d84a..bdd068021c 100644 --- a/submodules/LegacyComponents/LegacyComponents/TGMenuSheetButtonItemView.m +++ b/submodules/LegacyComponents/LegacyComponents/TGMenuSheetButtonItemView.m @@ -16,6 +16,7 @@ const CGFloat TGMenuSheetButtonItemViewHeight = 57.0f; bool _dark; bool _requiresDivider; UIView *_customDivider; + CGFloat _fontSize; TGMenuSheetPallete *_pallete; } @@ -23,12 +24,13 @@ const CGFloat TGMenuSheetButtonItemViewHeight = 57.0f; @implementation TGMenuSheetButtonItemView -- (instancetype)initWithTitle:(NSString *)title type:(TGMenuSheetButtonType)type action:(void (^)(void))action +- (instancetype)initWithTitle:(NSString *)title type:(TGMenuSheetButtonType)type fontSize:(CGFloat)fontSize action:(void (^)(void))action { self = [super initWithType:(type == TGMenuSheetButtonTypeCancel) ? TGMenuSheetItemTypeFooter : TGMenuSheetItemTypeDefault]; if (self != nil) { self.action = action; + _fontSize = fontSize; _buttonType = type; _requiresDivider = true; @@ -115,7 +117,7 @@ const CGFloat TGMenuSheetButtonItemViewHeight = 57.0f; - (void)_updateForType:(TGMenuSheetButtonType)type { - _button.titleLabel.font = (type == TGMenuSheetButtonTypeCancel || type == TGMenuSheetButtonTypeSend) ? TGMediumSystemFontOfSize(20) : TGSystemFontOfSize(20); + _button.titleLabel.font = (type == TGMenuSheetButtonTypeCancel || type == TGMenuSheetButtonTypeSend) ? TGMediumSystemFontOfSize(_fontSize) : TGSystemFontOfSize(_fontSize); UIColor *accentColor = _dark ? UIColorRGB(0x4fbcff) : TGAccentColor(); if (_pallete != nil) accentColor = _pallete.accentColor; diff --git a/submodules/LegacyComponents/LegacyComponents/TGPassportAttachMenu.m b/submodules/LegacyComponents/LegacyComponents/TGPassportAttachMenu.m index cfe5081397..fe894de053 100644 --- a/submodules/LegacyComponents/LegacyComponents/TGPassportAttachMenu.m +++ b/submodules/LegacyComponents/LegacyComponents/TGPassportAttachMenu.m @@ -84,7 +84,7 @@ }; [itemViews addObject:carouselItem]; - TGMenuSheetButtonItemView *galleryItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.ChoosePhoto") type:TGMenuSheetButtonTypeDefault action:^ + TGMenuSheetButtonItemView *galleryItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.ChoosePhoto") type:TGMenuSheetButtonTypeDefault fontSize:20.0 action:^ { __strong TGMenuSheetController *strongController = weakController; if (strongController == nil) @@ -101,7 +101,7 @@ if (iosMajorVersion() >= 8 && intent != TGPassportAttachIntentSelfie) { - TGMenuSheetButtonItemView *icloudItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Conversation.FileICloudDrive") type:TGMenuSheetButtonTypeDefault action:^ + TGMenuSheetButtonItemView *icloudItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Conversation.FileICloudDrive") type:TGMenuSheetButtonTypeDefault fontSize:20.0 action:^ { __strong TGMenuSheetController *strongController = weakController; if (strongController == nil) @@ -124,7 +124,7 @@ } carouselItem.remainingHeight = TGMenuSheetButtonItemViewHeight * (itemViews.count - 1); - TGMenuSheetButtonItemView *cancelItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.Cancel") type:TGMenuSheetButtonTypeCancel action:^ + TGMenuSheetButtonItemView *cancelItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.Cancel") type:TGMenuSheetButtonTypeCancel fontSize:20.0 action:^ { __strong TGMenuSheetController *strongController = weakController; if (strongController == nil) diff --git a/submodules/LegacyComponents/LegacyComponents/TGPhotoCropController.m b/submodules/LegacyComponents/LegacyComponents/TGPhotoCropController.m index 1f2dbdfd46..7e3847d2b7 100644 --- a/submodules/LegacyComponents/LegacyComponents/TGPhotoCropController.m +++ b/submodules/LegacyComponents/LegacyComponents/TGPhotoCropController.m @@ -625,8 +625,8 @@ NSString * const TGPhotoCropOriginalAspectRatio = @"original"; }; NSMutableArray *items = [[NSMutableArray alloc] init]; - [items addObject:[[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"PhotoEditor.CropAspectRatioOriginal") type:TGMenuSheetButtonTypeDefault action:^{ action(TGPhotoCropOriginalAspectRatio); }]]; - [items addObject:[[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"PhotoEditor.CropAspectRatioSquare") type:TGMenuSheetButtonTypeDefault action:^{ action(@"1.0"); }]]; + [items addObject:[[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"PhotoEditor.CropAspectRatioOriginal") type:TGMenuSheetButtonTypeDefault fontSize:20.0 action:^{ action(TGPhotoCropOriginalAspectRatio); }]]; + [items addObject:[[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"PhotoEditor.CropAspectRatioSquare") type:TGMenuSheetButtonTypeDefault fontSize:20.0 action:^{ action(@"1.0"); }]]; CGSize croppedImageSize = _cropView.cropRect.size; if (_cropView.cropOrientation == UIImageOrientationLeft || _cropView.cropOrientation == UIImageOrientationRight) @@ -666,10 +666,10 @@ NSString * const TGPhotoCropOriginalAspectRatio = @"original"; ratio = heightComponent / widthComponent; - [items addObject:[[TGMenuSheetButtonItemView alloc] initWithTitle:[NSString stringWithFormat:@"%d:%d", (int)widthComponent, (int)heightComponent] type:TGMenuSheetButtonTypeDefault action:^{ action([NSString stringWithFormat:@"%f", ratio]); }]]; + [items addObject:[[TGMenuSheetButtonItemView alloc] initWithTitle:[NSString stringWithFormat:@"%d:%d", (int)widthComponent, (int)heightComponent] type:TGMenuSheetButtonTypeDefault fontSize:20.0 action:^{ action([NSString stringWithFormat:@"%f", ratio]); }]]; } - [items addObject:[[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.Cancel") type:TGMenuSheetButtonTypeCancel action:^ + [items addObject:[[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.Cancel") type:TGMenuSheetButtonTypeCancel fontSize:20.0 action:^ { __strong TGMenuSheetController *strongController = weakController; if (strongController != nil) diff --git a/submodules/LegacyComponents/LegacyComponents/TGPhotoEditorController.m b/submodules/LegacyComponents/LegacyComponents/TGPhotoEditorController.m index ecab32e66d..0233810df4 100644 --- a/submodules/LegacyComponents/LegacyComponents/TGPhotoEditorController.m +++ b/submodules/LegacyComponents/LegacyComponents/TGPhotoEditorController.m @@ -1341,7 +1341,7 @@ NSArray *items = @ [ - [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"PhotoEditor.DiscardChanges") type:TGMenuSheetButtonTypeDefault action:^ + [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"PhotoEditor.DiscardChanges") type:TGMenuSheetButtonTypeDefault fontSize:20.0 action:^ { __strong TGMenuSheetController *strongController = weakController; if (strongController == nil) @@ -1352,7 +1352,7 @@ dismiss(); }]; }], - [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.Cancel") type:TGMenuSheetButtonTypeCancel action:^ + [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.Cancel") type:TGMenuSheetButtonTypeCancel fontSize:20.0 action:^ { __strong TGMenuSheetController *strongController = weakController; if (strongController != nil) diff --git a/submodules/LegacyComponents/LegacyComponents/TGPhotoPaintController.m b/submodules/LegacyComponents/LegacyComponents/TGPhotoPaintController.m index 664256614b..e8a25a309f 100644 --- a/submodules/LegacyComponents/LegacyComponents/TGPhotoPaintController.m +++ b/submodules/LegacyComponents/LegacyComponents/TGPhotoPaintController.m @@ -550,7 +550,7 @@ const CGFloat TGPhotoPaintStickerKeyboardSize = 260.0f; __weak TGPhotoPaintController *weakSelf = self; NSArray *items = @ [ - [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Paint.ClearConfirm") type:TGMenuSheetButtonTypeDestructive action:^ + [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Paint.ClearConfirm") type:TGMenuSheetButtonTypeDestructive fontSize:20.0 action:^ { __strong TGMenuSheetController *strongController = weakController; if (strongController == nil) @@ -570,7 +570,7 @@ const CGFloat TGPhotoPaintStickerKeyboardSize = 260.0f; [strongController dismissAnimated:true manual:false completion:nil]; }], - [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.Cancel") type:TGMenuSheetButtonTypeCancel action:^ + [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.Cancel") type:TGMenuSheetButtonTypeCancel fontSize:20.0 action:^ { __strong TGMenuSheetController *strongController = weakController; if (strongController != nil) diff --git a/submodules/LegacyComponents/LegacyComponents/TGSecretTimerMenu.m b/submodules/LegacyComponents/LegacyComponents/TGSecretTimerMenu.m index b14fcf5dce..1398251a35 100644 --- a/submodules/LegacyComponents/LegacyComponents/TGSecretTimerMenu.m +++ b/submodules/LegacyComponents/LegacyComponents/TGSecretTimerMenu.m @@ -37,7 +37,7 @@ __weak TGMenuSheetController *weakController = controller; __weak TGSecretTimerPickerItemView *weakTimerItem = timerItem; - TGMenuSheetButtonItemView *doneItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.Done") type:TGMenuSheetButtonTypeSend action:^ + TGMenuSheetButtonItemView *doneItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.Done") type:TGMenuSheetButtonTypeSend fontSize:20.0 action:^ { __strong TGSecretTimerPickerItemView *strongTimerItem = weakTimerItem; if (strongTimerItem != nil) diff --git a/submodules/LegacyMediaPickerUI/Sources/LegacyAttachmentMenu.swift b/submodules/LegacyMediaPickerUI/Sources/LegacyAttachmentMenu.swift index b4056dd51d..6b8cf2e9af 100644 --- a/submodules/LegacyMediaPickerUI/Sources/LegacyAttachmentMenu.swift +++ b/submodules/LegacyMediaPickerUI/Sources/LegacyAttachmentMenu.swift @@ -22,6 +22,8 @@ public struct LegacyAttachmentMenuMediaEditing: OptionSet { } public func legacyAttachmentMenu(context: AccountContext, peer: Peer, editMediaOptions: LegacyAttachmentMenuMediaEditing?, saveEditedPhotos: Bool, allowGrouping: Bool, hasSchedule: Bool, canSendPolls: Bool, presentationData: PresentationData, parentController: LegacyController, recentlyUsedInlineBots: [Peer], initialCaption: String, openGallery: @escaping () -> Void, openCamera: @escaping (TGAttachmentCameraView?, TGMenuSheetController?) -> Void, openFileGallery: @escaping () -> Void, openWebSearch: @escaping () -> Void, openMap: @escaping () -> Void, openContacts: @escaping () -> Void, openPoll: @escaping () -> Void, presentSelectionLimitExceeded: @escaping () -> Void, presentCantSendMultipleFiles: @escaping () -> Void, presentSchedulePicker: @escaping (@escaping (Int32) -> Void) -> Void, sendMessagesWithSignals: @escaping ([Any]?, Bool, Int32) -> Void, selectRecentlyUsedInlineBot: @escaping (Peer) -> Void) -> TGMenuSheetController { + let actionSheetTheme = ActionSheetControllerTheme(presentationData: presentationData) + let isSecretChat = peer.id.namespace == Namespaces.Peer.SecretChat let controller = TGMenuSheetController(context: parentController.context, dark: false)! @@ -99,7 +101,7 @@ public func legacyAttachmentMenu(context: AccountContext, peer: Peer, editMediaO carouselItem.editingContext.setInitialCaption(initialCaption, entities: []) itemViews.append(carouselItem) - let galleryItem = TGMenuSheetButtonItemView(title: editing ? presentationData.strings.Conversation_EditingMessageMediaChange : presentationData.strings.AttachmentMenu_PhotoOrVideo, type: TGMenuSheetButtonTypeDefault, action: { [weak controller] in + let galleryItem = TGMenuSheetButtonItemView(title: editing ? presentationData.strings.Conversation_EditingMessageMediaChange : presentationData.strings.AttachmentMenu_PhotoOrVideo, type: TGMenuSheetButtonTypeDefault, fontSize: actionSheetTheme.baseFontSize, action: { [weak controller] in controller?.dismiss(animated: true) openGallery() })! @@ -117,7 +119,7 @@ public func legacyAttachmentMenu(context: AccountContext, peer: Peer, editMediaO } if !editing { - let fileItem = TGMenuSheetButtonItemView(title: presentationData.strings.AttachmentMenu_File, type: TGMenuSheetButtonTypeDefault, action: {[weak controller] in + let fileItem = TGMenuSheetButtonItemView(title: presentationData.strings.AttachmentMenu_File, type: TGMenuSheetButtonTypeDefault, fontSize: actionSheetTheme.baseFontSize, action: {[weak controller] in controller?.dismiss(animated: true) openFileGallery() })! @@ -126,7 +128,7 @@ public func legacyAttachmentMenu(context: AccountContext, peer: Peer, editMediaO } if canEditCurrent { - let fileItem = TGMenuSheetButtonItemView(title: presentationData.strings.AttachmentMenu_File, type: TGMenuSheetButtonTypeDefault, action: {[weak controller] in + let fileItem = TGMenuSheetButtonItemView(title: presentationData.strings.AttachmentMenu_File, type: TGMenuSheetButtonTypeDefault, fontSize: actionSheetTheme.baseFontSize, action: {[weak controller] in controller?.dismiss(animated: true) openFileGallery() })! @@ -134,21 +136,21 @@ public func legacyAttachmentMenu(context: AccountContext, peer: Peer, editMediaO } if editMediaOptions == nil { - let locationItem = TGMenuSheetButtonItemView(title: presentationData.strings.Conversation_Location, type: TGMenuSheetButtonTypeDefault, action: { [weak controller] in + let locationItem = TGMenuSheetButtonItemView(title: presentationData.strings.Conversation_Location, type: TGMenuSheetButtonTypeDefault, fontSize: actionSheetTheme.baseFontSize, action: { [weak controller] in controller?.dismiss(animated: true) openMap() })! itemViews.append(locationItem) if (peer is TelegramGroup || peer is TelegramChannel) && canSendMessagesToPeer(peer) && canSendPolls { - let pollItem = TGMenuSheetButtonItemView(title: presentationData.strings.AttachmentMenu_Poll, type: TGMenuSheetButtonTypeDefault, action: { [weak controller] in + let pollItem = TGMenuSheetButtonItemView(title: presentationData.strings.AttachmentMenu_Poll, type: TGMenuSheetButtonTypeDefault, fontSize: actionSheetTheme.baseFontSize, action: { [weak controller] in controller?.dismiss(animated: true) openPoll() })! itemViews.append(pollItem) } - let contactItem = TGMenuSheetButtonItemView(title: presentationData.strings.Conversation_Contact, type: TGMenuSheetButtonTypeDefault, action: { [weak controller] in + let contactItem = TGMenuSheetButtonItemView(title: presentationData.strings.Conversation_Contact, type: TGMenuSheetButtonTypeDefault, fontSize: actionSheetTheme.baseFontSize, action: { [weak controller] in controller?.dismiss(animated: true) openContacts() })! @@ -162,7 +164,7 @@ public func legacyAttachmentMenu(context: AccountContext, peer: Peer, editMediaO let peer = recentlyUsedInlineBots[i] let addressName = peer.addressName if let addressName = addressName { - let botItem = TGMenuSheetButtonItemView(title: "@" + addressName, type: TGMenuSheetButtonTypeDefault, action: { [weak controller] in + let botItem = TGMenuSheetButtonItemView(title: "@" + addressName, type: TGMenuSheetButtonTypeDefault, fontSize: actionSheetTheme.baseFontSize, action: { [weak controller] in controller?.dismiss(animated: true) selectRecentlyUsedInlineBot(peer) @@ -175,7 +177,7 @@ public func legacyAttachmentMenu(context: AccountContext, peer: Peer, editMediaO carouselItemView?.remainingHeight = TGMenuSheetButtonItemViewHeight * CGFloat(itemViews.count - 1) - let cancelItem = TGMenuSheetButtonItemView(title: presentationData.strings.Common_Cancel, type: TGMenuSheetButtonTypeCancel, action: { [weak controller] in + let cancelItem = TGMenuSheetButtonItemView(title: presentationData.strings.Common_Cancel, type: TGMenuSheetButtonTypeCancel, fontSize: actionSheetTheme.baseFontSize, action: { [weak controller] in controller?.dismiss(animated: true) })! itemViews.append(cancelItem) diff --git a/submodules/LocationUI/Sources/LocationPickerController.swift b/submodules/LocationUI/Sources/LocationPickerController.swift index 0502606360..4d15fae2f7 100644 --- a/submodules/LocationUI/Sources/LocationPickerController.swift +++ b/submodules/LocationUI/Sources/LocationPickerController.swift @@ -135,7 +135,7 @@ public final class LocationPickerController: ViewController { guard let strongSelf = self else { return } - let controller = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let controller = ActionSheetController(presentationData: strongSelf.presentationData) var title = strongSelf.presentationData.strings.Map_LiveLocationGroupDescription if case let .share(peer, _, _) = strongSelf.mode, let receiver = peer { title = strongSelf.presentationData.strings.Map_LiveLocationPrivateDescription(receiver.compactDisplayTitle).0 diff --git a/submodules/MtProtoKit/MTProtoKit/MTContext.h b/submodules/MtProtoKit/MTProtoKit/MTContext.h index 57c6474d9e..c4cff82ef3 100644 --- a/submodules/MtProtoKit/MTProtoKit/MTContext.h +++ b/submodules/MtProtoKit/MTProtoKit/MTContext.h @@ -22,7 +22,7 @@ - (void)contextDatacenterAddressSetUpdated:(MTContext *)context datacenterId:(NSInteger)datacenterId addressSet:(MTDatacenterAddressSet *)addressSet; - (void)contextDatacenterAuthInfoUpdated:(MTContext *)context datacenterId:(NSInteger)datacenterId authInfo:(MTDatacenterAuthInfo *)authInfo; - (void)contextDatacenterAuthTokenUpdated:(MTContext *)context datacenterId:(NSInteger)datacenterId authToken:(id)authToken; -- (void)contextDatacenterTransportSchemesUpdated:(MTContext *)context datacenterId:(NSInteger)datacenterId; +- (void)contextDatacenterTransportSchemesUpdated:(MTContext *)context datacenterId:(NSInteger)datacenterId shouldReset:(bool)shouldReset; - (void)contextIsPasswordRequiredUpdated:(MTContext *)context datacenterId:(NSInteger)datacenterId; - (void)contextDatacenterPublicKeysUpdated:(MTContext *)context datacenterId:(NSInteger)datacenterId publicKeys:(NSArray *)publicKeys; - (MTSignal *)fetchContextDatacenterPublicKeys:(MTContext *)context datacenterId:(NSInteger)datacenterId; diff --git a/submodules/MtProtoKit/MTProtoKit/MTContext.m b/submodules/MtProtoKit/MTProtoKit/MTContext.m index 357148b856..e38d403363 100644 --- a/submodules/MtProtoKit/MTProtoKit/MTContext.m +++ b/submodules/MtProtoKit/MTProtoKit/MTContext.m @@ -491,10 +491,11 @@ static int32_t fixedTimeDifferenceValue = 0; [listener contextDatacenterAddressSetUpdated:self datacenterId:datacenterId addressSet:addressSet]; } - if (previousAddressSetWasEmpty || updateSchemes || true) { + if (true) { + bool shouldReset = previousAddressSetWasEmpty || updateSchemes; for (id listener in currentListeners) { - if ([listener respondsToSelector:@selector(contextDatacenterTransportSchemesUpdated:datacenterId:)]) { - [listener contextDatacenterTransportSchemesUpdated:self datacenterId:datacenterId]; + if ([listener respondsToSelector:@selector(contextDatacenterTransportSchemesUpdated:datacenterId:shouldReset:)]) { + [listener contextDatacenterTransportSchemesUpdated:self datacenterId:datacenterId shouldReset:shouldReset]; } } } else { @@ -664,8 +665,8 @@ static int32_t fixedTimeDifferenceValue = 0; } for (id listener in currentListeners) { - if ([listener respondsToSelector:@selector(contextDatacenterTransportSchemesUpdated:datacenterId:)]) - [listener contextDatacenterTransportSchemesUpdated:self datacenterId:datacenterId]; + if ([listener respondsToSelector:@selector(contextDatacenterTransportSchemesUpdated:datacenterId:shouldReset:)]) + [listener contextDatacenterTransportSchemesUpdated:self datacenterId:datacenterId shouldReset:true]; } } }]; diff --git a/submodules/MtProtoKit/MTProtoKit/MTProto.m b/submodules/MtProtoKit/MTProtoKit/MTProto.m index bba17b43ca..a88d60767f 100644 --- a/submodules/MtProtoKit/MTProtoKit/MTProto.m +++ b/submodules/MtProtoKit/MTProtoKit/MTProto.m @@ -2715,15 +2715,20 @@ static NSString *dumpHexString(NSData *data, int maxLength) { } } -- (void)contextDatacenterTransportSchemesUpdated:(MTContext *)context datacenterId:(NSInteger)datacenterId { +- (void)contextDatacenterTransportSchemesUpdated:(MTContext *)context datacenterId:(NSInteger)datacenterId shouldReset:(bool)shouldReset { [[MTProto managerQueue] dispatchOnQueue:^ { if (context == _context && datacenterId == _datacenterId && ![self isStopped]) { + bool resolvedShouldReset = shouldReset; + if (_mtState & MTProtoStateAwaitingDatacenterScheme) { [self setMtState:_mtState & (~MTProtoStateAwaitingDatacenterScheme)]; + resolvedShouldReset = true; } - [self resetTransport]; - [self requestTransportTransaction]; + if (resolvedShouldReset) { + [self resetTransport]; + [self requestTransportTransaction]; + } } }]; } diff --git a/submodules/NotificationMuteSettingsUI/Sources/NotificationMuteSettingsController.swift b/submodules/NotificationMuteSettingsUI/Sources/NotificationMuteSettingsController.swift index 513c4319c9..953e997502 100644 --- a/submodules/NotificationMuteSettingsUI/Sources/NotificationMuteSettingsController.swift +++ b/submodules/NotificationMuteSettingsUI/Sources/NotificationMuteSettingsController.swift @@ -23,7 +23,7 @@ public struct NotificationSoundSettings { } public func notificationMuteSettingsController(presentationData: PresentationData, notificationSettings: MessageNotificationSettings, soundSettings: NotificationSoundSettings?, openSoundSettings: @escaping () -> Void, updateSettings: @escaping (Int32?) -> Void) -> ViewController { - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } diff --git a/submodules/OpenInExternalAppUI/Sources/OpenInActionSheetController.swift b/submodules/OpenInExternalAppUI/Sources/OpenInActionSheetController.swift index cbb3711de7..3e84e47d75 100644 --- a/submodules/OpenInExternalAppUI/Sources/OpenInActionSheetController.swift +++ b/submodules/OpenInExternalAppUI/Sources/OpenInActionSheetController.swift @@ -35,11 +35,11 @@ public final class OpenInActionSheetController: ActionSheetController { let theme = presentationData.theme let strings = presentationData.strings - super.init(theme: ActionSheetControllerTheme(presentationTheme: theme)) + super.init(theme: ActionSheetControllerTheme(presentationData: presentationData)) self.presentationDisposable = context.sharedContext.presentationData.start(next: { [weak self] presentationData in if let strongSelf = self { - strongSelf.theme = ActionSheetControllerTheme(presentationTheme: presentationData.theme) + strongSelf.theme = ActionSheetControllerTheme(presentationData: presentationData) } }) @@ -116,9 +116,6 @@ private final class OpenInActionSheetItem: ActionSheetItem { } } -private let titleFont = Font.medium(20.0) -private let textFont = Font.regular(11.0) - private final class OpenInActionSheetItemNode: ActionSheetItemNode { let theme: ActionSheetControllerTheme let strings: PresentationStrings @@ -132,6 +129,9 @@ private final class OpenInActionSheetItemNode: ActionSheetItemNode { self.theme = theme self.strings = strings + let titleFont = Font.medium(floor(theme.baseFontSize * 20.0 / 17.0)) + let textFont = Font.regular(floor(theme.baseFontSize * 11.0 / 17.0)) + self.titleNode = ASTextNode() self.titleNode.isUserInteractionEnabled = false self.titleNode.displaysAsynchronously = true @@ -216,6 +216,7 @@ private final class OpenInAppNode : ASDisplayNode { } func setup(postbox: Postbox, context: AccountContext, theme: ActionSheetControllerTheme, option: OpenInOption, invokeAction: @escaping (OpenInAction) -> Void) { + let textFont = Font.regular(floor(theme.baseFontSize * 11.0 / 17.0)) self.textNode.attributedText = NSAttributedString(string: option.title, font: textFont, textColor: theme.primaryTextColor, paragraphAlignment: .center) let iconSize = CGSize(width: 60.0, height: 60.0) diff --git a/submodules/PasscodeUI/Sources/PasscodeSetupController.swift b/submodules/PasscodeUI/Sources/PasscodeSetupController.swift index b3c400ae9c..33a9f3cb4a 100644 --- a/submodules/PasscodeUI/Sources/PasscodeSetupController.swift +++ b/submodules/PasscodeUI/Sources/PasscodeSetupController.swift @@ -59,7 +59,7 @@ public final class PasscodeSetupController: ViewController { return } - let controller = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let controller = ActionSheetController(presentationData: strongSelf.presentationData) let dismissAction: () -> Void = { [weak controller] in self?.controllerNode.activateInput() controller?.dismissAnimated() diff --git a/submodules/PassportUI/Sources/SecureIdAuthControllerNode.swift b/submodules/PassportUI/Sources/SecureIdAuthControllerNode.swift index 0c1dc472dd..349dd669a8 100644 --- a/submodules/PassportUI/Sources/SecureIdAuthControllerNode.swift +++ b/submodules/PassportUI/Sources/SecureIdAuthControllerNode.swift @@ -727,7 +727,7 @@ final class SecureIdAuthControllerNode: ViewControllerTracingNode { } if let currentValue = currentValue { - let controller = ActionSheetController(presentationTheme: self.presentationData.theme) + let controller = ActionSheetController(presentationData: self.presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } @@ -847,7 +847,7 @@ final class SecureIdAuthControllerNode: ViewControllerTracingNode { return } - let controller = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let controller = ActionSheetController(presentationData: strongSelf.presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } @@ -916,7 +916,7 @@ final class SecureIdAuthControllerNode: ViewControllerTracingNode { ] } - let controller = ActionSheetController(presentationTheme: self.presentationData.theme) + let controller = ActionSheetController(presentationData: self.presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } @@ -961,7 +961,7 @@ final class SecureIdAuthControllerNode: ViewControllerTracingNode { } private func deleteAllValues() { - let controller = ActionSheetController(presentationTheme: self.presentationData.theme) + let controller = ActionSheetController(presentationData: self.presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } diff --git a/submodules/PassportUI/Sources/SecureIdDocumentFormControllerNode.swift b/submodules/PassportUI/Sources/SecureIdDocumentFormControllerNode.swift index e2b30260c5..e8782a86e6 100644 --- a/submodules/PassportUI/Sources/SecureIdDocumentFormControllerNode.swift +++ b/submodules/PassportUI/Sources/SecureIdDocumentFormControllerNode.swift @@ -2143,6 +2143,7 @@ final class SecureIdDocumentFormControllerNode: FormControllerNode Void = { [weak controller] in controller?.dismissAnimated() } @@ -2756,7 +2758,7 @@ final class SecureIdDocumentFormControllerNode: FormControllerNode Void = { [weak controller] in controller?.dismissAnimated() } @@ -2816,7 +2818,7 @@ final class SecureIdDocumentFormControllerNode: FormControllerNode Void = { [weak controller] in controller?.dismissAnimated() } diff --git a/submodules/PassportUI/Sources/SecureIdDocumentGalleryFooterContentNode.swift b/submodules/PassportUI/Sources/SecureIdDocumentGalleryFooterContentNode.swift index b3959526a6..269c1bdbdc 100644 --- a/submodules/PassportUI/Sources/SecureIdDocumentGalleryFooterContentNode.swift +++ b/submodules/PassportUI/Sources/SecureIdDocumentGalleryFooterContentNode.swift @@ -143,7 +143,7 @@ final class SecureIdDocumentGalleryFooterContentNode: GalleryFooterContentNode { @objc func deleteButtonPressed() { let presentationData = self.context.sharedContext.currentPresentationData.with { $0 } - let actionSheet = ActionSheetController(presentationTheme: presentationData.theme) + let actionSheet = ActionSheetController(presentationData: presentationData) let items: [ActionSheetItem] = [ ActionSheetButtonItem(title: presentationData.strings.Common_Delete, color: .destructive, action: { [weak self, weak actionSheet] in actionSheet?.dismissAnimated() diff --git a/submodules/PassportUI/Sources/SecureIdDocumentTypeSelectionController.swift b/submodules/PassportUI/Sources/SecureIdDocumentTypeSelectionController.swift index ba7ffea302..08b80c1d04 100644 --- a/submodules/PassportUI/Sources/SecureIdDocumentTypeSelectionController.swift +++ b/submodules/PassportUI/Sources/SecureIdDocumentTypeSelectionController.swift @@ -89,11 +89,11 @@ final class SecureIdDocumentTypeSelectionController: ActionSheetController { self.completion = completion - super.init(theme: ActionSheetControllerTheme(presentationTheme: theme)) + super.init(theme: ActionSheetControllerTheme(presentationData: presentationData)) self.presentationDisposable = context.sharedContext.presentationData.start(next: { [weak self] presentationData in if let strongSelf = self { - strongSelf.theme = ActionSheetControllerTheme(presentationTheme: presentationData.theme) + strongSelf.theme = ActionSheetControllerTheme(presentationData: presentationData) } }) diff --git a/submodules/PasswordSetupUI/Sources/TwoFactorAuthDataInputScreen.swift b/submodules/PasswordSetupUI/Sources/TwoFactorAuthDataInputScreen.swift index c3cb036a8a..444b537c47 100644 --- a/submodules/PasswordSetupUI/Sources/TwoFactorAuthDataInputScreen.swift +++ b/submodules/PasswordSetupUI/Sources/TwoFactorAuthDataInputScreen.swift @@ -505,12 +505,12 @@ private final class TwoFactorDataInputTextNode: ASDisplayNode, UITextFieldDelega self.backgroundNode = ASImageNode() self.backgroundNode.displaysAsynchronously = false self.backgroundNode.displayWithoutProcessing = true - self.backgroundNode.image = generateStretchableFilledCircleImage(diameter: 20.0, color: theme.actionSheet.inputBackgroundColor) + self.backgroundNode.image = generateStretchableFilledCircleImage(diameter: 20.0, color: theme.list.freePlainInputField.backgroundColor) self.inputNode = TextFieldNode() self.inputNode.textField.font = Font.regular(17.0) - self.inputNode.textField.textColor = theme.actionSheet.inputTextColor - self.inputNode.textField.attributedPlaceholder = NSAttributedString(string: placeholder, font: Font.regular(17.0), textColor: theme.actionSheet.inputPlaceholderColor) + self.inputNode.textField.textColor = theme.list.freePlainInputField.primaryColor + self.inputNode.textField.attributedPlaceholder = NSAttributedString(string: placeholder, font: Font.regular(17.0), textColor: theme.list.freePlainInputField.placeholderColor) self.hideButtonNode = HighlightableButtonNode() @@ -548,10 +548,10 @@ private final class TwoFactorDataInputTextNode: ASDisplayNode, UITextFieldDelega } self.inputNode.textField.keyboardAppearance = theme.rootController.keyboardColor.keyboardAppearance - self.hideButtonNode.setImage(generateTextHiddenImage(color: theme.actionSheet.inputClearButtonColor, on: false), for: []) + self.hideButtonNode.setImage(generateTextHiddenImage(color: theme.list.freePlainInputField.controlColor, on: false), for: []) self.clearButtonNode = HighlightableButtonNode() - self.clearButtonNode.setImage(generateClearImage(color: theme.actionSheet.inputClearButtonColor), for: []) + self.clearButtonNode.setImage(generateClearImage(color: theme.list.freePlainInputField.controlColor), for: []) self.clearButtonNode.isHidden = true super.init() @@ -1198,11 +1198,27 @@ private final class TwoFactorDataInputScreenNode: ViewControllerTracingNode, UIS transition.updateFrame(node: self.skipActionButtonNode, frame: buttonFrame) transition.updateFrame(node: self.skipActionTitleNode, frame: CGRect(origin: CGPoint(x: buttonFrame.minX + floor((buttonFrame.width - skipActionSize.width) / 2.0), y: buttonFrame.minY + floor((buttonFrame.height - skipActionSize.height) / 2.0)), size: skipActionSize)) - transition.updateFrame(node: self.changeEmailActionButtonNode, frame: CGRect(origin: CGPoint(x: buttonFrame.minX, y: buttonFrame.minY), size: CGSize(width: floor(buttonFrame.width / 2.0), height: buttonFrame.height))) - transition.updateFrame(node: self.resendCodeActionButtonNode, frame: CGRect(origin: CGPoint(x: buttonFrame.maxX - floor(buttonFrame.width / 2.0), y: buttonFrame.minY), size: CGSize(width: floor(buttonFrame.width / 2.0), height: buttonFrame.height))) + let changeEmailActionFrame: CGRect + let changeEmailActionButtonFrame: CGRect + let resendCodeActionFrame: CGRect + let resendCodeActionButtonFrame: CGRect + if changeEmailActionSize.width + resendCodeActionSize.width > layout.size.width - 24.0 { + changeEmailActionButtonFrame = CGRect(origin: CGPoint(x: buttonFrame.minX, y: buttonFrame.minY), size: CGSize(width: buttonFrame.width, height: buttonFrame.height)) + changeEmailActionFrame = CGRect(origin: CGPoint(x: changeEmailActionButtonFrame.minX + floor((changeEmailActionButtonFrame.width - changeEmailActionSize.width) / 2.0), y: changeEmailActionButtonFrame.minY + floor((changeEmailActionButtonFrame.height - changeEmailActionSize.height) / 2.0)), size: changeEmailActionSize) + resendCodeActionButtonFrame = CGRect(origin: CGPoint(x: buttonFrame.minX, y: buttonFrame.maxY), size: CGSize(width: buttonFrame.width, height: buttonFrame.height)) + resendCodeActionFrame = CGRect(origin: CGPoint(x: resendCodeActionButtonFrame.minX + floor((resendCodeActionButtonFrame.width - resendCodeActionSize.width) / 2.0), y: resendCodeActionButtonFrame.minY + floor((resendCodeActionButtonFrame.height - resendCodeActionSize.height) / 2.0)), size: resendCodeActionSize) + } else { + changeEmailActionButtonFrame = CGRect(origin: CGPoint(x: buttonFrame.minX, y: buttonFrame.minY), size: CGSize(width: floor(buttonFrame.width / 2.0), height: buttonFrame.height)) + changeEmailActionFrame = CGRect(origin: CGPoint(x: changeEmailActionButtonFrame.minX, y: changeEmailActionButtonFrame.minY + floor((changeEmailActionButtonFrame.height - changeEmailActionSize.height) / 2.0)), size: changeEmailActionSize) + resendCodeActionButtonFrame = CGRect(origin: CGPoint(x: buttonFrame.maxX - floor(buttonFrame.width / 2.0), y: buttonFrame.minY), size: CGSize(width: floor(buttonFrame.width / 2.0), height: buttonFrame.height)) + resendCodeActionFrame = CGRect(origin: CGPoint(x: resendCodeActionButtonFrame.maxX - resendCodeActionSize.width, y: resendCodeActionButtonFrame.minY + floor((resendCodeActionButtonFrame.height - resendCodeActionSize.height) / 2.0)), size: resendCodeActionSize) + } - transition.updateFrame(node: self.changeEmailActionTitleNode, frame: CGRect(origin: CGPoint(x: buttonFrame.minX, y: buttonFrame.minY + floor((buttonFrame.height - changeEmailActionSize.height) / 2.0)), size: changeEmailActionSize)) - transition.updateFrame(node: self.resendCodeActionTitleNode, frame: CGRect(origin: CGPoint(x: buttonFrame.maxX - resendCodeActionSize.width, y: buttonFrame.minY + floor((buttonFrame.height - resendCodeActionSize.height) / 2.0)), size: resendCodeActionSize)) + transition.updateFrame(node: self.changeEmailActionButtonNode, frame: changeEmailActionButtonFrame) + transition.updateFrame(node: self.resendCodeActionButtonNode, frame: resendCodeActionButtonFrame) + + transition.updateFrame(node: self.changeEmailActionTitleNode, frame: changeEmailActionFrame) + transition.updateFrame(node: self.resendCodeActionTitleNode, frame: resendCodeActionFrame) transition.animateView { self.scrollNode.view.contentInset = UIEdgeInsets(top: 0.0, left: 0.0, bottom: layout.insets(options: [.input]).bottom, right: 0.0) diff --git a/submodules/PeerAvatarGalleryUI/Sources/AvatarGalleryItemFooterContentNode.swift b/submodules/PeerAvatarGalleryUI/Sources/AvatarGalleryItemFooterContentNode.swift index a6542e8338..7132c6cfa2 100644 --- a/submodules/PeerAvatarGalleryUI/Sources/AvatarGalleryItemFooterContentNode.swift +++ b/submodules/PeerAvatarGalleryUI/Sources/AvatarGalleryItemFooterContentNode.swift @@ -148,7 +148,7 @@ final class AvatarGalleryItemFooterContentNode: GalleryFooterContentNode { @objc private func deleteButtonPressed() { let presentationData = self.context.sharedContext.currentPresentationData.with { $0 } - let actionSheet = ActionSheetController(presentationTheme: presentationData.theme) + let actionSheet = ActionSheetController(presentationData: presentationData) let items: [ActionSheetItem] = [ ActionSheetButtonItem(title: presentationData.strings.Common_Delete, color: .destructive, action: { [weak self, weak actionSheet] in actionSheet?.dismissAnimated() diff --git a/submodules/PeerInfoUI/Sources/ChannelAdminController.swift b/submodules/PeerInfoUI/Sources/ChannelAdminController.swift index e25514050f..f6de2685fa 100644 --- a/submodules/PeerInfoUI/Sources/ChannelAdminController.swift +++ b/submodules/PeerInfoUI/Sources/ChannelAdminController.swift @@ -868,7 +868,7 @@ public func channelAdminController(context: AccountContext, peerId: PeerId, admi } }, dismissAdmin: { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let actionSheet = ActionSheetController(presentationTheme: presentationData.theme) + let actionSheet = ActionSheetController(presentationData: presentationData) var items: [ActionSheetItem] = [] items.append(ActionSheetButtonItem(title: presentationData.strings.Channel_Moderator_AccessLevelRevoke, color: .destructive, font: .default, enabled: true, action: { [weak actionSheet] in actionSheet?.dismissAnimated() diff --git a/submodules/PeerInfoUI/Sources/ChannelBannedMemberController.swift b/submodules/PeerInfoUI/Sources/ChannelBannedMemberController.swift index cfc11dc4bc..8cdcc8a0d5 100644 --- a/submodules/PeerInfoUI/Sources/ChannelBannedMemberController.swift +++ b/submodules/PeerInfoUI/Sources/ChannelBannedMemberController.swift @@ -461,7 +461,7 @@ public func channelBannedMemberController(context: AccountContext, peerId: PeerI }) }, openTimeout: { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let actionSheet = ActionSheetController(presentationTheme: presentationData.theme) + let actionSheet = ActionSheetController(presentationData: presentationData) let intervals: [Int32] = [ 1 * 60 * 60 * 24, 7 * 60 * 60 * 24, @@ -499,7 +499,7 @@ public func channelBannedMemberController(context: AccountContext, peerId: PeerI presentControllerImpl?(actionSheet, nil) }, delete: { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let actionSheet = ActionSheetController(presentationTheme: presentationData.theme) + let actionSheet = ActionSheetController(presentationData: presentationData) var items: [ActionSheetItem] = [] items.append(ActionSheetButtonItem(title: presentationData.strings.GroupPermission_Delete, color: .destructive, font: .default, enabled: true, action: { [weak actionSheet] in actionSheet?.dismissAnimated() @@ -703,7 +703,7 @@ public func channelBannedMemberController(context: AccountContext, peerId: PeerI } let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let actionSheet = ActionSheetController(presentationTheme: presentationData.theme) + let actionSheet = ActionSheetController(presentationData: presentationData) var items: [ActionSheetItem] = [] items.append(ActionSheetTextItem(title: presentationData.strings.GroupPermission_ApplyAlertText(peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)).0)) items.append(ActionSheetButtonItem(title: presentationData.strings.GroupPermission_ApplyAlertAction, color: .accent, font: .default, enabled: true, action: { [weak actionSheet] in diff --git a/submodules/PeerInfoUI/Sources/ChannelBlacklistController.swift b/submodules/PeerInfoUI/Sources/ChannelBlacklistController.swift index 8420a3edc0..4af27181e4 100644 --- a/submodules/PeerInfoUI/Sources/ChannelBlacklistController.swift +++ b/submodules/PeerInfoUI/Sources/ChannelBlacklistController.swift @@ -359,7 +359,7 @@ public func channelBlacklistController(context: AccountContext, peerId: PeerId) return } let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let actionSheet = ActionSheetController(presentationTheme: presentationData.theme) + let actionSheet = ActionSheetController(presentationData: presentationData) var items: [ActionSheetItem] = [] if !participant.peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder).isEmpty { items.append(ActionSheetTextItem(title: participant.peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder))) diff --git a/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupActionSheetItem.swift b/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupActionSheetItem.swift index 282532c2cd..632fb32ace 100644 --- a/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupActionSheetItem.swift +++ b/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupActionSheetItem.swift @@ -75,9 +75,13 @@ private final class ChannelDiscussionGroupActionSheetItemNode: ActionSheetItemNo } else { text = strings.Channel_DiscussionGroup_PrivateChannelLink(groupPeer.displayTitle(strings: strings, displayOrder: nameDisplayOrder), channelPeer.displayTitle(strings: strings, displayOrder: nameDisplayOrder)) } - let attributedText = NSMutableAttributedString(attributedString: NSAttributedString(string: text.0, font: Font.regular(14.0), textColor: theme.primaryTextColor)) + + let textFont = Font.regular(floor(theme.baseFontSize * 14.0 / 17.0)) + let boldFont = Font.semibold(floor(theme.baseFontSize * 14.0 / 17.0)) + + let attributedText = NSMutableAttributedString(attributedString: NSAttributedString(string: text.0, font: textFont, textColor: theme.primaryTextColor)) for (_, range) in text.1 { - attributedText.addAttribute(.font, value: Font.semibold(14.0), range: range) + attributedText.addAttribute(.font, value: boldFont, range: range) } self.textNode.attributedText = attributedText diff --git a/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupSetupController.swift b/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupSetupController.swift index 208c3b2d51..4903486df0 100644 --- a/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupSetupController.swift +++ b/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupSetupController.swift @@ -305,7 +305,7 @@ public func channelDiscussionGroupSetupController(context: AccountContext, peerI } let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let actionSheet = ActionSheetController(presentationTheme: presentationData.theme) + let actionSheet = ActionSheetController(presentationData: presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ChannelDiscussionGroupActionSheetItem(context: context, channelPeer: channelPeer, groupPeer: groupPeer, strings: presentationData.strings, nameDisplayOrder: presentationData.nameDisplayOrder), ActionSheetButtonItem(title: presentationData.strings.Channel_DiscussionGroup_LinkGroup, color: .accent, action: { [weak actionSheet] in diff --git a/submodules/PeerInfoUI/Sources/ChannelInfoController.swift b/submodules/PeerInfoUI/Sources/ChannelInfoController.swift index 3d2f4770db..c6f54bc7a1 100644 --- a/submodules/PeerInfoUI/Sources/ChannelInfoController.swift +++ b/submodules/PeerInfoUI/Sources/ChannelInfoController.swift @@ -905,7 +905,7 @@ public func channelInfoController(context: AccountContext, peerId: PeerId) -> Vi return } let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } @@ -929,7 +929,7 @@ public func channelInfoController(context: AccountContext, peerId: PeerId) -> Vi return } let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } diff --git a/submodules/PeerInfoUI/Sources/ChannelVisibilityController.swift b/submodules/PeerInfoUI/Sources/ChannelVisibilityController.swift index 3a500896a4..7c8d773521 100644 --- a/submodules/PeerInfoUI/Sources/ChannelVisibilityController.swift +++ b/submodules/PeerInfoUI/Sources/ChannelVisibilityController.swift @@ -922,7 +922,7 @@ public func channelVisibilityController(context: AccountContext, peerId: PeerId, }) }, revokePrivateLink: { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } diff --git a/submodules/PeerInfoUI/Sources/DeviceContactInfoController.swift b/submodules/PeerInfoUI/Sources/DeviceContactInfoController.swift index 3c61919f78..1163927d61 100644 --- a/submodules/PeerInfoUI/Sources/DeviceContactInfoController.swift +++ b/submodules/PeerInfoUI/Sources/DeviceContactInfoController.swift @@ -869,7 +869,7 @@ public func deviceContactInfoController(context: AccountContext, subject: Device |> deliverOnMainQueue).start(next: { user in if let user = user, let phone = user.phone, formatPhoneNumber(phone) == formatPhoneNumber(number) { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } @@ -992,7 +992,7 @@ public func deviceContactInfoController(context: AccountContext, subject: Device inviteAction(subject.contactData.basicData.phoneNumbers[0].value) } else { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } @@ -1402,7 +1402,7 @@ private func addContactToExisting(context: AccountContext, parentController: Vie func addContactOptionsController(context: AccountContext, peer: Peer?, contactData: DeviceContactExtendedData) -> ActionSheetController { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } diff --git a/submodules/PeerInfoUI/Sources/GroupInfoController.swift b/submodules/PeerInfoUI/Sources/GroupInfoController.swift index 003f1668fe..6c0a565449 100644 --- a/submodules/PeerInfoUI/Sources/GroupInfoController.swift +++ b/submodules/PeerInfoUI/Sources/GroupInfoController.swift @@ -1998,7 +1998,7 @@ public func groupInfoController(context: AccountContext, peerId originalPeerId: let presentationData = context.sharedContext.currentPresentationData.with { $0 } if let channel = peerView.peers[peerView.peerId] as? TelegramChannel, channel.flags.contains(.isCreator), stateValue.with({ $0 }).editingState != nil { - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } @@ -2015,7 +2015,7 @@ public func groupInfoController(context: AccountContext, peerId originalPeerId: ]) presentControllerImpl?(controller, ViewControllerPresentationArguments(presentationAnimation: .modalSheet)) } else if let peer = peerView.peers[peerView.peerId] { - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } diff --git a/submodules/PeerInfoUI/Sources/GroupsInCommonController.swift b/submodules/PeerInfoUI/Sources/GroupsInCommonController.swift index 693185f0a9..fcbab9fe62 100644 --- a/submodules/PeerInfoUI/Sources/GroupsInCommonController.swift +++ b/submodules/PeerInfoUI/Sources/GroupsInCommonController.swift @@ -208,7 +208,7 @@ public func groupsInCommonController(context: AccountContext, peerId: PeerId) -> arguments.openPeer(peer.id) })) ] - let contextController = ContextController(account: context.account, theme: presentationData.theme, strings: presentationData.strings, source: .controller(ContextControllerContentSourceImpl(controller: chatController, sourceNode: node)), items: .single(items), reactionItems: [], gesture: gesture) + let contextController = ContextController(account: context.account, presentationData: presentationData, source: .controller(ContextControllerContentSourceImpl(controller: chatController, sourceNode: node)), items: .single(items), reactionItems: [], gesture: gesture) controller.presentInGlobalOverlay(contextController) } return controller diff --git a/submodules/PeerInfoUI/Sources/PeerBanTimeoutController.swift b/submodules/PeerInfoUI/Sources/PeerBanTimeoutController.swift index e0dfa93163..b6a7459613 100644 --- a/submodules/PeerInfoUI/Sources/PeerBanTimeoutController.swift +++ b/submodules/PeerInfoUI/Sources/PeerBanTimeoutController.swift @@ -23,13 +23,13 @@ final class PeerBanTimeoutController: ActionSheetController { let theme = presentationData.theme let strings = presentationData.strings - super.init(theme: ActionSheetControllerTheme(presentationTheme: theme)) + super.init(theme: ActionSheetControllerTheme(presentationData: presentationData)) self._ready.set(.single(true)) self.presentationDisposable = context.sharedContext.presentationData.start(next: { [weak self] presentationData in if let strongSelf = self { - strongSelf.theme = ActionSheetControllerTheme(presentationTheme: presentationData.theme) + strongSelf.theme = ActionSheetControllerTheme(presentationData: presentationData) } }) diff --git a/submodules/PeerInfoUI/Sources/PeerReportController.swift b/submodules/PeerInfoUI/Sources/PeerReportController.swift index e0ce0e9a09..5e057cf581 100644 --- a/submodules/PeerInfoUI/Sources/PeerReportController.swift +++ b/submodules/PeerInfoUI/Sources/PeerReportController.swift @@ -111,7 +111,7 @@ public func presentPeerReportOptions(context: AccountContext, parent: ViewContro public func peerReportOptionsController(context: AccountContext, subject: PeerReportSubject, present: @escaping (ViewController, Any?) -> Void, push: @escaping (ViewController) -> Void, completion: @escaping (Bool) -> Void) -> ViewController { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let controller = ActionSheetController(theme: ActionSheetControllerTheme(presentationTheme: presentationData.theme)) + let controller = ActionSheetController(theme: ActionSheetControllerTheme(presentationData: presentationData)) let options: [PeerReportOption] = [ .spam, diff --git a/submodules/PeerInfoUI/Sources/UserInfoController.swift b/submodules/PeerInfoUI/Sources/UserInfoController.swift index 564eb79e5e..4295034880 100644 --- a/submodules/PeerInfoUI/Sources/UserInfoController.swift +++ b/submodules/PeerInfoUI/Sources/UserInfoController.swift @@ -990,7 +990,7 @@ public func userInfoController(context: AccountContext, peerId: PeerId, mode: Pe } else { if value { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } @@ -1046,7 +1046,7 @@ public func userInfoController(context: AccountContext, peerId: PeerId, mode: Pe }) }, deleteContact: { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } @@ -1112,7 +1112,7 @@ public func userInfoController(context: AccountContext, peerId: PeerId, mode: Pe |> deliverOnMainQueue).start(next: { peer, _ in if let peer = peer as? TelegramUser, let peerPhoneNumber = peer.phone, formatPhoneNumber(number) == formatPhoneNumber(peerPhoneNumber) { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } @@ -1584,7 +1584,7 @@ public func userInfoController(context: AccountContext, peerId: PeerId, mode: Pe let presentationData = context.sharedContext.currentPresentationData.with { $0 } let text: String = presentationData.strings.UserInfo_TapToCall - let tooltipController = TooltipController(content: .text(text), dismissByTapOutside: true) + let tooltipController = TooltipController(content: .text(text), baseFontSize: presentationData.fontSize.baseDisplaySize, dismissByTapOutside: true) controller.present(tooltipController, in: .window(.root), with: TooltipControllerPresentationArguments(sourceNodeAndRect: { [weak resultItemNode] in if let resultItemNode = resultItemNode { return (resultItemNode, callButtonFrame) diff --git a/submodules/SettingsUI/Sources/Data and Storage/DataAndStorageSettingsController.swift b/submodules/SettingsUI/Sources/Data and Storage/DataAndStorageSettingsController.swift index 197baf416f..d98436d558 100644 --- a/submodules/SettingsUI/Sources/Data and Storage/DataAndStorageSettingsController.swift +++ b/submodules/SettingsUI/Sources/Data and Storage/DataAndStorageSettingsController.swift @@ -556,7 +556,7 @@ func dataAndStorageController(context: AccountContext, focusOnItemTag: DataAndSt pushControllerImpl?(autodownloadMediaConnectionTypeController(context: context, connectionType: connectionType)) }, resetAutomaticDownload: { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let actionSheet = ActionSheetController(presentationTheme: presentationData.theme) + let actionSheet = ActionSheetController(presentationData: presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetTextItem(title: presentationData.strings.AutoDownloadSettings_ResetHelp), ActionSheetButtonItem(title: presentationData.strings.AutoDownloadSettings_Reset, color: .destructive, action: { [weak actionSheet] in diff --git a/submodules/SettingsUI/Sources/Data and Storage/IntentsSettingsController.swift b/submodules/SettingsUI/Sources/Data and Storage/IntentsSettingsController.swift index 23ff903b84..a5b7a22b40 100644 --- a/submodules/SettingsUI/Sources/Data and Storage/IntentsSettingsController.swift +++ b/submodules/SettingsUI/Sources/Data and Storage/IntentsSettingsController.swift @@ -271,7 +271,7 @@ public func intentsSettingsController(context: AccountContext) -> ViewController let _ = updateIntentsSettingsInteractively(accountManager: context.sharedContext.accountManager, f).start() }, resetAll: { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let actionSheet = ActionSheetController(presentationTheme: presentationData.theme) + let actionSheet = ActionSheetController(presentationData: presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetButtonItem(title: presentationData.strings.IntentsSettings_Reset, color: .destructive, action: { [weak actionSheet] in actionSheet?.dismissAnimated() diff --git a/submodules/SettingsUI/Sources/Data and Storage/NetworkUsageStatsController.swift b/submodules/SettingsUI/Sources/Data and Storage/NetworkUsageStatsController.swift index a59748fcf5..87744afa82 100644 --- a/submodules/SettingsUI/Sources/Data and Storage/NetworkUsageStatsController.swift +++ b/submodules/SettingsUI/Sources/Data and Storage/NetworkUsageStatsController.swift @@ -389,7 +389,7 @@ func networkUsageStatsController(context: AccountContext) -> ViewController { let arguments = NetworkUsageStatsControllerArguments(resetStatistics: { [weak stats] section in let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } diff --git a/submodules/SettingsUI/Sources/Data and Storage/ProxyListSettingsController.swift b/submodules/SettingsUI/Sources/Data and Storage/ProxyListSettingsController.swift index 9d36248e23..317eedd81f 100644 --- a/submodules/SettingsUI/Sources/Data and Storage/ProxyListSettingsController.swift +++ b/submodules/SettingsUI/Sources/Data and Storage/ProxyListSettingsController.swift @@ -216,7 +216,7 @@ private enum ProxySettingsControllerEntry: ItemListNodeEntry { case let .serversHeader(theme, text): return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section) case let .addServer(theme, text, _): - return ProxySettingsActionItem(theme: theme, title: text, icon: .add, sectionId: self.section, editing: false, action: { + return ProxySettingsActionItem(presentationData: presentationData, title: text, icon: .add, sectionId: self.section, editing: false, action: { arguments.addNewServer() }) case let .server(_, theme, strings, settings, active, status, editing, enabled): @@ -230,7 +230,7 @@ private enum ProxySettingsControllerEntry: ItemListNodeEntry { arguments.removeServer(settings) }) case let .shareProxyList(theme, text): - return ProxySettingsActionItem(theme: theme, title: text, sectionId: self.section, editing: false, action: { + return ProxySettingsActionItem(presentationData: presentationData, title: text, sectionId: self.section, editing: false, action: { arguments.shareProxyList() }) case let .useForCalls(theme, text, value): diff --git a/submodules/SettingsUI/Sources/Data and Storage/ProxyServerActionSheetController.swift b/submodules/SettingsUI/Sources/Data and Storage/ProxyServerActionSheetController.swift index 0302f15264..d2d60c646e 100644 --- a/submodules/SettingsUI/Sources/Data and Storage/ProxyServerActionSheetController.swift +++ b/submodules/SettingsUI/Sources/Data and Storage/ProxyServerActionSheetController.swift @@ -29,7 +29,7 @@ public final class ProxyServerActionSheetController: ActionSheetController { } public init(presentationData: PresentationData, accountManager: AccountManager, postbox: Postbox, network: Network, server: ProxyServerSettings, updatedPresentationData: Signal?) { - let sheetTheme = ActionSheetControllerTheme(presentationTheme: presentationData.theme) + let sheetTheme = ActionSheetControllerTheme(presentationData: presentationData) super.init(theme: sheetTheme) self._ready.set(.single(true)) @@ -63,7 +63,7 @@ public final class ProxyServerActionSheetController: ActionSheetController { if let updatedPresentationData = updatedPresentationData { self.presentationDisposable = updatedPresentationData.start(next: { [weak self] presentationData in if let strongSelf = self { - strongSelf.theme = ActionSheetControllerTheme(presentationTheme: presentationData.theme) + strongSelf.theme = ActionSheetControllerTheme(presentationData: presentationData) } }) } @@ -97,8 +97,6 @@ private final class ProxyServerInfoItem: ActionSheetItem { } } -private let textFont = Font.regular(16.0) - private enum ProxyServerInfoStatusType { case generic(String) case failed(String) @@ -107,6 +105,7 @@ private enum ProxyServerInfoStatusType { private final class ProxyServerInfoItemNode: ActionSheetItemNode { private let theme: ActionSheetControllerTheme private let strings: PresentationStrings + private let textFont: UIFont private let network: Network private let server: ProxyServerSettings @@ -122,6 +121,8 @@ private final class ProxyServerInfoItemNode: ActionSheetItemNode { self.network = network self.server = server + self.textFont = Font.regular(floor(theme.baseFontSize * 16.0 / 17.0)) + var fieldNodes: [(ImmediateTextNode, ImmediateTextNode)] = [] let serverTitleNode = ImmediateTextNode() serverTitleNode.isUserInteractionEnabled = false @@ -317,10 +318,12 @@ private final class ProxyServerActionItemNode: ActionSheetItemNode { self.dismiss = dismiss self.present = present + let titleFont = Font.regular(floor(theme.baseFontSize * 20.0 / 17.0)) + self.titleNode = ImmediateTextNode() self.titleNode.isUserInteractionEnabled = false self.titleNode.displaysAsynchronously = false - self.titleNode.attributedText = NSAttributedString(string: presentationData.strings.SocksProxySetup_ConnectAndSave, font: Font.regular(20.0), textColor: theme.controlAccentColor) + self.titleNode.attributedText = NSAttributedString(string: presentationData.strings.SocksProxySetup_ConnectAndSave, font: titleFont, textColor: theme.controlAccentColor) self.activityIndicator = ActivityIndicator(type: .custom(theme.controlAccentColor, 22.0, 1.5, false)) self.activityIndicator.isHidden = true diff --git a/submodules/SettingsUI/Sources/Data and Storage/ProxySettingsActionItem.swift b/submodules/SettingsUI/Sources/Data and Storage/ProxySettingsActionItem.swift index abdf20b086..4e695deb2a 100644 --- a/submodules/SettingsUI/Sources/Data and Storage/ProxySettingsActionItem.swift +++ b/submodules/SettingsUI/Sources/Data and Storage/ProxySettingsActionItem.swift @@ -13,15 +13,15 @@ enum ProxySettingsActionIcon { } final class ProxySettingsActionItem: ListViewItem, ItemListItem { - let theme: PresentationTheme + let presentationData: ItemListPresentationData let title: String let icon: ProxySettingsActionIcon let editing: Bool let sectionId: ItemListSectionId let action: () -> Void - init(theme: PresentationTheme, title: String, icon: ProxySettingsActionIcon = .none, sectionId: ItemListSectionId, editing: Bool, action: @escaping () -> Void) { - self.theme = theme + init(presentationData: ItemListPresentationData, title: String, icon: ProxySettingsActionIcon = .none, sectionId: ItemListSectionId, editing: Bool, action: @escaping () -> Void) { + self.presentationData = presentationData self.title = title self.icon = icon self.editing = editing @@ -75,8 +75,6 @@ final class ProxySettingsActionItem: ListViewItem, ItemListItem { } } -private let titleFont = Font.regular(17.0) - private final class ProxySettingsActionItemNode: ListViewItemNode { private let backgroundNode: ASDisplayNode private let topStripeNode: ASDisplayNode @@ -130,24 +128,26 @@ private final class ProxySettingsActionItemNode: ListViewItemNode { return { item, params, neighbors in var updatedTheme: PresentationTheme? - if currentItem?.theme !== item.theme { - updatedTheme = item.theme + let titleFont = Font.regular(item.presentationData.fontSize.itemListBaseFontSize) + + if currentItem?.presentationData.theme !== item.presentationData.theme { + updatedTheme = item.presentationData.theme } let leftInset: CGFloat = (item.icon != .none ? 50.0 : 16.0) + params.leftInset let editingOffset: CGFloat = (item.editing ? 38.0 : 0.0) - let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.title, font: titleFont, textColor: item.theme.list.itemAccentColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - leftInset - editingOffset, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets())) + let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.title, font: titleFont, textColor: item.presentationData.theme.list.itemAccentColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - leftInset - editingOffset, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets())) let separatorHeight = UIScreenPixel let insets = itemListNeighborsGroupedInsets(neighbors) - let contentSize = CGSize(width: params.width, height: 44.0) + let contentSize = CGSize(width: params.width, height: 22.0 + titleLayout.size.height) let layout = ListViewItemNodeLayout(contentSize: contentSize, insets: insets) let layoutSize = layout.size - let icon = item.icon == .add ? PresentationResourcesItemList.plusIconImage(item.theme) : nil + let icon = item.icon == .add ? PresentationResourcesItemList.plusIconImage(item.presentationData.theme) : nil return (layout, { [weak self] animated in if let strongSelf = self { @@ -156,10 +156,10 @@ private final class ProxySettingsActionItemNode: ListViewItemNode { strongSelf.accessibilityLabel = item.title if let _ = updatedTheme { - strongSelf.topStripeNode.backgroundColor = item.theme.list.itemBlocksSeparatorColor - strongSelf.bottomStripeNode.backgroundColor = item.theme.list.itemBlocksSeparatorColor - strongSelf.backgroundNode.backgroundColor = item.theme.list.itemBlocksBackgroundColor - strongSelf.highlightedBackgroundNode.backgroundColor = item.theme.list.itemHighlightedBackgroundColor + strongSelf.topStripeNode.backgroundColor = item.presentationData.theme.list.itemBlocksSeparatorColor + strongSelf.bottomStripeNode.backgroundColor = item.presentationData.theme.list.itemBlocksSeparatorColor + strongSelf.backgroundNode.backgroundColor = item.presentationData.theme.list.itemBlocksBackgroundColor + strongSelf.highlightedBackgroundNode.backgroundColor = item.presentationData.theme.list.itemHighlightedBackgroundColor } let _ = titleApply() @@ -213,7 +213,7 @@ private final class ProxySettingsActionItemNode: ListViewItemNode { strongSelf.bottomStripeNode.isHidden = hasCorners } - strongSelf.maskNode.image = hasCorners ? PresentationResourcesItemList.cornersImage(item.theme, top: hasTopCorners, bottom: hasBottomCorners) : nil + strongSelf.maskNode.image = hasCorners ? PresentationResourcesItemList.cornersImage(item.presentationData.theme, top: hasTopCorners, bottom: hasBottomCorners) : nil strongSelf.backgroundNode.frame = CGRect(origin: CGPoint(x: 0.0, y: -min(insets.top, separatorHeight)), size: CGSize(width: params.width, height: contentSize.height + min(insets.top, separatorHeight) + min(insets.bottom, separatorHeight))) strongSelf.maskNode.frame = strongSelf.backgroundNode.frame.insetBy(dx: params.leftInset, dy: 0.0) diff --git a/submodules/SettingsUI/Sources/Data and Storage/ShareProxyServerActionSheetController.swift b/submodules/SettingsUI/Sources/Data and Storage/ShareProxyServerActionSheetController.swift index 6ec8d0002e..889ec22ec2 100644 --- a/submodules/SettingsUI/Sources/Data and Storage/ShareProxyServerActionSheetController.swift +++ b/submodules/SettingsUI/Sources/Data and Storage/ShareProxyServerActionSheetController.swift @@ -22,7 +22,7 @@ public final class ShareProxyServerActionSheetController: ActionSheetController private var isDismissed: Bool = false public init(presentationData: PresentationData, updatedPresentationData: Signal, link: String) { - let sheetTheme = ActionSheetControllerTheme(presentationTheme: presentationData.theme) + let sheetTheme = ActionSheetControllerTheme(presentationData: presentationData) super.init(theme: sheetTheme) let presentActivityController: (Any) -> Void = { [weak self] item in @@ -67,7 +67,7 @@ public final class ShareProxyServerActionSheetController: ActionSheetController self.presentationDisposable = updatedPresentationData.start(next: { [weak self] presentationData in if let strongSelf = self { - strongSelf.theme = ActionSheetControllerTheme(presentationTheme: presentationData.theme) + strongSelf.theme = ActionSheetControllerTheme(presentationData: presentationData) } }) } @@ -119,13 +119,15 @@ private final class ProxyServerQRCodeItemNode: ActionSheetItemNode { self.link = link self.ready = ready + let textFont = Font.regular(floor(theme.baseFontSize * 13.0 / 17.0)) + self.label = ASTextNode() self.label.isUserInteractionEnabled = false self.label.maximumNumberOfLines = 0 self.label.displaysAsynchronously = false self.label.truncationMode = .byTruncatingTail self.label.isUserInteractionEnabled = false - self.label.attributedText = NSAttributedString(string: strings.SocksProxySetup_ShareQRCodeInfo, font: ActionSheetTextNode.defaultFont, textColor: self.theme.secondaryTextColor, paragraphAlignment: .center) + self.label.attributedText = NSAttributedString(string: strings.SocksProxySetup_ShareQRCodeInfo, font: textFont, textColor: self.theme.secondaryTextColor, paragraphAlignment: .center) self.imageNode = TransformImageNode() self.imageNode.clipsToBounds = true diff --git a/submodules/SettingsUI/Sources/Data and Storage/StorageUsageController.swift b/submodules/SettingsUI/Sources/Data and Storage/StorageUsageController.swift index bf8d091e9e..45d5d70ac7 100644 --- a/submodules/SettingsUI/Sources/Data and Storage/StorageUsageController.swift +++ b/submodules/SettingsUI/Sources/Data and Storage/StorageUsageController.swift @@ -402,7 +402,7 @@ public func storageUsageController(context: AccountContext, cacheUsagePromise: P |> deliverOnMainQueue).start(next: { [weak statsPromise] result in if let result = result, case let .result(stats) = result { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } @@ -624,7 +624,7 @@ public func storageUsageController(context: AccountContext, cacheUsagePromise: P } let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } diff --git a/submodules/SettingsUI/Sources/DebugAccountsController.swift b/submodules/SettingsUI/Sources/DebugAccountsController.swift index decc358cc5..ccc2dc17fb 100644 --- a/submodules/SettingsUI/Sources/DebugAccountsController.swift +++ b/submodules/SettingsUI/Sources/DebugAccountsController.swift @@ -113,7 +113,7 @@ public func debugAccountsController(context: AccountContext, accountManager: Acc }).start() }, loginNewAccount: { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } diff --git a/submodules/SettingsUI/Sources/DebugController.swift b/submodules/SettingsUI/Sources/DebugController.swift index 8037757205..7ccce12457 100644 --- a/submodules/SettingsUI/Sources/DebugController.swift +++ b/submodules/SettingsUI/Sources/DebugController.swift @@ -155,7 +155,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { let _ = (Logger.shared.collectLogs() |> deliverOnMainQueue).start(next: { logs in let presentationData = arguments.sharedContext.currentPresentationData.with { $0 } - let actionSheet = ActionSheetController(presentationTheme: presentationData.theme) + let actionSheet = ActionSheetController(presentationData: presentationData) var items: [ActionSheetButtonItem] = [] @@ -206,7 +206,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { let _ = (Logger.shared.collectLogs() |> deliverOnMainQueue).start(next: { logs in let presentationData = arguments.sharedContext.currentPresentationData.with { $0 } - let actionSheet = ActionSheetController(presentationTheme: presentationData.theme) + let actionSheet = ActionSheetController(presentationData: presentationData) var items: [ActionSheetButtonItem] = [] @@ -284,7 +284,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { let _ = (Logger.shared.collectShortLogFiles() |> deliverOnMainQueue).start(next: { logs in let presentationData = arguments.sharedContext.currentPresentationData.with { $0 } - let actionSheet = ActionSheetController(presentationTheme: presentationData.theme) + let actionSheet = ActionSheetController(presentationData: presentationData) var items: [ActionSheetButtonItem] = [] @@ -409,7 +409,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { case let .resetData(theme): return ItemListActionItem(presentationData: presentationData, title: "Reset Data", kind: .destructive, alignment: .natural, sectionId: self.section, style: .blocks, action: { let presentationData = arguments.sharedContext.currentPresentationData.with { $0 } - let actionSheet = ActionSheetController(presentationTheme: presentationData.theme) + let actionSheet = ActionSheetController(presentationData: presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetTextItem(title: "All data will be lost."), ActionSheetButtonItem(title: "Reset Data", color: .destructive, action: { [weak actionSheet] in @@ -431,7 +431,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { return } let presentationData = arguments.sharedContext.currentPresentationData.with { $0 } - let actionSheet = ActionSheetController(presentationTheme: presentationData.theme) + let actionSheet = ActionSheetController(presentationData: presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetTextItem(title: "All secret chats will be lost."), ActionSheetButtonItem(title: "Clear Database", color: .destructive, action: { [weak actionSheet] in diff --git a/submodules/SettingsUI/Sources/Language Selection/LocalizationListControllerNode.swift b/submodules/SettingsUI/Sources/Language Selection/LocalizationListControllerNode.swift index 61a80c5d25..f2a2a2cbe7 100644 --- a/submodules/SettingsUI/Sources/Language Selection/LocalizationListControllerNode.swift +++ b/submodules/SettingsUI/Sources/Language Selection/LocalizationListControllerNode.swift @@ -501,7 +501,7 @@ final class LocalizationListControllerNode: ViewControllerTracingNode { applyImpl() return } - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } diff --git a/submodules/SettingsUI/Sources/Notifications/Exceptions/NotificationExceptionControllerNode.swift b/submodules/SettingsUI/Sources/Notifications/Exceptions/NotificationExceptionControllerNode.swift index b84a6cd490..ac0592a7eb 100644 --- a/submodules/SettingsUI/Sources/Notifications/Exceptions/NotificationExceptionControllerNode.swift +++ b/submodules/SettingsUI/Sources/Notifications/Exceptions/NotificationExceptionControllerNode.swift @@ -923,7 +923,7 @@ final class NotificationExceptionsControllerNode: ViewControllerTracingNode { }) }, removeAll: { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let actionSheet = ActionSheetController(presentationTheme: presentationData.theme) + let actionSheet = ActionSheetController(presentationData: presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetTextItem(title: presentationData.strings.Notification_Exceptions_DeleteAllConfirmation), ActionSheetButtonItem(title: presentationData.strings.Notification_Exceptions_DeleteAll, color: .destructive, action: { [weak actionSheet] in diff --git a/submodules/SettingsUI/Sources/Notifications/NotificationsAndSounds.swift b/submodules/SettingsUI/Sources/Notifications/NotificationsAndSounds.swift index 53d2af6514..3db7091c49 100644 --- a/submodules/SettingsUI/Sources/Notifications/NotificationsAndSounds.swift +++ b/submodules/SettingsUI/Sources/Notifications/NotificationsAndSounds.swift @@ -927,7 +927,7 @@ public func notificationsAndSoundsController(context: AccountContext, exceptions }).start() }, resetNotifications: { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let actionSheet = ActionSheetController(presentationTheme: presentationData.theme) + let actionSheet = ActionSheetController(presentationData: presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetButtonItem(title: presentationData.strings.Notifications_Reset, color: .destructive, action: { [weak actionSheet] in actionSheet?.dismissAnimated() diff --git a/submodules/SettingsUI/Sources/Privacy and Security/DataPrivacySettingsController.swift b/submodules/SettingsUI/Sources/Privacy and Security/DataPrivacySettingsController.swift index 92be569268..2372c84b27 100644 --- a/submodules/SettingsUI/Sources/Privacy and Security/DataPrivacySettingsController.swift +++ b/submodules/SettingsUI/Sources/Privacy and Security/DataPrivacySettingsController.swift @@ -306,7 +306,7 @@ public func dataPrivacyController(context: AccountContext) -> ViewController { let arguments = DataPrivacyControllerArguments(account: context.account, clearPaymentInfo: { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } @@ -453,7 +453,7 @@ public func dataPrivacyController(context: AccountContext) -> ViewController { } }, deleteCloudDrafts: { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } diff --git a/submodules/SettingsUI/Sources/Privacy and Security/PasscodeOptionsController.swift b/submodules/SettingsUI/Sources/Privacy and Security/PasscodeOptionsController.swift index 001dcc4335..3d566f2a7e 100644 --- a/submodules/SettingsUI/Sources/Privacy and Security/PasscodeOptionsController.swift +++ b/submodules/SettingsUI/Sources/Privacy and Security/PasscodeOptionsController.swift @@ -233,7 +233,7 @@ func passcodeOptionsController(context: AccountContext) -> ViewController { let arguments = PasscodeOptionsControllerArguments(turnPasscodeOff: { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let actionSheet = ActionSheetController(presentationTheme: presentationData.theme) + let actionSheet = ActionSheetController(presentationData: presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetButtonItem(title: presentationData.strings.PasscodeSettings_TurnPasscodeOff, color: .destructive, action: { [weak actionSheet] in actionSheet?.dismissAnimated() @@ -313,7 +313,7 @@ func passcodeOptionsController(context: AccountContext) -> ViewController { }) }, changePasscodeTimeout: { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let actionSheet = ActionSheetController(presentationTheme: presentationData.theme) + let actionSheet = ActionSheetController(presentationData: presentationData) var items: [ActionSheetItem] = [] let setAction: (Int32?) -> Void = { value in let _ = (passcodeOptionsDataPromise.get() diff --git a/submodules/SettingsUI/Sources/Privacy and Security/PrivacyAndSecurityController.swift b/submodules/SettingsUI/Sources/Privacy and Security/PrivacyAndSecurityController.swift index 2b2279a5d1..1e54c07ae4 100644 --- a/submodules/SettingsUI/Sources/Privacy and Security/PrivacyAndSecurityController.swift +++ b/submodules/SettingsUI/Sources/Privacy and Security/PrivacyAndSecurityController.swift @@ -677,7 +677,7 @@ public func privacyAndSecurityController(context: AccountContext, initialSetting updateAccountTimeoutDisposable.set(signal.start(next: { [weak updateAccountTimeoutDisposable] privacySettingsValue in if let _ = privacySettingsValue { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } diff --git a/submodules/SettingsUI/Sources/Privacy and Security/Recent Sessions/RecentSessionsController.swift b/submodules/SettingsUI/Sources/Privacy and Security/Recent Sessions/RecentSessionsController.swift index 1afaf5085f..2249300de1 100644 --- a/submodules/SettingsUI/Sources/Privacy and Security/Recent Sessions/RecentSessionsController.swift +++ b/submodules/SettingsUI/Sources/Privacy and Security/Recent Sessions/RecentSessionsController.swift @@ -467,7 +467,7 @@ public func recentSessionsController(context: AccountContext, activeSessionsCont } }, removeSession: { sessionId in let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } @@ -498,7 +498,7 @@ public func recentSessionsController(context: AccountContext, activeSessionsCont presentControllerImpl?(controller, ViewControllerPresentationArguments(presentationAnimation: .modalSheet)) }, terminateOtherSessions: { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } @@ -569,7 +569,7 @@ public func recentSessionsController(context: AccountContext, activeSessionsCont })) }, terminateAllWebSessions: { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } diff --git a/submodules/SettingsUI/Sources/SettingsController.swift b/submodules/SettingsUI/Sources/SettingsController.swift index c39ce89aee..a5caf22fd2 100644 --- a/submodules/SettingsUI/Sources/SettingsController.swift +++ b/submodules/SettingsUI/Sources/SettingsController.swift @@ -609,7 +609,7 @@ private struct SettingsState: Equatable { var isSearching: Bool } -private func settingsEntries(account: Account, presentationData: PresentationData, state: SettingsState, view: PeerView, proxySettings: ProxySettings, notifyExceptions: NotificationExceptionsList?, notificationsAuthorizationStatus: AccessType, notificationsWarningSuppressed: Bool, unreadTrendingStickerPacks: Int, archivedPacks: [ArchivedStickerPackItem]?, privacySettings: AccountPrivacySettings?, hasWallet: Bool, hasPassport: Bool, hasWatchApp: Bool, accountsAndPeers: [(Account, Peer, Int32)], inAppNotificationSettings: InAppNotificationSettings, experimentalUISettings: ExperimentalUISettings, displayPhoneNumberConfirmation: Bool, otherSessionCount: Int) -> [SettingsEntry] { +private func settingsEntries(account: Account, presentationData: PresentationData, state: SettingsState, view: PeerView, proxySettings: ProxySettings, notifyExceptions: NotificationExceptionsList?, notificationsAuthorizationStatus: AccessType, notificationsWarningSuppressed: Bool, unreadTrendingStickerPacks: Int, archivedPacks: [ArchivedStickerPackItem]?, privacySettings: AccountPrivacySettings?, hasWallet: Bool, hasPassport: Bool, hasWatchApp: Bool, accountsAndPeers: [(Account, Peer, Int32)], inAppNotificationSettings: InAppNotificationSettings, experimentalUISettings: ExperimentalUISettings, displayPhoneNumberConfirmation: Bool, otherSessionCount: Int, enableQRLogin: Bool) -> [SettingsEntry] { var entries: [SettingsEntry] = [] if let peer = peerViewMainPeer(view) as? TelegramUser { @@ -658,7 +658,9 @@ private func settingsEntries(account: Account, presentationData: PresentationDat entries.append(.savedMessages(presentationData.theme, PresentationResourcesSettings.savedMessages, presentationData.strings.Settings_SavedMessages)) entries.append(.recentCalls(presentationData.theme, PresentationResourcesSettings.recentCalls, presentationData.strings.CallSettings_RecentCalls)) entries.append(.stickers(presentationData.theme, PresentationResourcesSettings.stickers, presentationData.strings.ChatSettings_Stickers, unreadTrendingStickerPacks == 0 ? "" : "\(unreadTrendingStickerPacks)", archivedPacks)) - entries.append(.devices(presentationData.theme, UIImage(bundleImageName: "Settings/MenuIcons/Sessions")?.precomposed(), presentationData.strings.Settings_Devices, otherSessionCount == 0 ? presentationData.strings.Settings_AddDevice : "\(otherSessionCount)")) + if enableQRLogin { + entries.append(.devices(presentationData.theme, UIImage(bundleImageName: "Settings/MenuIcons/Sessions")?.precomposed(), presentationData.strings.Settings_Devices, otherSessionCount == 0 ? presentationData.strings.Settings_AddDevice : "\(otherSessionCount)")) + } let notificationsWarning = shouldDisplayNotificationsPermissionWarning(status: notificationsAuthorizationStatus, suppressed: notificationsWarningSuppressed) entries.append(.notificationsAndSounds(presentationData.theme, PresentationResourcesSettings.notifications, presentationData.strings.Settings_NotificationsAndSounds, notifyExceptions, notificationsWarning)) @@ -1079,7 +1081,7 @@ public func settingsController(context: AccountContext, accountManager: AccountM let presentationData = accountContext.sharedContext.currentPresentationData.with { $0 } - let contextController = ContextController(account: accountContext.account, theme: presentationData.theme, strings: presentationData.strings, source: .controller(ContextControllerContentSourceImpl(controller: chatListController, sourceNode: node)), items: accountContextMenuItems(context: accountContext, logout: { + let contextController = ContextController(account: accountContext.account, presentationData: presentationData, source: .controller(ContextControllerContentSourceImpl(controller: chatListController, sourceNode: node)), items: accountContextMenuItems(context: accountContext, logout: { removeAccountImpl?(id) }), reactionItems: [], gesture: gesture) presentInGlobalOverlayImpl?(contextController, nil) @@ -1332,7 +1334,22 @@ public func settingsController(context: AccountContext, accountManager: AccountM return context.account.viewTracker.featuredStickerPacks() } - let signal = combineLatest(queue: Queue.mainQueue(), contextValue.get(), updatedPresentationData, statePromise.get(), peerView, combineLatest(queue: Queue.mainQueue(), preferences, notifyExceptions.get(), notificationsAuthorizationStatus.get(), notificationsWarningSuppressed.get(), privacySettings.get(), displayPhoneNumberConfirmation.get()), combineLatest(featuredStickerPacks, archivedPacks.get()), combineLatest(hasWallet, hasPassport.get(), hasWatchApp), accountsAndPeers.get(), activeSessionsContextAndCount.get()) + let enableQRLogin = contextValue.get() + |> mapToSignal { context -> Signal in + return context.account.postbox.preferencesView(keys: [PreferencesKeys.appConfiguration]) + |> map { view -> Bool in + guard let appConfiguration = view.values[PreferencesKeys.appConfiguration] as? AppConfiguration else { + return false + } + guard let data = appConfiguration.data, let enableQR = data["qr_login_camera"] as? Bool, enableQR else { + return false + } + return true + } + |> distinctUntilChanged + } + + let signal = combineLatest(queue: Queue.mainQueue(), contextValue.get(), updatedPresentationData, statePromise.get(), peerView, combineLatest(queue: Queue.mainQueue(), preferences, notifyExceptions.get(), notificationsAuthorizationStatus.get(), notificationsWarningSuppressed.get(), privacySettings.get(), displayPhoneNumberConfirmation.get()), combineLatest(featuredStickerPacks, archivedPacks.get()), combineLatest(hasWallet, hasPassport.get(), hasWatchApp, enableQRLogin), accountsAndPeers.get(), activeSessionsContextAndCount.get()) |> map { context, presentationData, state, view, preferencesAndExceptions, featuredAndArchived, hasWalletPassportAndWatch, accountsAndPeers, activeSessionsContextAndCount -> (ItemListControllerState, (ItemListNodeState, Any)) in let otherSessionCount = activeSessionsContextAndCount.1 @@ -1372,8 +1389,8 @@ public func settingsController(context: AccountContext, accountManager: AccountM pushControllerImpl?(c) }, getNavigationController: getNavigationControllerImpl, exceptionsList: notifyExceptions.get(), archivedStickerPacks: archivedPacks.get(), privacySettings: privacySettings.get(), hasWallet: hasWallet) - let (hasWallet, hasPassport, hasWatchApp) = hasWalletPassportAndWatch - let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: settingsEntries(account: context.account, presentationData: presentationData, state: state, view: view, proxySettings: proxySettings, notifyExceptions: preferencesAndExceptions.1, notificationsAuthorizationStatus: preferencesAndExceptions.2, notificationsWarningSuppressed: preferencesAndExceptions.3, unreadTrendingStickerPacks: unreadTrendingStickerPacks, archivedPacks: featuredAndArchived.1, privacySettings: preferencesAndExceptions.4, hasWallet: hasWallet, hasPassport: hasPassport, hasWatchApp: hasWatchApp, accountsAndPeers: accountsAndPeers.1, inAppNotificationSettings: inAppNotificationSettings, experimentalUISettings: experimentalUISettings, displayPhoneNumberConfirmation: preferencesAndExceptions.5, otherSessionCount: otherSessionCount), style: .blocks, searchItem: searchItem, initialScrollToItem: ListViewScrollToItem(index: 0, position: .top(-navigationBarSearchContentHeight), animated: false, curve: .Default(duration: 0.0), directionHint: .Up)) + let (hasWallet, hasPassport, hasWatchApp, enableQRLogin) = hasWalletPassportAndWatch + let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: settingsEntries(account: context.account, presentationData: presentationData, state: state, view: view, proxySettings: proxySettings, notifyExceptions: preferencesAndExceptions.1, notificationsAuthorizationStatus: preferencesAndExceptions.2, notificationsWarningSuppressed: preferencesAndExceptions.3, unreadTrendingStickerPacks: unreadTrendingStickerPacks, archivedPacks: featuredAndArchived.1, privacySettings: preferencesAndExceptions.4, hasWallet: hasWallet, hasPassport: hasPassport, hasWatchApp: hasWatchApp, accountsAndPeers: accountsAndPeers.1, inAppNotificationSettings: inAppNotificationSettings, experimentalUISettings: experimentalUISettings, displayPhoneNumberConfirmation: preferencesAndExceptions.5, otherSessionCount: otherSessionCount, enableQRLogin: enableQRLogin), style: .blocks, searchItem: searchItem, initialScrollToItem: ListViewScrollToItem(index: 0, position: .top(-navigationBarSearchContentHeight), animated: false, curve: .Default(duration: 0.0), directionHint: .Up)) return (controllerState, (listState, arguments)) } @@ -1591,7 +1608,7 @@ public func settingsController(context: AccountContext, accountManager: AccountM |> deliverOnMainQueue |> take(1)).start(next: { context in let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } diff --git a/submodules/SettingsUI/Sources/Stickers/InstalledStickerPacksController.swift b/submodules/SettingsUI/Sources/Stickers/InstalledStickerPacksController.swift index 185820fe53..4a4b0920fd 100644 --- a/submodules/SettingsUI/Sources/Stickers/InstalledStickerPacksController.swift +++ b/submodules/SettingsUI/Sources/Stickers/InstalledStickerPacksController.swift @@ -507,7 +507,7 @@ public func installedStickerPacksController(context: AccountContext, mode: Insta } }, removePack: { archivedItem in let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } @@ -559,7 +559,7 @@ public func installedStickerPacksController(context: AccountContext, mode: Insta })) }, openSuggestOptions: { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } diff --git a/submodules/SettingsUI/Sources/Terms of Service/TermsOfServiceControllerNode.swift b/submodules/SettingsUI/Sources/Terms of Service/TermsOfServiceControllerNode.swift index fa73ee0171..b108e90377 100644 --- a/submodules/SettingsUI/Sources/Terms of Service/TermsOfServiceControllerNode.swift +++ b/submodules/SettingsUI/Sources/Terms of Service/TermsOfServiceControllerNode.swift @@ -138,7 +138,7 @@ final class TermsOfServiceControllerNode: ViewControllerTracingNode { return } let theme: PresentationTheme = strongSelf.presentationData.theme - let actionSheet = ActionSheetController(presentationTheme: theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetTextItem(title: strongSelf.presentationData.strings.Login_TermsOfService_ProceedBot(mention).0), ActionSheetButtonItem(title: strongSelf.presentationData.strings.PrivacyPolicy_Accept, color: .accent, action: { [weak actionSheet] in @@ -170,7 +170,7 @@ final class TermsOfServiceControllerNode: ViewControllerTracingNode { } if let url = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] as? String { let theme: PresentationTheme = strongSelf.presentationData.theme - let actionSheet = ActionSheetController(presentationTheme: theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetTextItem(title: url), ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_LinkDialogOpen, color: .accent, action: { [weak actionSheet] in diff --git a/submodules/SettingsUI/Sources/Themes/ThemeAutoNightTimeSelectionActionSheet.swift b/submodules/SettingsUI/Sources/Themes/ThemeAutoNightTimeSelectionActionSheet.swift index 0b98f3a872..7bdbbc2c7f 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeAutoNightTimeSelectionActionSheet.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeAutoNightTimeSelectionActionSheet.swift @@ -22,11 +22,11 @@ final class ThemeAutoNightTimeSelectionActionSheet: ActionSheetController { let theme = presentationData.theme let strings = presentationData.strings - super.init(theme: ActionSheetControllerTheme(presentationTheme: theme)) + super.init(theme: ActionSheetControllerTheme(presentationData: presentationData)) self.presentationDisposable = context.sharedContext.presentationData.start(next: { [weak self] presentationData in if let strongSelf = self { - strongSelf.theme = ActionSheetControllerTheme(presentationTheme: presentationData.theme) + strongSelf.theme = ActionSheetControllerTheme(presentationData: presentationData) } }) diff --git a/submodules/SettingsUI/Sources/Themes/ThemeGridController.swift b/submodules/SettingsUI/Sources/Themes/ThemeGridController.swift index 5faf6e41b0..d852bad83e 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeGridController.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeGridController.swift @@ -167,7 +167,7 @@ final class ThemeGridController: ViewController { } }, deleteWallpapers: { [weak self] wallpapers, completed in if let strongSelf = self { - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) var items: [ActionSheetItem] = [] items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.Wallpaper_DeleteConfirmation(Int32(wallpapers.count)), color: .destructive, action: { [weak self, weak actionSheet] in @@ -220,7 +220,7 @@ final class ThemeGridController: ViewController { } }, resetWallpapers: { [weak self] in if let strongSelf = self { - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) let items: [ActionSheetItem] = [ ActionSheetButtonItem(title: strongSelf.presentationData.strings.Wallpaper_ResetWallpapersConfirmation, color: .destructive, action: { [weak self, weak actionSheet] in actionSheet?.dismissAnimated() diff --git a/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift b/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift index 33e4c5df05..0cb29fb975 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift @@ -568,7 +568,7 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The }))) items.append(.action(ContextMenuActionItem(text: presentationData.strings.Appearance_RemoveTheme, textColor: .destructive, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Delete"), color: theme.contextMenu.destructiveColor) }, action: { c, f in c.dismiss(completion: { - let actionSheet = ActionSheetController(presentationTheme: presentationData.theme) + let actionSheet = ActionSheetController(presentationData: presentationData) var items: [ActionSheetItem] = [] items.append(ActionSheetButtonItem(title: presentationData.strings.Appearance_RemoveThemeConfirmation, color: .destructive, action: { [weak actionSheet] in actionSheet?.dismissAnimated() @@ -599,7 +599,7 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The }))) } - let contextController = ContextController(account: context.account, theme: presentationData.theme, strings: presentationData.strings, source: .controller(ContextControllerContentSourceImpl(controller: themeController, sourceNode: node)), items: .single(items), reactionItems: [], gesture: gesture) + let contextController = ContextController(account: context.account, presentationData: presentationData, source: .controller(ContextControllerContentSourceImpl(controller: themeController, sourceNode: node)), items: .single(items), reactionItems: [], gesture: gesture) presentInGlobalOverlayImpl?(contextController, nil) }) }) @@ -716,7 +716,7 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The } moreImpl = { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let actionSheet = ActionSheetController(presentationTheme: presentationData.theme) + let actionSheet = ActionSheetController(presentationData: presentationData) var items: [ActionSheetItem] = [] items.append(ActionSheetButtonItem(title: presentationData.strings.Appearance_CreateTheme, color: .accent, action: { [weak actionSheet] in actionSheet?.dismissAnimated() diff --git a/submodules/ShareController/Sources/ShareController.swift b/submodules/ShareController/Sources/ShareController.swift index a0ad6eb665..9f872fef59 100644 --- a/submodules/ShareController/Sources/ShareController.swift +++ b/submodules/ShareController/Sources/ShareController.swift @@ -680,7 +680,7 @@ public final class ShareController: ViewController { strongSelf.controllerNode.animateOut(shared: false, completion: {}) let presentationData = strongSelf.sharedContext.currentPresentationData.with { $0 } - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) controller.dismissed = { [weak self] cancelled in if cancelled { self?.controllerNode.animateIn() diff --git a/submodules/TelegramBaseController/Sources/LocationBroadcastActionSheetItem.swift b/submodules/TelegramBaseController/Sources/LocationBroadcastActionSheetItem.swift index b39b7b96c8..68f5d39929 100644 --- a/submodules/TelegramBaseController/Sources/LocationBroadcastActionSheetItem.swift +++ b/submodules/TelegramBaseController/Sources/LocationBroadcastActionSheetItem.swift @@ -50,7 +50,7 @@ private let avatarFont = avatarPlaceholderFont(size: 15.0) public class LocationBroadcastActionSheetItemNode: ActionSheetItemNode { private let theme: ActionSheetControllerTheme - public static let defaultFont: UIFont = Font.regular(20.0) + private let defaultFont: UIFont private var item: LocationBroadcastActionSheetItem? @@ -61,6 +61,7 @@ public class LocationBroadcastActionSheetItemNode: ActionSheetItemNode { override public init(theme: ActionSheetControllerTheme) { self.theme = theme + self.defaultFont = Font.regular(floor(theme.baseFontSize * 20.0 / 17.0)) self.button = HighlightTrackingButton() @@ -99,8 +100,10 @@ public class LocationBroadcastActionSheetItemNode: ActionSheetItemNode { func setItem(_ item: LocationBroadcastActionSheetItem) { self.item = item + let defaultFont = Font.regular(floor(theme.baseFontSize * 20.0 / 17.0)) + let textColor: UIColor = self.theme.primaryTextColor - self.label.attributedText = NSAttributedString(string: item.title, font: ActionSheetButtonNode.defaultFont, textColor: textColor) + self.label.attributedText = NSAttributedString(string: item.title, font: defaultFont, textColor: textColor) self.avatarNode.setPeer(account: item.context.account, theme: (item.context.sharedContext.currentPresentationData.with { $0 }).theme, peer: item.peer) diff --git a/submodules/TelegramBaseController/Sources/TelegramBaseController.swift b/submodules/TelegramBaseController/Sources/TelegramBaseController.swift index b09f37ef9a..6bd0c6ca87 100644 --- a/submodules/TelegramBaseController/Sources/TelegramBaseController.swift +++ b/submodules/TelegramBaseController/Sources/TelegramBaseController.swift @@ -309,7 +309,7 @@ open class TelegramBaseController: ViewController, KeyShortcutResponder { presentLiveLocationController(context: strongSelf.context, peerId: messages[0].id.peerId, controller: strongSelf) } else { let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 } - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } @@ -375,7 +375,7 @@ open class TelegramBaseController: ViewController, KeyShortcutResponder { closePeerId = peerId } let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 } - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } diff --git a/submodules/TelegramCallsUI/Sources/CallController.swift b/submodules/TelegramCallsUI/Sources/CallController.swift index 9d9d6c0f32..3644129160 100644 --- a/submodules/TelegramCallsUI/Sources/CallController.swift +++ b/submodules/TelegramCallsUI/Sources/CallController.swift @@ -132,7 +132,7 @@ public final class CallController: ViewController { } } } else { - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) var items: [ActionSheetItem] = [] for output in availableOutputs { let title: String diff --git a/submodules/TelegramCallsUI/Sources/CallRouteActionSheetItem.swift b/submodules/TelegramCallsUI/Sources/CallRouteActionSheetItem.swift index 173e147897..708287c54d 100644 --- a/submodules/TelegramCallsUI/Sources/CallRouteActionSheetItem.swift +++ b/submodules/TelegramCallsUI/Sources/CallRouteActionSheetItem.swift @@ -35,7 +35,7 @@ public class CallRouteActionSheetItem: ActionSheetItem { public class CallRouteActionSheetItemNode: ActionSheetItemNode { private let theme: ActionSheetControllerTheme - public static let defaultFont: UIFont = Font.regular(20.0) + private let defaultFont: UIFont private var item: CallRouteActionSheetItem? @@ -48,6 +48,7 @@ public class CallRouteActionSheetItemNode: ActionSheetItemNode { override public init(theme: ActionSheetControllerTheme) { self.theme = theme + self.defaultFont = Font.regular(floor(theme.baseFontSize * 20.0 / 17.0)) self.button = HighlightTrackingButton() self.button.isAccessibilityElement = false @@ -115,7 +116,9 @@ public class CallRouteActionSheetItemNode: ActionSheetItemNode { func setItem(_ item: CallRouteActionSheetItem) { self.item = item - self.label.attributedText = NSAttributedString(string: item.title, font: ActionSheetButtonNode.defaultFont, textColor: self.theme.standardActionTextColor) + let defaultFont = Font.regular(floor(theme.baseFontSize * 20.0 / 17.0)) + + self.label.attributedText = NSAttributedString(string: item.title, font: defaultFont, textColor: self.theme.standardActionTextColor) if let icon = item.icon { self.iconNode.image = generateTintedImage(image: icon, color: self.theme.standardActionTextColor) } else { diff --git a/submodules/TelegramCore/Sources/Network.swift b/submodules/TelegramCore/Sources/Network.swift index 3d74acad6e..24b84d3fff 100644 --- a/submodules/TelegramCore/Sources/Network.swift +++ b/submodules/TelegramCore/Sources/Network.swift @@ -514,7 +514,7 @@ func initializedNetwork(arguments: NetworkInitializationArguments, supplementary context.setDiscoverBackupAddressListSignal(MTBackupAddressSignals.fetchBackupIps(testingEnvironment, currentContext: context, additionalSource: wrappedAdditionalSource, phoneNumber: phoneNumber)) #if DEBUG - let _ = MTBackupAddressSignals.fetchBackupIps(testingEnvironment, currentContext: context, additionalSource: wrappedAdditionalSource, phoneNumber: phoneNumber).start(next: nil) + //let _ = MTBackupAddressSignals.fetchBackupIps(testingEnvironment, currentContext: context, additionalSource: wrappedAdditionalSource, phoneNumber: phoneNumber).start(next: nil) #endif let mtProto = MTProto(context: context, datacenterId: datacenterId, usageCalculationInfo: usageCalculationInfo(basePath: basePath, category: nil), requiredAuthToken: nil, authTokenMasterDatacenterId: 0)! diff --git a/submodules/TelegramPresentationData/Sources/ChatControllerBackgroundNode.swift b/submodules/TelegramPresentationData/Sources/ChatControllerBackgroundNode.swift index 8a0ca4388d..c701dcfbac 100644 --- a/submodules/TelegramPresentationData/Sources/ChatControllerBackgroundNode.swift +++ b/submodules/TelegramPresentationData/Sources/ChatControllerBackgroundNode.swift @@ -38,7 +38,7 @@ public func chatControllerBackgroundImage(theme: PresentationTheme?, wallpaper i } case let .color(color): backgroundImage = generateImage(CGSize(width: 1.0, height: 1.0), rotatedContext: { size, context in - context.setFillColor(UIColor(rgb: UInt32(bitPattern: color)).cgColor) + context.setFillColor(UIColor(rgb: UInt32(bitPattern: color)).withAlphaComponent(1.0).cgColor) context.fill(CGRect(origin: CGPoint(), size: size)) }) case let .gradient(topColor, bottomColor): diff --git a/submodules/TelegramPresentationData/Sources/ChatMessageBubbleImages.swift b/submodules/TelegramPresentationData/Sources/ChatMessageBubbleImages.swift index db0fadc18b..6680a8a2f6 100644 --- a/submodules/TelegramPresentationData/Sources/ChatMessageBubbleImages.swift +++ b/submodules/TelegramPresentationData/Sources/ChatMessageBubbleImages.swift @@ -31,7 +31,7 @@ public func messageBubbleImage(incoming: Bool, fillColor: UIColor, strokeColor: let corner: CGFloat = 7.0 let knockout = knockoutValue && !mask - let inset: CGFloat = extendedEdges ? 0.0 : 1.0 + let inset: CGFloat = (extendedEdges && !mask) ? 1.0 : 0.0 return generateImage(CGSize(width: 42.0 + inset * 2.0, height: diameter + inset * 2.0), contextGenerator: { rawSize, context in var drawWithClearColor = false @@ -48,26 +48,27 @@ public func messageBubbleImage(incoming: Bool, fillColor: UIColor, strokeColor: context.clear(CGRect(origin: CGPoint(), size: rawSize)) } - let size = CGSize(width: rawSize.width - inset * 2.0, height: rawSize.height - inset * 2.0) - context.translateBy(x: inset, y: inset) - let additionalOffset: CGFloat switch neighbors { - case .none, .bottom: - additionalOffset = 0.0 - case .both, .side, .top: - additionalOffset = 6.0 + case .none, .bottom: + additionalOffset = 0.0 + case .both, .side, .top: + additionalOffset = 6.0 } - context.translateBy(x: size.width / 2.0, y: size.height / 2.0) + context.translateBy(x: rawSize.width / 2.0, y: rawSize.height / 2.0) context.scaleBy(x: incoming ? 1.0 : -1.0, y: -1.0) - context.translateBy(x: -size.width / 2.0 + 0.5 + additionalOffset, y: -size.height / 2.0 + 0.5) + context.translateBy(x: -rawSize.width / 2.0 + 0.5 + additionalOffset, y: -rawSize.height / 2.0 + 0.5) + + let size = CGSize(width: rawSize.width - inset * 2.0, height: rawSize.height - inset * 2.0) + context.translateBy(x: inset, y: inset) let lineWidth: CGFloat = 1.0 if drawWithClearColor { context.setBlendMode(.copy) context.setFillColor(UIColor.clear.cgColor) + context.setStrokeColor(UIColor.clear.cgColor) } else { context.setFillColor(fillColor.cgColor) context.setLineWidth(lineWidth) diff --git a/submodules/TelegramPresentationData/Sources/ComponentsThemes.swift b/submodules/TelegramPresentationData/Sources/ComponentsThemes.swift index c167866c53..4466262fd5 100644 --- a/submodules/TelegramPresentationData/Sources/ComponentsThemes.swift +++ b/submodules/TelegramPresentationData/Sources/ComponentsThemes.swift @@ -68,15 +68,22 @@ public extension NavigationBarPresentationData { } public extension ActionSheetControllerTheme { - convenience init(presentationTheme: PresentationTheme) { + convenience init(presentationData: PresentationData) { + let presentationTheme = presentationData.theme + let actionSheet = presentationTheme.actionSheet - self.init(dimColor: actionSheet.dimColor, backgroundType: actionSheet.backgroundType == .light ? .light : .dark, itemBackgroundColor: actionSheet.itemBackgroundColor, itemHighlightedBackgroundColor: actionSheet.itemHighlightedBackgroundColor, standardActionTextColor: actionSheet.standardActionTextColor, destructiveActionTextColor: actionSheet.destructiveActionTextColor, disabledActionTextColor: actionSheet.disabledActionTextColor, primaryTextColor: actionSheet.primaryTextColor, secondaryTextColor: actionSheet.secondaryTextColor, controlAccentColor: actionSheet.controlAccentColor, controlColor: presentationTheme.list.disclosureArrowColor, switchFrameColor: presentationTheme.list.itemSwitchColors.frameColor, switchContentColor: presentationTheme.list.itemSwitchColors.contentColor, switchHandleColor: presentationTheme.list.itemSwitchColors.handleColor) + self.init(dimColor: actionSheet.dimColor, backgroundType: actionSheet.backgroundType == .light ? .light : .dark, itemBackgroundColor: actionSheet.itemBackgroundColor, itemHighlightedBackgroundColor: actionSheet.itemHighlightedBackgroundColor, standardActionTextColor: actionSheet.standardActionTextColor, destructiveActionTextColor: actionSheet.destructiveActionTextColor, disabledActionTextColor: actionSheet.disabledActionTextColor, primaryTextColor: actionSheet.primaryTextColor, secondaryTextColor: actionSheet.secondaryTextColor, controlAccentColor: actionSheet.controlAccentColor, controlColor: presentationTheme.list.disclosureArrowColor, switchFrameColor: presentationTheme.list.itemSwitchColors.frameColor, switchContentColor: presentationTheme.list.itemSwitchColors.contentColor, switchHandleColor: presentationTheme.list.itemSwitchColors.handleColor, baseFontSize: presentationData.fontSize.baseDisplaySize) + } + + convenience init(presentationTheme: PresentationTheme, fontSize: PresentationFontSize) { + let actionSheet = presentationTheme.actionSheet + self.init(dimColor: actionSheet.dimColor, backgroundType: actionSheet.backgroundType == .light ? .light : .dark, itemBackgroundColor: actionSheet.itemBackgroundColor, itemHighlightedBackgroundColor: actionSheet.itemHighlightedBackgroundColor, standardActionTextColor: actionSheet.standardActionTextColor, destructiveActionTextColor: actionSheet.destructiveActionTextColor, disabledActionTextColor: actionSheet.disabledActionTextColor, primaryTextColor: actionSheet.primaryTextColor, secondaryTextColor: actionSheet.secondaryTextColor, controlAccentColor: actionSheet.controlAccentColor, controlColor: presentationTheme.list.disclosureArrowColor, switchFrameColor: presentationTheme.list.itemSwitchColors.frameColor, switchContentColor: presentationTheme.list.itemSwitchColors.contentColor, switchHandleColor: presentationTheme.list.itemSwitchColors.handleColor, baseFontSize: fontSize.baseDisplaySize) } } public extension ActionSheetController { - convenience init(presentationTheme: PresentationTheme) { - self.init(theme: ActionSheetControllerTheme(presentationTheme: presentationTheme)) + convenience init(presentationData: PresentationData) { + self.init(theme: ActionSheetControllerTheme(presentationData: presentationData)) } } diff --git a/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift b/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift index 2956b21cde..13a4268b03 100644 --- a/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift @@ -187,6 +187,13 @@ private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UICo primaryColor: .white, controlColor: UIColor(rgb: 0x4d4d4d) ), + freePlainInputField: PresentationInputFieldTheme( + backgroundColor: UIColor(rgb: 0xffffff, alpha: 0.5), + strokeColor: UIColor(rgb: 0xffffff, alpha: 0.5), + placeholderColor: UIColor(rgb: 0x4d4d4d), + primaryColor: .white, + controlColor: UIColor(rgb: 0x4d4d4d) + ), mediaPlaceholderColor: UIColor(rgb: 0x1c1c1d), scrollIndicatorColor: UIColor(white: 1.0, alpha: 0.3), pageIndicatorInactiveColor: UIColor(white: 1.0, alpha: 0.3), diff --git a/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift b/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift index 1580481a0d..3372ca4474 100644 --- a/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift @@ -183,6 +183,13 @@ private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UICo primaryColor: .white, controlColor: UIColor(rgb: 0x4d4d4d) ), + freePlainInputField: PresentationInputFieldTheme( + backgroundColor: mainSecondaryTextColor.withAlphaComponent(0.5), + strokeColor: mainSecondaryTextColor.withAlphaComponent(0.5), + placeholderColor: UIColor(rgb: 0x4d4d4d), + primaryColor: .white, + controlColor: UIColor(rgb: 0x4d4d4d) + ), mediaPlaceholderColor: accentColor.withMultiplied(hue: 1.019, saturation: 0.585, brightness: 0.23), scrollIndicatorColor: UIColor(white: 1.0, alpha: 0.3), pageIndicatorInactiveColor: mainSecondaryTextColor.withAlphaComponent(0.4), diff --git a/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift b/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift index e33750ebe6..9533ee145d 100644 --- a/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift @@ -170,6 +170,13 @@ private func makeDefaultDayPresentationTheme(accentColor: UIColor, bubbleColors: primaryColor: .black, controlColor: UIColor(rgb: 0x96979d) ), + freePlainInputField: PresentationInputFieldTheme( + backgroundColor: UIColor(rgb: 0xe9e9e9), + strokeColor: UIColor(rgb: 0xe9e9e9), + placeholderColor: UIColor(rgb: 0x8E8D92), + primaryColor: .black, + controlColor: UIColor(rgb: 0xBCBCC0) + ), mediaPlaceholderColor: UIColor(rgb: 0xe4e4e4), scrollIndicatorColor: UIColor(white: 0.0, alpha: 0.3), pageIndicatorInactiveColor: UIColor(rgb: 0xe3e3e7), diff --git a/submodules/TelegramPresentationData/Sources/PresentationTheme.swift b/submodules/TelegramPresentationData/Sources/PresentationTheme.swift index c88d476fa3..a28f4bebc2 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationTheme.swift @@ -354,13 +354,14 @@ public final class PresentationThemeList { public let itemCheckColors: PresentationThemeFillStrokeForeground public let controlSecondaryColor: UIColor public let freeInputField: PresentationInputFieldTheme + public let freePlainInputField: PresentationInputFieldTheme public let mediaPlaceholderColor: UIColor public let scrollIndicatorColor: UIColor public let pageIndicatorInactiveColor: UIColor public let inputClearButtonColor: UIColor public let itemBarChart: PresentationThemeItemBarChart - public init(blocksBackgroundColor: UIColor, plainBackgroundColor: UIColor, itemPrimaryTextColor: UIColor, itemSecondaryTextColor: UIColor, itemDisabledTextColor: UIColor, itemAccentColor: UIColor, itemHighlightedColor: UIColor, itemDestructiveColor: UIColor, itemPlaceholderTextColor: UIColor, itemBlocksBackgroundColor: UIColor, itemHighlightedBackgroundColor: UIColor, itemBlocksSeparatorColor: UIColor, itemPlainSeparatorColor: UIColor, disclosureArrowColor: UIColor, sectionHeaderTextColor: UIColor, freeTextColor: UIColor, freeTextErrorColor: UIColor, freeTextSuccessColor: UIColor, freeMonoIconColor: UIColor, itemSwitchColors: PresentationThemeSwitch, itemDisclosureActions: PresentationThemeItemDisclosureActions, itemCheckColors: PresentationThemeFillStrokeForeground, controlSecondaryColor: UIColor, freeInputField: PresentationInputFieldTheme, mediaPlaceholderColor: UIColor, scrollIndicatorColor: UIColor, pageIndicatorInactiveColor: UIColor, inputClearButtonColor: UIColor, itemBarChart: PresentationThemeItemBarChart) { + public init(blocksBackgroundColor: UIColor, plainBackgroundColor: UIColor, itemPrimaryTextColor: UIColor, itemSecondaryTextColor: UIColor, itemDisabledTextColor: UIColor, itemAccentColor: UIColor, itemHighlightedColor: UIColor, itemDestructiveColor: UIColor, itemPlaceholderTextColor: UIColor, itemBlocksBackgroundColor: UIColor, itemHighlightedBackgroundColor: UIColor, itemBlocksSeparatorColor: UIColor, itemPlainSeparatorColor: UIColor, disclosureArrowColor: UIColor, sectionHeaderTextColor: UIColor, freeTextColor: UIColor, freeTextErrorColor: UIColor, freeTextSuccessColor: UIColor, freeMonoIconColor: UIColor, itemSwitchColors: PresentationThemeSwitch, itemDisclosureActions: PresentationThemeItemDisclosureActions, itemCheckColors: PresentationThemeFillStrokeForeground, controlSecondaryColor: UIColor, freeInputField: PresentationInputFieldTheme, freePlainInputField: PresentationInputFieldTheme, mediaPlaceholderColor: UIColor, scrollIndicatorColor: UIColor, pageIndicatorInactiveColor: UIColor, inputClearButtonColor: UIColor, itemBarChart: PresentationThemeItemBarChart) { self.blocksBackgroundColor = blocksBackgroundColor self.plainBackgroundColor = plainBackgroundColor self.itemPrimaryTextColor = itemPrimaryTextColor @@ -385,6 +386,7 @@ public final class PresentationThemeList { self.itemCheckColors = itemCheckColors self.controlSecondaryColor = controlSecondaryColor self.freeInputField = freeInputField + self.freePlainInputField = freePlainInputField self.mediaPlaceholderColor = mediaPlaceholderColor self.scrollIndicatorColor = scrollIndicatorColor self.pageIndicatorInactiveColor = pageIndicatorInactiveColor diff --git a/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift b/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift index 3bfc076f0e..38439f7dab 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift @@ -714,6 +714,7 @@ extension PresentationThemeList: Codable { case check case controlSecondary case freeInputField + case freePlainInputField case mediaPlaceholder case scrollIndicator case pageIndicatorInactive @@ -723,35 +724,46 @@ extension PresentationThemeList: Codable { public convenience init(from decoder: Decoder) throws { let values = try decoder.container(keyedBy: CodingKeys.self) - self.init(blocksBackgroundColor: try decodeColor(values, .blocksBg), - plainBackgroundColor: try decodeColor(values, .plainBg), - itemPrimaryTextColor: try decodeColor(values, .primaryText), - itemSecondaryTextColor: try decodeColor(values, .secondaryText), - itemDisabledTextColor: try decodeColor(values, .disabledText), - itemAccentColor: try decodeColor(values, .accent), - itemHighlightedColor: try decodeColor(values, .highlighted), - itemDestructiveColor: try decodeColor(values, .destructive), - itemPlaceholderTextColor: try decodeColor(values, .placeholderText), - itemBlocksBackgroundColor: try decodeColor(values, .itemBlocksBg), - itemHighlightedBackgroundColor: try decodeColor(values, .itemHighlightedBg), - itemBlocksSeparatorColor: try decodeColor(values, .blocksSeparator), - itemPlainSeparatorColor: try decodeColor(values, .plainSeparator), - disclosureArrowColor: try decodeColor(values, .disclosureArrow), - sectionHeaderTextColor: try decodeColor(values, .sectionHeaderText), - freeTextColor: try decodeColor(values, .freeText), - freeTextErrorColor: try decodeColor(values, .freeTextError), - freeTextSuccessColor: try decodeColor(values, .freeTextSuccess), - freeMonoIconColor: try decodeColor(values, .freeMonoIcon), - itemSwitchColors: try values.decode(PresentationThemeSwitch.self, forKey: .switch), - itemDisclosureActions: try values.decode(PresentationThemeItemDisclosureActions.self, forKey: .disclosureActions), - itemCheckColors: try values.decode(PresentationThemeFillStrokeForeground.self, forKey: .check), - controlSecondaryColor: try decodeColor(values, .controlSecondary), - freeInputField: try values.decode(PresentationInputFieldTheme.self, forKey: .freeInputField), - mediaPlaceholderColor: try decodeColor(values, .mediaPlaceholder), - scrollIndicatorColor: try decodeColor(values, .scrollIndicator), - pageIndicatorInactiveColor: try decodeColor(values, .pageIndicatorInactive), - inputClearButtonColor: try decodeColor(values, .inputClearButton), - itemBarChart: try values.decode(PresentationThemeItemBarChart.self, forKey: .itemBarChart)) + + let freePlainInputField: PresentationInputFieldTheme + if let value = try? values.decode(PresentationInputFieldTheme.self, forKey: .freePlainInputField) { + freePlainInputField = value + } else { + freePlainInputField = try values.decode(PresentationInputFieldTheme.self, forKey: .freeInputField) + } + + self.init( + blocksBackgroundColor: try decodeColor(values, .blocksBg), + plainBackgroundColor: try decodeColor(values, .plainBg), + itemPrimaryTextColor: try decodeColor(values, .primaryText), + itemSecondaryTextColor: try decodeColor(values, .secondaryText), + itemDisabledTextColor: try decodeColor(values, .disabledText), + itemAccentColor: try decodeColor(values, .accent), + itemHighlightedColor: try decodeColor(values, .highlighted), + itemDestructiveColor: try decodeColor(values, .destructive), + itemPlaceholderTextColor: try decodeColor(values, .placeholderText), + itemBlocksBackgroundColor: try decodeColor(values, .itemBlocksBg), + itemHighlightedBackgroundColor: try decodeColor(values, .itemHighlightedBg), + itemBlocksSeparatorColor: try decodeColor(values, .blocksSeparator), + itemPlainSeparatorColor: try decodeColor(values, .plainSeparator), + disclosureArrowColor: try decodeColor(values, .disclosureArrow), + sectionHeaderTextColor: try decodeColor(values, .sectionHeaderText), + freeTextColor: try decodeColor(values, .freeText), + freeTextErrorColor: try decodeColor(values, .freeTextError), + freeTextSuccessColor: try decodeColor(values, .freeTextSuccess), + freeMonoIconColor: try decodeColor(values, .freeMonoIcon), + itemSwitchColors: try values.decode(PresentationThemeSwitch.self, forKey: .switch), + itemDisclosureActions: try values.decode(PresentationThemeItemDisclosureActions.self, forKey: .disclosureActions), + itemCheckColors: try values.decode(PresentationThemeFillStrokeForeground.self, forKey: .check), + controlSecondaryColor: try decodeColor(values, .controlSecondary), + freeInputField: try values.decode(PresentationInputFieldTheme.self, forKey: .freeInputField), + freePlainInputField: freePlainInputField, + mediaPlaceholderColor: try decodeColor(values, .mediaPlaceholder), + scrollIndicatorColor: try decodeColor(values, .scrollIndicator), + pageIndicatorInactiveColor: try decodeColor(values, .pageIndicatorInactive), + inputClearButtonColor: try decodeColor(values, .inputClearButton), + itemBarChart: try values.decode(PresentationThemeItemBarChart.self, forKey: .itemBarChart) + ) } public func encode(to encoder: Encoder) throws { diff --git a/submodules/TelegramPresentationData/Sources/PresentationThemeEssentialGraphics.swift b/submodules/TelegramPresentationData/Sources/PresentationThemeEssentialGraphics.swift index 149f95ed03..fd799d341e 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationThemeEssentialGraphics.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationThemeEssentialGraphics.swift @@ -206,20 +206,20 @@ public final class PrincipalThemeEssentialGraphics { let emptyImage = UIImage() if preview { self.chatMessageBackgroundIncomingMaskImage = messageBubbleImage(incoming: true, fillColor: UIColor.black, strokeColor: UIColor.clear, neighbors: .none, theme: theme, wallpaper: .color(0xffffff), knockout: true, mask: true, extendedEdges: true) - self.chatMessageBackgroundIncomingImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .none, theme: theme, wallpaper: wallpaper, knockout: incomingKnockout) + self.chatMessageBackgroundIncomingImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .none, theme: theme, wallpaper: wallpaper, knockout: incomingKnockout, extendedEdges: true) self.chatMessageBackgroundOutgoingMaskImage = messageBubbleImage(incoming: false, fillColor: .black, strokeColor: .clear, neighbors: .none, theme: theme, wallpaper: .color(0xffffff), knockout: true, mask: true, extendedEdges: true) - self.chatMessageBackgroundOutgoingImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .none, theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout) + self.chatMessageBackgroundOutgoingImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .none, theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout, extendedEdges: true) self.checkBubbleFullImage = generateCheckImage(partial: false, color: theme.message.outgoingCheckColor, width: 11.0)! self.checkBubblePartialImage = generateCheckImage(partial: true, color: theme.message.outgoingCheckColor, width: 11.0)! self.chatMessageBackgroundIncomingHighlightedImage = emptyImage self.chatMessageBackgroundIncomingMergedTopMaskImage = emptyImage - self.chatMessageBackgroundIncomingMergedTopImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .top(side: false), theme: theme, wallpaper: wallpaper, knockout: incomingKnockout) + self.chatMessageBackgroundIncomingMergedTopImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .top(side: false), theme: theme, wallpaper: wallpaper, knockout: incomingKnockout, extendedEdges: true) self.chatMessageBackgroundIncomingMergedTopHighlightedImage = emptyImage self.chatMessageBackgroundIncomingMergedTopSideMaskImage = emptyImage self.chatMessageBackgroundIncomingMergedTopSideImage = emptyImage self.chatMessageBackgroundIncomingMergedTopSideHighlightedImage = emptyImage self.chatMessageBackgroundIncomingMergedBottomMaskImage = emptyImage - self.chatMessageBackgroundIncomingMergedBottomImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .bottom, theme: theme, wallpaper: wallpaper, knockout: incomingKnockout) + self.chatMessageBackgroundIncomingMergedBottomImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .bottom, theme: theme, wallpaper: wallpaper, knockout: incomingKnockout, extendedEdges: true) self.chatMessageBackgroundIncomingMergedBottomHighlightedImage = emptyImage self.chatMessageBackgroundIncomingMergedBothMaskImage = emptyImage self.chatMessageBackgroundIncomingMergedBothImage = emptyImage @@ -229,16 +229,16 @@ public final class PrincipalThemeEssentialGraphics { self.chatMessageBackgroundIncomingMergedSideHighlightedImage = emptyImage self.chatMessageBackgroundOutgoingHighlightedImage = emptyImage self.chatMessageBackgroundOutgoingMergedTopMaskImage = messageBubbleImage(incoming: false, fillColor: .black, strokeColor: .clear, neighbors: .top(side: false), theme: theme, wallpaper: .color(0xffffff), knockout: true, mask: true, extendedEdges: true) - self.chatMessageBackgroundOutgoingMergedTopImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .top(side: false), theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout) + self.chatMessageBackgroundOutgoingMergedTopImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .top(side: false), theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout, extendedEdges: true) self.chatMessageBackgroundOutgoingMergedTopHighlightedImage = emptyImage self.chatMessageBackgroundOutgoingMergedTopSideMaskImage = emptyImage self.chatMessageBackgroundOutgoingMergedTopSideImage = emptyImage self.chatMessageBackgroundOutgoingMergedTopSideHighlightedImage = emptyImage self.chatMessageBackgroundOutgoingMergedBottomMaskImage = messageBubbleImage(incoming: false, fillColor: .black, strokeColor: .white, neighbors: .bottom, theme: theme, wallpaper: .color(0xffffff), knockout: true, mask: true, extendedEdges: true) - self.chatMessageBackgroundOutgoingMergedBottomImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .bottom, theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout) + self.chatMessageBackgroundOutgoingMergedBottomImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .bottom, theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout, extendedEdges: true) self.chatMessageBackgroundOutgoingMergedBottomHighlightedImage = emptyImage self.chatMessageBackgroundOutgoingMergedBothMaskImage = messageBubbleImage(incoming: false, fillColor: .black, strokeColor: .clear, neighbors: .both, theme: theme, wallpaper: .color(0xffffff), knockout: true, mask: true, extendedEdges: true) - self.chatMessageBackgroundOutgoingMergedBothImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .both, theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout) + self.chatMessageBackgroundOutgoingMergedBothImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .both, theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout, extendedEdges: true) self.chatMessageBackgroundOutgoingMergedBothHighlightedImage = emptyImage self.chatMessageBackgroundOutgoingMergedSideMaskImage = emptyImage self.chatMessageBackgroundOutgoingMergedSideImage = emptyImage @@ -265,43 +265,43 @@ public final class PrincipalThemeEssentialGraphics { self.radialIndicatorFileIconOutgoing = emptyImage } else { self.chatMessageBackgroundIncomingMaskImage = messageBubbleImage(incoming: true, fillColor: .black, strokeColor: .clear, neighbors: .none, theme: theme, wallpaper: .color(0xffffff), knockout: true, mask: true, extendedEdges: true) - self.chatMessageBackgroundIncomingImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .none, theme: theme, wallpaper: wallpaper, knockout: incomingKnockout) - self.chatMessageBackgroundIncomingHighlightedImage = messageBubbleImage(incoming: true, fillColor: incoming.highlightedFill, strokeColor: incoming.stroke, neighbors: .none, theme: theme, wallpaper: wallpaper, knockout: incomingKnockout) + self.chatMessageBackgroundIncomingImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .none, theme: theme, wallpaper: wallpaper, knockout: incomingKnockout, extendedEdges: true) + self.chatMessageBackgroundIncomingHighlightedImage = messageBubbleImage(incoming: true, fillColor: incoming.highlightedFill, strokeColor: incoming.stroke, neighbors: .none, theme: theme, wallpaper: wallpaper, knockout: incomingKnockout, extendedEdges: true) self.chatMessageBackgroundIncomingMergedTopMaskImage = messageBubbleImage(incoming: true, fillColor: .black, strokeColor: .clear, neighbors: .top(side: false), theme: theme, wallpaper: .color(0xffffff), knockout: true, mask: true, extendedEdges: true) self.chatMessageBackgroundIncomingMergedTopImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .top(side: false), theme: theme, wallpaper: wallpaper, knockout: incomingKnockout) - self.chatMessageBackgroundIncomingMergedTopHighlightedImage = messageBubbleImage(incoming: true, fillColor: incoming.highlightedFill, strokeColor: incoming.stroke, neighbors: .top(side: false), theme: theme, wallpaper: wallpaper, knockout: incomingKnockout) + self.chatMessageBackgroundIncomingMergedTopHighlightedImage = messageBubbleImage(incoming: true, fillColor: incoming.highlightedFill, strokeColor: incoming.stroke, neighbors: .top(side: false), theme: theme, wallpaper: wallpaper, knockout: incomingKnockout, extendedEdges: true) self.chatMessageBackgroundIncomingMergedTopSideMaskImage = messageBubbleImage(incoming: true, fillColor: .black, strokeColor: .clear, neighbors: .top(side: true), theme: theme, wallpaper: .color(0xffffff), knockout: true, mask: true, extendedEdges: true) - self.chatMessageBackgroundIncomingMergedTopSideImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .top(side: true), theme: theme, wallpaper: wallpaper, knockout: incomingKnockout) - self.chatMessageBackgroundIncomingMergedTopSideHighlightedImage = messageBubbleImage(incoming: true, fillColor: incoming.highlightedFill, strokeColor: incoming.stroke, neighbors: .top(side: true), theme: theme, wallpaper: wallpaper, knockout: incomingKnockout) + self.chatMessageBackgroundIncomingMergedTopSideImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .top(side: true), theme: theme, wallpaper: wallpaper, knockout: incomingKnockout, extendedEdges: true) + self.chatMessageBackgroundIncomingMergedTopSideHighlightedImage = messageBubbleImage(incoming: true, fillColor: incoming.highlightedFill, strokeColor: incoming.stroke, neighbors: .top(side: true), theme: theme, wallpaper: wallpaper, knockout: incomingKnockout, extendedEdges: true) self.chatMessageBackgroundIncomingMergedBottomMaskImage = messageBubbleImage(incoming: true, fillColor: .black, strokeColor: .clear, neighbors: .bottom, theme: theme, wallpaper: .color(0xffffff), knockout: true, mask: true, extendedEdges: true) - self.chatMessageBackgroundIncomingMergedBottomImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .bottom, theme: theme, wallpaper: wallpaper, knockout: incomingKnockout) - self.chatMessageBackgroundIncomingMergedBottomHighlightedImage = messageBubbleImage(incoming: true, fillColor: incoming.highlightedFill, strokeColor: incoming.stroke, neighbors: .bottom, theme: theme, wallpaper: wallpaper, knockout: incomingKnockout) + self.chatMessageBackgroundIncomingMergedBottomImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .bottom, theme: theme, wallpaper: wallpaper, knockout: incomingKnockout, extendedEdges: true) + self.chatMessageBackgroundIncomingMergedBottomHighlightedImage = messageBubbleImage(incoming: true, fillColor: incoming.highlightedFill, strokeColor: incoming.stroke, neighbors: .bottom, theme: theme, wallpaper: wallpaper, knockout: incomingKnockout, extendedEdges: true) self.chatMessageBackgroundIncomingMergedBothMaskImage = messageBubbleImage(incoming: true, fillColor: .black, strokeColor: .clear, neighbors: .both, theme: theme, wallpaper: .color(0xffffff), knockout: true, mask: true, extendedEdges: true) - self.chatMessageBackgroundIncomingMergedBothImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .both, theme: theme, wallpaper: wallpaper, knockout: incomingKnockout) - self.chatMessageBackgroundIncomingMergedBothHighlightedImage = messageBubbleImage(incoming: true, fillColor: incoming.highlightedFill, strokeColor: incoming.stroke, neighbors: .both, theme: theme, wallpaper: wallpaper, knockout: incomingKnockout) + self.chatMessageBackgroundIncomingMergedBothImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .both, theme: theme, wallpaper: wallpaper, knockout: incomingKnockout, extendedEdges: true) + self.chatMessageBackgroundIncomingMergedBothHighlightedImage = messageBubbleImage(incoming: true, fillColor: incoming.highlightedFill, strokeColor: incoming.stroke, neighbors: .both, theme: theme, wallpaper: wallpaper, knockout: incomingKnockout, extendedEdges: true) self.chatMessageBackgroundOutgoingMaskImage = messageBubbleImage(incoming: false, fillColor: .black, strokeColor: .clear, neighbors: .none, theme: theme, wallpaper: .color(0xffffff), knockout: true, mask: true, extendedEdges: true) - self.chatMessageBackgroundOutgoingImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .none, theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout) - self.chatMessageBackgroundOutgoingHighlightedImage = messageBubbleImage(incoming: false, fillColor: outgoing.highlightedFill, strokeColor: outgoing.stroke, neighbors: .none, theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout) + self.chatMessageBackgroundOutgoingImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .none, theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout, extendedEdges: true) + self.chatMessageBackgroundOutgoingHighlightedImage = messageBubbleImage(incoming: false, fillColor: outgoing.highlightedFill, strokeColor: outgoing.stroke, neighbors: .none, theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout, extendedEdges: true) self.chatMessageBackgroundOutgoingMergedTopMaskImage = messageBubbleImage(incoming: false, fillColor: .black, strokeColor: .clear, neighbors: .top(side: false), theme: theme, wallpaper: .color(0xffffff), knockout: true, mask: true, extendedEdges: true) - self.chatMessageBackgroundOutgoingMergedTopImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .top(side: false), theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout) - self.chatMessageBackgroundOutgoingMergedTopHighlightedImage = messageBubbleImage(incoming: false, fillColor: outgoing.highlightedFill, strokeColor: outgoing.stroke, neighbors: .top(side: false), theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout) + self.chatMessageBackgroundOutgoingMergedTopImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .top(side: false), theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout, extendedEdges: true) + self.chatMessageBackgroundOutgoingMergedTopHighlightedImage = messageBubbleImage(incoming: false, fillColor: outgoing.highlightedFill, strokeColor: outgoing.stroke, neighbors: .top(side: false), theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout, extendedEdges: true) self.chatMessageBackgroundOutgoingMergedTopSideMaskImage = messageBubbleImage(incoming: false, fillColor: .black, strokeColor: .clear, neighbors: .top(side: true), theme: theme, wallpaper: .color(0xffffff), knockout: true, mask: true, extendedEdges: true) - self.chatMessageBackgroundOutgoingMergedTopSideImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .top(side: true), theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout) - self.chatMessageBackgroundOutgoingMergedTopSideHighlightedImage = messageBubbleImage(incoming: false, fillColor: outgoing.highlightedFill, strokeColor: outgoing.stroke, neighbors: .top(side: true), theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout) + self.chatMessageBackgroundOutgoingMergedTopSideImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .top(side: true), theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout, extendedEdges: true) + self.chatMessageBackgroundOutgoingMergedTopSideHighlightedImage = messageBubbleImage(incoming: false, fillColor: outgoing.highlightedFill, strokeColor: outgoing.stroke, neighbors: .top(side: true), theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout, extendedEdges: true) self.chatMessageBackgroundOutgoingMergedBottomMaskImage = messageBubbleImage(incoming: false, fillColor: .black, strokeColor: .white, neighbors: .bottom, theme: theme, wallpaper: .color(0xffffff), knockout: true, mask: true, extendedEdges: true) - self.chatMessageBackgroundOutgoingMergedBottomImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .bottom, theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout) - self.chatMessageBackgroundOutgoingMergedBottomHighlightedImage = messageBubbleImage(incoming: false, fillColor: outgoing.highlightedFill, strokeColor: outgoing.stroke, neighbors: .bottom, theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout) + self.chatMessageBackgroundOutgoingMergedBottomImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .bottom, theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout, extendedEdges: true) + self.chatMessageBackgroundOutgoingMergedBottomHighlightedImage = messageBubbleImage(incoming: false, fillColor: outgoing.highlightedFill, strokeColor: outgoing.stroke, neighbors: .bottom, theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout, extendedEdges: true) self.chatMessageBackgroundOutgoingMergedBothMaskImage = messageBubbleImage(incoming: false, fillColor: .black, strokeColor: .clear, neighbors: .both, theme: theme, wallpaper: .color(0xffffff), knockout: true, mask: true, extendedEdges: true) - self.chatMessageBackgroundOutgoingMergedBothImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .both, theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout) - self.chatMessageBackgroundOutgoingMergedBothHighlightedImage = messageBubbleImage(incoming: false, fillColor: outgoing.highlightedFill, strokeColor: outgoing.stroke, neighbors: .both, theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout) + self.chatMessageBackgroundOutgoingMergedBothImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .both, theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout, extendedEdges: true) + self.chatMessageBackgroundOutgoingMergedBothHighlightedImage = messageBubbleImage(incoming: false, fillColor: outgoing.highlightedFill, strokeColor: outgoing.stroke, neighbors: .both, theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout, extendedEdges: true) self.chatMessageBackgroundIncomingMergedSideMaskImage = messageBubbleImage(incoming: true, fillColor: .black, strokeColor: .clear, neighbors: .side, theme: theme, wallpaper: .color(0xffffff), knockout: true, mask: true, extendedEdges: true) - self.chatMessageBackgroundIncomingMergedSideImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .side, theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout) + self.chatMessageBackgroundIncomingMergedSideImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .side, theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout, extendedEdges: true) self.chatMessageBackgroundOutgoingMergedSideMaskImage = messageBubbleImage(incoming: false, fillColor: .black, strokeColor: .clear, neighbors: .side, theme: theme, wallpaper: .color(0xffffff), knockout: true, mask: true, extendedEdges: true) - self.chatMessageBackgroundOutgoingMergedSideImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .side, theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout) - self.chatMessageBackgroundIncomingMergedSideHighlightedImage = messageBubbleImage(incoming: true, fillColor: incoming.highlightedFill, strokeColor: incoming.stroke, neighbors: .side, theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout) - self.chatMessageBackgroundOutgoingMergedSideHighlightedImage = messageBubbleImage(incoming: false, fillColor: outgoing.highlightedFill, strokeColor: outgoing.stroke, neighbors: .side, theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout) + self.chatMessageBackgroundOutgoingMergedSideImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .side, theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout, extendedEdges: true) + self.chatMessageBackgroundIncomingMergedSideHighlightedImage = messageBubbleImage(incoming: true, fillColor: incoming.highlightedFill, strokeColor: incoming.stroke, neighbors: .side, theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout, extendedEdges: true) + self.chatMessageBackgroundOutgoingMergedSideHighlightedImage = messageBubbleImage(incoming: false, fillColor: outgoing.highlightedFill, strokeColor: outgoing.stroke, neighbors: .side, theme: theme, wallpaper: wallpaper, knockout: outgoingKnockout, extendedEdges: true) self.checkBubbleFullImage = generateCheckImage(partial: false, color: theme.message.outgoingCheckColor, width: 11.0)! self.checkBubblePartialImage = generateCheckImage(partial: true, color: theme.message.outgoingCheckColor, width: 11.0)! @@ -332,8 +332,8 @@ public final class PrincipalThemeEssentialGraphics { self.mediaImpressionIcon = generateTintedImage(image: impressionCountImage, color: .white)! self.freeImpressionIcon = generateTintedImage(image: impressionCountImage, color: serviceColor.primaryText)! - self.radialIndicatorFileIconIncoming = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/RadialProgressIconDocument"), color: theme.message.incoming.mediaControlInnerBackgroundColor)! - self.radialIndicatorFileIconOutgoing = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/RadialProgressIconDocument"), color: theme.message.outgoing.mediaControlInnerBackgroundColor)! + self.radialIndicatorFileIconIncoming = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/RadialProgressIconDocument"), color: .black)! + self.radialIndicatorFileIconOutgoing = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/RadialProgressIconDocument"), color: .black)! } let chatDateSize: CGFloat = 20.0 diff --git a/submodules/TelegramUI/TelegramUI/ApplicationContext.swift b/submodules/TelegramUI/TelegramUI/ApplicationContext.swift index a6c622efdc..b4475e127c 100644 --- a/submodules/TelegramUI/TelegramUI/ApplicationContext.swift +++ b/submodules/TelegramUI/TelegramUI/ApplicationContext.swift @@ -339,8 +339,8 @@ final class AuthorizedApplicationContext { let chatController = ChatControllerImpl(context: strongSelf.context, chatLocation: .peer(firstMessage.id.peerId), mode: .overlay) //chatController.navigation_setNavigationController(strongSelf.rootController) chatController.presentationArguments = ChatControllerOverlayPresentationData(expandData: expandData()) - strongSelf.rootController.pushViewController(chatController) - //(strongSelf.rootController.viewControllers.last as? ViewController)?.present(chatController, in: .window(.root), with: ChatControllerOverlayPresentationData(expandData: expandData())) + //strongSelf.rootController.pushViewController(chatController) + (strongSelf.rootController.viewControllers.last as? ViewController)?.present(chatController, in: .window(.root), with: ChatControllerOverlayPresentationData(expandData: expandData())) } })) } diff --git a/submodules/TelegramUI/TelegramUI/ChatController.swift b/submodules/TelegramUI/TelegramUI/ChatController.swift index 4f4b954278..7c430943f9 100644 --- a/submodules/TelegramUI/TelegramUI/ChatController.swift +++ b/submodules/TelegramUI/TelegramUI/ChatController.swift @@ -361,12 +361,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } super.init(context: context, navigationBarPresentationData: navigationBarPresentationData, mediaAccessoryPanelVisibility: mediaAccessoryPanelVisibility, locationBroadcastPanelSource: locationBroadcastPanelSource) - switch mode { + /*switch mode { case .overlay: self.navigationPresentation = .standaloneModal default: break - } + }*/ self.blocksBackgroundWhenInOverlay = true @@ -590,7 +590,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G if Namespaces.Message.allScheduled.contains(message.id.namespace) { reactionItems = [] } - let controller = ContextController(account: strongSelf.context.account, theme: strongSelf.presentationData.theme, strings: strongSelf.presentationData.strings, source: .extracted(ChatMessageContextExtractedContentSource(chatNode: strongSelf.chatDisplayNode, message: message)), items: .single(actions), reactionItems: reactionItems, recognizer: recognizer) + let controller = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .extracted(ChatMessageContextExtractedContentSource(chatNode: strongSelf.chatDisplayNode, message: message)), items: .single(actions), reactionItems: reactionItems, recognizer: recognizer) strongSelf.currentContextController = controller controller.reactionSelected = { [weak controller] value in guard let strongSelf = self, let message = updatedMessages.first else { @@ -1180,7 +1180,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } else if canOpenIn { openText = strongSelf.presentationData.strings.Conversation_FileOpenIn } - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) var items: [ActionSheetItem] = [] items.append(ActionSheetTextItem(title: cleanUrl)) @@ -1222,7 +1222,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G strongSelf.chatDisplayNode.dismissInput() strongSelf.present(actionSheet, in: .window(.root)) case let .peerMention(peerId, mention): - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) var items: [ActionSheetItem] = [] if !mention.isEmpty { items.append(ActionSheetTextItem(title: mention)) @@ -1247,7 +1247,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G strongSelf.chatDisplayNode.dismissInput() strongSelf.present(actionSheet, in: .window(.root)) case let .mention(mention): - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetTextItem(title: mention), ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_LinkDialogOpen, color: .accent, action: { [weak actionSheet] in @@ -1268,7 +1268,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G strongSelf.chatDisplayNode.dismissInput() strongSelf.present(actionSheet, in: .window(.root)) case let .command(command): - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) var items: [ActionSheetItem] = [] items.append(ActionSheetTextItem(title: command)) if canSendMessagesToChat(strongSelf.presentationInterfaceState) { @@ -1291,7 +1291,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G strongSelf.chatDisplayNode.dismissInput() strongSelf.present(actionSheet, in: .window(.root)) case let .hashtag(hashtag): - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetTextItem(title: hashtag), ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_LinkDialogOpen, color: .accent, action: { [weak actionSheet] in @@ -1328,7 +1328,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G guard let message = message else { return } - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetTextItem(title: text), ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_LinkDialogOpen, color: .accent, action: { [weak actionSheet] in @@ -1424,7 +1424,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } }))) - let controller = ContextController(account: strongSelf.context.account, theme: strongSelf.presentationData.theme, strings: strongSelf.presentationData.strings, source: .extracted(ChatMessageContextExtractedContentSource(chatNode: strongSelf.chatDisplayNode, message: message)), items: .single(actions), reactionItems: [], recognizer: nil) + let controller = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .extracted(ChatMessageContextExtractedContentSource(chatNode: strongSelf.chatDisplayNode, message: message)), items: .single(actions), reactionItems: [], recognizer: nil) strongSelf.currentContextController = controller strongSelf.window?.presentInGlobalOverlay(controller) }) @@ -1495,7 +1495,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G f(.dismissWithoutContent) }))) - let controller = ContextController(account: strongSelf.context.account, theme: strongSelf.presentationData.theme, strings: strongSelf.presentationData.strings, source: .extracted(ChatMessageContextExtractedContentSource(chatNode: strongSelf.chatDisplayNode, message: topMessage)), items: .single(actions), reactionItems: [], recognizer: nil) + let controller = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .extracted(ChatMessageContextExtractedContentSource(chatNode: strongSelf.chatDisplayNode, message: topMessage)), items: .single(actions), reactionItems: [], recognizer: nil) strongSelf.currentContextController = controller strongSelf.window?.presentInGlobalOverlay(controller) }) @@ -1572,7 +1572,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G if let strongSelf = self { if let node = node { strongSelf.messageTooltipController?.dismiss() - let tooltipController = TooltipController(content: .text(text), dismissByTapOutside: true, dismissImmediatelyOnLayoutUpdate: true) + let tooltipController = TooltipController(content: .text(text), baseFontSize: strongSelf.presentationData.fontSize.baseDisplaySize, dismissByTapOutside: true, dismissImmediatelyOnLayoutUpdate: true) strongSelf.messageTooltipController = tooltipController tooltipController.dismissed = { [weak tooltipController] _ in if let strongSelf = self, let tooltipController = tooltipController, strongSelf.messageTooltipController === tooltipController { @@ -1782,7 +1782,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G self?.navigationButtonAction(.openChatInfo) })) ] - let contextController = ContextController(account: strongSelf.context.account, theme: strongSelf.presentationData.theme, strings: strongSelf.presentationData.strings, source: .controller(ContextControllerContentSourceImpl(controller: galleryController, sourceNode: node)), items: .single(items), reactionItems: [], gesture: gesture) + let contextController = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: galleryController, sourceNode: node)), items: .single(items), reactionItems: [], gesture: gesture) strongSelf.presentInGlobalOverlay(contextController) } chatInfoButtonItem = UIBarButtonItem(customDisplayNode: avatarNode)! @@ -2400,7 +2400,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G return state }) - self.currentContextController?.updateTheme(theme: self.presentationData.theme) + self.currentContextController?.updateTheme(presentationData: self.presentationData) } override public func loadDisplayNode() { @@ -2688,7 +2688,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G if let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(index.id) { let highlightedState = ChatInterfaceHighlightedState(messageStableId: message.stableId) controllerInteraction.highlightedState = highlightedState - strongSelf.updateItemNodesHighlightedStates(animated: true) + strongSelf.updateItemNodesHighlightedStates(animated: false) strongSelf.messageContextDisposable.set((Signal.complete() |> delay(0.7, queue: Queue.mainQueue())).start(completed: { if let strongSelf = self, let controllerInteraction = strongSelf.controllerInteraction { @@ -2931,7 +2931,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G guard let strongSelf = self else { return } - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetButtonItem(title: strongSelf.presentationData.strings.WebSearch_RecentSectionClear, color: .accent, action: { [weak actionSheet] in actionSheet?.dismissAnimated() @@ -3222,27 +3222,34 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G })) } }, beginMessageSearch: { [weak self] domain, query in - if let strongSelf = self { - strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { current in - return current.updatedTitlePanelContext { - if let index = $0.firstIndex(where: { - switch $0 { - case .chatInfo: - return true - default: - return false - } - }) { - var updatedContexts = $0 - updatedContexts.remove(at: index) - return updatedContexts - } else { - return $0 - } - }.updatedSearch(current.search == nil ? ChatSearchData(domain: domain).withUpdatedQuery(query) : current.search?.withUpdatedDomain(domain).withUpdatedQuery(query)) - }) - strongSelf.updateItemNodesSearchTextHighlightStates() + guard let strongSelf = self else { + return } + var interactive = true + if strongSelf.chatDisplayNode.isInputViewFocused { + interactive = false + strongSelf.context.sharedContext.mainWindow?.doNotAnimateLikelyKeyboardAutocorrectionSwitch() + } + + strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: interactive, { current in + return current.updatedTitlePanelContext { + if let index = $0.firstIndex(where: { + switch $0 { + case .chatInfo: + return true + default: + return false + } + }) { + var updatedContexts = $0 + updatedContexts.remove(at: index) + return updatedContexts + } else { + return $0 + } + }.updatedSearch(current.search == nil ? ChatSearchData(domain: domain).withUpdatedQuery(query) : current.search?.withUpdatedDomain(domain).withUpdatedQuery(query)) + }) + strongSelf.updateItemNodesSearchTextHighlightStates() }, dismissMessageSearch: { [weak self] in if let strongSelf = self { strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { current in @@ -3358,7 +3365,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G if let strongSelf = self, case let .peer(peerId) = strongSelf.chatLocation { strongSelf.chatDisplayNode.dismissInput() - let controller = ChatDateSelectionSheet(theme: strongSelf.presentationData.theme, strings: strongSelf.presentationData.strings, completion: { timestamp in + let controller = ChatDateSelectionSheet(presentationData: strongSelf.presentationData, completion: { timestamp in if let strongSelf = self { strongSelf.loadingMessage.set(true) strongSelf.messageIndexDisposable.set((searchMessageIdByTimestamp(account: strongSelf.context.account, peerId: peerId, timestamp: timestamp) |> deliverOnMainQueue).start(next: { messageId in @@ -3606,7 +3613,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G tooltipController.updateContent(.text(banDescription), animated: true, extendTimer: true) } else if let rect = rect { strongSelf.mediaRestrictedTooltipController?.dismiss() - let tooltipController = TooltipController(content: .text(banDescription)) + let tooltipController = TooltipController(content: .text(banDescription), baseFontSize: strongSelf.presentationData.fontSize.baseDisplaySize) strongSelf.mediaRestrictedTooltipController = tooltipController strongSelf.mediaRestrictedTooltipControllerMode = isStickers tooltipController.dismissed = { [weak tooltipController] _ in @@ -3642,7 +3649,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } if let location = location, let icon = icon { strongSelf.videoUnmuteTooltipController?.dismiss() - let tooltipController = TooltipController(content: .iconAndText(icon, strongSelf.presentationInterfaceState.strings.Conversation_PressVolumeButtonForSound), timeout: 3.5, dismissByTapOutside: true, dismissImmediatelyOnLayoutUpdate: true) + let tooltipController = TooltipController(content: .iconAndText(icon, strongSelf.presentationInterfaceState.strings.Conversation_PressVolumeButtonForSound), baseFontSize: strongSelf.presentationData.fontSize.baseDisplaySize, timeout: 3.5, dismissByTapOutside: true, dismissImmediatelyOnLayoutUpdate: true) strongSelf.videoUnmuteTooltipController = tooltipController tooltipController.dismissed = { [weak tooltipController] _ in if let strongSelf = self, let tooltipController = tooltipController, strongSelf.videoUnmuteTooltipController === tooltipController { @@ -3897,7 +3904,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G if let tooltipController = strongSelf.silentPostTooltipController { tooltipController.updateContent(.text(text), animated: true, extendTimer: true) } else if let rect = rect { - let tooltipController = TooltipController(content: .text(text)) + let tooltipController = TooltipController(content: .text(text), baseFontSize: strongSelf.presentationData.fontSize.baseDisplaySize) strongSelf.silentPostTooltipController = tooltipController tooltipController.dismissed = { [weak tooltipController] _ in if let strongSelf = self, let tooltipController = tooltipController, strongSelf.silentPostTooltipController === tooltipController { @@ -3947,7 +3954,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G return } - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetTextItem(title: strongSelf.presentationData.strings.Conversation_StopPollConfirmationTitle), ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_StopPollConfirmation, color: .destructive, action: { [weak self, weak actionSheet] in @@ -4090,7 +4097,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G strongSelf.slowmodeTooltipController = nil slowmodeTooltipController.dismiss() } - let slowmodeTooltipController = ChatSlowmodeHintController(strings: strongSelf.presentationData.strings, slowmodeState: + let slowmodeTooltipController = ChatSlowmodeHintController(presentationData: strongSelf.presentationData, slowmodeState: slowmodeState) slowmodeTooltipController.presentationArguments = TooltipControllerPresentationArguments(sourceNodeAndRect: { if let strongSelf = self { @@ -4131,7 +4138,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G }, displaySearchResultsTooltip: { [weak self] node, nodeRect in if let strongSelf = self { strongSelf.searchResultsTooltipController?.dismiss() - let tooltipController = TooltipController(content: .text(strongSelf.presentationData.strings.ChatSearch_ResultsTooltip), dismissByTapOutside: true, dismissImmediatelyOnLayoutUpdate: true) + let tooltipController = TooltipController(content: .text(strongSelf.presentationData.strings.ChatSearch_ResultsTooltip), baseFontSize: strongSelf.presentationData.fontSize.baseDisplaySize, dismissByTapOutside: true, dismissImmediatelyOnLayoutUpdate: true) strongSelf.searchResultsTooltipController = tooltipController tooltipController.dismissed = { [weak tooltipController] _ in if let strongSelf = self, let tooltipController = tooltipController, strongSelf.searchResultsTooltipController === tooltipController { @@ -4384,7 +4391,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G return a && b }) - self.chatDisplayNode.loadInputPanels(theme: self.presentationInterfaceState.theme, strings: self.presentationInterfaceState.strings) + self.chatDisplayNode.loadInputPanels(theme: self.presentationInterfaceState.theme, strings: self.presentationInterfaceState.strings, fontSize: self.presentationInterfaceState.fontSize) self.recentlyUsedInlineBotsDisposable = (recentlyUsedInlineBots(postbox: self.context.account.postbox) |> deliverOnMainQueue).start(next: { [weak self] peers in self?.recentlyUsedInlineBotsValue = peers.filter({ $0.1 >= 0.14 }).map({ $0.0 }) @@ -4598,7 +4605,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G case .standard, .inline: break case .overlay: - if layout.safeInsets.top.isZero { + if case .Ignore = self.statusBar.statusBarStyle { + } else if layout.safeInsets.top.isZero { self.statusBar.statusBarStyle = .Hide } else { self.statusBar.statusBarStyle = .Ignore @@ -5060,7 +5068,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G }), in: .current) } - let actionSheet = ActionSheetController(presentationTheme: self.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: self.presentationData) var items: [ActionSheetItem] = [] if self.presentationInterfaceState.isScheduledMessages { @@ -5175,7 +5183,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G return } let presentationData = strongSelf.presentationData - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } @@ -5420,7 +5428,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G banDescription = strongSelf.presentationInterfaceState.strings.Conversation_DefaultRestrictedMedia } - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) var items: [ActionSheetItem] = [] items.append(ActionSheetTextItem(title: banDescription)) items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_Location, color: .accent, action: { [weak actionSheet] in @@ -5595,7 +5603,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } private func presentFileMediaPickerOptions(editingMessage: Bool) { - let actionSheet = ActionSheetController(presentationTheme: self.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: self.presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetButtonItem(title: self.presentationData.strings.Conversation_FilePhotoOrVideo, action: { [weak self, weak actionSheet] in actionSheet?.dismissAnimated() @@ -6529,18 +6537,27 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G self.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: self.context, chatLocation: .peer(messageId.peerId), subject: .message(messageId), keepStack: .always)) } } else if case let .peer(peerId) = self.chatLocation, (messageLocation.peerId == peerId || forceInCurrentChat) { + if let _ = fromId, let fromIndex = fromIndex, rememberInStack { + self.historyNavigationStack.add(fromIndex) + } + + let scrollFromIndex: MessageIndex? if let fromIndex = fromIndex { - if let _ = fromId, rememberInStack { - self.historyNavigationStack.add(fromIndex) - } - + scrollFromIndex = fromIndex + } else if let message = self.chatDisplayNode.historyNode.lastVisbleMesssage() { + scrollFromIndex = message.index + } else { + scrollFromIndex = nil + } + + if let scrollFromIndex = scrollFromIndex { if let messageId = messageLocation.messageId, let message = self.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId) { self.loadingMessage.set(false) self.messageIndexDisposable.set(nil) - self.chatDisplayNode.historyNode.scrollToMessage(from: fromIndex, to: message.index, animated: animated, scrollPosition: scrollPosition) + self.chatDisplayNode.historyNode.scrollToMessage(from: scrollFromIndex, to: message.index, animated: animated, scrollPosition: scrollPosition) completion?() } else if case let .index(index) = messageLocation, index.id.id == 0 && index.timestamp > 0, self.presentationInterfaceState.isScheduledMessages { - self.chatDisplayNode.historyNode.scrollToMessage(from: fromIndex, to: index, animated: animated, scrollPosition: scrollPosition) + self.chatDisplayNode.historyNode.scrollToMessage(from: scrollFromIndex, to: index, animated: animated, scrollPosition: scrollPosition) } else { self.loadingMessage.set(true) let searchLocation: ChatHistoryInitialSearchLocation @@ -6606,12 +6623,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } |> deliverOnMainQueue).start(next: { [weak self] index in if let strongSelf = self, let index = index.0 { - strongSelf.chatDisplayNode.historyNode.scrollToMessage(from: fromIndex, to: index, animated: animated, scrollPosition: scrollPosition) + strongSelf.chatDisplayNode.historyNode.scrollToMessage(from: scrollFromIndex, to: index, animated: animated, scrollPosition: scrollPosition) completion?() } else if index.1 { if !progressStarted { progressStarted = true - progressDisposable.set(progressSignal.start()) + progressDisposable.set(progressSignal.start()) } } }, completed: { [weak self] in @@ -6981,7 +6998,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G self.chatDisplayNode.dismissInput() if let peer = peer as? TelegramChannel, let username = peer.username, !username.isEmpty { - let actionSheet = ActionSheetController(presentationTheme: self.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: self.presentationData) var items: [ActionSheetItem] = [] items.append(ActionSheetButtonItem(title: self.presentationData.strings.Conversation_ReportSpamAndLeave, color: .destructive, action: { [weak self, weak actionSheet] in @@ -7009,7 +7026,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G }), in: .window(.root))*/ } else if let _ = peer as? TelegramUser { let presentationData = self.presentationData - let controller = ActionSheetController(presentationTheme: presentationData.theme) + let controller = ActionSheetController(presentationData: presentationData) let dismissAction: () -> Void = { [weak controller] in controller?.dismissAnimated() } @@ -7075,7 +7092,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G title = self.presentationData.strings.Conversation_ReportSpam infoString = self.presentationData.strings.Conversation_ReportSpamConfirmation } - let actionSheet = ActionSheetController(presentationTheme: self.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: self.presentationData) var items: [ActionSheetItem] = [] if let infoString = infoString { @@ -7110,7 +7127,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G return } - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) var items: [ActionSheetItem] = [] items.append(ActionSheetTextItem(title: strongSelf.presentationData.strings.Conversation_ShareMyPhoneNumberConfirmation(formatPhoneNumber(phoneNumber), peer.compactDisplayTitle).0)) items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_ShareMyPhoneNumber, action: { [weak actionSheet] in @@ -7579,7 +7596,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G if let strongSelf = self { let canBan = participant?.canBeBannedBy(peerId: accountPeerId) ?? true - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) var items: [ActionSheetItem] = [] var actions = Set([0]) @@ -7655,7 +7672,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } private func presentDeleteMessageOptions(messageIds: Set, options: ChatAvailableMessageActionOptions, contextController: ContextController?, completion: @escaping (ContextMenuActionResult) -> Void) { - let actionSheet = ActionSheetController(presentationTheme: self.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: self.presentationData) var items: [ActionSheetItem] = [] var personalPeerName: String? var isChannel = false @@ -7762,7 +7779,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } self.updateChatPresentationInterfaceState(animated: true, interactive: true, { $0.updatedInterfaceState({ $0.withoutSelectionState() }) }) - let actionSheet = ActionSheetController(presentationTheme: self.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: self.presentationData) var items: [ActionSheetItem] = [] items.append(DeleteChatPeerActionSheetItem(context: self.context, peer: peer, chatPeer: peer, action: .clearCacheSuggestion, strings: self.presentationData.strings, nameDisplayOrder: self.presentationData.nameDisplayOrder)) @@ -7846,7 +7863,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G if let tooltipController = self.mediaRecordingModeTooltipController { tooltipController.updateContent(.text(text), animated: true, extendTimer: true) } else if let rect = rect { - let tooltipController = TooltipController(content: .text(text)) + let tooltipController = TooltipController(content: .text(text), baseFontSize: self.presentationData.fontSize.baseDisplaySize) self.mediaRecordingModeTooltipController = tooltipController tooltipController.dismissed = { [weak self, weak tooltipController] _ in if let strongSelf = self, let tooltipController = tooltipController, strongSelf.mediaRecordingModeTooltipController === tooltipController { @@ -7867,7 +7884,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G return } self.sendingOptionsTooltipController?.dismiss() - let tooltipController = TooltipController(content: .text(self.presentationData.strings.Conversation_SendingOptionsTooltip), timeout: 3.0, dismissByTapOutside: true, dismissImmediatelyOnLayoutUpdate: true) + let tooltipController = TooltipController(content: .text(self.presentationData.strings.Conversation_SendingOptionsTooltip), baseFontSize: self.presentationData.fontSize.baseDisplaySize, timeout: 3.0, dismissByTapOutside: true, dismissImmediatelyOnLayoutUpdate: true) self.sendingOptionsTooltipController = tooltipController tooltipController.dismissed = { [weak self, weak tooltipController] _ in if let strongSelf = self, let tooltipController = tooltipController, strongSelf.sendingOptionsTooltipController === tooltipController { diff --git a/submodules/TelegramUI/TelegramUI/ChatControllerNode.swift b/submodules/TelegramUI/TelegramUI/ChatControllerNode.swift index ba0db387c8..141d18e59d 100644 --- a/submodules/TelegramUI/TelegramUI/ChatControllerNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatControllerNode.swift @@ -97,6 +97,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { private var titleAccessoryPanelNode: ChatTitleAccessoryPanelNode? private var inputPanelNode: ChatInputPanelNode? + private weak var currentDismissedInputPanelNode: ASDisplayNode? private var secondaryInputPanelNode: ChatInputPanelNode? private var accessoryPanelNode: AccessoryPanelNode? private var inputContextPanelNode: ChatInputContextPanelNode? @@ -1105,7 +1106,12 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { inputPanelNode.frame = apparentInputPanelFrame.offsetBy(dx: 0.0, dy: apparentInputPanelFrame.height + previousInputPanelBackgroundFrame.maxY - apparentInputBackgroundFrame.maxY) inputPanelNode.alpha = 0.0 } - + if !transition.isAnimated { + inputPanelNode.layer.removeAllAnimations() + if let currentDismissedInputPanelNode = self.currentDismissedInputPanelNode, inputPanelNode is ChatSearchInputPanelNode { + currentDismissedInputPanelNode.layer.removeAllAnimations() + } + } transition.updateFrame(node: inputPanelNode, frame: apparentInputPanelFrame) transition.updateAlpha(node: inputPanelNode, alpha: 1.0) } @@ -1197,12 +1203,19 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { if let dismissedInputPanelNode = dismissedInputPanelNode, dismissedInputPanelNode !== self.secondaryInputPanelNode { var frameCompleted = false var alphaCompleted = false + self.currentDismissedInputPanelNode = dismissedInputPanelNode let completed = { [weak self, weak dismissedInputPanelNode] in - if let strongSelf = self, let dismissedInputPanelNode = dismissedInputPanelNode, strongSelf.inputPanelNode === dismissedInputPanelNode { + guard let strongSelf = self, let dismissedInputPanelNode = dismissedInputPanelNode else { + return + } + if strongSelf.currentDismissedInputPanelNode === dismissedInputPanelNode { + strongSelf.currentDismissedInputPanelNode = nil + } + if strongSelf.inputPanelNode === dismissedInputPanelNode { return } if frameCompleted && alphaCompleted { - dismissedInputPanelNode?.removeFromSupernode() + dismissedInputPanelNode.removeFromSupernode() } } let transitionTargetY = layout.size.height - insets.bottom @@ -1638,13 +1651,13 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { self.setNeedsLayout() } - func loadInputPanels(theme: PresentationTheme, strings: PresentationStrings) { + func loadInputPanels(theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize) { if self.inputMediaNode == nil { var peerId: PeerId? if case let .peer(id) = self.chatPresentationInterfaceState.chatLocation { peerId = id } - let inputNode = ChatMediaInputNode(context: self.context, peerId: peerId, controllerInteraction: self.controllerInteraction, theme: theme, strings: strings, gifPaneIsActiveUpdated: { [weak self] value in + let inputNode = ChatMediaInputNode(context: self.context, peerId: peerId, controllerInteraction: self.controllerInteraction, theme: theme, strings: strings, fontSize: fontSize, gifPaneIsActiveUpdated: { [weak self] value in if let strongSelf = self, let interfaceInteraction = strongSelf.interfaceInteraction { interfaceInteraction.updateInputModeAndDismissedButtonKeyboardMessageId { state in if case let .media(_, expanded) = state.inputMode { @@ -2258,4 +2271,8 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { completion?() }) } + + func setEnablePredictiveTextInput(_ value: Bool) { + self.textInputPanelNode?.enablePredictiveInput = value + } } diff --git a/submodules/TelegramUI/TelegramUI/ChatDateSelectionSheet.swift b/submodules/TelegramUI/TelegramUI/ChatDateSelectionSheet.swift index 8d2dd7a994..36a3ef2686 100644 --- a/submodules/TelegramUI/TelegramUI/ChatDateSelectionSheet.swift +++ b/submodules/TelegramUI/TelegramUI/ChatDateSelectionSheet.swift @@ -15,20 +15,20 @@ final class ChatDateSelectionSheet: ActionSheetController { return self._ready } - init(theme: PresentationTheme, strings: PresentationStrings, completion: @escaping (Int32) -> Void) { - self.strings = strings + init(presentationData: PresentationData, completion: @escaping (Int32) -> Void) { + self.strings = presentationData.strings - super.init(theme: ActionSheetControllerTheme(presentationTheme: theme)) + super.init(theme: ActionSheetControllerTheme(presentationData: presentationData)) self._ready.set(.single(true)) var updatedValue: Int32? self.setItemGroups([ ActionSheetItemGroup(items: [ - ChatDateSelectorItem(strings: strings, valueChanged: { value in + ChatDateSelectorItem(strings: self.strings, valueChanged: { value in updatedValue = value }), - ActionSheetButtonItem(title: strings.Common_Search, action: { [weak self] in + ActionSheetButtonItem(title: self.strings.Common_Search, action: { [weak self] in self?.dismissAnimated() if let updatedValue = updatedValue { completion(updatedValue) @@ -36,7 +36,7 @@ final class ChatDateSelectionSheet: ActionSheetController { }) ]), ActionSheetItemGroup(items: [ - ActionSheetButtonItem(title: strings.Common_Cancel, action: { [weak self] in + ActionSheetButtonItem(title: self.strings.Common_Cancel, action: { [weak self] in self?.dismissAnimated() }), ]) diff --git a/submodules/TelegramUI/TelegramUI/ChatHistoryListNode.swift b/submodules/TelegramUI/TelegramUI/ChatHistoryListNode.swift index 26b472281d..06be57e178 100644 --- a/submodules/TelegramUI/TelegramUI/ChatHistoryListNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatHistoryListNode.swift @@ -1435,6 +1435,28 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode { } } + func lastVisbleMesssage() -> Message? { + var currentMessage: Message? + if let historyView = self.historyView { + if let visibleRange = self.displayedItemRange.visibleRange { + var index = 0 + loop: for entry in historyView.filteredEntries.reversed() { + if index >= visibleRange.firstIndex && index <= visibleRange.lastIndex { + if case let .MessageEntry(message, _, _, _, _, _) = entry { + currentMessage = message + break loop + } else if case let .MessageGroupEntry(_, messages, _) = entry { + currentMessage = messages.first?.0 + break loop + } + } + index += 1 + } + } + } + return currentMessage + } + func immediateScrollState() -> ChatInterfaceHistoryScrollState? { var currentMessage: Message? if let historyView = self.historyView { diff --git a/submodules/TelegramUI/TelegramUI/ChatInterfaceInputNodes.swift b/submodules/TelegramUI/TelegramUI/ChatInterfaceInputNodes.swift index 5aefaec90a..27389e1cba 100644 --- a/submodules/TelegramUI/TelegramUI/ChatInterfaceInputNodes.swift +++ b/submodules/TelegramUI/TelegramUI/ChatInterfaceInputNodes.swift @@ -21,7 +21,7 @@ func inputNodeForChatPresentationIntefaceState(_ chatPresentationInterfaceState: if case let .peer(id) = chatPresentationInterfaceState.chatLocation { peerId = id } - let inputNode = ChatMediaInputNode(context: context, peerId: peerId, controllerInteraction: controllerInteraction, theme: chatPresentationInterfaceState.theme, strings: chatPresentationInterfaceState.strings, gifPaneIsActiveUpdated: { [weak interfaceInteraction] value in + let inputNode = ChatMediaInputNode(context: context, peerId: peerId, controllerInteraction: controllerInteraction, theme: chatPresentationInterfaceState.theme, strings: chatPresentationInterfaceState.strings, fontSize: chatPresentationInterfaceState.fontSize, gifPaneIsActiveUpdated: { [weak interfaceInteraction] value in if let interfaceInteraction = interfaceInteraction { interfaceInteraction.updateInputModeAndDismissedButtonKeyboardMessageId { state in if case let .media(_, expanded) = state.inputMode { diff --git a/submodules/TelegramUI/TelegramUI/ChatMediaInputNode.swift b/submodules/TelegramUI/TelegramUI/ChatMediaInputNode.swift index cf68f5bb3a..ea1b72b82d 100644 --- a/submodules/TelegramUI/TelegramUI/ChatMediaInputNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatMediaInputNode.swift @@ -7,6 +7,7 @@ import TelegramCore import SyncCore import SwiftSignalKit import TelegramPresentationData +import TelegramUIPreferences import MergeLists import AccountContext import StickerPackPreviewUI @@ -434,6 +435,7 @@ final class ChatMediaInputNode: ChatInputNode { private var theme: PresentationTheme private var strings: PresentationStrings + private var fontSize: PresentationFontSize private let themeAndStringsPromise: Promise<(PresentationTheme, PresentationStrings)> private let _ready = Promise() @@ -442,12 +444,13 @@ final class ChatMediaInputNode: ChatInputNode { return self._ready.get() } - init(context: AccountContext, peerId: PeerId?, controllerInteraction: ChatControllerInteraction, theme: PresentationTheme, strings: PresentationStrings, gifPaneIsActiveUpdated: @escaping (Bool) -> Void) { + init(context: AccountContext, peerId: PeerId?, controllerInteraction: ChatControllerInteraction, theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize, gifPaneIsActiveUpdated: @escaping (Bool) -> Void) { self.context = context self.peerId = peerId self.controllerInteraction = controllerInteraction self.theme = theme self.strings = strings + self.fontSize = fontSize self.gifPaneIsActiveUpdated = gifPaneIsActiveUpdated self.themeAndStringsPromise = Promise((theme, strings)) @@ -589,7 +592,7 @@ final class ChatMediaInputNode: ChatInputNode { self?.dismissPeerSpecificPackSetup() }, clearRecentlyUsedStickers: { [weak self] in if let strongSelf = self { - let actionSheet = ActionSheetController(presentationTheme: strongSelf.theme) + let actionSheet = ActionSheetController(theme: ActionSheetControllerTheme(presentationTheme: strongSelf.theme, fontSize: strongSelf.fontSize)) var items: [ActionSheetItem] = [] items.append(ActionSheetButtonItem(title: strongSelf.strings.Stickers_ClearRecent, color: .destructive, action: { [weak actionSheet] in actionSheet?.dismissAnimated() @@ -839,7 +842,7 @@ final class ChatMediaInputNode: ChatInputNode { let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 } - let contextController = ContextController(account: strongSelf.context.account, theme: presentationData.theme, strings: presentationData.strings, source: .controller(ContextControllerContentSourceImpl(controller: gallery, sourceNode: sourceNode, sourceRect: sourceRect)), items: .single(items), reactionItems: [], gesture: gesture) + let contextController = ContextController(account: strongSelf.context.account, presentationData: presentationData, source: .controller(ContextControllerContentSourceImpl(controller: gallery, sourceNode: sourceNode, sourceRect: sourceRect)), items: .single(items), reactionItems: [], gesture: gesture) strongSelf.controllerInteraction.presentGlobalOverlayController(contextController, nil) } } diff --git a/submodules/TelegramUI/TelegramUI/ChatMessageBackground.swift b/submodules/TelegramUI/TelegramUI/ChatMessageBackground.swift index fbbec1aeae..bf45a9ac5b 100644 --- a/submodules/TelegramUI/TelegramUI/ChatMessageBackground.swift +++ b/submodules/TelegramUI/TelegramUI/ChatMessageBackground.swift @@ -145,11 +145,11 @@ class ChatMessageBackground: ASDisplayNode { if let previousType = previousType, previousType != .none, type == .none { if transition.isAnimated { let tempLayer = CALayer() - tempLayer.contents = self.layer.contents - tempLayer.contentsScale = self.layer.contentsScale - tempLayer.rasterizationScale = self.layer.rasterizationScale - tempLayer.contentsGravity = self.layer.contentsGravity - tempLayer.contentsCenter = self.layer.contentsCenter + tempLayer.contents = self.imageNode.layer.contents + tempLayer.contentsScale = self.imageNode.layer.contentsScale + tempLayer.rasterizationScale = self.imageNode.layer.rasterizationScale + tempLayer.contentsGravity = self.imageNode.layer.contentsGravity + tempLayer.contentsCenter = self.imageNode.layer.contentsCenter tempLayer.frame = self.bounds self.layer.addSublayer(tempLayer) @@ -157,6 +157,10 @@ class ChatMessageBackground: ASDisplayNode { tempLayer?.removeFromSuperlayer() }) } + } else if transition.isAnimated { + if let previousContents = self.imageNode.layer.contents, let image = image { + self.imageNode.layer.animate(from: previousContents as AnyObject, to: image.cgImage! as AnyObject, keyPath: "contents", timingFunction: CAMediaTimingFunctionName.easeInEaseOut.rawValue, duration: 0.42) + } } self.imageNode.image = image diff --git a/submodules/TelegramUI/TelegramUI/ChatMessageBubbleBackdrop.swift b/submodules/TelegramUI/TelegramUI/ChatMessageBubbleBackdrop.swift index 4597efff8c..b6c2890b57 100644 --- a/submodules/TelegramUI/TelegramUI/ChatMessageBubbleBackdrop.swift +++ b/submodules/TelegramUI/TelegramUI/ChatMessageBubbleBackdrop.swift @@ -4,7 +4,7 @@ import Display import Postbox import TelegramPresentationData -private let maskInset: CGFloat = UIScreenPixel +private let maskInset: CGFloat = 0.0 final class ChatMessageBubbleBackdrop: ASDisplayNode { private let backgroundContent: ASDisplayNode diff --git a/submodules/TelegramUI/TelegramUI/ChatMessageBubbleItemNode.swift b/submodules/TelegramUI/TelegramUI/ChatMessageBubbleItemNode.swift index ee779d5229..3e9ce21790 100644 --- a/submodules/TelegramUI/TelegramUI/ChatMessageBubbleItemNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatMessageBubbleItemNode.swift @@ -2716,19 +2716,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePrevewItemNode if let backgroundType = self.backgroundType { let graphics = PresentationResourcesChat.principalGraphics(mediaBox: item.context.account.postbox.mediaBox, knockoutWallpaper: item.context.sharedContext.immediateExperimentalUISettings.knockoutWallpaper, theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper) - if highlighted { - self.backgroundNode.setType(type: backgroundType, highlighted: true, graphics: graphics, maskMode: self.contextSourceNode.isExtractedToContextPreview, transition: .immediate) - } else { - if let previousContents = self.backgroundNode.layer.contents, animated { - self.backgroundNode.setType(type: backgroundType, highlighted: false, graphics: graphics, maskMode: self.contextSourceNode.isExtractedToContextPreview, transition: .immediate) - - if let updatedContents = self.backgroundNode.layer.contents { - self.backgroundNode.layer.animate(from: previousContents as AnyObject, to: updatedContents as AnyObject, keyPath: "contents", timingFunction: CAMediaTimingFunctionName.easeInEaseOut.rawValue, duration: 0.42) - } - } else { - self.backgroundNode.setType(type: backgroundType, highlighted: false, graphics: graphics, maskMode: self.contextSourceNode.isExtractedToContextPreview, transition: .immediate) - } - } + self.backgroundNode.setType(type: backgroundType, highlighted: highlighted, graphics: graphics, maskMode: self.contextSourceNode.isExtractedToContextPreview, transition: animated ? .animated(duration: 0.3, curve: .easeInOut) : .immediate) } } } diff --git a/submodules/TelegramUI/TelegramUI/ChatMessageDateAndStatusNode.swift b/submodules/TelegramUI/TelegramUI/ChatMessageDateAndStatusNode.swift index a41d7dbf94..43bdfbba29 100644 --- a/submodules/TelegramUI/TelegramUI/ChatMessageDateAndStatusNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatMessageDateAndStatusNode.swift @@ -397,7 +397,7 @@ class ChatMessageDateAndStatusNode: ASDisplayNode { strongSelf.impressionIcon = currentImpressionIcon strongSelf.addSubnode(currentImpressionIcon) } - currentImpressionIcon.frame = CGRect(origin: CGPoint(x: leftInset + backgroundInsets.left, y: backgroundInsets.top + 3.0 + offset), size: impressionSize) + currentImpressionIcon.frame = CGRect(origin: CGPoint(x: leftInset + backgroundInsets.left, y: backgroundInsets.top + 1.0 + offset + floor((date.size.height - impressionSize.height) / 2.0)), size: impressionSize) } else if let impressionIcon = strongSelf.impressionIcon { impressionIcon.removeFromSupernode() strongSelf.impressionIcon = nil diff --git a/submodules/TelegramUI/TelegramUI/ChatMessageDateHeader.swift b/submodules/TelegramUI/TelegramUI/ChatMessageDateHeader.swift index 55a5b9ff7f..f612189569 100644 --- a/submodules/TelegramUI/TelegramUI/ChatMessageDateHeader.swift +++ b/submodules/TelegramUI/TelegramUI/ChatMessageDateHeader.swift @@ -59,8 +59,6 @@ final class ChatMessageDateHeader: ListViewItemHeader { } } -private let titleFont = Font.medium(13.0) - private func monthAtIndex(_ index: Int, strings: PresentationStrings) -> String { switch index { case 0: @@ -172,6 +170,8 @@ final class ChatMessageDateHeaderNode: ListViewItemHeaderNode { self.addSubnode(self.backgroundNode) self.addSubnode(self.labelNode) + let titleFont = Font.medium(min(18.0, floor(presentationData.fontSize.baseDisplaySize * 13.0 / 17.0))) + let attributedString = NSAttributedString(string: text, font: titleFont, textColor: bubbleVariableColor(variableColor: presentationData.theme.theme.chat.serviceMessage.dateTextColor, wallpaper: presentationData.theme.wallpaper)) let labelLayout = TextNode.asyncLayout(self.labelNode) @@ -192,6 +192,8 @@ final class ChatMessageDateHeaderNode: ListViewItemHeaderNode { self.backgroundNode.image = graphics.dateStaticBackground self.stickBackgroundNode.image = graphics.dateFloatingBackground + let titleFont = Font.medium(min(18.0, floor(presentationData.fontSize.baseDisplaySize * 13.0 / 17.0))) + let attributedString = NSAttributedString(string: self.text, font: titleFont, textColor: bubbleVariableColor(variableColor: presentationData.theme.theme.chat.serviceMessage.dateTextColor, wallpaper: presentationData.theme.wallpaper)) let labelLayout = TextNode.asyncLayout(self.labelNode) diff --git a/submodules/TelegramUI/TelegramUI/ChatMessageInteractiveMediaNode.swift b/submodules/TelegramUI/TelegramUI/ChatMessageInteractiveMediaNode.swift index 9066975417..19717b8816 100644 --- a/submodules/TelegramUI/TelegramUI/ChatMessageInteractiveMediaNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatMessageInteractiveMediaNode.swift @@ -523,8 +523,12 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio if file.isVideo && !isSecretMedia && automaticPlayback && !uploading { updateVideoFile = file if hasCurrentVideoNode { - if let currentFile = currentMedia as? TelegramMediaFile, currentFile.resource is EmptyMediaResource { - replaceVideoNode = true + if let currentFile = currentMedia as? TelegramMediaFile { + if currentFile.resource is EmptyMediaResource { + replaceVideoNode = true + } else if currentFile.fileId.namespace == Namespaces.Media.CloudFile && file.fileId.namespace == Namespaces.Media.CloudFile && currentFile.fileId != file.fileId { + replaceVideoNode = true + } } } else if !(file.resource is LocalFileVideoMediaResource) { replaceVideoNode = true diff --git a/submodules/TelegramUI/TelegramUI/ChatMessageReplyInfoNode.swift b/submodules/TelegramUI/TelegramUI/ChatMessageReplyInfoNode.swift index d7c1303b7f..593c6cc003 100644 --- a/submodules/TelegramUI/TelegramUI/ChatMessageReplyInfoNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatMessageReplyInfoNode.swift @@ -111,10 +111,26 @@ class ChatMessageReplyInfoNode: ASDisplayNode { } } + var imageTextInset: CGFloat = 0.0 + if let _ = imageDimensions { + imageTextInset += floor(presentationData.fontSize.baseDisplaySize * 32.0 / 17.0) + } + + let maximumTextWidth = max(0.0, constrainedSize.width - imageTextInset) + + let contrainedTextSize = CGSize(width: maximumTextWidth, height: constrainedSize.height) + + let textInsets = UIEdgeInsets(top: 3.0, left: 0.0, bottom: 3.0, right: 0.0) + + let (titleLayout, titleApply) = titleNodeLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: titleString, font: titleFont, textColor: titleColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: contrainedTextSize, alignment: .natural, cutout: nil, insets: textInsets)) + let (textLayout, textApply) = textNodeLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: textString, font: textFont, textColor: textColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: contrainedTextSize, alignment: .natural, cutout: nil, insets: textInsets)) + + let imageSide = titleLayout.size.height + textLayout.size.height - 16.0 + var applyImage: (() -> TransformImageNode)? if let imageDimensions = imageDimensions { - leftInset += 32.0 - let boundingSize = CGSize(width: 30.0, height: 30.0) + let boundingSize = CGSize(width: imageSide, height: imageSide) + leftInset += imageSide + 2.0 var radius: CGFloat = 2.0 var imageSize = imageDimensions.aspectFilled(boundingSize) if hasRoundImage { @@ -145,15 +161,6 @@ class ChatMessageReplyInfoNode: ASDisplayNode { } } - let maximumTextWidth = max(0.0, constrainedSize.width - leftInset) - - let contrainedTextSize = CGSize(width: maximumTextWidth, height: constrainedSize.height) - - let textInsets = UIEdgeInsets(top: 3.0, left: 0.0, bottom: 3.0, right: 0.0) - - let (titleLayout, titleApply) = titleNodeLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: titleString, font: titleFont, textColor: titleColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: contrainedTextSize, alignment: .natural, cutout: nil, insets: textInsets)) - let (textLayout, textApply) = textNodeLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: textString, font: textFont, textColor: textColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: contrainedTextSize, alignment: .natural, cutout: nil, insets: textInsets)) - let size = CGSize(width: max(titleLayout.size.width - textInsets.left - textInsets.right, textLayout.size.width - textInsets.left - textInsets.right) + leftInset, height: titleLayout.size.height + textLayout.size.height - 2 * (textInsets.top + textInsets.bottom) + 2 * spacing) return (size, { @@ -191,7 +198,7 @@ class ChatMessageReplyInfoNode: ASDisplayNode { node.addSubnode(imageNode) node.imageNode = imageNode } - imageNode.frame = CGRect(origin: CGPoint(x: 8.0, y: 4.0 + UIScreenPixel), size: CGSize(width: 30.0, height: 30.0)) + imageNode.frame = CGRect(origin: CGPoint(x: 8.0, y: 4.0 + UIScreenPixel), size: CGSize(width: imageSide, height: imageSide)) if let updateImageSignal = updateImageSignal { imageNode.setSignal(updateImageSignal) diff --git a/submodules/TelegramUI/TelegramUI/ChatRecentActionsControllerNode.swift b/submodules/TelegramUI/TelegramUI/ChatRecentActionsControllerNode.swift index 48e6906735..ad7e3cf4ff 100644 --- a/submodules/TelegramUI/TelegramUI/ChatRecentActionsControllerNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatRecentActionsControllerNode.swift @@ -262,7 +262,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode { } else if canOpenIn { openText = strongSelf.presentationData.strings.Conversation_FileOpenIn } - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) var items: [ActionSheetItem] = [] items.append(ActionSheetTextItem(title: cleanUrl)) @@ -291,7 +291,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode { ])]) strongSelf.presentController(actionSheet, nil) case let .peerMention(peerId, mention): - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) var items: [ActionSheetItem] = [] if !mention.isEmpty { items.append(ActionSheetTextItem(title: mention)) @@ -315,7 +315,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode { ])]) strongSelf.presentController(actionSheet, nil) case let .mention(mention): - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetTextItem(title: mention), ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_LinkDialogOpen, color: .accent, action: { [weak actionSheet] in @@ -335,7 +335,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode { ])]) strongSelf.presentController(actionSheet, nil) case let .command(command): - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetTextItem(title: command), ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_LinkDialogCopy, color: .accent, action: { [weak actionSheet] in @@ -349,7 +349,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode { ])]) strongSelf.presentController(actionSheet, nil) case let .hashtag(hashtag): - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetTextItem(title: hashtag), ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_LinkDialogOpen, color: .accent, action: { [weak actionSheet] in @@ -373,7 +373,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode { guard let message = message else { return } - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetTextItem(title: text), ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_LinkDialogOpen, color: .accent, action: { [weak actionSheet] in diff --git a/submodules/TelegramUI/TelegramUI/ChatSearchNavigationContentNode.swift b/submodules/TelegramUI/TelegramUI/ChatSearchNavigationContentNode.swift index 1d1523fc78..9a504c8862 100644 --- a/submodules/TelegramUI/TelegramUI/ChatSearchNavigationContentNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatSearchNavigationContentNode.swift @@ -8,6 +8,7 @@ import SyncCore import TelegramPresentationData import SearchBarNode import LocalizedPeerData +import SwiftSignalKit private let searchBarFont = Font.regular(17.0) @@ -19,6 +20,8 @@ final class ChatSearchNavigationContentNode: NavigationBarContentNode { private let searchBar: SearchBarNode private let interaction: ChatPanelInterfaceInteraction + private var searchingActivityDisposable: Disposable? + init(theme: PresentationTheme, strings: PresentationStrings, chatLocation: ChatLocation, interaction: ChatPanelInterfaceInteraction) { self.theme = theme self.strings = strings @@ -51,6 +54,17 @@ final class ChatSearchNavigationContentNode: NavigationBarContentNode { self.searchBar.clearPrefix = { [weak self] in self?.interaction.toggleMembersSearch(false) } + + if let statuses = interaction.statuses { + self.searchingActivityDisposable = (statuses.searching + |> deliverOnMainQueue).start(next: { [weak self] value in + self?.searchBar.activity = value + }) + } + } + + deinit { + self.searchingActivityDisposable?.dispose() } override var nominalHeight: CGFloat { diff --git a/submodules/TelegramUI/TelegramUI/ChatSecretAutoremoveTimerActionSheet.swift b/submodules/TelegramUI/TelegramUI/ChatSecretAutoremoveTimerActionSheet.swift index c51fa40377..367006984c 100644 --- a/submodules/TelegramUI/TelegramUI/ChatSecretAutoremoveTimerActionSheet.swift +++ b/submodules/TelegramUI/TelegramUI/ChatSecretAutoremoveTimerActionSheet.swift @@ -23,11 +23,11 @@ final class ChatSecretAutoremoveTimerActionSheetController: ActionSheetControlle let theme = presentationData.theme let strings = presentationData.strings - super.init(theme: ActionSheetControllerTheme(presentationTheme: theme)) + super.init(theme: ActionSheetControllerTheme(presentationData: presentationData)) self.presentationDisposable = context.sharedContext.presentationData.start(next: { [weak self] presentationData in if let strongSelf = self { - strongSelf.theme = ActionSheetControllerTheme(presentationTheme: presentationData.theme) + strongSelf.theme = ActionSheetControllerTheme(presentationData: presentationData) } }) diff --git a/submodules/TelegramUI/TelegramUI/ChatSlowmodeHintController.swift b/submodules/TelegramUI/TelegramUI/ChatSlowmodeHintController.swift index fad91ee725..5e3b12567d 100644 --- a/submodules/TelegramUI/TelegramUI/ChatSlowmodeHintController.swift +++ b/submodules/TelegramUI/TelegramUI/ChatSlowmodeHintController.swift @@ -21,10 +21,10 @@ final class ChatSlowmodeHintController: TooltipController { private var timer: SwiftSignalKit.Timer? - init(strings: PresentationStrings, slowmodeState: ChatSlowmodeState) { - self.strings = strings + init(presentationData: PresentationData, slowmodeState: ChatSlowmodeState) { + self.strings = presentationData.strings self.slowmodeState = slowmodeState - super.init(content: .text(timeoutValue(strings: strings, slowmodeState: slowmodeState)), timeout: 2.0, dismissByTapOutside: false, dismissByTapOutsideSource: true) + super.init(content: .text(timeoutValue(strings: presentationData.strings, slowmodeState: slowmodeState)), baseFontSize: presentationData.fontSize.baseDisplaySize, timeout: 2.0, dismissByTapOutside: false, dismissByTapOutsideSource: true) } required init(coder aDecoder: NSCoder) { diff --git a/submodules/TelegramUI/TelegramUI/ChatTextInputPanelNode.swift b/submodules/TelegramUI/TelegramUI/ChatTextInputPanelNode.swift index 2b44953eab..6a36ceb492 100644 --- a/submodules/TelegramUI/TelegramUI/ChatTextInputPanelNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatTextInputPanelNode.swift @@ -267,6 +267,14 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { } } + var enablePredictiveInput: Bool = true { + didSet { + if let textInputNode = self.textInputNode { + textInputNode.textView.autocorrectionType = self.enablePredictiveInput ? .default : .no + } + } + } + override var context: AccountContext? { didSet { self.actionButtons.micButton.account = self.context?.account diff --git a/submodules/TelegramUI/TelegramUI/PeerMediaCollectionController.swift b/submodules/TelegramUI/TelegramUI/PeerMediaCollectionController.swift index 054cd7b321..32b916f6e1 100644 --- a/submodules/TelegramUI/TelegramUI/PeerMediaCollectionController.swift +++ b/submodules/TelegramUI/TelegramUI/PeerMediaCollectionController.swift @@ -149,7 +149,7 @@ public class PeerMediaCollectionController: TelegramBaseController { if let strongSelf = self, strongSelf.isNodeLoaded { if let message = strongSelf.mediaCollectionDisplayNode.messageForGallery(message.id)?.message { - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) var items: [ActionSheetButtonItem] = [] items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.SharedMedia_ViewInChat, color: .accent, action: { [weak actionSheet] in @@ -282,7 +282,7 @@ public class PeerMediaCollectionController: TelegramBaseController { switch previewData { case let .gallery(gallery): gallery.setHintWillBePresentedInPreviewingContext(true) - let contextController = ContextController(account: strongSelf.context.account, theme: strongSelf.presentationData.theme, strings: strongSelf.presentationData.strings, source: .controller(ContextControllerContentSourceImpl(controller: gallery, sourceNode: node)), items: items, reactionItems: [], gesture: gesture) + let contextController = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: gallery, sourceNode: node)), items: items, reactionItems: [], gesture: gesture) strongSelf.presentInGlobalOverlay(contextController) case .instantPage: break @@ -363,7 +363,7 @@ public class PeerMediaCollectionController: TelegramBaseController { case let .url(url): let canOpenIn = availableOpenInOptions(context: strongSelf.context, item: .url(url: url)).count > 1 let openText = canOpenIn ? strongSelf.presentationData.strings.Conversation_FileOpenIn : strongSelf.presentationData.strings.Conversation_LinkDialogOpen - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetTextItem(title: url), ActionSheetButtonItem(title: openText, color: .accent, action: { [weak actionSheet] in @@ -870,7 +870,7 @@ public class PeerMediaCollectionController: TelegramBaseController { if !messageIds.isEmpty { self.messageContextDisposable.set((combineLatest(self.context.sharedContext.chatAvailableMessageActions(postbox: self.context.account.postbox, accountPeerId: self.context.account.peerId, messageIds: messageIds), self.peer.get() |> take(1)) |> deliverOnMainQueue).start(next: { [weak self] actions, peer in if let strongSelf = self, let peer = peer, !actions.options.isEmpty { - let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme) + let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) var items: [ActionSheetItem] = [] var personalPeerName: String? var isChannel = false diff --git a/submodules/TelegramUI/TelegramUI/TextLinkHandling.swift b/submodules/TelegramUI/TelegramUI/TextLinkHandling.swift index fae6469493..e440f40f72 100644 --- a/submodules/TelegramUI/TelegramUI/TextLinkHandling.swift +++ b/submodules/TelegramUI/TelegramUI/TextLinkHandling.swift @@ -105,7 +105,7 @@ func handleTextLinkActionImpl(context: AccountContext, peerId: PeerId?, navigate case let .url(url): let canOpenIn = availableOpenInOptions(context: context, item: .url(url: url)).count > 1 let openText = canOpenIn ? presentationData.strings.Conversation_FileOpenIn : presentationData.strings.Conversation_LinkDialogOpen - let actionSheet = ActionSheetController(presentationTheme: presentationData.theme) + let actionSheet = ActionSheetController(presentationData: presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetTextItem(title: url), ActionSheetButtonItem(title: openText, color: .accent, action: { [weak actionSheet] in @@ -129,7 +129,7 @@ func handleTextLinkActionImpl(context: AccountContext, peerId: PeerId?, navigate ])]) controller.present(actionSheet, in: .window(.root)) case let .mention(mention): - let actionSheet = ActionSheetController(presentationTheme: presentationData.theme) + let actionSheet = ActionSheetController(presentationData: presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetTextItem(title: mention), ActionSheetButtonItem(title: presentationData.strings.Conversation_LinkDialogOpen, color: .accent, action: { [weak actionSheet] in @@ -147,7 +147,7 @@ func handleTextLinkActionImpl(context: AccountContext, peerId: PeerId?, navigate ])]) controller.present(actionSheet, in: .window(.root)) case let .hashtag(_, hashtag): - let actionSheet = ActionSheetController(presentationTheme: presentationData.theme) + let actionSheet = ActionSheetController(presentationData: presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetTextItem(title: hashtag), ActionSheetButtonItem(title: presentationData.strings.Conversation_LinkDialogOpen, color: .accent, action: { [weak actionSheet] in diff --git a/submodules/TelegramUI/TelegramUI/WalletContextImpl.swift b/submodules/TelegramUI/TelegramUI/WalletContextImpl.swift index b57bb672ca..d3ecede9b6 100644 --- a/submodules/TelegramUI/TelegramUI/WalletContextImpl.swift +++ b/submodules/TelegramUI/TelegramUI/WalletContextImpl.swift @@ -200,7 +200,7 @@ final class WalletContextImpl: WalletContext { navigationBar: navigationBarData.theme, keyboardAppearance: theme.rootController.keyboardColor.keyboardAppearance, alert: AlertControllerTheme(presentationData: presentationData), - actionSheet: ActionSheetControllerTheme(presentationTheme: theme) + actionSheet: ActionSheetControllerTheme(presentationData: presentationData) ), strings: WalletStrings( primaryComponent: WalletStringsComponent( languageCode: strings.primaryComponent.languageCode, diff --git a/submodules/TextFormat/Sources/ChatTextInputAttributes.swift b/submodules/TextFormat/Sources/ChatTextInputAttributes.swift index 82cc311a45..33aa43790d 100644 --- a/submodules/TextFormat/Sources/ChatTextInputAttributes.swift +++ b/submodules/TextFormat/Sources/ChatTextInputAttributes.swift @@ -560,14 +560,14 @@ public func trimChatInputText(_ text: NSAttributedString) -> NSAttributedString } public func breakChatInputText(_ text: NSAttributedString) -> [NSAttributedString] { - if text.length <= 4000 { + if text.length <= 4096 { return [text] } else { let rawText: NSString = text.string as NSString var result: [NSAttributedString] = [] var offset = 0 while offset < text.length { - var range = NSRange(location: offset, length: min(text.length - offset, 4000)) + var range = NSRange(location: offset, length: min(text.length - offset, 4096)) if range.upperBound < text.length { inner: for i in (range.lowerBound ..< range.upperBound).reversed() { let c = rawText.character(at: i) diff --git a/submodules/WalletUI/Sources/WalletTransactionInfoScreen.swift b/submodules/WalletUI/Sources/WalletTransactionInfoScreen.swift index 12b9061deb..d09e8f2097 100644 --- a/submodules/WalletUI/Sources/WalletTransactionInfoScreen.swift +++ b/submodules/WalletUI/Sources/WalletTransactionInfoScreen.swift @@ -239,7 +239,7 @@ final class WalletTransactionInfoScreen: ViewController { } else { text = NSAttributedString(string: strongSelf.context.presentationData.strings.Wallet_TransactionInfo_StorageFeeInfo, font: Font.regular(14.0), textColor: .white, paragraphAlignment: .center) } - let controller = TooltipController(content: .attributedText(text), timeout: 3.0, dismissByTapOutside: true, dismissByTapOutsideSource: false, dismissImmediatelyOnLayoutUpdate: false, arrowOnBottom: false) + let controller = TooltipController(content: .attributedText(text), baseFontSize: 17.0, timeout: 3.0, dismissByTapOutside: true, dismissByTapOutsideSource: false, dismissImmediatelyOnLayoutUpdate: false, arrowOnBottom: false) controller.dismissed = { [weak self] tappedInside in if let strongSelf = self, tappedInside { if let feeInfoUrl = strongSelf.context.feeInfoUrl {