diff --git a/submodules/AlertUI/Sources/ThemedTextAlertController.swift b/submodules/AlertUI/Sources/ThemedTextAlertController.swift index 26f21b0fbd..48f595f572 100644 --- a/submodules/AlertUI/Sources/ThemedTextAlertController.swift +++ b/submodules/AlertUI/Sources/ThemedTextAlertController.swift @@ -17,14 +17,16 @@ public func textAlertController(context: AccountContext, title: String?, text: S return controller } -public func richTextAlertController(context: AccountContext, title: NSAttributedString?, text: NSAttributedString, actions: [TextAlertAction], actionLayout: TextAlertContentActionLayout = .horizontal) -> AlertController { +public func richTextAlertController(context: AccountContext, title: NSAttributedString?, text: NSAttributedString, actions: [TextAlertAction], actionLayout: TextAlertContentActionLayout = .horizontal, dismissAutomatically: Bool = true) -> AlertController { let presentationData = context.sharedContext.currentPresentationData.with { $0 } let theme = AlertControllerTheme(presentationTheme: presentationData.theme) var dismissImpl: (() -> Void)? let controller = AlertController(theme: theme, contentNode: TextAlertContentNode(theme: theme, title: title, text: text, actions: actions.map { action in return TextAlertAction(type: action.type, title: action.title, action: { - dismissImpl?() + if dismissAutomatically { + dismissImpl?() + } action.action() }) }, actionLayout: actionLayout)) diff --git a/submodules/Display/Display/TabBarNode.swift b/submodules/Display/Display/TabBarNode.swift index 65fe8636f9..03e54f3807 100644 --- a/submodules/Display/Display/TabBarNode.swift +++ b/submodules/Display/Display/TabBarNode.swift @@ -341,14 +341,14 @@ class TabBarNode: ASDisplayNode { let previousTextImageSize = node.textImageNode.image?.size ?? CGSize() if let selectedIndex = self.selectedIndex, selectedIndex == index { let (textImage, contentWidth) = tabBarItemImage(item.selectedImage, title: item.title ?? "", backgroundColor: .clear, tintColor: self.theme.tabBarSelectedTextColor, horizontal: self.horizontal, imageMode: false) - let (image, imageContentWidth) = tabBarItemImage(item.selectedImage, title: item.title ?? "", backgroundColor: .clear, tintColor: self.theme.tabBarSelectedTextColor, horizontal: self.horizontal, imageMode: true) + let (image, imageContentWidth) = tabBarItemImage(item.selectedImage, title: item.title ?? "", backgroundColor: .clear, tintColor: self.theme.tabBarSelectedIconColor, horizontal: self.horizontal, imageMode: true) node.textImageNode.image = textImage node.accessibilityLabel = item.title node.imageNode.image = image node.contentWidth = max(contentWidth, imageContentWidth) } else { let (textImage, contentWidth) = tabBarItemImage(item.image, title: item.title ?? "", backgroundColor: .clear, tintColor: self.theme.tabBarTextColor, horizontal: self.horizontal, imageMode: false) - let (image, imageContentWidth) = tabBarItemImage(item.image, title: item.title ?? "", backgroundColor: .clear, tintColor: self.theme.tabBarTextColor, horizontal: self.horizontal, imageMode: true) + let (image, imageContentWidth) = tabBarItemImage(item.image, title: item.title ?? "", backgroundColor: .clear, tintColor: self.theme.tabBarIconColor, horizontal: self.horizontal, imageMode: true) node.textImageNode.image = textImage node.accessibilityLabel = item.title node.imageNode.image = image diff --git a/submodules/Display/Display/TextAlertController.swift b/submodules/Display/Display/TextAlertController.swift index 6e9628db98..aa26d61180 100644 --- a/submodules/Display/Display/TextAlertController.swift +++ b/submodules/Display/Display/TextAlertController.swift @@ -356,7 +356,7 @@ public func textAlertController(theme: AlertControllerTheme, title: NSAttributed public func standardTextAlertController(theme: AlertControllerTheme, title: String?, text: String, actions: [TextAlertAction], actionLayout: TextAlertContentActionLayout = .horizontal) -> AlertController { var dismissImpl: (() -> Void)? - let controller = AlertController(theme: theme, contentNode: TextAlertContentNode(theme: theme, title: title != nil ? NSAttributedString(string: title!, font: Font.medium(17.0), textColor: theme.primaryColor, paragraphAlignment: .center) : nil, text: NSAttributedString(string: text, font: title == nil ? Font.semibold(17.0) : Font.regular(13.0), textColor: theme.primaryColor, paragraphAlignment: .center), actions: actions.map { action in + let controller = AlertController(theme: theme, contentNode: TextAlertContentNode(theme: theme, title: title != nil ? NSAttributedString(string: title!, font: Font.semibold(17.0), textColor: theme.primaryColor, paragraphAlignment: .center) : nil, text: NSAttributedString(string: text, font: title == nil ? Font.semibold(17.0) : Font.regular(13.0), textColor: theme.primaryColor, paragraphAlignment: .center), actions: actions.map { action in return TextAlertAction(type: action.type, title: action.title, action: { dismissImpl?() action.action() diff --git a/submodules/SettingsUI/Sources/SettingsController.swift b/submodules/SettingsUI/Sources/SettingsController.swift index 9660acbea4..fa38b0f10b 100644 --- a/submodules/SettingsUI/Sources/SettingsController.swift +++ b/submodules/SettingsUI/Sources/SettingsController.swift @@ -1278,34 +1278,56 @@ public func settingsController(context: AccountContext, accountManager: AccountM } |> distinctUntilChanged - let accountTabBarAvatar: Signal = accountsAndPeers.get() - |> map { primary, other -> (Account, Peer)? in - if let primary = primary, !other.isEmpty { - return (primary.0, primary.1) + let accountTabBarAvatar: Signal<(UIImage, UIImage)?, NoError> = combineLatest(accountsAndPeers.get(), updatedPresentationData) + |> map { primaryAndOther, presentationData -> (Account, Peer, PresentationTheme)? in + if let primary = primaryAndOther.0, !primaryAndOther.1.isEmpty { + return (primary.0, primary.1, presentationData.theme) } else { return nil } } |> distinctUntilChanged(isEqual: { $0?.0 === $1?.0 && arePeersEqual($0?.1, $1?.1) }) - |> mapToSignal { primary -> Signal in + |> mapToSignal { primary -> Signal<(UIImage, UIImage)?, NoError> in if let primary = primary { - if let signal = peerAvatarImage(account: primary.0, peer: primary.1, authorOfMessage: nil, representation: primary.1.profileImageRepresentations.first, displayDimensions: CGSize(width: 31.0, height: 31.0), inset: 3.0, emptyColor: nil, synchronousLoad: false) { + let size = CGSize(width: 31.0, height: 31.0) + let inset: CGFloat = 3.0 + if let signal = peerAvatarImage(account: primary.0, peer: primary.1, authorOfMessage: nil, representation: primary.1.profileImageRepresentations.first, displayDimensions: size, inset: 3.0, emptyColor: nil, synchronousLoad: false) { return signal - |> map { image -> UIImage? in - return image.flatMap { image -> UIImage in - return image.withRenderingMode(.alwaysOriginal) + |> map { image -> (UIImage, UIImage)? in + if let image = image, let selectedImage = generateImage(size, rotatedContext: { size, context in + context.clear(CGRect(origin: CGPoint(), size: size)) + context.translateBy(x: size.width / 2.0, y: size.height / 2.0) + context.scaleBy(x: 1.0, y: -1.0) + context.translateBy(x: -size.width / 2.0, y: -size.height / 2.0) + context.draw(image.cgImage!, in: CGRect(x: 0.0, y: 0.0, width: size.width, height: size.height)) + context.setLineWidth(1.0) + context.setStrokeColor(primary.2.rootController.tabBar.selectedIconColor.cgColor) + context.strokeEllipse(in: CGRect(x: 1.5, y: 1.5, width: 28.0, height: 28.0)) + }) { + return (image.withRenderingMode(.alwaysOriginal), selectedImage.withRenderingMode(.alwaysOriginal)) + } else { + return nil } } } else { return Signal { subscriber in - let size = CGSize(width: 31.0, height: 31.0) - let inset: CGFloat = 3.0 let image = generateImage(size, rotatedContext: { size, context in context.clear(CGRect(origin: CGPoint(), size: size)) context.translateBy(x: inset, y: inset) drawPeerAvatarLetters(context: context, size: CGSize(width: size.width - inset * 2.0, height: size.height - inset * 2.0), font: avatarFont, letters: primary.1.displayLetters, accountPeerId: primary.1.id, peerId: primary.1.id) })?.withRenderingMode(.alwaysOriginal) - subscriber.putNext(image) + + let selectedImage = generateImage(size, rotatedContext: { size, context in + context.clear(CGRect(origin: CGPoint(), size: size)) + context.translateBy(x: inset, y: inset) + drawPeerAvatarLetters(context: context, size: CGSize(width: size.width - inset * 2.0, height: size.height - inset * 2.0), font: avatarFont, letters: primary.1.displayLetters, accountPeerId: primary.1.id, peerId: primary.1.id) + context.translateBy(x: -inset, y: -inset) + context.setLineWidth(1.0) + context.setStrokeColor(primary.2.rootController.tabBar.selectedIconColor.cgColor) + context.strokeEllipse(in: CGRect(x: 1.0, y: 1.0, width: 27.0, height: 27.0)) + })?.withRenderingMode(.alwaysOriginal) + + subscriber.putNext(image.flatMap { ($0, $0) }) subscriber.putCompletion() return EmptyDisposable } @@ -1316,7 +1338,13 @@ public func settingsController(context: AccountContext, accountManager: AccountM } } |> distinctUntilChanged(isEqual: { lhs, rhs in - if lhs !== rhs { + if let lhs = lhs, let rhs = rhs { + if lhs.0 !== rhs.0 || lhs.1 !== rhs.1 { + return false + } else { + return true + } + } else if (lhs == nil) != (rhs == nil) { return false } return true @@ -1329,7 +1357,7 @@ public func settingsController(context: AccountContext, accountManager: AccountM if accountTabBarAvatarBadge > 0 { otherAccountsBadge = compactNumericCountString(Int(accountTabBarAvatarBadge), decimalSeparator: presentationData.dateTimeFormat.decimalSeparator) } - return ItemListControllerTabBarItem(title: presentationData.strings.Settings_Title, image: accountTabBarAvatar ?? icon, selectedImage: accountTabBarAvatar ?? icon, tintImages: accountTabBarAvatar == nil, badgeValue: notificationsWarning ? "!" : otherAccountsBadge) + return ItemListControllerTabBarItem(title: presentationData.strings.Settings_Title, image: accountTabBarAvatar?.0 ?? icon, selectedImage: accountTabBarAvatar?.1 ?? icon, tintImages: accountTabBarAvatar == nil, badgeValue: notificationsWarning ? "!" : otherAccountsBadge) } let controller = SettingsControllerImpl(currentContext: context, contextValue: contextValue, state: signal, tabBarItem: tabBarItem, accountsAndPeers: accountsAndPeers.get()) diff --git a/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift b/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift index 85f7bab782..4bcb96d378 100644 --- a/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift @@ -101,6 +101,9 @@ private func makeDarkPresentationTheme(accentColor: UIColor, baseColor: Presenta let intro = PresentationThemeIntro( statusBarStyle: .white, + primaryTextColor: .white, + accentTextColor: accentColor, + disabledTextColor: UIColor(rgb: 0x525252), startButtonColor: accentColor, dotColor: UIColor(rgb: 0x5e5e5e) ) diff --git a/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift b/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift index 78322cd22b..2617916b1a 100644 --- a/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift @@ -53,7 +53,7 @@ private func makeDarkPresentationTheme(accentColor: UIColor, baseColor: Presenta let rootNavigationBar = PresentationThemeRootNavigationBar( buttonColor: accentColor, disabledButtonColor: accentColor.withMultiplied(hue: 1.033, saturation: 0.219, brightness: 0.44), - primaryTextColor: UIColor(rgb: 0xffffff), + primaryTextColor: .white, secondaryTextColor: mainSecondaryColor, controlColor: mainSecondaryColor, accentTextColor: accentColor, @@ -77,6 +77,9 @@ private func makeDarkPresentationTheme(accentColor: UIColor, baseColor: Presenta let intro = PresentationThemeIntro( statusBarStyle: .white, + primaryTextColor: .white, + accentTextColor: accentColor, + disabledTextColor: accentColor.withMultiplied(hue: 1.033, saturation: 0.219, brightness: 0.44), startButtonColor: accentColor, dotColor: mainSecondaryColor ) diff --git a/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift b/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift index 63433df863..cdd3aab7ed 100644 --- a/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift @@ -84,6 +84,9 @@ private func makeDefaultDayPresentationTheme(accentColor: UIColor, serviceBackgr let intro = PresentationThemeIntro( statusBarStyle: .black, + primaryTextColor: .black, + accentTextColor: accentColor, + disabledTextColor: UIColor(rgb: 0xd0d0d0), startButtonColor: UIColor(rgb: 0x2ca5e0), dotColor: UIColor(rgb: 0xd9d9d9) ) diff --git a/submodules/TelegramPresentationData/Sources/PresentationTheme.swift b/submodules/TelegramPresentationData/Sources/PresentationTheme.swift index 09fa702e4e..8e3dc3f8c7 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationTheme.swift @@ -20,11 +20,17 @@ public final class PresentationThemeGradientColors { public final class PresentationThemeIntro { public let statusBarStyle: PresentationThemeStatusBarStyle + public let primaryTextColor: UIColor + public let accentTextColor: UIColor + public let disabledTextColor: UIColor public let startButtonColor: UIColor public let dotColor: UIColor - public init(statusBarStyle: PresentationThemeStatusBarStyle, startButtonColor: UIColor, dotColor: UIColor) { + public init(statusBarStyle: PresentationThemeStatusBarStyle, primaryTextColor: UIColor, accentTextColor: UIColor, disabledTextColor: UIColor, startButtonColor: UIColor, dotColor: UIColor) { self.statusBarStyle = statusBarStyle + self.primaryTextColor = primaryTextColor + self.accentTextColor = accentTextColor + self.disabledTextColor = disabledTextColor self.startButtonColor = startButtonColor self.dotColor = dotColor } diff --git a/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift b/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift index 3fa70fb89a..9e0b451141 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift @@ -238,6 +238,9 @@ extension PresentationThemeGradientColors: Codable { extension PresentationThemeIntro: Codable { enum CodingKeys: String, CodingKey { case statusBar + case primaryText + case accentText + case disabledText case startButton case dot } @@ -245,6 +248,9 @@ extension PresentationThemeIntro: Codable { public convenience init(from decoder: Decoder) throws { let values = try decoder.container(keyedBy: CodingKeys.self) self.init(statusBarStyle: try values.decode(PresentationThemeStatusBarStyle.self, forKey: .statusBar), + primaryTextColor: try decodeColor(values, .primaryText), + accentTextColor: try decodeColor(values, .accentText), + disabledTextColor: try decodeColor(values, .disabledText), startButtonColor: try decodeColor(values, .startButton), dotColor: try decodeColor(values, .dot)) } @@ -252,6 +258,9 @@ extension PresentationThemeIntro: Codable { public func encode(to encoder: Encoder) throws { var values = encoder.container(keyedBy: CodingKeys.self) try values.encode(self.statusBarStyle, forKey: .statusBar) + try encodeColor(&values, self.primaryTextColor, .primaryText) + try encodeColor(&values, self.accentTextColor, .accentText) + try encodeColor(&values, self.disabledTextColor, .disabledText) try encodeColor(&values, self.startButtonColor, .startButton) try encodeColor(&values, self.dotColor, .dot) } diff --git a/submodules/TelegramUI/TelegramUI/AuthorizationSequenceController.swift b/submodules/TelegramUI/TelegramUI/AuthorizationSequenceController.swift index 58d9816535..359f0ec165 100644 --- a/submodules/TelegramUI/TelegramUI/AuthorizationSequenceController.swift +++ b/submodules/TelegramUI/TelegramUI/AuthorizationSequenceController.swift @@ -25,7 +25,7 @@ private enum InnerState: Equatable { public final class AuthorizationSequenceController: NavigationController, MFMailComposeViewControllerDelegate { static func navigationBarTheme(_ theme: PresentationTheme) -> NavigationBarTheme { - return NavigationBarTheme(buttonColor: theme.rootController.navigationBar.buttonColor, disabledButtonColor: theme.rootController.navigationBar.disabledButtonColor, primaryTextColor: theme.rootController.navigationBar.primaryTextColor, backgroundColor: .clear, separatorColor: .clear, badgeBackgroundColor: theme.rootController.navigationBar.badgeBackgroundColor, badgeStrokeColor: theme.rootController.navigationBar.badgeStrokeColor, badgeTextColor: theme.rootController.navigationBar.badgeTextColor) + return NavigationBarTheme(buttonColor: theme.intro.accentTextColor, disabledButtonColor: theme.intro.disabledTextColor, primaryTextColor: theme.intro.primaryTextColor, backgroundColor: .clear, separatorColor: .clear, badgeBackgroundColor: theme.rootController.navigationBar.badgeBackgroundColor, badgeStrokeColor: theme.rootController.navigationBar.badgeStrokeColor, badgeTextColor: theme.rootController.navigationBar.badgeTextColor) } private let sharedContext: SharedAccountContext diff --git a/submodules/TelegramUI/TelegramUI/ChatController.swift b/submodules/TelegramUI/TelegramUI/ChatController.swift index ab121d6da2..1ad7055bed 100644 --- a/submodules/TelegramUI/TelegramUI/ChatController.swift +++ b/submodules/TelegramUI/TelegramUI/ChatController.swift @@ -4718,12 +4718,6 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G completion(.immediate) } -// if let selectionState = self.presentationInterfaceState.interfaceState.selectionState, !selectionState.selectedIds.isEmpty { -// self.chatTitleView?.titleContent = .custom(self.presentationData.strings.Conversation_SelectedMessages(Int32(selectionState.selectedIds.count))) -// } else { -// -// } - if let button = leftNavigationButtonForChatInterfaceState(updatedChatPresentationInterfaceState, subject: self.subject, strings: updatedChatPresentationInterfaceState.strings, currentButton: self.leftNavigationButton, target: self, selector: #selector(self.leftNavigationButtonAction)) { if self.leftNavigationButton != button { var animated = transition.isAnimated