Use global theme in auth controllers

Multiaccount updates
This commit is contained in:
Peter 2019-02-12 20:44:06 +04:00
parent 9a35187cec
commit c453f00524
56 changed files with 483 additions and 523 deletions

View File

@ -400,7 +400,6 @@
D099D74D1EEFEE1500A3128C /* GameController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D099D74C1EEFEE1500A3128C /* GameController.swift */; }; D099D74D1EEFEE1500A3128C /* GameController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D099D74C1EEFEE1500A3128C /* GameController.swift */; };
D099D74F1EEFEE6A00A3128C /* GameControllerNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D099D74E1EEFEE6A00A3128C /* GameControllerNode.swift */; }; D099D74F1EEFEE6A00A3128C /* GameControllerNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D099D74E1EEFEE6A00A3128C /* GameControllerNode.swift */; };
D099D7511EEFF91E00A3128C /* GameControllerTitleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D099D7501EEFF91E00A3128C /* GameControllerTitleView.swift */; }; D099D7511EEFF91E00A3128C /* GameControllerTitleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D099D7501EEFF91E00A3128C /* GameControllerTitleView.swift */; };
D09D886F1F86C11F00BEB4C9 /* AuthorizationTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = D09D886E1F86C11F00BEB4C9 /* AuthorizationTheme.swift */; };
D09D88711F86D36700BEB4C9 /* CountryList.swift in Sources */ = {isa = PBXBuildFile; fileRef = D09D88701F86D36700BEB4C9 /* CountryList.swift */; }; D09D88711F86D36700BEB4C9 /* CountryList.swift in Sources */ = {isa = PBXBuildFile; fileRef = D09D88701F86D36700BEB4C9 /* CountryList.swift */; };
D09D88731F86D56B00BEB4C9 /* AuthorizationLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = D09D88721F86D56B00BEB4C9 /* AuthorizationLayout.swift */; }; D09D88731F86D56B00BEB4C9 /* AuthorizationLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = D09D88721F86D56B00BEB4C9 /* AuthorizationLayout.swift */; };
D09E637C1F0E7C28003444CD /* SharedMediaPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D09E637B1F0E7C28003444CD /* SharedMediaPlayer.swift */; }; D09E637C1F0E7C28003444CD /* SharedMediaPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D09E637B1F0E7C28003444CD /* SharedMediaPlayer.swift */; };
@ -1821,7 +1820,6 @@
D099EA2C1DE76782001AF5A8 /* PeerMessageManagedMediaId.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PeerMessageManagedMediaId.swift; sourceTree = "<group>"; }; D099EA2C1DE76782001AF5A8 /* PeerMessageManagedMediaId.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PeerMessageManagedMediaId.swift; sourceTree = "<group>"; };
D099EA2E1DE775BB001AF5A8 /* ChatContextResultManagedMediaId.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChatContextResultManagedMediaId.swift; sourceTree = "<group>"; }; D099EA2E1DE775BB001AF5A8 /* ChatContextResultManagedMediaId.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChatContextResultManagedMediaId.swift; sourceTree = "<group>"; };
D09AEFD31E5BAF67005C1A8B /* ItemListTextEmptyStateItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ItemListTextEmptyStateItem.swift; sourceTree = "<group>"; }; D09AEFD31E5BAF67005C1A8B /* ItemListTextEmptyStateItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ItemListTextEmptyStateItem.swift; sourceTree = "<group>"; };
D09D886E1F86C11F00BEB4C9 /* AuthorizationTheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthorizationTheme.swift; sourceTree = "<group>"; };
D09D88701F86D36700BEB4C9 /* CountryList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CountryList.swift; sourceTree = "<group>"; }; D09D88701F86D36700BEB4C9 /* CountryList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CountryList.swift; sourceTree = "<group>"; };
D09D88721F86D56B00BEB4C9 /* AuthorizationLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthorizationLayout.swift; sourceTree = "<group>"; }; D09D88721F86D56B00BEB4C9 /* AuthorizationLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthorizationLayout.swift; sourceTree = "<group>"; };
D09E637B1F0E7C28003444CD /* SharedMediaPlayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SharedMediaPlayer.swift; sourceTree = "<group>"; }; D09E637B1F0E7C28003444CD /* SharedMediaPlayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SharedMediaPlayer.swift; sourceTree = "<group>"; };
@ -4387,7 +4385,6 @@
D0F69DE71D6B8A590046BCD6 /* Authorization */ = { D0F69DE71D6B8A590046BCD6 /* Authorization */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
D09D886E1F86C11F00BEB4C9 /* AuthorizationTheme.swift */,
D09D88721F86D56B00BEB4C9 /* AuthorizationLayout.swift */, D09D88721F86D56B00BEB4C9 /* AuthorizationLayout.swift */,
D049EAF21E44DE2500A2CD3A /* AuthorizationSequenceController.swift */, D049EAF21E44DE2500A2CD3A /* AuthorizationSequenceController.swift */,
D04BB2B61E44E5BB00650E93 /* Splash */, D04BB2B61E44E5BB00650E93 /* Splash */,
@ -5515,7 +5512,6 @@
D099D7511EEFF91E00A3128C /* GameControllerTitleView.swift in Sources */, D099D7511EEFF91E00A3128C /* GameControllerTitleView.swift in Sources */,
D0EC6D711EB9F58800EBF1C3 /* AuthorizationSequencePasswordEntryController.swift in Sources */, D0EC6D711EB9F58800EBF1C3 /* AuthorizationSequencePasswordEntryController.swift in Sources */,
D0EC6D721EB9F58800EBF1C3 /* AuthorizationSequencePasswordEntryControllerNode.swift in Sources */, D0EC6D721EB9F58800EBF1C3 /* AuthorizationSequencePasswordEntryControllerNode.swift in Sources */,
D09D886F1F86C11F00BEB4C9 /* AuthorizationTheme.swift in Sources */,
D0EC6D731EB9F58800EBF1C3 /* AuthorizationSequenceSignUpController.swift in Sources */, D0EC6D731EB9F58800EBF1C3 /* AuthorizationSequenceSignUpController.swift in Sources */,
0979787C210642CB0077D77F /* WebEmbedPlayerNode.swift in Sources */, 0979787C210642CB0077D77F /* WebEmbedPlayerNode.swift in Sources */,
D0C12EB01F9A8D1300600BB2 /* ListMessageDateHeader.swift in Sources */, D0C12EB01F9A8D1300600BB2 /* ListMessageDateHeader.swift in Sources */,

View File

@ -116,10 +116,6 @@ public final class AccountContext {
deinit { deinit {
} }
public func attachOverlayMediaController(_ controller: OverlayMediaController) {
self.sharedContext.mediaManager.overlayMediaManager.attachOverlayMediaController(controller)
}
public func storeSecureIdPassword(password: String) { public func storeSecureIdPassword(password: String) {
self.storedPassword?.2.invalidate() self.storedPassword?.2.invalidate()
let timer = SwiftSignalKit.Timer(timeout: 1.0 * 60.0 * 60.0, repeat: false, completion: { [weak self] in let timer = SwiftSignalKit.Timer(timeout: 1.0 * 60.0 * 60.0, repeat: false, completion: { [weak self] in

View File

@ -9,13 +9,15 @@ public class ActionSheetPeerItem: ActionSheetItem {
public let peer: Peer public let peer: Peer
public let theme: PresentationTheme public let theme: PresentationTheme
public let title: String public let title: String
public let isSelected: Bool
public let strings: PresentationStrings public let strings: PresentationStrings
public let action: () -> Void public let action: () -> Void
public init(account: Account, peer: Peer, title: String, strings: PresentationStrings, theme: PresentationTheme, action: @escaping () -> Void) { public init(account: Account, peer: Peer, title: String, isSelected: Bool, strings: PresentationStrings, theme: PresentationTheme, action: @escaping () -> Void) {
self.account = account self.account = account
self.peer = peer self.peer = peer
self.title = title self.title = title
self.isSelected = isSelected
self.strings = strings self.strings = strings
self.theme = theme self.theme = theme
self.action = action self.action = action
@ -49,6 +51,7 @@ public class ActionSheetPeerItemNode: ActionSheetItemNode {
private let button: HighlightTrackingButton private let button: HighlightTrackingButton
private let avatarNode: AvatarNode private let avatarNode: AvatarNode
private let label: ImmediateTextNode private let label: ImmediateTextNode
private let checkNode: ASImageNode
override public init(theme: ActionSheetControllerTheme) { override public init(theme: ActionSheetControllerTheme) {
self.theme = theme self.theme = theme
@ -63,11 +66,17 @@ public class ActionSheetPeerItemNode: ActionSheetItemNode {
self.label.displaysAsynchronously = false self.label.displaysAsynchronously = false
self.label.maximumNumberOfLines = 1 self.label.maximumNumberOfLines = 1
self.checkNode = ASImageNode()
self.checkNode.displaysAsynchronously = false
self.checkNode.displayWithoutProcessing = true
self.checkNode.image = generateItemListCheckIcon(color: theme.primaryTextColor)
super.init(theme: theme) super.init(theme: theme)
self.view.addSubview(self.button) self.view.addSubview(self.button)
self.addSubnode(self.avatarNode) self.addSubnode(self.avatarNode)
self.addSubnode(self.label) self.addSubnode(self.label)
self.addSubnode(self.checkNode)
self.button.highligthedChanged = { [weak self] highlighted in self.button.highligthedChanged = { [weak self] highlighted in
if let strongSelf = self { if let strongSelf = self {
@ -92,6 +101,8 @@ public class ActionSheetPeerItemNode: ActionSheetItemNode {
self.avatarNode.setPeer(account: item.account, theme: item.theme, peer: item.peer) self.avatarNode.setPeer(account: item.account, theme: item.theme, peer: item.peer)
self.checkNode.isHidden = !item.isSelected
self.setNeedsLayout() self.setNeedsLayout()
} }
@ -113,6 +124,10 @@ public class ActionSheetPeerItemNode: ActionSheetItemNode {
let labelSize = self.label.updateLayout(CGSize(width: max(1.0, size.width - avatarInset - 16.0 - 16.0 - 30.0), height: size.height)) let labelSize = self.label.updateLayout(CGSize(width: max(1.0, size.width - avatarInset - 16.0 - 16.0 - 30.0), height: size.height))
self.label.frame = CGRect(origin: CGPoint(x: 16.0 + avatarInset, y: floorToScreenPixels((size.height - labelSize.height) / 2.0)), size: labelSize) self.label.frame = CGRect(origin: CGPoint(x: 16.0 + avatarInset, y: floorToScreenPixels((size.height - labelSize.height) / 2.0)), size: labelSize)
if let image = self.checkNode.image {
self.checkNode.frame = CGRect(origin: CGPoint(x: size.width - image.size.width - 16.0, y: floor((size.height - image.size.height) / 2.0)), size: image.size)
}
} }
@objc func buttonPressed() { @objc func buttonPressed() {

View File

@ -8,7 +8,7 @@ final class AuthorizationSequenceAwaitingAccountResetController: ViewController
} }
private let strings: PresentationStrings private let strings: PresentationStrings
private let theme: AuthorizationTheme private let theme: PresentationTheme
var logout: (() -> Void)? var logout: (() -> Void)?
var reset: (() -> Void)? var reset: (() -> Void)?
@ -19,7 +19,7 @@ final class AuthorizationSequenceAwaitingAccountResetController: ViewController
var inProgress: Bool = false { var inProgress: Bool = false {
didSet { didSet {
if self.inProgress { if self.inProgress {
let item = UIBarButtonItem(customDisplayNode: ProgressNavigationButtonNode(color: self.theme.accentColor)) let item = UIBarButtonItem(customDisplayNode: ProgressNavigationButtonNode(color: self.theme.rootController.navigationBar.accentTextColor))
self.navigationItem.rightBarButtonItem = item self.navigationItem.rightBarButtonItem = item
} else { } else {
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: self.strings.Common_Next, style: .done, target: self, action: #selector(self.logoutPressed)) self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: self.strings.Common_Next, style: .done, target: self, action: #selector(self.logoutPressed))
@ -27,7 +27,7 @@ final class AuthorizationSequenceAwaitingAccountResetController: ViewController
} }
} }
init(strings: PresentationStrings, theme: AuthorizationTheme, back: @escaping () -> Void) { init(strings: PresentationStrings, theme: PresentationTheme, back: @escaping () -> Void) {
self.strings = strings self.strings = strings
self.theme = theme self.theme = theme
@ -35,7 +35,7 @@ final class AuthorizationSequenceAwaitingAccountResetController: ViewController
self.supportedOrientations = ViewControllerSupportedOrientations(regularSize: .all, compactSize: .portrait) self.supportedOrientations = ViewControllerSupportedOrientations(regularSize: .all, compactSize: .portrait)
self.statusBar.statusBarStyle = theme.statusBarStyle self.statusBar.statusBarStyle = theme.rootController.statusBar.style.style
self.attemptNavigation = { _ in self.attemptNavigation = { _ in
return false return false

View File

@ -23,7 +23,7 @@ private func timerValueString(days: Int32, hours: Int32, minutes: Int32, color:
final class AuthorizationSequenceAwaitingAccountResetControllerNode: ASDisplayNode, UITextFieldDelegate { final class AuthorizationSequenceAwaitingAccountResetControllerNode: ASDisplayNode, UITextFieldDelegate {
private let strings: PresentationStrings private let strings: PresentationStrings
private let theme: AuthorizationTheme private let theme: PresentationTheme
private let titleNode: ASTextNode private let titleNode: ASTextNode
private let noticeNode: ASTextNode private let noticeNode: ASTextNode
@ -40,14 +40,14 @@ final class AuthorizationSequenceAwaitingAccountResetControllerNode: ASDisplayNo
private var timer: SwiftSignalKit.Timer? private var timer: SwiftSignalKit.Timer?
init(strings: PresentationStrings, theme: AuthorizationTheme) { init(strings: PresentationStrings, theme: PresentationTheme) {
self.strings = strings self.strings = strings
self.theme = theme self.theme = theme
self.titleNode = ASTextNode() self.titleNode = ASTextNode()
self.titleNode.isUserInteractionEnabled = false self.titleNode.isUserInteractionEnabled = false
self.titleNode.displaysAsynchronously = false self.titleNode.displaysAsynchronously = false
self.titleNode.attributedText = NSAttributedString(string: strings.Login_ResetAccountProtected_Title, font: Font.light(30.0), textColor: self.theme.primaryColor) self.titleNode.attributedText = NSAttributedString(string: strings.Login_ResetAccountProtected_Title, font: Font.light(30.0), textColor: self.theme.list.itemPrimaryTextColor)
self.noticeNode = ASTextNode() self.noticeNode = ASTextNode()
self.noticeNode.isUserInteractionEnabled = false self.noticeNode.isUserInteractionEnabled = false
@ -56,15 +56,15 @@ final class AuthorizationSequenceAwaitingAccountResetControllerNode: ASDisplayNo
self.timerTitleNode = ASTextNode() self.timerTitleNode = ASTextNode()
self.timerTitleNode.isLayerBacked = true self.timerTitleNode.isLayerBacked = true
self.timerTitleNode.displaysAsynchronously = false self.timerTitleNode.displaysAsynchronously = false
self.timerTitleNode.attributedText = NSAttributedString(string: strings.Login_ResetAccountProtected_TimerTitle, font: Font.regular(16.0), textColor: self.theme.primaryColor) self.timerTitleNode.attributedText = NSAttributedString(string: strings.Login_ResetAccountProtected_TimerTitle, font: Font.regular(16.0), textColor: self.theme.list.itemPrimaryTextColor)
self.timerValueNode = ASTextNode() self.timerValueNode = ASTextNode()
self.timerValueNode.isLayerBacked = true self.timerValueNode.isLayerBacked = true
self.timerValueNode.displaysAsynchronously = false self.timerValueNode.displaysAsynchronously = false
self.resetNode = HighlightableButtonNode() self.resetNode = HighlightableButtonNode()
self.resetNode.setAttributedTitle(NSAttributedString(string: strings.Login_ResetAccountProtected_Reset, font: Font.regular(21.0), textColor: self.theme.accentColor), for: []) self.resetNode.setAttributedTitle(NSAttributedString(string: strings.Login_ResetAccountProtected_Reset, font: Font.regular(21.0), textColor: self.theme.list.itemAccentColor), for: [])
self.resetNode.setAttributedTitle(NSAttributedString(string: strings.Login_ResetAccountProtected_Reset, font: Font.regular(21.0), textColor: self.theme.textPlaceholderColor), for: [.disabled]) self.resetNode.setAttributedTitle(NSAttributedString(string: strings.Login_ResetAccountProtected_Reset, font: Font.regular(21.0), textColor: self.theme.list.itemPlaceholderTextColor), for: [.disabled])
self.resetNode.displaysAsynchronously = false self.resetNode.displaysAsynchronously = false
self.resetNode.isEnabled = false self.resetNode.isEnabled = false
@ -74,7 +74,7 @@ final class AuthorizationSequenceAwaitingAccountResetControllerNode: ASDisplayNo
return UITracingLayerView() return UITracingLayerView()
}) })
self.backgroundColor = self.theme.backgroundColor self.backgroundColor = self.theme.list.plainBackgroundColor
self.addSubnode(self.titleNode) self.addSubnode(self.titleNode)
self.addSubnode(self.noticeNode) self.addSubnode(self.noticeNode)
@ -93,7 +93,7 @@ final class AuthorizationSequenceAwaitingAccountResetControllerNode: ASDisplayNo
self.protectedUntil = protectedUntil self.protectedUntil = protectedUntil
self.updateTimerValue() self.updateTimerValue()
self.noticeNode.attributedText = NSAttributedString(string: strings.Login_ResetAccountProtected_Text(number).0, font: Font.regular(16.0), textColor: self.theme.primaryColor, paragraphAlignment: .center) self.noticeNode.attributedText = NSAttributedString(string: strings.Login_ResetAccountProtected_Text(number).0, font: Font.regular(16.0), textColor: self.theme.list.itemPrimaryTextColor, paragraphAlignment: .center)
if let (layout, navigationHeight) = self.layoutArguments { if let (layout, navigationHeight) = self.layoutArguments {
self.containerLayoutUpdated(layout, navigationBarHeight: navigationHeight, transition: .immediate) self.containerLayoutUpdated(layout, navigationBarHeight: navigationHeight, transition: .immediate)
@ -127,7 +127,7 @@ final class AuthorizationSequenceAwaitingAccountResetControllerNode: ASDisplayNo
minutes = 1 minutes = 1
} }
self.timerValueNode.attributedText = timerValueString(days: days, hours: hours, minutes: minutes, color: self.theme.primaryColor, strings: self.strings) self.timerValueNode.attributedText = timerValueString(days: days, hours: hours, minutes: minutes, color: self.theme.list.itemPrimaryTextColor, strings: self.strings)
self.resetNode.isEnabled = timerSeconds <= 0 self.resetNode.isEnabled = timerSeconds <= 0
@ -143,9 +143,9 @@ final class AuthorizationSequenceAwaitingAccountResetControllerNode: ASDisplayNo
insets.top = navigationBarHeight insets.top = navigationBarHeight
if max(layout.size.width, layout.size.height) > 1023.0 { if max(layout.size.width, layout.size.height) > 1023.0 {
self.titleNode.attributedText = NSAttributedString(string: self.strings.Login_ResetAccountProtected_Title, font: Font.light(40.0), textColor: self.theme.primaryColor) self.titleNode.attributedText = NSAttributedString(string: self.strings.Login_ResetAccountProtected_Title, font: Font.light(40.0), textColor: self.theme.list.itemPrimaryTextColor)
} else { } else {
self.titleNode.attributedText = NSAttributedString(string: self.strings.Login_ResetAccountProtected_Title, font: Font.light(30.0), textColor: self.theme.primaryColor) self.titleNode.attributedText = NSAttributedString(string: self.strings.Login_ResetAccountProtected_Title, font: Font.light(30.0), textColor: self.theme.list.itemPrimaryTextColor)
} }
let titleSize = self.titleNode.measure(CGSize(width: layout.size.width, height: CGFloat.greatestFiniteMagnitude)) let titleSize = self.titleNode.measure(CGSize(width: layout.size.width, height: CGFloat.greatestFiniteMagnitude))

View File

@ -9,7 +9,7 @@ final class AuthorizationSequenceCodeEntryController: ViewController {
} }
private let strings: PresentationStrings private let strings: PresentationStrings
private let theme: AuthorizationTheme private let theme: PresentationTheme
private let openUrl: (String) -> Void private let openUrl: (String) -> Void
var loginWithCode: ((String) -> Void)? var loginWithCode: ((String) -> Void)?
@ -24,7 +24,7 @@ final class AuthorizationSequenceCodeEntryController: ViewController {
var inProgress: Bool = false { var inProgress: Bool = false {
didSet { didSet {
if self.inProgress { if self.inProgress {
let item = UIBarButtonItem(customDisplayNode: ProgressNavigationButtonNode(color: self.theme.accentColor)) let item = UIBarButtonItem(customDisplayNode: ProgressNavigationButtonNode(color: self.theme.rootController.navigationBar.accentTextColor))
self.navigationItem.rightBarButtonItem = item self.navigationItem.rightBarButtonItem = item
} else { } else {
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: self.strings.Common_Next, style: .done, target: self, action: #selector(self.nextPressed)) self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: self.strings.Common_Next, style: .done, target: self, action: #selector(self.nextPressed))
@ -33,7 +33,7 @@ final class AuthorizationSequenceCodeEntryController: ViewController {
} }
} }
init(strings: PresentationStrings, theme: AuthorizationTheme, openUrl: @escaping (String) -> Void, back: @escaping () -> Void) { init(strings: PresentationStrings, theme: PresentationTheme, openUrl: @escaping (String) -> Void, back: @escaping () -> Void) {
self.strings = strings self.strings = strings
self.theme = theme self.theme = theme
self.openUrl = openUrl self.openUrl = openUrl
@ -44,7 +44,7 @@ final class AuthorizationSequenceCodeEntryController: ViewController {
self.hasActiveInput = true self.hasActiveInput = true
self.statusBar.statusBarStyle = theme.statusBarStyle self.statusBar.statusBarStyle = theme.rootController.statusBar.style.style
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: self.strings.Common_Next, style: .done, target: self, action: #selector(self.nextPressed)) self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: self.strings.Common_Next, style: .done, target: self, action: #selector(self.nextPressed))
@ -52,7 +52,7 @@ final class AuthorizationSequenceCodeEntryController: ViewController {
return false return false
} }
self.navigationBar?.backPressed = { [weak self] in self.navigationBar?.backPressed = { [weak self] in
self?.present(standardTextAlertController(theme: AlertControllerTheme(authTheme: theme), title: nil, text: strings.Login_CancelPhoneVerification, actions: [TextAlertAction(type: .genericAction, title: strings.Login_CancelPhoneVerificationContinue, action: { self?.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: theme), title: nil, text: strings.Login_CancelPhoneVerification, actions: [TextAlertAction(type: .genericAction, title: strings.Login_CancelPhoneVerificationContinue, action: {
}), TextAlertAction(type: .defaultAction, title: strings.Login_CancelPhoneVerificationStop, action: { }), TextAlertAction(type: .defaultAction, title: strings.Login_CancelPhoneVerificationStop, action: {
back() back()
})]), in: .window(.root)) })]), in: .window(.root))

View File

@ -50,7 +50,7 @@ func authorizationNextOptionText(currentType: SentAuthorizationCodeType, nextTyp
final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextFieldDelegate { final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextFieldDelegate {
private let strings: PresentationStrings private let strings: PresentationStrings
private let theme: AuthorizationTheme private let theme: PresentationTheme
private let titleNode: ImmediateTextNode private let titleNode: ImmediateTextNode
private let titleIconNode: ASImageNode private let titleIconNode: ASImageNode
@ -92,7 +92,7 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
} }
} }
init(strings: PresentationStrings, theme: AuthorizationTheme) { init(strings: PresentationStrings, theme: PresentationTheme) {
self.strings = strings self.strings = strings
self.theme = theme self.theme = theme
@ -109,8 +109,8 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
self.titleIconNode.image = generateImage(CGSize(width: 81.0, height: 52.0), rotatedContext: { size, context in self.titleIconNode.image = generateImage(CGSize(width: 81.0, height: 52.0), rotatedContext: { size, context in
context.clear(CGRect(origin: CGPoint(), size: size)) context.clear(CGRect(origin: CGPoint(), size: size))
context.setFillColor(theme.primaryColor.cgColor) context.setFillColor(theme.list.itemPrimaryTextColor.cgColor)
context.setStrokeColor(theme.primaryColor.cgColor) context.setStrokeColor(theme.list.itemPrimaryTextColor.cgColor)
context.setLineWidth(2.97) context.setLineWidth(2.97)
let _ = try? drawSvgPath(context, path: "M9.87179487,9.04664384 C9.05602951,9.04664384 8.39525641,9.70682916 8.39525641,10.5205479 L8.39525641,44.0547945 C8.39525641,44.8685133 9.05602951,45.5286986 9.87179487,45.5286986 L65.1538462,45.5286986 C65.9696115,45.5286986 66.6303846,44.8685133 66.6303846,44.0547945 L66.6303846,10.5205479 C66.6303846,9.70682916 65.9696115,9.04664384 65.1538462,9.04664384 L9.87179487,9.04664384 S ") let _ = try? drawSvgPath(context, path: "M9.87179487,9.04664384 C9.05602951,9.04664384 8.39525641,9.70682916 8.39525641,10.5205479 L8.39525641,44.0547945 C8.39525641,44.8685133 9.05602951,45.5286986 9.87179487,45.5286986 L65.1538462,45.5286986 C65.9696115,45.5286986 66.6303846,44.8685133 66.6303846,44.0547945 L66.6303846,10.5205479 C66.6303846,9.70682916 65.9696115,9.04664384 65.1538462,9.04664384 L9.87179487,9.04664384 S ")
@ -118,14 +118,14 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
let _ = try? drawSvgPath(context, path: "M2.96153846,16.4383562 L14.1495726,16.4383562 C15.7851852,16.4383562 17.1111111,17.7631027 17.1111111,19.3972603 L17.1111111,45.0410959 C17.1111111,46.6752535 15.7851852,48 14.1495726,48 L2.96153846,48 C1.32592593,48 0,46.6752535 0,45.0410959 L0,19.3972603 C0,17.7631027 1.32592593,16.4383562 2.96153846,16.4383562 Z ") let _ = try? drawSvgPath(context, path: "M2.96153846,16.4383562 L14.1495726,16.4383562 C15.7851852,16.4383562 17.1111111,17.7631027 17.1111111,19.3972603 L17.1111111,45.0410959 C17.1111111,46.6752535 15.7851852,48 14.1495726,48 L2.96153846,48 C1.32592593,48 0,46.6752535 0,45.0410959 L0,19.3972603 C0,17.7631027 1.32592593,16.4383562 2.96153846,16.4383562 Z ")
context.setStrokeColor(theme.backgroundColor.cgColor) context.setStrokeColor(theme.list.plainBackgroundColor.cgColor)
context.setLineWidth(1.65) context.setLineWidth(1.65)
let _ = try? drawSvgPath(context, path: "M2.96153846,15.6133562 L14.1495726,15.6133562 C16.2406558,15.6133562 17.9361111,17.3073033 17.9361111,19.3972603 L17.9361111,45.0410959 C17.9361111,47.1310529 16.2406558,48.825 14.1495726,48.825 L2.96153846,48.825 C0.870455286,48.825 -0.825,47.1310529 -0.825,45.0410959 L-0.825,19.3972603 C-0.825,17.3073033 0.870455286,15.6133562 2.96153846,15.6133562 S ") let _ = try? drawSvgPath(context, path: "M2.96153846,15.6133562 L14.1495726,15.6133562 C16.2406558,15.6133562 17.9361111,17.3073033 17.9361111,19.3972603 L17.9361111,45.0410959 C17.9361111,47.1310529 16.2406558,48.825 14.1495726,48.825 L2.96153846,48.825 C0.870455286,48.825 -0.825,47.1310529 -0.825,45.0410959 L-0.825,19.3972603 C-0.825,17.3073033 0.870455286,15.6133562 2.96153846,15.6133562 S ")
context.setFillColor(theme.backgroundColor.cgColor) context.setFillColor(theme.list.plainBackgroundColor.cgColor)
let _ = try? drawSvgPath(context, path: "M1.64529915,20.3835616 L15.465812,20.3835616 L15.465812,44.0547945 L1.64529915,44.0547945 Z ") let _ = try? drawSvgPath(context, path: "M1.64529915,20.3835616 L15.465812,20.3835616 L15.465812,44.0547945 L1.64529915,44.0547945 Z ")
context.setFillColor(theme.accentColor.cgColor) context.setFillColor(theme.list.itemAccentColor.cgColor)
let _ = try? drawSvgPath(context, path: "M66.4700855,0.0285884455 C60.7084674,0.0285884455 55.9687848,4.08259697 55.9687848,9.14830256 C55.9687848,12.0875991 57.5993165,14.6795278 60.0605723,16.3382966 C60.0568181,16.4358994 60.0611217,16.5884309 59.9318097,17.067302 C59.7721478,17.6586615 59.4575977,18.4958519 58.8015608,19.4258487 L58.3294314,20.083383 L59.1449275,20.0976772 C61.9723538,20.1099725 63.6110772,18.2528913 63.8662207,17.9535438 C64.7014993,18.1388449 65.5698144,18.2680167 66.4700855,18.2680167 C72.2312622,18.2680167 76.9713861,14.2140351 76.9713861,9.14830256 C76.9713861,4.08256999 72.2312622,0.0285884455 66.4700855,0.0285884455 Z ") let _ = try? drawSvgPath(context, path: "M66.4700855,0.0285884455 C60.7084674,0.0285884455 55.9687848,4.08259697 55.9687848,9.14830256 C55.9687848,12.0875991 57.5993165,14.6795278 60.0605723,16.3382966 C60.0568181,16.4358994 60.0611217,16.5884309 59.9318097,17.067302 C59.7721478,17.6586615 59.4575977,18.4958519 58.8015608,19.4258487 L58.3294314,20.083383 L59.1449275,20.0976772 C61.9723538,20.1099725 63.6110772,18.2528913 63.8662207,17.9535438 C64.7014993,18.1388449 65.5698144,18.2680167 66.4700855,18.2680167 C72.2312622,18.2680167 76.9713861,14.2140351 76.9713861,9.14830256 C76.9713861,4.08256999 72.2312622,0.0285884455 66.4700855,0.0285884455 Z ")
let _ = try? drawSvgPath(context, path: "M64.1551769,18.856071 C63.8258967,19.1859287 63.4214479,19.5187 62.9094963,19.840779 C61.8188563,20.5269227 60.5584776,20.9288319 59.1304689,20.9225505 L56.7413094,20.8806727 L57.6592902,19.6022014 L58.127415,18.9502938 C58.6361919,18.2290526 58.9525079,17.5293964 59.1353377,16.8522267 C59.1487516,16.8025521 59.1603548,16.7584153 59.1703974,16.7187893 C56.653362,14.849536 55.1437848,12.1128655 55.1437848,9.14830256 C55.1437848,3.61947515 60.2526259,-0.796411554 66.4700855,-0.796411554 C72.6872626,-0.796411554 77.7963861,3.61958236 77.7963861,9.14830256 C77.7963861,14.6770228 72.6872626,19.0930167 66.4700855,19.0930167 C65.7185957,19.0930167 64.9627196,19.0118067 64.1551769,18.856071 S ") let _ = try? drawSvgPath(context, path: "M64.1551769,18.856071 C63.8258967,19.1859287 63.4214479,19.5187 62.9094963,19.840779 C61.8188563,20.5269227 60.5584776,20.9288319 59.1304689,20.9225505 L56.7413094,20.8806727 L57.6592902,19.6022014 L58.127415,18.9502938 C58.6361919,18.2290526 58.9525079,17.5293964 59.1353377,16.8522267 C59.1487516,16.8025521 59.1603548,16.7584153 59.1703974,16.7187893 C56.653362,14.849536 55.1437848,12.1128655 55.1437848,9.14830256 C55.1437848,3.61947515 60.2526259,-0.796411554 66.4700855,-0.796411554 C72.6872626,-0.796411554 77.7963861,3.61958236 77.7963861,9.14830256 C77.7963861,14.6770228 72.6872626,19.0930167 66.4700855,19.0930167 C65.7185957,19.0930167 64.9627196,19.0118067 64.1551769,18.856071 S ")
@ -137,13 +137,13 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
self.nextOptionNode = HighlightableButtonNode() self.nextOptionNode = HighlightableButtonNode()
self.nextOptionNode.displaysAsynchronously = false self.nextOptionNode.displaysAsynchronously = false
let (nextOptionText, nextOptionActive) = authorizationNextOptionText(currentType: .sms(length: 5), nextType: .call, timeout: 60, strings: self.strings, primaryColor: self.theme.primaryColor, accentColor: self.theme.accentColor) let (nextOptionText, nextOptionActive) = authorizationNextOptionText(currentType: .sms(length: 5), nextType: .call, timeout: 60, strings: self.strings, primaryColor: self.theme.list.itemPrimaryTextColor, accentColor: self.theme.list.itemAccentColor)
self.nextOptionNode.setAttributedTitle(nextOptionText, for: []) self.nextOptionNode.setAttributedTitle(nextOptionText, for: [])
self.nextOptionNode.isUserInteractionEnabled = nextOptionActive self.nextOptionNode.isUserInteractionEnabled = nextOptionActive
self.codeSeparatorNode = ASDisplayNode() self.codeSeparatorNode = ASDisplayNode()
self.codeSeparatorNode.isLayerBacked = true self.codeSeparatorNode.isLayerBacked = true
self.codeSeparatorNode.backgroundColor = self.theme.separatorColor self.codeSeparatorNode.backgroundColor = self.theme.list.itemPlainSeparatorColor
self.codeField = TextFieldNode() self.codeField = TextFieldNode()
self.codeField.textField.font = Font.regular(24.0) self.codeField.textField.font = Font.regular(24.0)
@ -155,10 +155,10 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
} }
#endif #endif
self.codeField.textField.returnKeyType = .done self.codeField.textField.returnKeyType = .done
self.codeField.textField.textColor = self.theme.primaryColor self.codeField.textField.textColor = self.theme.list.itemPrimaryTextColor
self.codeField.textField.keyboardAppearance = self.theme.keyboard.keyboardAppearance self.codeField.textField.keyboardAppearance = self.theme.chatList.searchBarKeyboardColor.keyboardAppearance
self.codeField.textField.disableAutomaticKeyboardHandling = [.forward, .backward] self.codeField.textField.disableAutomaticKeyboardHandling = [.forward, .backward]
self.codeField.textField.tintColor = self.theme.accentColor self.codeField.textField.tintColor = self.theme.list.itemAccentColor
super.init() super.init()
@ -166,7 +166,7 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
return UITracingLayerView() return UITracingLayerView()
}) })
self.backgroundColor = self.theme.backgroundColor self.backgroundColor = self.theme.list.plainBackgroundColor
self.addSubnode(self.codeSeparatorNode) self.addSubnode(self.codeSeparatorNode)
self.addSubnode(self.codeField) self.addSubnode(self.codeField)
@ -178,7 +178,8 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
self.codeField.textField.delegate = self self.codeField.textField.delegate = self
self.codeField.textField.addTarget(self, action: #selector(self.codeFieldTextChanged(_:)), for: .editingChanged) self.codeField.textField.addTarget(self, action: #selector(self.codeFieldTextChanged(_:)), for: .editingChanged)
self.codeField.textField.attributedPlaceholder = NSAttributedString(string: strings.Login_Code, font: Font.regular(24.0), textColor: self.theme.textPlaceholderColor) self.codeField.textField.attributedPlaceholder = NSAttributedString(string: strings.Login_Code, font: Font.regular(24.0), textColor: self.theme.list.itemPlaceholderTextColor
)
self.nextOptionNode.addTarget(self, action: #selector(self.nextOptionNodePressed), forControlEvents: .touchUpInside) self.nextOptionNode.addTarget(self, action: #selector(self.nextOptionNodePressed), forControlEvents: .touchUpInside)
} }
@ -212,14 +213,14 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
self.codeType = codeType self.codeType = codeType
self.phoneNumber = number self.phoneNumber = number
self.currentOptionNode.attributedText = authorizationCurrentOptionText(codeType, strings: self.strings, primaryColor: self.theme.primaryColor, accentColor: self.theme.accentColor) self.currentOptionNode.attributedText = authorizationCurrentOptionText(codeType, strings: self.strings, primaryColor: self.theme.list.itemPrimaryTextColor, accentColor: self.theme.list.itemAccentColor)
if let timeout = timeout { if let timeout = timeout {
self.currentTimeoutTime = timeout self.currentTimeoutTime = timeout
let disposable = ((Signal<Int, NoError>.single(1) |> delay(1.0, queue: Queue.mainQueue())) |> restart).start(next: { [weak self] _ in let disposable = ((Signal<Int, NoError>.single(1) |> delay(1.0, queue: Queue.mainQueue())) |> restart).start(next: { [weak self] _ in
if let strongSelf = self { if let strongSelf = self {
if let currentTimeoutTime = strongSelf.currentTimeoutTime, currentTimeoutTime > 0 { if let currentTimeoutTime = strongSelf.currentTimeoutTime, currentTimeoutTime > 0 {
strongSelf.currentTimeoutTime = currentTimeoutTime - 1 strongSelf.currentTimeoutTime = currentTimeoutTime - 1
let (nextOptionText, nextOptionActive) = authorizationNextOptionText(currentType: codeType, nextType: nextType, timeout:strongSelf.currentTimeoutTime, strings: strongSelf.strings, primaryColor: strongSelf.theme.primaryColor, accentColor: strongSelf.theme.accentColor) let (nextOptionText, nextOptionActive) = authorizationNextOptionText(currentType: codeType, nextType: nextType, timeout:strongSelf.currentTimeoutTime, strings: strongSelf.strings, primaryColor: strongSelf.theme.list.itemPrimaryTextColor, accentColor: strongSelf.theme.list.itemAccentColor)
strongSelf.nextOptionNode.setAttributedTitle(nextOptionText, for: []) strongSelf.nextOptionNode.setAttributedTitle(nextOptionText, for: [])
strongSelf.nextOptionNode.isUserInteractionEnabled = nextOptionActive strongSelf.nextOptionNode.isUserInteractionEnabled = nextOptionActive
@ -237,7 +238,7 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
self.currentTimeoutTime = nil self.currentTimeoutTime = nil
self.countdownDisposable.set(nil) self.countdownDisposable.set(nil)
} }
let (nextOptionText, nextOptionActive) = authorizationNextOptionText(currentType: codeType, nextType: nextType, timeout: self.currentTimeoutTime, strings: self.strings, primaryColor: self.theme.primaryColor, accentColor: self.theme.accentColor) let (nextOptionText, nextOptionActive) = authorizationNextOptionText(currentType: codeType, nextType: nextType, timeout: self.currentTimeoutTime, strings: self.strings, primaryColor: self.theme.list.itemPrimaryTextColor, accentColor: self.theme.list.itemAccentColor)
self.nextOptionNode.setAttributedTitle(nextOptionText, for: []) self.nextOptionNode.setAttributedTitle(nextOptionText, for: [])
self.nextOptionNode.isUserInteractionEnabled = nextOptionActive self.nextOptionNode.isUserInteractionEnabled = nextOptionActive
} }
@ -258,9 +259,9 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
if max(layout.size.width, layout.size.height) > 1023.0 { if max(layout.size.width, layout.size.height) > 1023.0 {
if let codeType = self.codeType, case .otherSession = codeType { if let codeType = self.codeType, case .otherSession = codeType {
self.titleNode.attributedText = NSAttributedString(string: self.strings.Login_CheckOtherSessionMessages, font: Font.medium(32.0), textColor: self.theme.primaryColor) self.titleNode.attributedText = NSAttributedString(string: self.strings.Login_CheckOtherSessionMessages, font: Font.medium(32.0), textColor: self.theme.list.itemPrimaryTextColor)
} else { } else {
self.titleNode.attributedText = NSAttributedString(string: self.phoneNumber, font: Font.light(40.0), textColor: self.theme.primaryColor) self.titleNode.attributedText = NSAttributedString(string: self.phoneNumber, font: Font.light(40.0), textColor: self.theme.list.itemPrimaryTextColor)
} }
} else { } else {
if let codeType = self.codeType, case .otherSession = codeType { if let codeType = self.codeType, case .otherSession = codeType {
@ -270,9 +271,9 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
} else { } else {
fontSize = 18.0 fontSize = 18.0
} }
self.titleNode.attributedText = NSAttributedString(string: self.strings.Login_CheckOtherSessionMessages, font: Font.semibold(fontSize), textColor: self.theme.primaryColor) self.titleNode.attributedText = NSAttributedString(string: self.strings.Login_CheckOtherSessionMessages, font: Font.semibold(fontSize), textColor: self.theme.list.itemPrimaryTextColor)
} else { } else {
self.titleNode.attributedText = NSAttributedString(string: self.phoneNumber, font: Font.light(30.0), textColor: self.theme.primaryColor) self.titleNode.attributedText = NSAttributedString(string: self.phoneNumber, font: Font.light(30.0), textColor: self.theme.list.itemPrimaryTextColor)
} }
} }

View File

@ -14,8 +14,8 @@ private enum InnerState: Equatable {
} }
public final class AuthorizationSequenceController: NavigationController { public final class AuthorizationSequenceController: NavigationController {
static func navigationBarTheme(_ theme: AuthorizationTheme) -> NavigationBarTheme { static func navigationBarTheme(_ theme: PresentationTheme) -> NavigationBarTheme {
return NavigationBarTheme(buttonColor: theme.accentColor, disabledButtonColor: UIColor(rgb: 0xd0d0d0), primaryTextColor: .black, backgroundColor: .clear, separatorColor: .clear, badgeBackgroundColor: .clear, badgeStrokeColor: .clear, badgeTextColor: .clear) 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)
} }
private let sharedContext: SharedAccountContext private let sharedContext: SharedAccountContext
@ -24,7 +24,7 @@ public final class AuthorizationSequenceController: NavigationController {
private let apiId: Int32 private let apiId: Int32
private let apiHash: String private let apiHash: String
private var strings: PresentationStrings private var strings: PresentationStrings
public let theme: AuthorizationTheme public let theme: PresentationTheme
private let openUrl: (String) -> Void private let openUrl: (String) -> Void
private var stateDisposable: Disposable? private var stateDisposable: Disposable?
@ -32,15 +32,15 @@ public final class AuthorizationSequenceController: NavigationController {
private var didPlayPresentationAnimation = false private var didPlayPresentationAnimation = false
public init(sharedContext: SharedAccountContext, account: UnauthorizedAccount, otherAccountPhoneNumbers: ((String, AccountRecordId)?, [(String, AccountRecordId)]), strings: PresentationStrings, openUrl: @escaping (String) -> Void, apiId: Int32, apiHash: String) { public init(sharedContext: SharedAccountContext, account: UnauthorizedAccount, otherAccountPhoneNumbers: ((String, AccountRecordId)?, [(String, AccountRecordId)]), strings: PresentationStrings, theme: PresentationTheme, openUrl: @escaping (String) -> Void, apiId: Int32, apiHash: String) {
self.sharedContext = sharedContext self.sharedContext = sharedContext
self.account = account self.account = account
self.otherAccountPhoneNumbers = otherAccountPhoneNumbers self.otherAccountPhoneNumbers = otherAccountPhoneNumbers
self.apiId = apiId self.apiId = apiId
self.apiHash = apiHash self.apiHash = apiHash
self.strings = strings self.strings = strings
self.theme = theme
self.openUrl = openUrl self.openUrl = openUrl
self.theme = defaultLightAuthorizationTheme
super.init(mode: .single, theme: NavigationControllerTheme(navigationBar: AuthorizationSequenceController.navigationBarTheme(theme), emptyAreaColor: .black, emptyDetailIcon: nil)) super.init(mode: .single, theme: NavigationControllerTheme(navigationBar: AuthorizationSequenceController.navigationBarTheme(theme), emptyAreaColor: .black, emptyDetailIcon: nil))
@ -71,7 +71,7 @@ public final class AuthorizationSequenceController: NavigationController {
override public func loadView() { override public func loadView() {
super.loadView() super.loadView()
self.view.backgroundColor = self.theme.backgroundColor self.view.backgroundColor = self.theme.list.plainBackgroundColor
} }
private func splashController() -> AuthorizationSequenceSplashController { private func splashController() -> AuthorizationSequenceSplashController {
@ -215,7 +215,7 @@ public final class AuthorizationSequenceController: NavigationController {
controller.present(proxySettingsController(accountManager: strongSelf.sharedContext.accountManager, postbox: strongSelf.account.postbox, network: strongSelf.account.network, mode: .modal, theme: defaultPresentationTheme, strings: strongSelf.strings, updatedPresentationData: .single((defaultPresentationTheme, strongSelf.strings))), in: .window(.root), with: ViewControllerPresentationArguments(presentationAnimation: .modalSheet)) controller.present(proxySettingsController(accountManager: strongSelf.sharedContext.accountManager, postbox: strongSelf.account.postbox, network: strongSelf.account.network, mode: .modal, theme: defaultPresentationTheme, strings: strongSelf.strings, updatedPresentationData: .single((defaultPresentationTheme, strongSelf.strings))), in: .window(.root), with: ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
})) }))
} }
controller.present(standardTextAlertController(theme: AlertControllerTheme(authTheme: strongSelf.theme), title: nil, text: text, actions: actions), in: .window(.root)) controller.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: strongSelf.theme), title: nil, text: text, actions: actions), in: .window(.root))
} }
})) }))
} }
@ -270,7 +270,7 @@ public final class AuthorizationSequenceController: NavigationController {
return return
} }
var dismissImpl: (() -> Void)? var dismissImpl: (() -> Void)?
let alertTheme = AlertControllerTheme(authTheme: strongSelf.theme) let alertTheme = AlertControllerTheme(presentationTheme: strongSelf.theme)
let attributedText = stringWithAppliedEntities(termsOfService.text, entities: termsOfService.entities, baseColor: alertTheme.primaryColor, linkColor: alertTheme.accentColor, baseFont: Font.regular(13.0), linkFont: Font.regular(13.0), boldFont: Font.semibold(13.0), italicFont: Font.italic(13.0), fixedFont: Font.regular(13.0)) let attributedText = stringWithAppliedEntities(termsOfService.text, entities: termsOfService.entities, baseColor: alertTheme.primaryColor, linkColor: alertTheme.accentColor, baseFont: Font.regular(13.0), linkFont: Font.regular(13.0), boldFont: Font.semibold(13.0), italicFont: Font.italic(13.0), fixedFont: Font.regular(13.0))
let contentNode = TextAlertContentNode(theme: alertTheme, title: NSAttributedString(string: strongSelf.strings.Login_TermsOfServiceHeader, font: Font.medium(17.0), textColor: alertTheme.primaryColor, paragraphAlignment: .center), text: attributedText, actions: [ let contentNode = TextAlertContentNode(theme: alertTheme, title: NSAttributedString(string: strongSelf.strings.Login_TermsOfServiceHeader, font: Font.medium(17.0), textColor: alertTheme.primaryColor, paragraphAlignment: .center), text: attributedText, actions: [
TextAlertAction(type: .defaultAction, title: strongSelf.strings.Login_TermsOfServiceAgree, action: { TextAlertAction(type: .defaultAction, title: strongSelf.strings.Login_TermsOfServiceAgree, action: {
@ -340,7 +340,7 @@ public final class AuthorizationSequenceController: NavigationController {
}).start() }).start()
} }
controller.present(standardTextAlertController(theme: AlertControllerTheme(authTheme: strongSelf.theme), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.strings.Common_OK, action: {})]), in: .window(.root)) controller.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: strongSelf.theme), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.strings.Common_OK, action: {})]), in: .window(.root))
} }
} }
})) }))
@ -361,7 +361,7 @@ public final class AuthorizationSequenceController: NavigationController {
controller?.view.window?.rootViewController?.present(composeController, animated: true, completion: nil) controller?.view.window?.rootViewController?.present(composeController, animated: true, completion: nil)
} else { } else {
controller?.present(standardTextAlertController(theme: AlertControllerTheme(authTheme: strongSelf.theme), title: nil, text: strongSelf.strings.Login_EmailNotConfiguredError, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.strings.Common_OK, action: {})]), in: .window(.root)) controller?.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: strongSelf.theme), title: nil, text: strongSelf.strings.Login_EmailNotConfiguredError, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.strings.Common_OK, action: {})]), in: .window(.root))
} }
} else { } else {
controller?.inProgress = true controller?.inProgress = true
@ -388,7 +388,7 @@ public final class AuthorizationSequenceController: NavigationController {
text = strongSelf.strings.Login_NetworkError text = strongSelf.strings.Login_NetworkError
} }
controller.present(standardTextAlertController(theme: AlertControllerTheme(authTheme: strongSelf.theme), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.strings.Common_OK, action: {})]), in: .window(.root)) controller.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: strongSelf.theme), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.strings.Common_OK, action: {})]), in: .window(.root))
} }
})) }))
} }
@ -447,7 +447,7 @@ public final class AuthorizationSequenceController: NavigationController {
text = strongSelf.strings.Login_UnknownError text = strongSelf.strings.Login_UnknownError
} }
controller.present(standardTextAlertController(theme: AlertControllerTheme(authTheme: strongSelf.theme), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.strings.Common_OK, action: {})]), in: .window(.root)) controller.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: strongSelf.theme), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.strings.Common_OK, action: {})]), in: .window(.root))
controller.passwordIsInvalid() controller.passwordIsInvalid()
} }
} }
@ -470,7 +470,7 @@ public final class AuthorizationSequenceController: NavigationController {
} }
}).start() }).start()
case .none: case .none:
strongController.present(standardTextAlertController(theme: AlertControllerTheme(authTheme: strongSelf.theme), title: nil, text: strongSelf.strings.TwoStepAuth_RecoveryUnavailable, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.strings.Common_OK, action: {})]), in: .window(.root)) strongController.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: strongSelf.theme), title: nil, text: strongSelf.strings.TwoStepAuth_RecoveryUnavailable, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.strings.Common_OK, action: {})]), in: .window(.root))
strongController.didForgotWithNoRecovery = true strongController.didForgotWithNoRecovery = true
} }
} }
@ -483,7 +483,7 @@ public final class AuthorizationSequenceController: NavigationController {
} }
controller.reset = { [weak self, weak controller] in controller.reset = { [weak self, weak controller] in
if let strongSelf = self, let strongController = controller { if let strongSelf = self, let strongController = controller {
strongController.present(standardTextAlertController(theme: AlertControllerTheme(authTheme: strongSelf.theme), title: nil, text: suggestReset ? strongSelf.strings.TwoStepAuth_RecoveryFailed : strongSelf.strings.TwoStepAuth_RecoveryUnavailable, actions: [ strongController.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: strongSelf.theme), title: nil, text: suggestReset ? strongSelf.strings.TwoStepAuth_RecoveryFailed : strongSelf.strings.TwoStepAuth_RecoveryUnavailable, actions: [
TextAlertAction(type: .defaultAction, title: strongSelf.strings.Common_Cancel, action: {}), TextAlertAction(type: .defaultAction, title: strongSelf.strings.Common_Cancel, action: {}),
TextAlertAction(type: .destructiveAction, title: strongSelf.strings.Login_ResetAccountProtected_Reset, action: { TextAlertAction(type: .destructiveAction, title: strongSelf.strings.Login_ResetAccountProtected_Reset, action: {
if let strongSelf = self, let strongController = controller { if let strongSelf = self, let strongController = controller {
@ -503,7 +503,7 @@ public final class AuthorizationSequenceController: NavigationController {
case .limitExceeded: case .limitExceeded:
text = strongSelf.strings.Login_ResetAccountProtected_LimitExceeded text = strongSelf.strings.Login_ResetAccountProtected_LimitExceeded
} }
strongController.present(standardTextAlertController(theme: AlertControllerTheme(authTheme: strongSelf.theme), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.strings.Common_OK, action: {})]), in: .window(.root)) strongController.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: strongSelf.theme), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.strings.Common_OK, action: {})]), in: .window(.root))
} }
})) }))
} }
@ -555,7 +555,7 @@ public final class AuthorizationSequenceController: NavigationController {
text = strongSelf.strings.Login_CodeExpiredError text = strongSelf.strings.Login_CodeExpiredError
} }
controller.present(standardTextAlertController(theme: AlertControllerTheme(authTheme: strongSelf.theme), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.strings.Common_OK, action: {})]), in: .window(.root)) controller.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: strongSelf.theme), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.strings.Common_OK, action: {})]), in: .window(.root))
} }
} }
})) }))
@ -563,7 +563,7 @@ public final class AuthorizationSequenceController: NavigationController {
} }
controller.noAccess = { [weak self, weak controller] in controller.noAccess = { [weak self, weak controller] in
if let strongSelf = self, let controller = controller { if let strongSelf = self, let controller = controller {
controller.present(standardTextAlertController(theme: AlertControllerTheme(authTheme: strongSelf.theme), title: nil, text: strongSelf.strings.TwoStepAuth_RecoveryFailed, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.strings.Common_OK, action: {})]), in: .window(.root)) controller.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: strongSelf.theme), title: nil, text: strongSelf.strings.TwoStepAuth_RecoveryFailed, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.strings.Common_OK, action: {})]), in: .window(.root))
let account = strongSelf.account let account = strongSelf.account
let _ = (strongSelf.account.postbox.transaction { transaction -> Void in let _ = (strongSelf.account.postbox.transaction { transaction -> Void in
if let state = transaction.getState() as? UnauthorizedAccountState, case let .passwordRecovery(hint, number, code, _) = state.contents { if let state = transaction.getState() as? UnauthorizedAccountState, case let .passwordRecovery(hint, number, code, _) = state.contents {
@ -601,7 +601,7 @@ public final class AuthorizationSequenceController: NavigationController {
}) })
controller.reset = { [weak self, weak controller] in controller.reset = { [weak self, weak controller] in
if let strongSelf = self, let strongController = controller { if let strongSelf = self, let strongController = controller {
strongController.present(standardTextAlertController(theme: AlertControllerTheme(authTheme: strongSelf.theme), title: nil, text: strongSelf.strings.TwoStepAuth_ResetAccountConfirmation, actions: [ strongController.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: strongSelf.theme), title: nil, text: strongSelf.strings.TwoStepAuth_ResetAccountConfirmation, actions: [
TextAlertAction(type: .defaultAction, title: strongSelf.strings.Common_Cancel, action: {}), TextAlertAction(type: .defaultAction, title: strongSelf.strings.Common_Cancel, action: {}),
TextAlertAction(type: .destructiveAction, title: strongSelf.strings.Login_ResetAccountProtected_Reset, action: { TextAlertAction(type: .destructiveAction, title: strongSelf.strings.Login_ResetAccountProtected_Reset, action: {
if let strongSelf = self, let strongController = controller { if let strongSelf = self, let strongController = controller {
@ -621,7 +621,7 @@ public final class AuthorizationSequenceController: NavigationController {
case .limitExceeded: case .limitExceeded:
text = strongSelf.strings.Login_ResetAccountProtected_LimitExceeded text = strongSelf.strings.Login_ResetAccountProtected_LimitExceeded
} }
strongController.present(standardTextAlertController(theme: AlertControllerTheme(authTheme: strongSelf.theme), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.strings.Common_OK, action: {})]), in: .window(.root)) strongController.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: strongSelf.theme), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.strings.Common_OK, action: {})]), in: .window(.root))
} }
})) }))
} }
@ -687,7 +687,7 @@ public final class AuthorizationSequenceController: NavigationController {
text = strongSelf.strings.Login_UnknownError text = strongSelf.strings.Login_UnknownError
} }
controller.present(standardTextAlertController(theme: AlertControllerTheme(authTheme: strongSelf.theme), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.strings.Common_OK, action: {})]), in: .window(.root)) controller.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: strongSelf.theme), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.strings.Common_OK, action: {})]), in: .window(.root))
} }
} }
})) }))
@ -785,7 +785,7 @@ public final class AuthorizationSequenceController: NavigationController {
controller.view.window?.rootViewController?.present(composeController, animated: true, completion: nil) controller.view.window?.rootViewController?.present(composeController, animated: true, completion: nil)
} else { } else {
controller.present(standardTextAlertController(theme: AlertControllerTheme(authTheme: self.theme), title: nil, text: self.strings.Login_EmailNotConfiguredError, actions: [TextAlertAction(type: .defaultAction, title: self.strings.Common_OK, action: {})]), in: .window(.root)) controller.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: self.theme), title: nil, text: self.strings.Login_EmailNotConfiguredError, actions: [TextAlertAction(type: .defaultAction, title: self.strings.Common_OK, action: {})]), in: .window(.root))
} }
} }

View File

@ -51,36 +51,8 @@ private func loadCountryCodes() -> [(String, Int)] {
private let countryCodes: [(String, Int)] = loadCountryCodes() private let countryCodes: [(String, Int)] = loadCountryCodes()
final class AuthorizationSequenceCountrySelectionTheme {
let statusBar: PresentationThemeStatusBarStyle
let searchBar: SearchBarNodeTheme
let listBackground: UIColor
let listSeparator: UIColor
let listAccent: UIColor
let listPrimary: UIColor
let listItemHighlight: UIColor
init(statusBar: PresentationThemeStatusBarStyle, searchBar: SearchBarNodeTheme, listBackground: UIColor, listSeparator: UIColor, listAccent: UIColor, listPrimary: UIColor, listItemHighlight: UIColor) {
self.statusBar = statusBar
self.searchBar = searchBar
self.listBackground = listBackground
self.listSeparator = listSeparator
self.listAccent = listAccent
self.listPrimary = listPrimary
self.listItemHighlight = listItemHighlight
}
convenience init(presentationTheme: PresentationTheme) {
self.init(statusBar: presentationTheme.rootController.statusBar.style, searchBar: SearchBarNodeTheme(theme: presentationTheme), listBackground: presentationTheme.list.plainBackgroundColor, listSeparator: presentationTheme.list.itemPlainSeparatorColor, listAccent: presentationTheme.list.itemAccentColor, listPrimary: presentationTheme.list.itemPrimaryTextColor, listItemHighlight: presentationTheme.list.itemHighlightedBackgroundColor)
}
convenience init(authorizationTheme: AuthorizationTheme) {
self.init(statusBar: PresentationThemeStatusBarStyle(authorizationTheme.statusBarStyle), searchBar: SearchBarNodeTheme(background: authorizationTheme.navigationBarBackgroundColor, separator: authorizationTheme.navigationBarSeparatorColor, inputFill: authorizationTheme.searchBarFillColor, primaryText: authorizationTheme.searchBarTextColor, placeholder: authorizationTheme.searchBarPlaceholderColor, inputIcon: authorizationTheme.searchBarPlaceholderColor, inputClear: authorizationTheme.searchBarPlaceholderColor, accent: authorizationTheme.accentColor, keyboard: authorizationTheme.keyboard), listBackground: authorizationTheme.backgroundColor, listSeparator: authorizationTheme.separatorColor, listAccent: authorizationTheme.accentColor, listPrimary: authorizationTheme.primaryColor, listItemHighlight: authorizationTheme.itemHighlightedBackgroundColor)
}
}
private final class AuthorizationSequenceCountrySelectionNavigationContentNode: NavigationBarContentNode { private final class AuthorizationSequenceCountrySelectionNavigationContentNode: NavigationBarContentNode {
private let theme: AuthorizationSequenceCountrySelectionTheme private let theme: PresentationTheme
private let strings: PresentationStrings private let strings: PresentationStrings
private let cancel: () -> Void private let cancel: () -> Void
@ -89,17 +61,17 @@ private final class AuthorizationSequenceCountrySelectionNavigationContentNode:
private var queryUpdated: ((String) -> Void)? private var queryUpdated: ((String) -> Void)?
init(theme: AuthorizationSequenceCountrySelectionTheme, strings: PresentationStrings, cancel: @escaping () -> Void) { init(theme: PresentationTheme, strings: PresentationStrings, cancel: @escaping () -> Void) {
self.theme = theme self.theme = theme
self.strings = strings self.strings = strings
self.cancel = cancel self.cancel = cancel
self.searchBar = SearchBarNode(theme: theme.searchBar, strings: strings, fieldStyle: .modern) self.searchBar = SearchBarNode(theme: SearchBarNodeTheme(theme: theme), strings: strings, fieldStyle: .modern)
let placeholderText = strings.Common_Search let placeholderText = strings.Common_Search
let searchBarFont = Font.regular(17.0) let searchBarFont = Font.regular(17.0)
self.searchBar.placeholderString = NSAttributedString(string: placeholderText, font: searchBarFont, textColor: theme.searchBar.placeholder) self.searchBar.placeholderString = NSAttributedString(string: placeholderText, font: searchBarFont, textColor: theme.rootController.activeNavigationSearchBar.inputPlaceholderTextColor)
super.init() super.init()
@ -161,7 +133,7 @@ final class AuthorizationSequenceCountrySelectionController: ViewController {
return nil return nil
} }
private let theme: AuthorizationSequenceCountrySelectionTheme private let theme: PresentationTheme
private let strings: PresentationStrings private let strings: PresentationStrings
private let displayCodes: Bool private let displayCodes: Bool
@ -174,14 +146,14 @@ final class AuthorizationSequenceCountrySelectionController: ViewController {
var completeWithCountryCode: ((Int, String) -> Void)? var completeWithCountryCode: ((Int, String) -> Void)?
var dismissed: (() -> Void)? var dismissed: (() -> Void)?
init(strings: PresentationStrings, theme: AuthorizationSequenceCountrySelectionTheme, displayCodes: Bool = true) { init(strings: PresentationStrings, theme: PresentationTheme, displayCodes: Bool = true) {
self.theme = theme self.theme = theme
self.strings = strings self.strings = strings
self.displayCodes = displayCodes self.displayCodes = displayCodes
super.init(navigationBarPresentationData: NavigationBarPresentationData(theme: NavigationBarTheme(buttonColor: theme.searchBar.accent, disabledButtonColor: UIColor(rgb: 0xd0d0d0), primaryTextColor: theme.searchBar.primaryText, backgroundColor: theme.searchBar.background, separatorColor: theme.searchBar.separator, badgeBackgroundColor: theme.searchBar.accent, badgeStrokeColor: .clear, badgeTextColor: theme.searchBar.background), strings: NavigationBarStrings(presentationStrings: strings))) super.init(navigationBarPresentationData: NavigationBarPresentationData(theme: NavigationBarTheme(rootControllerTheme: theme), strings: NavigationBarStrings(presentationStrings: strings)))
self.statusBar.statusBarStyle = theme.statusBar.style self.statusBar.statusBarStyle = theme.rootController.statusBar.style.style
let navigationContentNode = AuthorizationSequenceCountrySelectionNavigationContentNode(theme: theme, strings: strings, cancel: { [weak self] in let navigationContentNode = AuthorizationSequenceCountrySelectionNavigationContentNode(theme: theme, strings: strings, cancel: { [weak self] in
self?.dismissed?() self?.dismissed?()

View File

@ -68,7 +68,7 @@ func localizedContryNamesAndCodes(strings: PresentationStrings) -> [((String, St
final class AuthorizationSequenceCountrySelectionControllerNode: ASDisplayNode, UITableViewDelegate, UITableViewDataSource { final class AuthorizationSequenceCountrySelectionControllerNode: ASDisplayNode, UITableViewDelegate, UITableViewDataSource {
let itemSelected: (((String, String), String, Int)) -> Void let itemSelected: (((String, String), String, Int)) -> Void
private let theme: AuthorizationSequenceCountrySelectionTheme private let theme: PresentationTheme
private let strings: PresentationStrings private let strings: PresentationStrings
private let displayCodes: Bool private let displayCodes: Bool
private let needsSubtitle: Bool private let needsSubtitle: Bool
@ -81,7 +81,7 @@ final class AuthorizationSequenceCountrySelectionControllerNode: ASDisplayNode,
private var searchResults: [((String, String), String, Int)] = [] private var searchResults: [((String, String), String, Int)] = []
init(theme: AuthorizationSequenceCountrySelectionTheme, strings: PresentationStrings, displayCodes: Bool, itemSelected: @escaping (((String, String), String, Int)) -> Void) { init(theme: PresentationTheme, strings: PresentationStrings, displayCodes: Bool, itemSelected: @escaping (((String, String), String, Int)) -> Void) {
self.theme = theme self.theme = theme
self.strings = strings self.strings = strings
self.displayCodes = displayCodes self.displayCodes = displayCodes
@ -116,21 +116,21 @@ final class AuthorizationSequenceCountrySelectionControllerNode: ASDisplayNode,
return UITracingLayerView() return UITracingLayerView()
}) })
self.backgroundColor = theme.listBackground self.backgroundColor = theme.list.plainBackgroundColor
self.tableView.backgroundColor = theme.listBackground self.tableView.backgroundColor = theme.list.plainBackgroundColor
self.tableView.backgroundColor = self.theme.listBackground self.tableView.backgroundColor = self.theme.list.plainBackgroundColor
self.tableView.separatorColor = self.theme.listSeparator self.tableView.separatorColor = self.theme.list.itemPlainSeparatorColor
self.tableView.backgroundView = UIView() self.tableView.backgroundView = UIView()
self.tableView.sectionIndexColor = self.theme.searchBar.accent self.tableView.sectionIndexColor = self.theme.list.itemAccentColor
self.searchTableView.backgroundColor = theme.listBackground self.searchTableView.backgroundColor = self.theme.list.plainBackgroundColor
self.searchTableView.backgroundColor = self.theme.listBackground self.searchTableView.backgroundColor = self.theme.list.plainBackgroundColor
self.searchTableView.separatorColor = self.theme.listSeparator self.searchTableView.separatorColor = self.theme.list.itemPlainSeparatorColor
self.searchTableView.backgroundView = UIView() self.searchTableView.backgroundView = UIView()
self.searchTableView.sectionIndexColor = self.theme.searchBar.accent self.searchTableView.sectionIndexColor = self.theme.list.itemAccentColor
self.tableView.delegate = self self.tableView.delegate = self
self.tableView.dataSource = self self.tableView.dataSource = self
@ -205,8 +205,8 @@ final class AuthorizationSequenceCountrySelectionControllerNode: ASDisplayNode,
} }
func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) { func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
(view as? UITableViewHeaderFooterView)?.backgroundView?.backgroundColor = self.theme.listBackground (view as? UITableViewHeaderFooterView)?.backgroundView?.backgroundColor = self.theme.list.plainBackgroundColor
(view as? UITableViewHeaderFooterView)?.textLabel?.textColor = self.theme.listPrimary (view as? UITableViewHeaderFooterView)?.textLabel?.textColor = self.theme.list.itemPrimaryTextColor
} }
func sectionIndexTitles(for tableView: UITableView) -> [String]? { func sectionIndexTitles(for tableView: UITableView) -> [String]? {
@ -259,12 +259,12 @@ final class AuthorizationSequenceCountrySelectionControllerNode: ASDisplayNode,
if self.displayCodes, let label = cell.accessoryView as? UILabel { if self.displayCodes, let label = cell.accessoryView as? UILabel {
label.text = code label.text = code
label.sizeToFit() label.sizeToFit()
label.textColor = self.theme.listPrimary label.textColor = self.theme.list.itemPrimaryTextColor
} }
cell.textLabel?.textColor = self.theme.listPrimary cell.textLabel?.textColor = self.theme.list.itemPrimaryTextColor
cell.detailTextLabel?.textColor = self.theme.listPrimary cell.detailTextLabel?.textColor = self.theme.list.itemPrimaryTextColor
cell.backgroundColor = self.theme.listBackground cell.backgroundColor = self.theme.list.plainBackgroundColor
cell.selectedBackgroundView?.backgroundColor = self.theme.listItemHighlight cell.selectedBackgroundView?.backgroundColor = self.theme.list.itemHighlightedBackgroundColor
return cell return cell
} }

View File

@ -8,7 +8,7 @@ final class AuthorizationSequencePasswordEntryController: ViewController {
} }
private let strings: PresentationStrings private let strings: PresentationStrings
private let theme: AuthorizationTheme private let theme: PresentationTheme
var loginWithPassword: ((String) -> Void)? var loginWithPassword: ((String) -> Void)?
var forgot: (() -> Void)? var forgot: (() -> Void)?
@ -32,7 +32,7 @@ final class AuthorizationSequencePasswordEntryController: ViewController {
var inProgress: Bool = false { var inProgress: Bool = false {
didSet { didSet {
if self.inProgress { if self.inProgress {
let item = UIBarButtonItem(customDisplayNode: ProgressNavigationButtonNode(color: self.theme.accentColor)) let item = UIBarButtonItem(customDisplayNode: ProgressNavigationButtonNode(color: self.theme.rootController.navigationBar.accentTextColor))
self.navigationItem.rightBarButtonItem = item self.navigationItem.rightBarButtonItem = item
} else { } else {
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: self.strings.Common_Next, style: .done, target: self, action: #selector(self.nextPressed)) self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: self.strings.Common_Next, style: .done, target: self, action: #selector(self.nextPressed))
@ -41,7 +41,7 @@ final class AuthorizationSequencePasswordEntryController: ViewController {
} }
} }
init(strings: PresentationStrings, theme: AuthorizationTheme, back: @escaping () -> Void) { init(strings: PresentationStrings, theme: PresentationTheme, back: @escaping () -> Void) {
self.strings = strings self.strings = strings
self.theme = theme self.theme = theme
@ -51,7 +51,7 @@ final class AuthorizationSequencePasswordEntryController: ViewController {
self.hasActiveInput = true self.hasActiveInput = true
self.statusBar.statusBarStyle = theme.statusBarStyle self.statusBar.statusBarStyle = theme.rootController.statusBar.style.style
self.attemptNavigation = { _ in self.attemptNavigation = { _ in
return false return false
@ -127,9 +127,9 @@ final class AuthorizationSequencePasswordEntryController: ViewController {
func forgotPressed() { func forgotPressed() {
if self.suggestReset { if self.suggestReset {
self.present(standardTextAlertController(theme: AlertControllerTheme(authTheme: self.theme), title: nil, text: self.strings.TwoStepAuth_RecoveryFailed, actions: [TextAlertAction(type: .defaultAction, title: self.strings.Common_OK, action: {})]), in: .window(.root)) self.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: self.theme), title: nil, text: self.strings.TwoStepAuth_RecoveryFailed, actions: [TextAlertAction(type: .defaultAction, title: self.strings.Common_OK, action: {})]), in: .window(.root))
} else if self.didForgotWithNoRecovery { } else if self.didForgotWithNoRecovery {
self.present(standardTextAlertController(theme: AlertControllerTheme(authTheme: self.theme), title: nil, text: self.strings.TwoStepAuth_RecoveryUnavailable, actions: [TextAlertAction(type: .defaultAction, title: self.strings.Common_OK, action: {})]), in: .window(.root)) self.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: self.theme), title: nil, text: self.strings.TwoStepAuth_RecoveryUnavailable, actions: [TextAlertAction(type: .defaultAction, title: self.strings.Common_OK, action: {})]), in: .window(.root))
} else { } else {
self.forgot?() self.forgot?()
} }

View File

@ -4,7 +4,7 @@ import Display
final class AuthorizationSequencePasswordEntryControllerNode: ASDisplayNode, UITextFieldDelegate { final class AuthorizationSequencePasswordEntryControllerNode: ASDisplayNode, UITextFieldDelegate {
private let strings: PresentationStrings private let strings: PresentationStrings
private let theme: AuthorizationTheme private let theme: PresentationTheme
private let titleNode: ASTextNode private let titleNode: ASTextNode
private let noticeNode: ASTextNode private let noticeNode: ASTextNode
@ -35,41 +35,41 @@ final class AuthorizationSequencePasswordEntryControllerNode: ASDisplayNode, UIT
} }
} }
init(strings: PresentationStrings, theme: AuthorizationTheme) { init(strings: PresentationStrings, theme: PresentationTheme) {
self.strings = strings self.strings = strings
self.theme = theme self.theme = theme
self.titleNode = ASTextNode() self.titleNode = ASTextNode()
self.titleNode.isUserInteractionEnabled = false self.titleNode.isUserInteractionEnabled = false
self.titleNode.displaysAsynchronously = false self.titleNode.displaysAsynchronously = false
self.titleNode.attributedText = NSAttributedString(string: strings.LoginPassword_Title, font: Font.light(30.0), textColor: self.theme.primaryColor) self.titleNode.attributedText = NSAttributedString(string: strings.LoginPassword_Title, font: Font.light(30.0), textColor: self.theme.list.itemPrimaryTextColor)
self.noticeNode = ASTextNode() self.noticeNode = ASTextNode()
self.noticeNode.isUserInteractionEnabled = false self.noticeNode.isUserInteractionEnabled = false
self.noticeNode.displaysAsynchronously = false self.noticeNode.displaysAsynchronously = false
self.noticeNode.attributedText = NSAttributedString(string: strings.TwoStepAuth_EnterPasswordHelp, font: Font.regular(16.0), textColor: self.theme.primaryColor, paragraphAlignment: .center) self.noticeNode.attributedText = NSAttributedString(string: strings.TwoStepAuth_EnterPasswordHelp, font: Font.regular(16.0), textColor: self.theme.list.itemPrimaryTextColor, paragraphAlignment: .center)
self.forgotNode = HighlightableButtonNode() self.forgotNode = HighlightableButtonNode()
self.forgotNode.displaysAsynchronously = false self.forgotNode.displaysAsynchronously = false
self.forgotNode.setAttributedTitle(NSAttributedString(string: self.strings.TwoStepAuth_EnterPasswordForgot, font: Font.regular(16.0), textColor: self.theme.accentColor, paragraphAlignment: .center), for: []) self.forgotNode.setAttributedTitle(NSAttributedString(string: self.strings.TwoStepAuth_EnterPasswordForgot, font: Font.regular(16.0), textColor: self.theme.list.itemAccentColor, paragraphAlignment: .center), for: [])
self.resetNode = HighlightableButtonNode() self.resetNode = HighlightableButtonNode()
self.resetNode.displaysAsynchronously = false self.resetNode.displaysAsynchronously = false
self.resetNode.setAttributedTitle(NSAttributedString(string: self.strings.LoginPassword_ResetAccount, font: Font.regular(16.0), textColor: self.theme.destructiveColor, paragraphAlignment: .center), for: []) self.resetNode.setAttributedTitle(NSAttributedString(string: self.strings.LoginPassword_ResetAccount, font: Font.regular(16.0), textColor: self.theme.list.itemDestructiveColor, paragraphAlignment: .center), for: [])
self.codeSeparatorNode = ASDisplayNode() self.codeSeparatorNode = ASDisplayNode()
self.codeSeparatorNode.isLayerBacked = true self.codeSeparatorNode.isLayerBacked = true
self.codeSeparatorNode.backgroundColor = self.theme.separatorColor self.codeSeparatorNode.backgroundColor = self.theme.list.itemPlainSeparatorColor
self.codeField = TextFieldNode() self.codeField = TextFieldNode()
self.codeField.textField.font = Font.regular(20.0) self.codeField.textField.font = Font.regular(20.0)
self.codeField.textField.textColor = self.theme.primaryColor self.codeField.textField.textColor = self.theme.list.itemPrimaryTextColor
self.codeField.textField.textAlignment = .natural self.codeField.textField.textAlignment = .natural
self.codeField.textField.isSecureTextEntry = true self.codeField.textField.isSecureTextEntry = true
self.codeField.textField.returnKeyType = .done self.codeField.textField.returnKeyType = .done
self.codeField.textField.keyboardAppearance = self.theme.keyboard.keyboardAppearance self.codeField.textField.keyboardAppearance = self.theme.chatList.searchBarKeyboardColor.keyboardAppearance
self.codeField.textField.disableAutomaticKeyboardHandling = [.forward, .backward] self.codeField.textField.disableAutomaticKeyboardHandling = [.forward, .backward]
self.codeField.textField.tintColor = self.theme.accentColor self.codeField.textField.tintColor = self.theme.list.itemAccentColor
super.init() super.init()
@ -77,7 +77,7 @@ final class AuthorizationSequencePasswordEntryControllerNode: ASDisplayNode, UIT
return UITracingLayerView() return UITracingLayerView()
}) })
self.backgroundColor = self.theme.backgroundColor self.backgroundColor = self.theme.list.plainBackgroundColor
self.codeField.textField.delegate = self self.codeField.textField.delegate = self
@ -95,7 +95,7 @@ final class AuthorizationSequencePasswordEntryControllerNode: ASDisplayNode, UIT
func updateData(hint: String, didForgotWithNoRecovery: Bool, suggestReset: Bool) { func updateData(hint: String, didForgotWithNoRecovery: Bool, suggestReset: Bool) {
self.didForgotWithNoRecovery = didForgotWithNoRecovery self.didForgotWithNoRecovery = didForgotWithNoRecovery
self.suggestReset = suggestReset self.suggestReset = suggestReset
self.codeField.textField.attributedPlaceholder = NSAttributedString(string: hint, font: Font.regular(20.0), textColor: self.theme.textPlaceholderColor) self.codeField.textField.attributedPlaceholder = NSAttributedString(string: hint, font: Font.regular(20.0), textColor: self.theme.list.itemPlaceholderTextColor)
if let (layout, navigationHeight) = self.layoutArguments { if let (layout, navigationHeight) = self.layoutArguments {
self.containerLayoutUpdated(layout, navigationBarHeight: navigationHeight, transition: .immediate) self.containerLayoutUpdated(layout, navigationBarHeight: navigationHeight, transition: .immediate)
} }
@ -116,9 +116,9 @@ final class AuthorizationSequencePasswordEntryControllerNode: ASDisplayNode, UIT
} }
if max(layout.size.width, layout.size.height) > 1023.0 { if max(layout.size.width, layout.size.height) > 1023.0 {
self.titleNode.attributedText = NSAttributedString(string: self.strings.LoginPassword_Title, font: Font.light(40.0), textColor: self.theme.primaryColor) self.titleNode.attributedText = NSAttributedString(string: self.strings.LoginPassword_Title, font: Font.light(40.0), textColor: self.theme.list.itemPrimaryTextColor)
} else { } else {
self.titleNode.attributedText = NSAttributedString(string: self.strings.LoginPassword_Title, font: Font.light(30.0), textColor: self.theme.primaryColor) self.titleNode.attributedText = NSAttributedString(string: self.strings.LoginPassword_Title, font: Font.light(30.0), textColor: self.theme.list.itemPrimaryTextColor)
} }
let titleSize = self.titleNode.measure(CGSize(width: layout.size.width, height: CGFloat.greatestFiniteMagnitude)) let titleSize = self.titleNode.measure(CGSize(width: layout.size.width, height: CGFloat.greatestFiniteMagnitude))

View File

@ -8,7 +8,7 @@ final class AuthorizationSequencePasswordRecoveryController: ViewController {
} }
private let strings: PresentationStrings private let strings: PresentationStrings
private let theme: AuthorizationTheme private let theme: PresentationTheme
var recoverWithCode: ((String) -> Void)? var recoverWithCode: ((String) -> Void)?
var noAccess: (() -> Void)? var noAccess: (() -> Void)?
@ -20,7 +20,7 @@ final class AuthorizationSequencePasswordRecoveryController: ViewController {
var inProgress: Bool = false { var inProgress: Bool = false {
didSet { didSet {
if self.inProgress { if self.inProgress {
let item = UIBarButtonItem(customDisplayNode: ProgressNavigationButtonNode(color: self.theme.accentColor)) let item = UIBarButtonItem(customDisplayNode: ProgressNavigationButtonNode(color: self.theme.rootController.navigationBar.accentTextColor))
self.navigationItem.rightBarButtonItem = item self.navigationItem.rightBarButtonItem = item
} else { } else {
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: self.strings.Common_Next, style: .done, target: self, action: #selector(self.nextPressed)) self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: self.strings.Common_Next, style: .done, target: self, action: #selector(self.nextPressed))
@ -29,7 +29,7 @@ final class AuthorizationSequencePasswordRecoveryController: ViewController {
} }
} }
init(strings: PresentationStrings, theme: AuthorizationTheme, back: @escaping () -> Void) { init(strings: PresentationStrings, theme: PresentationTheme, back: @escaping () -> Void) {
self.strings = strings self.strings = strings
self.theme = theme self.theme = theme
@ -39,7 +39,7 @@ final class AuthorizationSequencePasswordRecoveryController: ViewController {
self.hasActiveInput = true self.hasActiveInput = true
self.statusBar.statusBarStyle = theme.statusBarStyle self.statusBar.statusBarStyle = theme.rootController.statusBar.style.style
self.attemptNavigation = { _ in self.attemptNavigation = { _ in
return false return false

View File

@ -4,7 +4,7 @@ import Display
final class AuthorizationSequencePasswordRecoveryControllerNode: ASDisplayNode, UITextFieldDelegate { final class AuthorizationSequencePasswordRecoveryControllerNode: ASDisplayNode, UITextFieldDelegate {
private let strings: PresentationStrings private let strings: PresentationStrings
private let theme: AuthorizationTheme private let theme: PresentationTheme
private let titleNode: ASTextNode private let titleNode: ASTextNode
private let noticeNode: ASTextNode private let noticeNode: ASTextNode
@ -28,36 +28,36 @@ final class AuthorizationSequencePasswordRecoveryControllerNode: ASDisplayNode,
} }
} }
init(strings: PresentationStrings, theme: AuthorizationTheme) { init(strings: PresentationStrings, theme: PresentationTheme) {
self.strings = strings self.strings = strings
self.theme = theme self.theme = theme
self.titleNode = ASTextNode() self.titleNode = ASTextNode()
self.titleNode.isUserInteractionEnabled = false self.titleNode.isUserInteractionEnabled = false
self.titleNode.displaysAsynchronously = false self.titleNode.displaysAsynchronously = false
self.titleNode.attributedText = NSAttributedString(string: strings.TwoStepAuth_RecoveryTitle, font: Font.light(30.0), textColor: self.theme.primaryColor) self.titleNode.attributedText = NSAttributedString(string: strings.TwoStepAuth_RecoveryTitle, font: Font.light(30.0), textColor: self.theme.list.itemPrimaryTextColor)
self.noticeNode = ASTextNode() self.noticeNode = ASTextNode()
self.noticeNode.isUserInteractionEnabled = false self.noticeNode.isUserInteractionEnabled = false
self.noticeNode.displaysAsynchronously = false self.noticeNode.displaysAsynchronously = false
self.noticeNode.attributedText = NSAttributedString(string: strings.TwoStepAuth_RecoveryCodeHelp, font: Font.regular(16.0), textColor: self.theme.primaryColor, paragraphAlignment: .center) self.noticeNode.attributedText = NSAttributedString(string: strings.TwoStepAuth_RecoveryCodeHelp, font: Font.regular(16.0), textColor: self.theme.list.itemPrimaryTextColor, paragraphAlignment: .center)
self.noAccessNode = HighlightableButtonNode() self.noAccessNode = HighlightableButtonNode()
self.noAccessNode.displaysAsynchronously = false self.noAccessNode.displaysAsynchronously = false
self.codeSeparatorNode = ASDisplayNode() self.codeSeparatorNode = ASDisplayNode()
self.codeSeparatorNode.isLayerBacked = true self.codeSeparatorNode.isLayerBacked = true
self.codeSeparatorNode.backgroundColor = self.theme.separatorColor self.codeSeparatorNode.backgroundColor = self.theme.list.itemPlainSeparatorColor
self.codeField = TextFieldNode() self.codeField = TextFieldNode()
self.codeField.textField.font = Font.regular(20.0) self.codeField.textField.font = Font.regular(20.0)
self.codeField.textField.textColor = self.theme.primaryColor self.codeField.textField.textColor = self.theme.list.itemPrimaryTextColor
self.codeField.textField.textAlignment = .center self.codeField.textField.textAlignment = .center
self.codeField.textField.attributedPlaceholder = NSAttributedString(string: self.strings.TwoStepAuth_RecoveryCode, font: Font.regular(20.0), textColor: self.theme.textPlaceholderColor) self.codeField.textField.attributedPlaceholder = NSAttributedString(string: self.strings.TwoStepAuth_RecoveryCode, font: Font.regular(20.0), textColor: self.theme.list.itemPlaceholderTextColor)
self.codeField.textField.returnKeyType = .done self.codeField.textField.returnKeyType = .done
self.codeField.textField.keyboardAppearance = self.theme.keyboard.keyboardAppearance self.codeField.textField.keyboardAppearance = self.theme.chatList.searchBarKeyboardColor.keyboardAppearance
self.codeField.textField.disableAutomaticKeyboardHandling = [.forward, .backward] self.codeField.textField.disableAutomaticKeyboardHandling = [.forward, .backward]
self.codeField.textField.tintColor = self.theme.accentColor self.codeField.textField.tintColor = self.theme.list.itemAccentColor
super.init() super.init()
@ -65,7 +65,7 @@ final class AuthorizationSequencePasswordRecoveryControllerNode: ASDisplayNode,
return UITracingLayerView() return UITracingLayerView()
}) })
self.backgroundColor = self.theme.backgroundColor self.backgroundColor = self.theme.list.plainBackgroundColor
self.codeField.textField.delegate = self self.codeField.textField.delegate = self
@ -79,7 +79,7 @@ final class AuthorizationSequencePasswordRecoveryControllerNode: ASDisplayNode,
} }
func updateData(emailPattern: String) { func updateData(emailPattern: String) {
self.noAccessNode.setAttributedTitle(NSAttributedString(string: self.strings.TwoStepAuth_RecoveryEmailUnavailable(emailPattern).0, font: Font.regular(16.0), textColor: self.theme.accentColor, paragraphAlignment: .center), for: []) self.noAccessNode.setAttributedTitle(NSAttributedString(string: self.strings.TwoStepAuth_RecoveryEmailUnavailable(emailPattern).0, font: Font.regular(16.0), textColor: self.theme.list.itemAccentColor, paragraphAlignment: .center), for: [])
} }
func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationBarHeight: CGFloat, transition: ContainedViewLayoutTransition) { func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationBarHeight: CGFloat, transition: ContainedViewLayoutTransition) {
@ -89,9 +89,9 @@ final class AuthorizationSequencePasswordRecoveryControllerNode: ASDisplayNode,
insets.top = navigationBarHeight insets.top = navigationBarHeight
if max(layout.size.width, layout.size.height) > 1023.0 { if max(layout.size.width, layout.size.height) > 1023.0 {
self.titleNode.attributedText = NSAttributedString(string: self.strings.TwoStepAuth_RecoveryTitle, font: Font.light(40.0), textColor: self.theme.primaryColor) self.titleNode.attributedText = NSAttributedString(string: self.strings.TwoStepAuth_RecoveryTitle, font: Font.light(40.0), textColor: self.theme.list.itemPrimaryTextColor)
} else { } else {
self.titleNode.attributedText = NSAttributedString(string: self.strings.TwoStepAuth_RecoveryTitle, font: Font.light(30.0), textColor: self.theme.primaryColor) self.titleNode.attributedText = NSAttributedString(string: self.strings.TwoStepAuth_RecoveryTitle, font: Font.light(30.0), textColor: self.theme.list.itemPrimaryTextColor)
} }
let titleSize = self.titleNode.measure(CGSize(width: layout.size.width, height: CGFloat.greatestFiniteMagnitude)) let titleSize = self.titleNode.measure(CGSize(width: layout.size.width, height: CGFloat.greatestFiniteMagnitude))

View File

@ -14,7 +14,7 @@ final class AuthorizationSequencePhoneEntryController: ViewController {
private let otherAccountPhoneNumbers: ((String, AccountRecordId)?, [(String, AccountRecordId)]) private let otherAccountPhoneNumbers: ((String, AccountRecordId)?, [(String, AccountRecordId)])
private let network: Network private let network: Network
private let strings: PresentationStrings private let strings: PresentationStrings
private let theme: AuthorizationTheme private let theme: PresentationTheme
private let openUrl: (String) -> Void private let openUrl: (String) -> Void
private let back: () -> Void private let back: () -> Void
@ -24,7 +24,7 @@ final class AuthorizationSequencePhoneEntryController: ViewController {
var inProgress: Bool = false { var inProgress: Bool = false {
didSet { didSet {
if self.inProgress { if self.inProgress {
let item = UIBarButtonItem(customDisplayNode: ProgressNavigationButtonNode(color: self.theme.accentColor)) let item = UIBarButtonItem(customDisplayNode: ProgressNavigationButtonNode(color: self.theme.rootController.navigationBar.accentTextColor))
self.navigationItem.rightBarButtonItem = item self.navigationItem.rightBarButtonItem = item
} else { } else {
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: self.strings.Common_Next, style: .done, target: self, action: #selector(self.nextPressed)) self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: self.strings.Common_Next, style: .done, target: self, action: #selector(self.nextPressed))
@ -38,7 +38,7 @@ final class AuthorizationSequencePhoneEntryController: ViewController {
private let hapticFeedback = HapticFeedback() private let hapticFeedback = HapticFeedback()
init(sharedContext: SharedAccountContext, otherAccountPhoneNumbers: ((String, AccountRecordId)?, [(String, AccountRecordId)]), network: Network, strings: PresentationStrings, theme: AuthorizationTheme, openUrl: @escaping (String) -> Void, back: @escaping () -> Void) { init(sharedContext: SharedAccountContext, otherAccountPhoneNumbers: ((String, AccountRecordId)?, [(String, AccountRecordId)]), network: Network, strings: PresentationStrings, theme: PresentationTheme, openUrl: @escaping (String) -> Void, back: @escaping () -> Void) {
self.sharedContext = sharedContext self.sharedContext = sharedContext
self.otherAccountPhoneNumbers = otherAccountPhoneNumbers self.otherAccountPhoneNumbers = otherAccountPhoneNumbers
self.network = network self.network = network
@ -53,7 +53,7 @@ final class AuthorizationSequencePhoneEntryController: ViewController {
self.hasActiveInput = true self.hasActiveInput = true
self.statusBar.statusBarStyle = theme.statusBarStyle self.statusBar.statusBarStyle = theme.rootController.statusBar.style.style
self.attemptNavigation = { _ in self.attemptNavigation = { _ in
return false return false
} }
@ -94,7 +94,7 @@ final class AuthorizationSequencePhoneEntryController: ViewController {
self.displayNodeDidLoad() self.displayNodeDidLoad()
self.controllerNode.selectCountryCode = { [weak self] in self.controllerNode.selectCountryCode = { [weak self] in
if let strongSelf = self { if let strongSelf = self {
let controller = AuthorizationSequenceCountrySelectionController(strings: strongSelf.strings, theme: AuthorizationSequenceCountrySelectionTheme(authorizationTheme: strongSelf.theme)) let controller = AuthorizationSequenceCountrySelectionController(strings: strongSelf.strings, theme: strongSelf.theme)
controller.completeWithCountryCode = { code, name in controller.completeWithCountryCode = { code, name in
if let strongSelf = self, let currentData = strongSelf.currentData { if let strongSelf = self, let currentData = strongSelf.currentData {
strongSelf.updateData(countryCode: Int32(code), countryName: name, number: currentData.2) strongSelf.updateData(countryCode: Int32(code), countryName: name, number: currentData.2)
@ -151,7 +151,7 @@ final class AuthorizationSequencePhoneEntryController: ViewController {
})) }))
} }
actions.append(TextAlertAction(type: .defaultAction, title: self.strings.Common_OK, action: {})) actions.append(TextAlertAction(type: .defaultAction, title: self.strings.Common_OK, action: {}))
self.present(standardTextAlertController(theme: AlertControllerTheme(authTheme: self.theme), title: nil, text: self.strings.Login_PhoneNumberAlreadyAuthorized, actions: actions), in: .window(.root)) self.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: self.theme), title: nil, text: self.strings.Login_PhoneNumberAlreadyAuthorized, actions: actions), in: .window(.root))
} else { } else {
self.loginWithNumber?(self.controllerNode.currentNumber) self.loginWithNumber?(self.controllerNode.currentNumber)
} }

View File

@ -30,14 +30,14 @@ private final class PhoneAndCountryNode: ASDisplayNode {
var selectCountryCode: (() -> Void)? var selectCountryCode: (() -> Void)?
var checkPhone: (() -> Void)? var checkPhone: (() -> Void)?
init(strings: PresentationStrings, theme: AuthorizationTheme) { init(strings: PresentationStrings, theme: PresentationTheme) {
self.strings = strings self.strings = strings
let countryButtonBackground = generateImage(CGSize(width: 61.0, height: 67.0), rotatedContext: { size, context in let countryButtonBackground = generateImage(CGSize(width: 61.0, height: 67.0), rotatedContext: { size, context in
let arrowSize: CGFloat = 10.0 let arrowSize: CGFloat = 10.0
let lineWidth = UIScreenPixel let lineWidth = UIScreenPixel
context.clear(CGRect(origin: CGPoint(), size: size)) context.clear(CGRect(origin: CGPoint(), size: size))
context.setStrokeColor(theme.separatorColor.cgColor) context.setStrokeColor(theme.list.itemPlainSeparatorColor.cgColor)
context.setLineWidth(lineWidth) context.setLineWidth(lineWidth)
context.move(to: CGPoint(x: 15.0, y: lineWidth / 2.0)) context.move(to: CGPoint(x: 15.0, y: lineWidth / 2.0))
context.addLine(to: CGPoint(x: size.width, y: lineWidth / 2.0)) context.addLine(to: CGPoint(x: size.width, y: lineWidth / 2.0))
@ -54,7 +54,7 @@ private final class PhoneAndCountryNode: ASDisplayNode {
let countryButtonHighlightedBackground = generateImage(CGSize(width: 60.0, height: 67.0), rotatedContext: { size, context in let countryButtonHighlightedBackground = generateImage(CGSize(width: 60.0, height: 67.0), rotatedContext: { size, context in
let arrowSize: CGFloat = 10.0 let arrowSize: CGFloat = 10.0
context.clear(CGRect(origin: CGPoint(), size: size)) context.clear(CGRect(origin: CGPoint(), size: size))
context.setFillColor(theme.itemHighlightedBackgroundColor.cgColor) context.setFillColor(theme.list.itemHighlightedBackgroundColor.cgColor)
context.fill(CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: size.height - arrowSize))) context.fill(CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: size.height - arrowSize)))
context.move(to: CGPoint(x: size.width, y: size.height - arrowSize)) context.move(to: CGPoint(x: size.width, y: size.height - arrowSize))
context.addLine(to: CGPoint(x: size.width - 1.0, y: size.height - arrowSize)) context.addLine(to: CGPoint(x: size.width - 1.0, y: size.height - arrowSize))
@ -67,7 +67,7 @@ private final class PhoneAndCountryNode: ASDisplayNode {
let phoneInputBackground = generateImage(CGSize(width: 85.0, height: 57.0), rotatedContext: { size, context in let phoneInputBackground = generateImage(CGSize(width: 85.0, height: 57.0), rotatedContext: { size, context in
let lineWidth = UIScreenPixel let lineWidth = UIScreenPixel
context.clear(CGRect(origin: CGPoint(), size: size)) context.clear(CGRect(origin: CGPoint(), size: size))
context.setStrokeColor(theme.separatorColor.cgColor) context.setStrokeColor(theme.list.itemPlainSeparatorColor.cgColor)
context.setLineWidth(lineWidth) context.setLineWidth(lineWidth)
context.move(to: CGPoint(x: 15.0, y: size.height - lineWidth / 2.0)) context.move(to: CGPoint(x: 15.0, y: size.height - lineWidth / 2.0))
context.addLine(to: CGPoint(x: size.width, y: size.height - lineWidth / 2.0)) context.addLine(to: CGPoint(x: size.width, y: size.height - lineWidth / 2.0))
@ -98,13 +98,13 @@ private final class PhoneAndCountryNode: ASDisplayNode {
self.addSubnode(self.countryButton) self.addSubnode(self.countryButton)
self.addSubnode(self.phoneInputNode) self.addSubnode(self.phoneInputNode)
self.phoneInputNode.countryCodeField.textField.keyboardAppearance = theme.keyboard.keyboardAppearance self.phoneInputNode.countryCodeField.textField.keyboardAppearance = theme.chatList.searchBarKeyboardColor.keyboardAppearance
self.phoneInputNode.numberField.textField.keyboardAppearance = theme.keyboard.keyboardAppearance self.phoneInputNode.numberField.textField.keyboardAppearance = theme.chatList.searchBarKeyboardColor.keyboardAppearance
self.phoneInputNode.countryCodeField.textField.textColor = theme.primaryColor self.phoneInputNode.countryCodeField.textField.textColor = theme.list.itemPrimaryTextColor
self.phoneInputNode.numberField.textField.textColor = theme.primaryColor self.phoneInputNode.numberField.textField.textColor = theme.list.itemPrimaryTextColor
self.phoneInputNode.countryCodeField.textField.tintColor = theme.accentColor self.phoneInputNode.countryCodeField.textField.tintColor = theme.list.itemAccentColor
self.phoneInputNode.numberField.textField.tintColor = theme.accentColor self.phoneInputNode.numberField.textField.tintColor = theme.list.itemAccentColor
self.phoneInputNode.countryCodeField.textField.disableAutomaticKeyboardHandling = [.forward] self.phoneInputNode.countryCodeField.textField.disableAutomaticKeyboardHandling = [.forward]
self.phoneInputNode.numberField.textField.disableAutomaticKeyboardHandling = [.forward] self.phoneInputNode.numberField.textField.disableAutomaticKeyboardHandling = [.forward]
@ -113,7 +113,7 @@ private final class PhoneAndCountryNode: ASDisplayNode {
self.countryButton.contentEdgeInsets = UIEdgeInsets(top: 0.0, left: 15.0, bottom: 10.0, right: 0.0) self.countryButton.contentEdgeInsets = UIEdgeInsets(top: 0.0, left: 15.0, bottom: 10.0, right: 0.0)
self.countryButton.contentHorizontalAlignment = .left self.countryButton.contentHorizontalAlignment = .left
self.phoneInputNode.numberField.textField.attributedPlaceholder = NSAttributedString(string: strings.Login_PhonePlaceholder, font: Font.regular(20.0), textColor: theme.textPlaceholderColor) self.phoneInputNode.numberField.textField.attributedPlaceholder = NSAttributedString(string: strings.Login_PhonePlaceholder, font: Font.regular(20.0), textColor: theme.list.itemPlaceholderTextColor)
self.countryButton.addTarget(self, action: #selector(self.countryPressed), forControlEvents: .touchUpInside) self.countryButton.addTarget(self, action: #selector(self.countryPressed), forControlEvents: .touchUpInside)
@ -122,13 +122,13 @@ private final class PhoneAndCountryNode: ASDisplayNode {
if let code = Int(code), let name = name, let countryName = countryCodeAndIdToName[CountryCodeAndId(code: code, id: name)] { if let code = Int(code), let name = name, let countryName = countryCodeAndIdToName[CountryCodeAndId(code: code, id: name)] {
let flagString = emojiFlagForISOCountryCode(name as NSString) let flagString = emojiFlagForISOCountryCode(name as NSString)
let localizedName: String = AuthorizationSequenceCountrySelectionController.lookupCountryNameById(name, strings: strongSelf.strings) ?? countryName let localizedName: String = AuthorizationSequenceCountrySelectionController.lookupCountryNameById(name, strings: strongSelf.strings) ?? countryName
strongSelf.countryButton.setTitle("\(flagString) \(localizedName)", with: Font.regular(20.0), with: theme.primaryColor, for: []) strongSelf.countryButton.setTitle("\(flagString) \(localizedName)", with: Font.regular(20.0), with: theme.list.itemPrimaryTextColor, for: [])
} else if let code = Int(code), let (countryId, countryName) = countryCodeToIdAndName[code] { } else if let code = Int(code), let (countryId, countryName) = countryCodeToIdAndName[code] {
let flagString = emojiFlagForISOCountryCode(countryId as NSString) let flagString = emojiFlagForISOCountryCode(countryId as NSString)
let localizedName: String = AuthorizationSequenceCountrySelectionController.lookupCountryNameById(countryId, strings: strongSelf.strings) ?? countryName let localizedName: String = AuthorizationSequenceCountrySelectionController.lookupCountryNameById(countryId, strings: strongSelf.strings) ?? countryName
strongSelf.countryButton.setTitle("\(flagString) \(localizedName)", with: Font.regular(20.0), with: theme.primaryColor, for: []) strongSelf.countryButton.setTitle("\(flagString) \(localizedName)", with: Font.regular(20.0), with: theme.list.itemPrimaryTextColor, for: [])
} else { } else {
strongSelf.countryButton.setTitle(strings.Login_SelectCountry_Title, with: Font.regular(20.0), with: theme.textPlaceholderColor, for: []) strongSelf.countryButton.setTitle(strings.Login_SelectCountry_Title, with: Font.regular(20.0), with: theme.list.itemPlaceholderTextColor, for: [])
} }
} }
} }
@ -164,7 +164,7 @@ private final class PhoneAndCountryNode: ASDisplayNode {
final class AuthorizationSequencePhoneEntryControllerNode: ASDisplayNode { final class AuthorizationSequencePhoneEntryControllerNode: ASDisplayNode {
private let strings: PresentationStrings private let strings: PresentationStrings
private let theme: AuthorizationTheme private let theme: PresentationTheme
private let titleNode: ASTextNode private let titleNode: ASTextNode
private let noticeNode: ASTextNode private let noticeNode: ASTextNode
@ -194,27 +194,27 @@ final class AuthorizationSequencePhoneEntryControllerNode: ASDisplayNode {
} }
} }
init(strings: PresentationStrings, theme: AuthorizationTheme) { init(strings: PresentationStrings, theme: PresentationTheme) {
self.strings = strings self.strings = strings
self.theme = theme self.theme = theme
self.titleNode = ASTextNode() self.titleNode = ASTextNode()
self.titleNode.isUserInteractionEnabled = false self.titleNode.isUserInteractionEnabled = false
self.titleNode.displaysAsynchronously = false self.titleNode.displaysAsynchronously = false
self.titleNode.attributedText = NSAttributedString(string: strings.Login_PhoneTitle, font: Font.light(30.0), textColor: theme.primaryColor) self.titleNode.attributedText = NSAttributedString(string: strings.Login_PhoneTitle, font: Font.light(30.0), textColor: theme.list.itemPrimaryTextColor)
self.noticeNode = ASTextNode() self.noticeNode = ASTextNode()
self.noticeNode.isUserInteractionEnabled = false self.noticeNode.isUserInteractionEnabled = false
self.noticeNode.displaysAsynchronously = false self.noticeNode.displaysAsynchronously = false
self.noticeNode.attributedText = NSAttributedString(string: strings.Login_PhoneAndCountryHelp, font: Font.regular(16.0), textColor: theme.primaryColor, paragraphAlignment: .center) self.noticeNode.attributedText = NSAttributedString(string: strings.Login_PhoneAndCountryHelp, font: Font.regular(16.0), textColor: theme.list.itemPrimaryTextColor, paragraphAlignment: .center)
self.termsOfServiceNode = ImmediateTextNode() self.termsOfServiceNode = ImmediateTextNode()
self.termsOfServiceNode.maximumNumberOfLines = 0 self.termsOfServiceNode.maximumNumberOfLines = 0
self.termsOfServiceNode.textAlignment = .center self.termsOfServiceNode.textAlignment = .center
self.termsOfServiceNode.displaysAsynchronously = false self.termsOfServiceNode.displaysAsynchronously = false
let termsOfServiceAttributes = MarkdownAttributeSet(font: Font.regular(16.0), textColor: self.theme.primaryColor) let termsOfServiceAttributes = MarkdownAttributeSet(font: Font.regular(16.0), textColor: self.theme.list.itemPrimaryTextColor)
let termsOfServiceLinkAttributes = MarkdownAttributeSet(font: Font.regular(16.0), textColor: self.theme.accentColor, additionalAttributes: [NSAttributedStringKey.underlineStyle.rawValue: NSUnderlineStyle.styleSingle.rawValue as NSNumber, TelegramTextAttributes.URL: ""]) let termsOfServiceLinkAttributes = MarkdownAttributeSet(font: Font.regular(16.0), textColor: self.theme.list.itemAccentColor, additionalAttributes: [NSAttributedStringKey.underlineStyle.rawValue: NSUnderlineStyle.styleSingle.rawValue as NSNumber, TelegramTextAttributes.URL: ""])
let termsString = parseMarkdownIntoAttributedString(self.strings.Login_TermsOfServiceLabel.replacingOccurrences(of: "]", with: "]()"), attributes: MarkdownAttributes(body: termsOfServiceAttributes, bold: termsOfServiceAttributes, link: termsOfServiceLinkAttributes, linkAttribute: { _ in let termsString = parseMarkdownIntoAttributedString(self.strings.Login_TermsOfServiceLabel.replacingOccurrences(of: "]", with: "]()"), attributes: MarkdownAttributes(body: termsOfServiceAttributes, bold: termsOfServiceAttributes, link: termsOfServiceLinkAttributes, linkAttribute: { _ in
return nil return nil
@ -229,7 +229,7 @@ final class AuthorizationSequencePhoneEntryControllerNode: ASDisplayNode {
return UITracingLayerView() return UITracingLayerView()
}) })
self.backgroundColor = theme.backgroundColor self.backgroundColor = theme.list.plainBackgroundColor
self.addSubnode(self.titleNode) self.addSubnode(self.titleNode)
//self.addSubnode(self.termsOfServiceNode) //self.addSubnode(self.termsOfServiceNode)
@ -254,7 +254,7 @@ final class AuthorizationSequencePhoneEntryControllerNode: ASDisplayNode {
if let _ = attributes[NSAttributedStringKey(rawValue: TelegramTextAttributes.URL)] as? String { if let _ = attributes[NSAttributedStringKey(rawValue: TelegramTextAttributes.URL)] as? String {
} }
} }
self.termsOfServiceNode.linkHighlightColor = theme.accentColor.withAlphaComponent(0.5) self.termsOfServiceNode.linkHighlightColor = theme.list.itemAccentColor.withAlphaComponent(0.5)
} }
func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationBarHeight: CGFloat, transition: ContainedViewLayoutTransition) { func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationBarHeight: CGFloat, transition: ContainedViewLayoutTransition) {
@ -270,9 +270,9 @@ final class AuthorizationSequencePhoneEntryControllerNode: ASDisplayNode {
} }
if max(layout.size.width, layout.size.height) > 1023.0 { if max(layout.size.width, layout.size.height) > 1023.0 {
self.titleNode.attributedText = NSAttributedString(string: strings.Login_PhoneTitle, font: Font.light(40.0), textColor: self.theme.primaryColor) self.titleNode.attributedText = NSAttributedString(string: strings.Login_PhoneTitle, font: Font.light(40.0), textColor: self.theme.list.itemPrimaryTextColor)
} else { } else {
self.titleNode.attributedText = NSAttributedString(string: strings.Login_PhoneTitle, font: Font.light(30.0), textColor: self.theme.primaryColor) self.titleNode.attributedText = NSAttributedString(string: strings.Login_PhoneTitle, font: Font.light(30.0), textColor: self.theme.list.itemPrimaryTextColor)
} }
let titleSize = self.titleNode.measure(CGSize(width: layout.size.width, height: CGFloat.greatestFiniteMagnitude)) let titleSize = self.titleNode.measure(CGSize(width: layout.size.width, height: CGFloat.greatestFiniteMagnitude))

View File

@ -12,7 +12,7 @@ final class AuthorizationSequenceSignUpController: ViewController {
} }
private let strings: PresentationStrings private let strings: PresentationStrings
private let theme: AuthorizationTheme private let theme: PresentationTheme
var initialName: (String, String) = ("", "") var initialName: (String, String) = ("", "")
private var termsOfService: UnauthorizedAccountTermsOfService? private var termsOfService: UnauthorizedAccountTermsOfService?
@ -24,7 +24,7 @@ final class AuthorizationSequenceSignUpController: ViewController {
var inProgress: Bool = false { var inProgress: Bool = false {
didSet { didSet {
if self.inProgress { if self.inProgress {
let item = UIBarButtonItem(customDisplayNode: ProgressNavigationButtonNode(color: self.theme.accentColor)) let item = UIBarButtonItem(customDisplayNode: ProgressNavigationButtonNode(color: self.theme.rootController.navigationBar.accentTextColor))
self.navigationItem.rightBarButtonItem = item self.navigationItem.rightBarButtonItem = item
} else { } else {
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: self.strings.Common_Next, style: .done, target: self, action: #selector(self.nextPressed)) self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: self.strings.Common_Next, style: .done, target: self, action: #selector(self.nextPressed))
@ -33,7 +33,7 @@ final class AuthorizationSequenceSignUpController: ViewController {
} }
} }
init(strings: PresentationStrings, theme: AuthorizationTheme, back: @escaping () -> Void) { init(strings: PresentationStrings, theme: PresentationTheme, back: @escaping () -> Void) {
self.strings = strings self.strings = strings
self.theme = theme self.theme = theme
@ -41,7 +41,7 @@ final class AuthorizationSequenceSignUpController: ViewController {
self.supportedOrientations = ViewControllerSupportedOrientations(regularSize: .all, compactSize: .portrait) self.supportedOrientations = ViewControllerSupportedOrientations(regularSize: .all, compactSize: .portrait)
self.statusBar.statusBarStyle = self.theme.statusBarStyle self.statusBar.statusBarStyle = self.theme.rootController.statusBar.style.style
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: self.strings.Common_Next, style: .done, target: self, action: #selector(self.nextPressed)) self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: self.strings.Common_Next, style: .done, target: self, action: #selector(self.nextPressed))
@ -52,7 +52,7 @@ final class AuthorizationSequenceSignUpController: ViewController {
guard let strongSelf = self else { guard let strongSelf = self else {
return return
} }
strongSelf.present(standardTextAlertController(theme: AlertControllerTheme(authTheme: theme), title: nil, text: strings.Login_CancelSignUpConfirmation, actions: [TextAlertAction(type: .genericAction, title: strings.Login_CancelPhoneVerificationContinue, action: { strongSelf.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: theme), title: nil, text: strings.Login_CancelSignUpConfirmation, actions: [TextAlertAction(type: .genericAction, title: strings.Login_CancelPhoneVerificationContinue, action: {
}), TextAlertAction(type: .defaultAction, title: strings.Login_CancelPhoneVerificationStop, action: { }), TextAlertAction(type: .defaultAction, title: strings.Login_CancelPhoneVerificationStop, action: {
back() back()
})]), in: .window(.root)) })]), in: .window(.root))

View File

@ -16,7 +16,7 @@ private func roundCorners(diameter: CGFloat) -> UIImage {
} }
final class AuthorizationSequenceSignUpControllerNode: ASDisplayNode, UITextFieldDelegate { final class AuthorizationSequenceSignUpControllerNode: ASDisplayNode, UITextFieldDelegate {
private let theme: AuthorizationTheme private let theme: PresentationTheme
private let strings: PresentationStrings private let strings: PresentationStrings
private let addPhoto: () -> Void private let addPhoto: () -> Void
@ -63,7 +63,7 @@ final class AuthorizationSequenceSignUpControllerNode: ASDisplayNode, UITextFiel
} }
} }
init(theme: AuthorizationTheme, strings: PresentationStrings, addPhoto: @escaping () -> Void) { init(theme: PresentationTheme, strings: PresentationStrings, addPhoto: @escaping () -> Void) {
self.theme = theme self.theme = theme
self.strings = strings self.strings = strings
self.addPhoto = addPhoto self.addPhoto = addPhoto
@ -71,35 +71,35 @@ final class AuthorizationSequenceSignUpControllerNode: ASDisplayNode, UITextFiel
self.titleNode = ASTextNode() self.titleNode = ASTextNode()
self.titleNode.isUserInteractionEnabled = false self.titleNode.isUserInteractionEnabled = false
self.titleNode.displaysAsynchronously = false self.titleNode.displaysAsynchronously = false
self.titleNode.attributedText = NSAttributedString(string: self.strings.Login_InfoTitle, font: Font.light(30.0), textColor: theme.primaryColor) self.titleNode.attributedText = NSAttributedString(string: self.strings.Login_InfoTitle, font: Font.light(30.0), textColor: theme.list.itemPrimaryTextColor)
self.currentOptionNode = ASTextNode() self.currentOptionNode = ASTextNode()
self.currentOptionNode.isUserInteractionEnabled = false self.currentOptionNode.isUserInteractionEnabled = false
self.currentOptionNode.displaysAsynchronously = false self.currentOptionNode.displaysAsynchronously = false
self.currentOptionNode.attributedText = NSAttributedString(string: self.strings.Login_InfoHelp, font: Font.regular(16.0), textColor: theme.textPlaceholderColor, paragraphAlignment: .center) self.currentOptionNode.attributedText = NSAttributedString(string: self.strings.Login_InfoHelp, font: Font.regular(16.0), textColor: theme.list.itemPlaceholderTextColor, paragraphAlignment: .center)
self.termsNode = ImmediateTextNode() self.termsNode = ImmediateTextNode()
self.termsNode.textAlignment = .center self.termsNode.textAlignment = .center
self.termsNode.maximumNumberOfLines = 0 self.termsNode.maximumNumberOfLines = 0
self.termsNode.displaysAsynchronously = false self.termsNode.displaysAsynchronously = false
let body = MarkdownAttributeSet(font: Font.regular(16.0), textColor: theme.primaryColor) let body = MarkdownAttributeSet(font: Font.regular(16.0), textColor: theme.list.itemPrimaryTextColor)
let link = MarkdownAttributeSet(font: Font.regular(16.0), textColor: theme.accentColor, additionalAttributes: [TelegramTextAttributes.URL: ""]) let link = MarkdownAttributeSet(font: Font.regular(16.0), textColor: theme.list.itemAccentColor, additionalAttributes: [TelegramTextAttributes.URL: ""])
self.termsNode.attributedText = parseMarkdownIntoAttributedString(strings.Login_TermsOfServiceLabel.replacingOccurrences(of: "]", with: "]()"), attributes: MarkdownAttributes(body: body, bold: body, link: link, linkAttribute: { _ in nil }), textAlignment: .center) self.termsNode.attributedText = parseMarkdownIntoAttributedString(strings.Login_TermsOfServiceLabel.replacingOccurrences(of: "]", with: "]()"), attributes: MarkdownAttributes(body: body, bold: body, link: link, linkAttribute: { _ in nil }), textAlignment: .center)
self.firstSeparatorNode = ASDisplayNode() self.firstSeparatorNode = ASDisplayNode()
self.firstSeparatorNode.isLayerBacked = true self.firstSeparatorNode.isLayerBacked = true
self.firstSeparatorNode.backgroundColor = self.theme.separatorColor self.firstSeparatorNode.backgroundColor = self.theme.list.itemPlainSeparatorColor
self.lastSeparatorNode = ASDisplayNode() self.lastSeparatorNode = ASDisplayNode()
self.lastSeparatorNode.isLayerBacked = true self.lastSeparatorNode.isLayerBacked = true
self.lastSeparatorNode.backgroundColor = self.theme.separatorColor self.lastSeparatorNode.backgroundColor = self.theme.list.itemPlainSeparatorColor
self.firstNameField = TextFieldNode() self.firstNameField = TextFieldNode()
self.firstNameField.textField.font = Font.regular(20.0) self.firstNameField.textField.font = Font.regular(20.0)
self.firstNameField.textField.textColor = self.theme.primaryColor self.firstNameField.textField.textColor = self.theme.list.itemPrimaryTextColor
self.firstNameField.textField.textAlignment = .natural self.firstNameField.textField.textAlignment = .natural
self.firstNameField.textField.returnKeyType = .next self.firstNameField.textField.returnKeyType = .next
self.firstNameField.textField.attributedPlaceholder = NSAttributedString(string: self.strings.UserInfo_FirstNamePlaceholder, font: self.firstNameField.textField.font, textColor: self.theme.textPlaceholderColor) self.firstNameField.textField.attributedPlaceholder = NSAttributedString(string: self.strings.UserInfo_FirstNamePlaceholder, font: self.firstNameField.textField.font, textColor: self.theme.list.itemPlaceholderTextColor)
self.firstNameField.textField.autocapitalizationType = .words self.firstNameField.textField.autocapitalizationType = .words
self.firstNameField.textField.autocorrectionType = .no self.firstNameField.textField.autocorrectionType = .no
if #available(iOSApplicationExtension 10.0, *) { if #available(iOSApplicationExtension 10.0, *) {
@ -108,10 +108,10 @@ final class AuthorizationSequenceSignUpControllerNode: ASDisplayNode, UITextFiel
self.lastNameField = TextFieldNode() self.lastNameField = TextFieldNode()
self.lastNameField.textField.font = Font.regular(20.0) self.lastNameField.textField.font = Font.regular(20.0)
self.lastNameField.textField.textColor = self.theme.primaryColor self.lastNameField.textField.textColor = self.theme.list.itemPrimaryTextColor
self.lastNameField.textField.textAlignment = .natural self.lastNameField.textField.textAlignment = .natural
self.lastNameField.textField.returnKeyType = .done self.lastNameField.textField.returnKeyType = .done
self.lastNameField.textField.attributedPlaceholder = NSAttributedString(string: strings.UserInfo_LastNamePlaceholder, font: self.lastNameField.textField.font, textColor: self.theme.textPlaceholderColor) self.lastNameField.textField.attributedPlaceholder = NSAttributedString(string: strings.UserInfo_LastNamePlaceholder, font: self.lastNameField.textField.font, textColor: self.theme.list.itemPlaceholderTextColor)
self.lastNameField.textField.autocapitalizationType = .words self.lastNameField.textField.autocapitalizationType = .words
self.lastNameField.textField.autocorrectionType = .no self.lastNameField.textField.autocorrectionType = .no
if #available(iOSApplicationExtension 10.0, *) { if #available(iOSApplicationExtension 10.0, *) {
@ -124,8 +124,8 @@ final class AuthorizationSequenceSignUpControllerNode: ASDisplayNode, UITextFiel
self.currentPhotoNode.displayWithoutProcessing = true self.currentPhotoNode.displayWithoutProcessing = true
self.addPhotoButton = HighlightableButtonNode() self.addPhotoButton = HighlightableButtonNode()
self.addPhotoButton.setAttributedTitle(NSAttributedString(string: "\(self.strings.Login_InfoAvatarAdd)\n\(self.strings.Login_InfoAvatarPhoto)", font: Font.regular(16.0), textColor: self.theme.textPlaceholderColor, paragraphAlignment: .center), for: .normal) self.addPhotoButton.setAttributedTitle(NSAttributedString(string: "\(self.strings.Login_InfoAvatarAdd)\n\(self.strings.Login_InfoAvatarPhoto)", font: Font.regular(16.0), textColor: self.theme.list.itemPlaceholderTextColor, paragraphAlignment: .center), for: .normal)
self.addPhotoButton.setBackgroundImage(generateCircleImage(diameter: 110.0, lineWidth: 1.0, color: self.theme.textPlaceholderColor), for: .normal) self.addPhotoButton.setBackgroundImage(generateCircleImage(diameter: 110.0, lineWidth: 1.0, color: self.theme.list.itemPlaceholderTextColor), for: .normal)
self.addPhotoButton.addSubnode(self.currentPhotoNode) self.addPhotoButton.addSubnode(self.currentPhotoNode)
self.addPhotoButton.allowsGroupOpacity = true self.addPhotoButton.allowsGroupOpacity = true
@ -136,7 +136,7 @@ final class AuthorizationSequenceSignUpControllerNode: ASDisplayNode, UITextFiel
return UITracingLayerView() return UITracingLayerView()
}) })
self.backgroundColor = self.theme.backgroundColor self.backgroundColor = self.theme.list.plainBackgroundColor
self.firstNameField.textField.delegate = self self.firstNameField.textField.delegate = self
self.lastNameField.textField.delegate = self self.lastNameField.textField.delegate = self
@ -151,25 +151,9 @@ final class AuthorizationSequenceSignUpControllerNode: ASDisplayNode, UITextFiel
self.termsNode.isHidden = true self.termsNode.isHidden = true
self.addSubnode(self.addPhotoButton) self.addSubnode(self.addPhotoButton)
/*self.addPhotoButton.highligthedChanged = { [weak self] highlighted in
if let strongSelf = self {
if highlighted {
strongSelf.addPhotoButton.layer.removeAnimation(forKey: "opacity")
strongSelf.addPhotoButton.alpha = 0.4
strongSelf.currentPhotoNode.layer.removeAnimation(forKey: "opacity")
strongSelf.currentPhotoNode.alpha = 0.4
} else {
strongSelf.addPhotoButton.alpha = 1.0
strongSelf.addPhotoButton.layer.animateAlpha(from: 0.4, to: 1.0, duration: 0.2)
strongSelf.currentPhotoNode.alpha = 1.0
strongSelf.currentPhotoNode.layer.animateAlpha(from: 0.4, to: 1.0, duration: 0.2)
}
}
}*/
self.addPhotoButton.addTarget(self, action: #selector(self.addPhotoPressed), forControlEvents: .touchUpInside) self.addPhotoButton.addTarget(self, action: #selector(self.addPhotoPressed), forControlEvents: .touchUpInside)
self.termsNode.linkHighlightColor = self.theme.accentColor.withAlphaComponent(0.5) self.termsNode.linkHighlightColor = self.theme.list.itemAccentColor.withAlphaComponent(0.5)
self.termsNode.highlightAttributeAction = { attributes in self.termsNode.highlightAttributeAction = { attributes in
if let _ = attributes[NSAttributedStringKey(rawValue: TelegramTextAttributes.URL)] { if let _ = attributes[NSAttributedStringKey(rawValue: TelegramTextAttributes.URL)] {
return NSAttributedStringKey(rawValue: TelegramTextAttributes.URL) return NSAttributedStringKey(rawValue: TelegramTextAttributes.URL)
@ -186,8 +170,8 @@ final class AuthorizationSequenceSignUpControllerNode: ASDisplayNode, UITextFiel
func updateData(firstName: String, lastName: String, hasTermsOfService: Bool) { func updateData(firstName: String, lastName: String, hasTermsOfService: Bool) {
self.termsNode.isHidden = !hasTermsOfService self.termsNode.isHidden = !hasTermsOfService
self.firstNameField.textField.attributedPlaceholder = NSAttributedString(string: firstName, font: Font.regular(20.0), textColor: self.theme.textPlaceholderColor) self.firstNameField.textField.attributedPlaceholder = NSAttributedString(string: firstName, font: Font.regular(20.0), textColor: self.theme.list.itemPlaceholderTextColor)
self.lastNameField.textField.attributedPlaceholder = NSAttributedString(string: lastName, font: Font.regular(20.0), textColor: self.theme.textPlaceholderColor) self.lastNameField.textField.attributedPlaceholder = NSAttributedString(string: lastName, font: Font.regular(20.0), textColor: self.theme.list.itemPlaceholderTextColor)
if let (layout, navigationHeight) = self.layoutArguments { if let (layout, navigationHeight) = self.layoutArguments {
self.containerLayoutUpdated(layout, navigationBarHeight: navigationHeight, transition: .immediate) self.containerLayoutUpdated(layout, navigationBarHeight: navigationHeight, transition: .immediate)
@ -209,9 +193,9 @@ final class AuthorizationSequenceSignUpControllerNode: ASDisplayNode, UITextFiel
let availableHeight = max(1.0, layout.size.height - insets.top - insets.bottom) let availableHeight = max(1.0, layout.size.height - insets.top - insets.bottom)
if max(layout.size.width, layout.size.height) > 1023.0 { if max(layout.size.width, layout.size.height) > 1023.0 {
self.titleNode.attributedText = NSAttributedString(string: self.strings.Login_InfoTitle, font: Font.light(40.0), textColor: self.theme.primaryColor) self.titleNode.attributedText = NSAttributedString(string: self.strings.Login_InfoTitle, font: Font.light(40.0), textColor: self.theme.list.itemPrimaryTextColor)
} else { } else {
self.titleNode.attributedText = NSAttributedString(string: self.strings.Login_InfoTitle, font: Font.light(30.0), textColor: self.theme.primaryColor) self.titleNode.attributedText = NSAttributedString(string: self.strings.Login_InfoTitle, font: Font.light(30.0), textColor: self.theme.list.itemPrimaryTextColor)
} }
let titleSize = self.titleNode.measure(CGSize(width: layout.size.width, height: CGFloat.greatestFiniteMagnitude)) let titleSize = self.titleNode.measure(CGSize(width: layout.size.width, height: CGFloat.greatestFiniteMagnitude))

View File

@ -16,7 +16,7 @@ final class AuthorizationSequenceSplashController: ViewController {
private let accountManager: AccountManager private let accountManager: AccountManager
private let postbox: Postbox private let postbox: Postbox
private let network: Network private let network: Network
private let theme: AuthorizationTheme private let theme: PresentationTheme
private let controller: RMIntroViewController private let controller: RMIntroViewController
@ -25,7 +25,7 @@ final class AuthorizationSequenceSplashController: ViewController {
private let suggestedLocalization = Promise<SuggestedLocalizationInfo?>() private let suggestedLocalization = Promise<SuggestedLocalizationInfo?>()
private let activateLocalizationDisposable = MetaDisposable() private let activateLocalizationDisposable = MetaDisposable()
init(accountManager: AccountManager, postbox: Postbox, network: Network, theme: AuthorizationTheme) { init(accountManager: AccountManager, postbox: Postbox, network: Network, theme: PresentationTheme) {
self.accountManager = accountManager self.accountManager = accountManager
self.postbox = postbox self.postbox = postbox
self.network = network self.network = network
@ -66,13 +66,13 @@ final class AuthorizationSequenceSplashController: ViewController {
}) })
}) })
self.controller = RMIntroViewController(backroundColor: theme.backgroundColor, primaryColor: theme.primaryColor, buttonColor: theme.startButtonColor, accentColor: theme.accentColor, regularDotColor: theme.dotColor, highlightedDotColor: theme.primaryColor, suggestedLocalizationSignal: localizationSignal) self.controller = RMIntroViewController(backroundColor: theme.list.plainBackgroundColor, primaryColor: theme.list.itemPrimaryTextColor, buttonColor: theme.auth.introStartButton, accentColor: theme.list.itemAccentColor, regularDotColor: theme.auth.introDotColor, highlightedDotColor: theme.list.itemPrimaryTextColor, suggestedLocalizationSignal: localizationSignal)
super.init(navigationBarPresentationData: nil) super.init(navigationBarPresentationData: nil)
self.supportedOrientations = ViewControllerSupportedOrientations(regularSize: .all, compactSize: .portrait) self.supportedOrientations = ViewControllerSupportedOrientations(regularSize: .all, compactSize: .portrait)
self.statusBar.statusBarStyle = theme.statusBarStyle self.statusBar.statusBarStyle = theme.rootController.statusBar.style.style
self.controller.startMessaging = { [weak self] in self.controller.startMessaging = { [weak self] in
self?.activateLocalization("en") self?.activateLocalization("en")

View File

@ -3,14 +3,14 @@ import AsyncDisplayKit
import Display import Display
final class AuthorizationSequenceSplashControllerNode: ASDisplayNode { final class AuthorizationSequenceSplashControllerNode: ASDisplayNode {
init(theme: AuthorizationTheme) { init(theme: PresentationTheme) {
super.init() super.init()
self.setViewBlock({ self.setViewBlock({
return UITracingLayerView() return UITracingLayerView()
}) })
self.backgroundColor = theme.backgroundColor self.backgroundColor = theme.list.plainBackgroundColor
self.view.disablesInteractiveTransitionGestureRecognizer = true self.view.disablesInteractiveTransitionGestureRecognizer = true
} }

View File

@ -1,100 +0,0 @@
import Foundation
import UIKit
import Display
public final class AuthorizationTheme {
let statusBarStyle: StatusBarStyle
let navigationBarBackgroundColor: UIColor
let navigationBarTextColor: UIColor
let navigationBarSeparatorColor: UIColor
let searchBarBackgroundColor: UIColor
let searchBarFillColor: UIColor
let searchBarPlaceholderColor: UIColor
let searchBarTextColor: UIColor
let keyboard: PresentationThemeKeyboardColor
let backgroundColor: UIColor
let primaryColor: UIColor
let separatorColor: UIColor
let itemHighlightedBackgroundColor: UIColor
let dotColor: UIColor
let startButtonColor: UIColor
let accentColor: UIColor
let destructiveColor: UIColor
let disclosureControlColor: UIColor
let textPlaceholderColor: UIColor
let alertBackgroundColor: UIColor
let listBackgroundColor: UIColor
init(statusBarStyle: StatusBarStyle, navigationBarBackgroundColor: UIColor, navigationBarTextColor: UIColor, navigationBarSeparatorColor: UIColor, searchBarBackgroundColor: UIColor, searchBarFillColor: UIColor, searchBarPlaceholderColor: UIColor, searchBarTextColor: UIColor, keyboard: PresentationThemeKeyboardColor, backgroundColor: UIColor, primaryColor: UIColor, separatorColor: UIColor, itemHighlightedBackgroundColor: UIColor, dotColor: UIColor, startButtonColor: UIColor, accentColor: UIColor, destructiveColor: UIColor, disclosureControlColor: UIColor, textPlaceholderColor: UIColor, alertBackgroundColor: UIColor, listBackgroundColor: UIColor) {
self.statusBarStyle = statusBarStyle
self.navigationBarBackgroundColor = navigationBarBackgroundColor
self.navigationBarTextColor = navigationBarTextColor
self.navigationBarSeparatorColor = navigationBarSeparatorColor
self.searchBarBackgroundColor = searchBarBackgroundColor
self.searchBarFillColor = searchBarFillColor
self.searchBarPlaceholderColor = searchBarPlaceholderColor
self.searchBarTextColor = searchBarTextColor
self.keyboard = keyboard
self.backgroundColor = backgroundColor
self.primaryColor = primaryColor
self.separatorColor = separatorColor
self.itemHighlightedBackgroundColor = itemHighlightedBackgroundColor
self.dotColor = dotColor
self.startButtonColor = startButtonColor
self.accentColor = accentColor
self.destructiveColor = destructiveColor
self.disclosureControlColor = disclosureControlColor
self.textPlaceholderColor = textPlaceholderColor
self.alertBackgroundColor = alertBackgroundColor
self.listBackgroundColor = listBackgroundColor
}
}
let defaultLightAuthorizationTheme = AuthorizationTheme(
statusBarStyle: .Black,
navigationBarBackgroundColor: UIColor(red: 0.968626451, green: 0.968626451, blue: 0.968626451, alpha: 1.0),
navigationBarTextColor: .black,
navigationBarSeparatorColor: UIColor(red: 0.6953125, green: 0.6953125, blue: 0.6953125, alpha: 1.0),
searchBarBackgroundColor: .white,
searchBarFillColor: UIColor(rgb: 0xe9e9e9),
searchBarPlaceholderColor: UIColor(rgb: 0x8e8e93),
searchBarTextColor: .black,
keyboard: .light,
backgroundColor: .white,
primaryColor: .black,
separatorColor: UIColor(red: 0.6953125, green: 0.6953125, blue: 0.6953125, alpha: 1.0),
itemHighlightedBackgroundColor: UIColor(rgb: 0xd9d9d9),
dotColor: UIColor(rgb: 0xd9d9d9),
startButtonColor: UIColor(rgb: 0x2ca5e0),
accentColor: UIColor(rgb: 0x007ee5),
destructiveColor: UIColor(rgb: 0xff3b30),
disclosureControlColor: UIColor(rgb: 0xbab9be),
textPlaceholderColor: UIColor(rgb: 0x8e8e93),
alertBackgroundColor: .white,
listBackgroundColor: UIColor(rgb: 0xefeff4)
)
let defaultAuthorizationTheme = AuthorizationTheme(
statusBarStyle: .White,
navigationBarBackgroundColor: .black,
navigationBarTextColor: .white,
navigationBarSeparatorColor: UIColor(rgb: 0x252525),
searchBarBackgroundColor: .black,
searchBarFillColor: UIColor(rgb: 0x272728),
searchBarPlaceholderColor: UIColor(rgb: 0x5e5e5e),
searchBarTextColor: .white,
keyboard: .dark,
backgroundColor: .black,
primaryColor: .white,
separatorColor: UIColor(rgb: 0x252525),
itemHighlightedBackgroundColor: UIColor(rgb: 0x1b1b1b),
dotColor: UIColor(rgb: 0x717171),
startButtonColor: .white,
accentColor: .white,
destructiveColor: UIColor(rgb: 0xFF736B),
disclosureControlColor: UIColor(rgb: 0x717171),
textPlaceholderColor: UIColor(rgb: 0x4d4d4d),
alertBackgroundColor: UIColor(rgb: 0x1c1c1c),
listBackgroundColor: UIColor(rgb: 0xefeff4)
)

View File

@ -872,7 +872,7 @@ final class BotCheckoutControllerNode: ItemListControllerNode<BotCheckoutEntry>,
} }
return nil return nil
} }
let _ = (combineLatest(ApplicationSpecificNotice.getBotPaymentLiability(postbox: self.context.account.postbox, peerId: self.messageId.peerId), botPeer, self.context.account.postbox.loadedPeerWithId(paymentForm.providerId)) let _ = (combineLatest(ApplicationSpecificNotice.getBotPaymentLiability(accountManager: self.context.sharedContext.accountManager, peerId: self.messageId.peerId), botPeer, self.context.account.postbox.loadedPeerWithId(paymentForm.providerId))
|> deliverOnMainQueue).start(next: { [weak self] value, botPeer, providerPeer in |> deliverOnMainQueue).start(next: { [weak self] value, botPeer, providerPeer in
if let strongSelf = self, let botPeer = botPeer { if let strongSelf = self, let botPeer = botPeer {
if value { if value {
@ -880,7 +880,7 @@ final class BotCheckoutControllerNode: ItemListControllerNode<BotCheckoutEntry>,
} else { } else {
strongSelf.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: strongSelf.presentationData.theme), title: strongSelf.presentationData.strings.Checkout_LiabilityAlertTitle, text: strongSelf.presentationData.strings.Checkout_LiabilityAlert(botPeer.displayTitle, providerPeer.displayTitle).0, actions: [TextAlertAction(type: .genericAction, title: strongSelf.presentationData.strings.Common_Cancel, action: { }), TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: { strongSelf.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: strongSelf.presentationData.theme), title: strongSelf.presentationData.strings.Checkout_LiabilityAlertTitle, text: strongSelf.presentationData.strings.Checkout_LiabilityAlert(botPeer.displayTitle, providerPeer.displayTitle).0, actions: [TextAlertAction(type: .genericAction, title: strongSelf.presentationData.strings.Common_Cancel, action: { }), TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {
if let strongSelf = self { if let strongSelf = self {
let _ = ApplicationSpecificNotice.setBotPaymentLiability(postbox: strongSelf.context.account.postbox, peerId: strongSelf.messageId.peerId).start() let _ = ApplicationSpecificNotice.setBotPaymentLiability(accountManager: strongSelf.context.sharedContext.accountManager, peerId: strongSelf.messageId.peerId).start()
strongSelf.pay(savedCredentialsToken: savedCredentialsToken, liabilityNoticeAccepted: true) strongSelf.pay(savedCredentialsToken: savedCredentialsToken, liabilityNoticeAccepted: true)
} }
})]), nil) })]), nil)

View File

@ -73,7 +73,7 @@ final class BotCheckoutInfoController: ViewController {
self?.presentingViewController?.dismiss(animated: false, completion: nil) self?.presentingViewController?.dismiss(animated: false, completion: nil)
}, openCountrySelection: { [weak self] in }, openCountrySelection: { [weak self] in
if let strongSelf = self { if let strongSelf = self {
let controller = AuthorizationSequenceCountrySelectionController(strings: strongSelf.presentationData.strings, theme: AuthorizationSequenceCountrySelectionTheme(presentationTheme: strongSelf.presentationData.theme), displayCodes: false) let controller = AuthorizationSequenceCountrySelectionController(strings: strongSelf.presentationData.strings, theme: strongSelf.presentationData.theme, displayCodes: false)
controller.completeWithCountryCode = { _, id in controller.completeWithCountryCode = { _, id in
if let strongSelf = self { if let strongSelf = self {
strongSelf.controllerNode.updateCountry(id) strongSelf.controllerNode.updateCountry(id)

View File

@ -70,7 +70,7 @@ final class BotCheckoutNativeCardEntryController: ViewController {
self?.presentingViewController?.dismiss(animated: false, completion: nil) self?.presentingViewController?.dismiss(animated: false, completion: nil)
}, openCountrySelection: { [weak self] in }, openCountrySelection: { [weak self] in
if let strongSelf = self { if let strongSelf = self {
let controller = AuthorizationSequenceCountrySelectionController(strings: strongSelf.presentationData.strings, theme: AuthorizationSequenceCountrySelectionTheme(presentationTheme: strongSelf.presentationData.theme), displayCodes: false) let controller = AuthorizationSequenceCountrySelectionController(strings: strongSelf.presentationData.strings, theme: strongSelf.presentationData.theme, displayCodes: false)
controller.completeWithCountryCode = { _, id in controller.completeWithCountryCode = { _, id in
if let strongSelf = self { if let strongSelf = self {
strongSelf.controllerNode.updateCountry(id) strongSelf.controllerNode.updateCountry(id)

View File

@ -126,7 +126,7 @@ private struct ChangePhoneNumberCodeControllerState: Equatable {
} }
} }
private func changePhoneNumberCodeControllerEntries(presentationData: PresentationData, state: ChangePhoneNumberCodeControllerState, codeData: ChangeAccountPhoneNumberData, timeout: Int32?, strings: PresentationStrings, theme: AuthorizationTheme) -> [ChangePhoneNumberCodeEntry] { private func changePhoneNumberCodeControllerEntries(presentationData: PresentationData, state: ChangePhoneNumberCodeControllerState, codeData: ChangeAccountPhoneNumberData, timeout: Int32?, strings: PresentationStrings) -> [ChangePhoneNumberCodeEntry] {
var entries: [ChangePhoneNumberCodeEntry] = [] var entries: [ChangePhoneNumberCodeEntry] = []
entries.append(.codeEntry(presentationData.theme, presentationData.strings.ChangePhoneNumberCode_CodePlaceholder, state.codeText)) entries.append(.codeEntry(presentationData.theme, presentationData.strings.ChangePhoneNumberCode_CodePlaceholder, state.codeText))
@ -302,7 +302,7 @@ func changePhoneNumberCodeController(context: AccountContext, phoneNumber: Strin
} }
let controllerState = ItemListControllerState(theme: presentationData.theme, title: .text(formatPhoneNumber(phoneNumber)), leftNavigationButton: nil, rightNavigationButton: rightNavigationButton, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back), animateChanges: false) let controllerState = ItemListControllerState(theme: presentationData.theme, title: .text(formatPhoneNumber(phoneNumber)), leftNavigationButton: nil, rightNavigationButton: rightNavigationButton, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back), animateChanges: false)
let listState = ItemListNodeState(entries: changePhoneNumberCodeControllerEntries(presentationData: presentationData, state: state, codeData: data, timeout: timeout, strings: presentationData.strings, theme: defaultLightAuthorizationTheme), style: .blocks, focusItemTag: ChangePhoneNumberCodeTag.input, emptyStateItem: nil, animateChanges: false) let listState = ItemListNodeState(entries: changePhoneNumberCodeControllerEntries(presentationData: presentationData, state: state, codeData: data, timeout: timeout, strings: presentationData.strings), style: .blocks, focusItemTag: ChangePhoneNumberCodeTag.input, emptyStateItem: nil, animateChanges: false)
return (controllerState, (listState, arguments)) return (controllerState, (listState, arguments))
} |> afterDisposed { } |> afterDisposed {

View File

@ -66,7 +66,7 @@ final class ChangePhoneNumberController: ViewController {
self.displayNodeDidLoad() self.displayNodeDidLoad()
self.controllerNode.selectCountryCode = { [weak self] in self.controllerNode.selectCountryCode = { [weak self] in
if let strongSelf = self { if let strongSelf = self {
let controller = AuthorizationSequenceCountrySelectionController(strings: strongSelf.presentationData.strings, theme: AuthorizationSequenceCountrySelectionTheme(presentationTheme: strongSelf.presentationData.theme)) let controller = AuthorizationSequenceCountrySelectionController(strings: strongSelf.presentationData.strings, theme: strongSelf.presentationData.theme)
controller.completeWithCountryCode = { code, name in controller.completeWithCountryCode = { code, name in
if let strongSelf = self { if let strongSelf = self {
strongSelf.updateData(countryCode: Int32(code), countryName: name, number: strongSelf.controllerNode.codeAndNumber.2) strongSelf.updateData(countryCode: Int32(code), countryName: name, number: strongSelf.controllerNode.codeAndNumber.2)

View File

@ -969,7 +969,7 @@ public func channelVisibilityController(context: AccountContext, peerId: PeerId,
updateState { state in updateState { state in
return state.withUpdatedUpdatingAddressName(true) return state.withUpdatedUpdatingAddressName(true)
} }
_ = ApplicationSpecificNotice.markAsSeenSetPublicChannelLink(postbox: context.account.postbox).start() _ = ApplicationSpecificNotice.markAsSeenSetPublicChannelLink(accountManager: context.sharedContext.accountManager).start()
updateAddressNameDisposable.set((updateAddressName(account: context.account, domain: .peer(peerId), name: updatedAddressNameValue.isEmpty ? nil : updatedAddressNameValue) |> timeout(10, queue: Queue.mainQueue(), alternate: .fail(.generic)) updateAddressNameDisposable.set((updateAddressName(account: context.account, domain: .peer(peerId), name: updatedAddressNameValue.isEmpty ? nil : updatedAddressNameValue) |> timeout(10, queue: Queue.mainQueue(), alternate: .fail(.generic))
|> deliverOnMainQueue).start(error: { _ in |> deliverOnMainQueue).start(error: { _ in
@ -993,7 +993,7 @@ public func channelVisibilityController(context: AccountContext, peerId: PeerId,
} }
_ = (ApplicationSpecificNotice.getSetPublicChannelLink(postbox: context.account.postbox) |> deliverOnMainQueue).start(next: { showAlert in _ = (ApplicationSpecificNotice.getSetPublicChannelLink(accountManager: context.sharedContext.accountManager) |> deliverOnMainQueue).start(next: { showAlert in
if showAlert { if showAlert {
let confirm = standardTextAlertController(theme: AlertControllerTheme(presentationTheme: presentationData.theme), title: nil, text: presentationData.strings.Channel_Edit_PrivatePublicLinkAlert, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_Cancel, action: {}), TextAlertAction(type: .genericAction, title: presentationData.strings.Common_OK, action: invokeAction)]) let confirm = standardTextAlertController(theme: AlertControllerTheme(presentationTheme: presentationData.theme), title: nil, text: presentationData.strings.Channel_Edit_PrivatePublicLinkAlert, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_Cancel, action: {}), TextAlertAction(type: .genericAction, title: presentationData.strings.Common_OK, action: invokeAction)])
@ -1043,7 +1043,7 @@ public func channelVisibilityController(context: AccountContext, peerId: PeerId,
updateState { state in updateState { state in
return state.withUpdatedUpdatingAddressName(true) return state.withUpdatedUpdatingAddressName(true)
} }
_ = ApplicationSpecificNotice.markAsSeenSetPublicChannelLink(postbox: context.account.postbox).start() _ = ApplicationSpecificNotice.markAsSeenSetPublicChannelLink(accountManager: context.sharedContext.accountManager).start()
let signal = convertGroupToSupergroup(account: context.account, peerId: peerId) let signal = convertGroupToSupergroup(account: context.account, peerId: peerId)
|> map(Optional.init) |> map(Optional.init)
@ -1083,7 +1083,7 @@ public func channelVisibilityController(context: AccountContext, peerId: PeerId,
})) }))
} }
_ = (ApplicationSpecificNotice.getSetPublicChannelLink(postbox: context.account.postbox) |> deliverOnMainQueue).start(next: { showAlert in _ = (ApplicationSpecificNotice.getSetPublicChannelLink(accountManager: context.sharedContext.accountManager) |> deliverOnMainQueue).start(next: { showAlert in
if showAlert { if showAlert {
let confirm = standardTextAlertController(theme: AlertControllerTheme(presentationTheme: presentationData.theme), title: nil, text: presentationData.strings.Channel_Edit_PrivatePublicLinkAlert, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_Cancel, action: {}), TextAlertAction(type: .genericAction, title: presentationData.strings.Common_OK, action: invokeAction)]) let confirm = standardTextAlertController(theme: AlertControllerTheme(presentationTheme: presentationData.theme), title: nil, text: presentationData.strings.Channel_Edit_PrivatePublicLinkAlert, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_Cancel, action: {}), TextAlertAction(type: .genericAction, title: presentationData.strings.Common_OK, action: invokeAction)])

View File

@ -2672,7 +2672,7 @@ public final class ChatController: TelegramController, KeyShortcutResponder, Gal
}) })
if let updatedMode = updatedMode, updatedMode == .video { if let updatedMode = updatedMode, updatedMode == .video {
let _ = ApplicationSpecificNotice.incrementChatMediaMediaRecordingTips(postbox: strongSelf.context.account.postbox, count: 3).start() let _ = ApplicationSpecificNotice.incrementChatMediaMediaRecordingTips(accountManager: strongSelf.context.sharedContext.accountManager, count: 3).start()
} }
strongSelf.displayMediaRecordingTip() strongSelf.displayMediaRecordingTip()
@ -3292,7 +3292,7 @@ public final class ChatController: TelegramController, KeyShortcutResponder, Gal
canSendMedia = true canSendMedia = true
} }
if canSendMedia { if canSendMedia {
let _ = (ApplicationSpecificNotice.getChatMediaMediaRecordingTips(postbox: self.context.account.postbox) let _ = (ApplicationSpecificNotice.getChatMediaMediaRecordingTips(accountManager: self.context.sharedContext.accountManager)
|> deliverOnMainQueue).start(next: { [weak self] counter in |> deliverOnMainQueue).start(next: { [weak self] counter in
guard let strongSelf = self else { guard let strongSelf = self else {
return return
@ -3304,7 +3304,7 @@ public final class ChatController: TelegramController, KeyShortcutResponder, Gal
displayTip = true displayTip = true
} }
if displayTip { if displayTip {
let _ = ApplicationSpecificNotice.incrementChatMediaMediaRecordingTips(postbox: strongSelf.context.account.postbox).start() let _ = ApplicationSpecificNotice.incrementChatMediaMediaRecordingTips(accountManager: strongSelf.context.sharedContext.accountManager).start()
strongSelf.displayMediaRecordingTip() strongSelf.displayMediaRecordingTip()
} }
}) })
@ -3458,10 +3458,10 @@ public final class ChatController: TelegramController, KeyShortcutResponder, Gal
if case let .peer(peerId) = self.chatLocation, peerId.namespace == Namespaces.Peer.SecretChat { if case let .peer(peerId) = self.chatLocation, peerId.namespace == Namespaces.Peer.SecretChat {
if case .contextRequest = query { if case .contextRequest = query {
let _ = (ApplicationSpecificNotice.getSecretChatInlineBotUsage(postbox: self.context.account.postbox) let _ = (ApplicationSpecificNotice.getSecretChatInlineBotUsage(accountManager: self.context.sharedContext.accountManager)
|> deliverOnMainQueue).start(next: { [weak self] value in |> deliverOnMainQueue).start(next: { [weak self] value in
if let strongSelf = self, !value { if let strongSelf = self, !value {
let _ = ApplicationSpecificNotice.setSecretChatInlineBotUsage(postbox: strongSelf.context.account.postbox).start() let _ = ApplicationSpecificNotice.setSecretChatInlineBotUsage(accountManager: strongSelf.context.sharedContext.accountManager).start()
strongSelf.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: strongSelf.presentationData.theme), title: nil, text: strongSelf.presentationData.strings.Conversation_SecretChatContextBotAlert, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root)) strongSelf.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: strongSelf.presentationData.theme), title: nil, text: strongSelf.presentationData.strings.Conversation_SecretChatContextBotAlert, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root))
} }
}) })
@ -3502,7 +3502,7 @@ public final class ChatController: TelegramController, KeyShortcutResponder, Gal
var inScopeResult: ((TelegramMediaWebpage?) -> TelegramMediaWebpage?)? var inScopeResult: ((TelegramMediaWebpage?) -> TelegramMediaWebpage?)?
let linkPreviews: Signal<Bool, NoError> let linkPreviews: Signal<Bool, NoError>
if case let .peer(peerId) = self.chatLocation, peerId.namespace == Namespaces.Peer.SecretChat { if case let .peer(peerId) = self.chatLocation, peerId.namespace == Namespaces.Peer.SecretChat {
linkPreviews = interactiveChatLinkPreviewsEnabled(postbox: self.context.account.postbox, displayAlert: { [weak self] f in linkPreviews = interactiveChatLinkPreviewsEnabled(accountManager: self.context.sharedContext.accountManager, displayAlert: { [weak self] f in
if let strongSelf = self { if let strongSelf = self {
strongSelf.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: strongSelf.presentationData.theme), title: nil, text: strongSelf.presentationData.strings.Conversation_SecretLinkPreviewAlert, actions: [ strongSelf.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: strongSelf.presentationData.theme), title: nil, text: strongSelf.presentationData.strings.Conversation_SecretLinkPreviewAlert, actions: [
TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_Yes, action: { TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_Yes, action: {

View File

@ -10,8 +10,8 @@ final class InteractiveChatLinkPreviewsResult {
} }
} }
func interactiveChatLinkPreviewsEnabled(postbox: Postbox, displayAlert: @escaping (InteractiveChatLinkPreviewsResult) -> Void) -> Signal<Bool, NoError> { func interactiveChatLinkPreviewsEnabled(accountManager: AccountManager, displayAlert: @escaping (InteractiveChatLinkPreviewsResult) -> Void) -> Signal<Bool, NoError> {
return ApplicationSpecificNotice.getSecretChatLinkPreviews(postbox: postbox) return ApplicationSpecificNotice.getSecretChatLinkPreviews(accountManager: accountManager)
|> mapToSignal { value -> Signal<Bool, NoError> in |> mapToSignal { value -> Signal<Bool, NoError> in
if let value = value { if let value = value {
return .single(value) return .single(value)
@ -19,7 +19,7 @@ func interactiveChatLinkPreviewsEnabled(postbox: Postbox, displayAlert: @escapin
return Signal { subscriber in return Signal { subscriber in
Queue.mainQueue().async { Queue.mainQueue().async {
displayAlert(InteractiveChatLinkPreviewsResult({ result in displayAlert(InteractiveChatLinkPreviewsResult({ result in
let _ = ApplicationSpecificNotice.setSecretChatLinkPreviews(postbox: postbox, value: result).start() let _ = ApplicationSpecificNotice.setSecretChatLinkPreviews(accountManager: accountManager, value: result).start()
subscriber.putNext(result) subscriber.putNext(result)
subscriber.putCompletion() subscriber.putCompletion()
})) }))

View File

@ -468,7 +468,7 @@ public class ChatListController: TelegramController, KeyShortcutResponder, UIVie
if let strongSelf = self { if let strongSelf = self {
if let navigationController = strongSelf.navigationController as? NavigationController { if let navigationController = strongSelf.navigationController as? NavigationController {
if isAd { if isAd {
let _ = (ApplicationSpecificNotice.getProxyAdsAcknowledgment(postbox: strongSelf.context.account.postbox) let _ = (ApplicationSpecificNotice.getProxyAdsAcknowledgment(accountManager: strongSelf.context.sharedContext.accountManager)
|> deliverOnMainQueue).start(next: { value in |> deliverOnMainQueue).start(next: { value in
guard let strongSelf = self else { guard let strongSelf = self else {
return return
@ -476,7 +476,7 @@ public class ChatListController: TelegramController, KeyShortcutResponder, UIVie
if !value { if !value {
strongSelf.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: strongSelf.presentationData.theme), title: nil, text: strongSelf.presentationData.strings.DialogList_AdNoticeAlert, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: { strongSelf.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: strongSelf.presentationData.theme), title: nil, text: strongSelf.presentationData.strings.DialogList_AdNoticeAlert, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {
if let strongSelf = self { if let strongSelf = self {
let _ = ApplicationSpecificNotice.setProxyAdsAcknowledgment(postbox: strongSelf.context.account.postbox).start() let _ = ApplicationSpecificNotice.setProxyAdsAcknowledgment(accountManager: strongSelf.context.sharedContext.accountManager).start()
} }
})]), in: .window(.root)) })]), in: .window(.root))
} }
@ -685,12 +685,12 @@ public class ChatListController: TelegramController, KeyShortcutResponder, UIVie
} }
if let lockViewFrame = self.titleView.lockViewFrame, !self.didShowPasscodeLockTooltipController { if let lockViewFrame = self.titleView.lockViewFrame, !self.didShowPasscodeLockTooltipController {
self.passcodeLockTooltipDisposable.set(combineLatest(queue: .mainQueue(), ApplicationSpecificNotice.getPasscodeLockTips(postbox: self.context.account.postbox), self.context.sharedContext.accountManager.accessChallengeData() |> take(1)).start(next: { [weak self] tooltipValue, passcodeView in self.passcodeLockTooltipDisposable.set(combineLatest(queue: .mainQueue(), ApplicationSpecificNotice.getPasscodeLockTips(accountManager: self.context.sharedContext.accountManager), self.context.sharedContext.accountManager.accessChallengeData() |> take(1)).start(next: { [weak self] tooltipValue, passcodeView in
if let strongSelf = self { if let strongSelf = self {
if !tooltipValue { if !tooltipValue {
let hasPasscode = passcodeView.data.isLockable let hasPasscode = passcodeView.data.isLockable
if hasPasscode { if hasPasscode {
let _ = ApplicationSpecificNotice.setPasscodeLockTips(postbox: strongSelf.context.account.postbox).start() let _ = ApplicationSpecificNotice.setPasscodeLockTips(accountManager: strongSelf.context.sharedContext.accountManager).start()
let tooltipController = TooltipController(text: strongSelf.presentationData.strings.DialogList_PasscodeLockHelp, dismissByTapOutside: true) let tooltipController = TooltipController(text: strongSelf.presentationData.strings.DialogList_PasscodeLockHelp, dismissByTapOutside: true)
strongSelf.present(tooltipController, in: .window(.root), with: TooltipControllerPresentationArguments(sourceViewAndRect: { [weak self] in strongSelf.present(tooltipController, in: .window(.root), with: TooltipControllerPresentationArguments(sourceViewAndRect: { [weak self] in

View File

@ -45,10 +45,6 @@ public extension AlertControllerTheme {
let actionSheet = presentationTheme.actionSheet let actionSheet = presentationTheme.actionSheet
self.init(backgroundColor: actionSheet.opaqueItemBackgroundColor, separatorColor: actionSheet.opaqueItemSeparatorColor, highlightedItemColor: actionSheet.opaqueItemHighlightedBackgroundColor, primaryColor: actionSheet.primaryTextColor, secondaryColor: actionSheet.secondaryTextColor, accentColor: actionSheet.controlAccentColor, destructiveColor: actionSheet.destructiveActionTextColor) self.init(backgroundColor: actionSheet.opaqueItemBackgroundColor, separatorColor: actionSheet.opaqueItemSeparatorColor, highlightedItemColor: actionSheet.opaqueItemHighlightedBackgroundColor, primaryColor: actionSheet.primaryTextColor, secondaryColor: actionSheet.secondaryTextColor, accentColor: actionSheet.controlAccentColor, destructiveColor: actionSheet.destructiveActionTextColor)
} }
convenience init(authTheme: AuthorizationTheme) {
self.init(backgroundColor: authTheme.alertBackgroundColor, separatorColor: authTheme.separatorColor, highlightedItemColor: authTheme.itemHighlightedBackgroundColor, primaryColor: authTheme.primaryColor, secondaryColor: authTheme.textPlaceholderColor, accentColor: authTheme.accentColor, destructiveColor: authTheme.destructiveColor)
}
} }
extension PeekControllerTheme { extension PeekControllerTheme {

View File

@ -112,7 +112,7 @@ private struct ConfirmPhoneNumberCodeControllerState: Equatable {
} }
} }
private func confirmPhoneNumberCodeControllerEntries(presentationData: PresentationData, state: ConfirmPhoneNumberCodeControllerState, phoneNumber: String, codeData: CancelAccountResetData, timeout: Int32?, strings: PresentationStrings, theme: AuthorizationTheme) -> [ConfirmPhoneNumberCodeEntry] { private func confirmPhoneNumberCodeControllerEntries(presentationData: PresentationData, state: ConfirmPhoneNumberCodeControllerState, phoneNumber: String, codeData: CancelAccountResetData, timeout: Int32?, strings: PresentationStrings, theme: PresentationTheme) -> [ConfirmPhoneNumberCodeEntry] {
var entries: [ConfirmPhoneNumberCodeEntry] = [] var entries: [ConfirmPhoneNumberCodeEntry] = []
entries.append(.codeEntry(presentationData.theme, presentationData.strings.ChangePhoneNumberCode_CodePlaceholder, state.codeText)) entries.append(.codeEntry(presentationData.theme, presentationData.strings.ChangePhoneNumberCode_CodePlaceholder, state.codeText))
@ -301,7 +301,7 @@ func confirmPhoneNumberCodeController(context: AccountContext, phoneNumber: Stri
} }
let controllerState = ItemListControllerState(theme: presentationData.theme, title: .text(presentationData.strings.CancelResetAccount_Title), leftNavigationButton: leftNavigationButton, rightNavigationButton: rightNavigationButton, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back), animateChanges: false) let controllerState = ItemListControllerState(theme: presentationData.theme, title: .text(presentationData.strings.CancelResetAccount_Title), leftNavigationButton: leftNavigationButton, rightNavigationButton: rightNavigationButton, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back), animateChanges: false)
let listState = ItemListNodeState(entries: confirmPhoneNumberCodeControllerEntries(presentationData: presentationData, state: state, phoneNumber: phoneNumber, codeData: data, timeout: timeout, strings: presentationData.strings, theme: defaultLightAuthorizationTheme), style: .blocks, focusItemTag: ConfirmPhoneNumberCodeTag.input, emptyStateItem: nil, animateChanges: false) let listState = ItemListNodeState(entries: confirmPhoneNumberCodeControllerEntries(presentationData: presentationData, state: state, phoneNumber: phoneNumber, codeData: data, timeout: timeout, strings: presentationData.strings, theme: presentationData.theme), style: .blocks, focusItemTag: ConfirmPhoneNumberCodeTag.input, emptyStateItem: nil, animateChanges: false)
return (controllerState, (listState, arguments)) return (controllerState, (listState, arguments))
} }

View File

@ -816,15 +816,14 @@ final class ContactListNode: ASDisplayNode {
contactsAuthorization.set(.single(.allowed) contactsAuthorization.set(.single(.allowed)
|> then(DeviceAccess.authorizationStatus(context: context, subject: .contacts))) |> then(DeviceAccess.authorizationStatus(context: context, subject: .contacts)))
let warningKey = PostboxViewKey.noticeEntry(ApplicationSpecificNotice.contactsPermissionWarningKey())
let contactsWarningSuppressed = Promise<(Bool, Bool)>() let contactsWarningSuppressed = Promise<(Bool, Bool)>()
contactsWarningSuppressed.set(.single((false, false)) contactsWarningSuppressed.set(.single((false, false))
|> then( |> then(
combineLatest(context.account.postbox.combinedView(keys: [warningKey]), context.sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.contactSynchronizationSettings])) combineLatest(context.sharedContext.accountManager.noticeEntry(key: ApplicationSpecificNotice.contactsPermissionWarningKey()), context.sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.contactSynchronizationSettings]))
|> map { combined, sharedData -> (Bool, Bool) in |> map { noticeView, sharedData -> (Bool, Bool) in
let synchronizeDeviceContacts: Bool = (sharedData.entries[ApplicationSpecificSharedDataKeys.contactSynchronizationSettings] as? ContactSynchronizationSettings)?.synchronizeDeviceContacts ?? true let synchronizeDeviceContacts: Bool = (sharedData.entries[ApplicationSpecificSharedDataKeys.contactSynchronizationSettings] as? ContactSynchronizationSettings)?.synchronizeDeviceContacts ?? true
let suppressed: Bool let suppressed: Bool
let timestamp = (combined.views[warningKey] as? NoticeEntryView)?.value.flatMap({ ApplicationSpecificNotice.getTimestampValue($0) }) let timestamp = noticeView.value.flatMap({ ApplicationSpecificNotice.getTimestampValue($0) })
if let timestamp = timestamp, timestamp > 0 { if let timestamp = timestamp, timestamp > 0 {
suppressed = true suppressed = true
} else { } else {

View File

@ -119,16 +119,15 @@ public class ContactsController: ViewController {
}) })
if #available(iOSApplicationExtension 10.0, *) { if #available(iOSApplicationExtension 10.0, *) {
let warningKey = PostboxViewKey.noticeEntry(ApplicationSpecificNotice.contactsPermissionWarningKey()) self.authorizationDisposable = (combineLatest(DeviceAccess.authorizationStatus(context: context, subject: .contacts), combineLatest(context.sharedContext.accountManager.noticeEntry(key: ApplicationSpecificNotice.contactsPermissionWarningKey()), context.sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.contactSynchronizationSettings]))
self.authorizationDisposable = (combineLatest(DeviceAccess.authorizationStatus(context: context, subject: .contacts), combineLatest(context.account.postbox.combinedView(keys: [warningKey]), context.sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.contactSynchronizationSettings])) |> map { noticeView, sharedData -> (Bool, ContactsSortOrder) in
|> map { combined, sharedData -> (Bool, ContactsSortOrder) in
let settings = sharedData.entries[ApplicationSpecificSharedDataKeys.contactSynchronizationSettings] as? ContactSynchronizationSettings let settings = sharedData.entries[ApplicationSpecificSharedDataKeys.contactSynchronizationSettings] as? ContactSynchronizationSettings
let synchronizeDeviceContacts: Bool = settings?.synchronizeDeviceContacts ?? true let synchronizeDeviceContacts: Bool = settings?.synchronizeDeviceContacts ?? true
let sortOrder: ContactsSortOrder = settings?.sortOrder ?? .presence let sortOrder: ContactsSortOrder = settings?.sortOrder ?? .presence
if !synchronizeDeviceContacts { if !synchronizeDeviceContacts {
return (true, sortOrder) return (true, sortOrder)
} }
let timestamp = (combined.views[warningKey] as? NoticeEntryView)?.value.flatMap({ ApplicationSpecificNotice.getTimestampValue($0) }) let timestamp = noticeView.value.flatMap({ ApplicationSpecificNotice.getTimestampValue($0) })
if let timestamp = timestamp, timestamp > 0 { if let timestamp = timestamp, timestamp > 0 {
return (true, sortOrder) return (true, sortOrder)
} else { } else {

View File

@ -368,7 +368,7 @@ public func dataPrivacyController(context: AccountContext) -> ViewController {
]) ])
presentControllerImpl?(controller) presentControllerImpl?(controller)
}, updateSecretChatLinkPreviews: { value in }, updateSecretChatLinkPreviews: { value in
let _ = ApplicationSpecificNotice.setSecretChatLinkPreviews(postbox: context.account.postbox, value: value).start() let _ = ApplicationSpecificNotice.setSecretChatLinkPreviews(accountManager: context.sharedContext.accountManager, value: value).start()
}, deleteContacts: { }, deleteContacts: {
var canBegin = false var canBegin = false
updateState { state in updateState { state in
@ -477,9 +477,9 @@ public func dataPrivacyController(context: AccountContext) -> ViewController {
actionsDisposable.add(managedUpdatedRecentPeers(accountPeerId: context.account.peerId, postbox: context.account.postbox, network: context.account.network).start()) actionsDisposable.add(managedUpdatedRecentPeers(accountPeerId: context.account.peerId, postbox: context.account.postbox, network: context.account.network).start())
let signal = combineLatest(queue: .mainQueue(), context.sharedContext.presentationData, statePromise.get(), context.account.postbox.combinedView(keys: [.noticeEntry(ApplicationSpecificNotice.secretChatLinkPreviewsKey())]), context.sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.contactSynchronizationSettings]), recentPeers(account: context.account)) let signal = combineLatest(queue: .mainQueue(), context.sharedContext.presentationData, statePromise.get(), context.sharedContext.accountManager.noticeEntry(key: ApplicationSpecificNotice.secretChatLinkPreviewsKey()), context.sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.contactSynchronizationSettings]), recentPeers(account: context.account))
|> map { presentationData, state, combined, sharedData, recentPeers -> (ItemListControllerState, (ItemListNodeState<PrivacyAndSecurityEntry>, PrivacyAndSecurityEntry.ItemGenerationArguments)) in |> map { presentationData, state, noticeView, sharedData, recentPeers -> (ItemListControllerState, (ItemListNodeState<PrivacyAndSecurityEntry>, PrivacyAndSecurityEntry.ItemGenerationArguments)) in
let secretChatLinkPreviews = (combined.views[.noticeEntry(ApplicationSpecificNotice.secretChatLinkPreviewsKey())] as? NoticeEntryView)?.value.flatMap({ ApplicationSpecificNotice.getSecretChatLinkPreviews($0) }) let secretChatLinkPreviews = noticeView.value.flatMap({ ApplicationSpecificNotice.getSecretChatLinkPreviews($0) })
let synchronizeDeviceContacts: Bool = (sharedData.entries[ApplicationSpecificSharedDataKeys.contactSynchronizationSettings] as? ContactSynchronizationSettings)?.synchronizeDeviceContacts ?? true let synchronizeDeviceContacts: Bool = (sharedData.entries[ApplicationSpecificSharedDataKeys.contactSynchronizationSettings] as? ContactSynchronizationSettings)?.synchronizeDeviceContacts ?? true

View File

@ -47,6 +47,11 @@ private let activeNavigationSearchBar = PresentationThemeActiveNavigationSearchB
separatorColor: UIColor(rgb: 0x18222C) separatorColor: UIColor(rgb: 0x18222C)
) )
private let auth = PresentationThemeAuth(
introStartButton: accentColor,
introDotColor: UIColor(rgb: 0x8B9197)
)
private let rootController = PresentationThemeRootController( private let rootController = PresentationThemeRootController(
statusBar: rootStatusBar, statusBar: rootStatusBar,
tabBar: rootTabBar, tabBar: rootTabBar,
@ -314,6 +319,7 @@ let defaultDarkAccentPresentationTheme = PresentationTheme(
name: .builtin(.nightAccent), name: .builtin(.nightAccent),
overallDarkAppearance: true, overallDarkAppearance: true,
allowsCustomWallpapers: false, allowsCustomWallpapers: false,
auth: auth,
rootController: rootController, rootController: rootController,
list: list, list: list,
chatList: chatList, chatList: chatList,

View File

@ -47,6 +47,11 @@ private let activeNavigationSearchBar = PresentationThemeActiveNavigationSearchB
separatorColor: UIColor(rgb: 0x000000) separatorColor: UIColor(rgb: 0x000000)
) )
private let auth = PresentationThemeAuth(
introStartButton: accentColor,
introDotColor: UIColor(rgb: 0x5e5e5e)
)
private let rootController = PresentationThemeRootController( private let rootController = PresentationThemeRootController(
statusBar: rootStatusBar, statusBar: rootStatusBar,
tabBar: rootTabBar, tabBar: rootTabBar,
@ -314,6 +319,7 @@ let defaultDarkPresentationTheme = PresentationTheme(
name: .builtin(.nightGrayscale), name: .builtin(.nightGrayscale),
overallDarkAppearance: true, overallDarkAppearance: true,
allowsCustomWallpapers: false, allowsCustomWallpapers: false,
auth: auth,
rootController: rootController, rootController: rootController,
list: list, list: list,
chatList: chatList, chatList: chatList,

View File

@ -47,6 +47,11 @@ private func makeDefaultPresentationTheme(accentColor: UIColor, serviceBackgroun
separatorColor: UIColor(red: 0.6953125, green: 0.6953125, blue: 0.6953125, alpha: 1.0) separatorColor: UIColor(red: 0.6953125, green: 0.6953125, blue: 0.6953125, alpha: 1.0)
) )
let auth = PresentationThemeAuth(
introStartButton: UIColor(rgb: 0x2ca5e0),
introDotColor: UIColor(rgb: 0xd9d9d9)
)
let rootController = PresentationThemeRootController( let rootController = PresentationThemeRootController(
statusBar: rootStatusBar, statusBar: rootStatusBar,
tabBar: rootTabBar, tabBar: rootTabBar,
@ -418,6 +423,7 @@ private func makeDefaultPresentationTheme(accentColor: UIColor, serviceBackgroun
name: .builtin(day ? .day : .dayClassic), name: .builtin(day ? .day : .dayClassic),
overallDarkAppearance: false, overallDarkAppearance: false,
allowsCustomWallpapers: true, allowsCustomWallpapers: true,
auth: auth,
rootController: rootController, rootController: rootController,
list: list, list: list,
chatList: day ? chatListDay : chatList, chatList: day ? chatListDay : chatList,

View File

@ -291,6 +291,7 @@ class GalleryController: ViewController {
var temporaryDoNotWaitForReady = false var temporaryDoNotWaitForReady = false
private let accountInUseDisposable = MetaDisposable()
private let disposable = MetaDisposable() private let disposable = MetaDisposable()
private var entries: [MessageHistoryEntry] = [] private var entries: [MessageHistoryEntry] = []
@ -692,6 +693,7 @@ class GalleryController: ViewController {
} }
deinit { deinit {
self.accountInUseDisposable.dispose()
self.disposable.dispose() self.disposable.dispose()
self.centralItemAttributesDisposable.dispose() self.centralItemAttributesDisposable.dispose()
if let hiddenMediaManagerIndex = self.hiddenMediaManagerIndex { if let hiddenMediaManagerIndex = self.hiddenMediaManagerIndex {
@ -887,6 +889,14 @@ class GalleryController: ViewController {
} }
} }
} }
self.accountInUseDisposable.set(self.context.sharedContext.setAccountUserInterfaceInUse(self.context.account.id))
}
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
self.accountInUseDisposable.set(nil)
} }
override func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) { override func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {

View File

@ -66,7 +66,7 @@ public final class MediaManager: NSObject {
private let inForeground: Signal<Bool, NoError> private let inForeground: Signal<Bool, NoError>
public let audioSession: ManagedAudioSession public let audioSession: ManagedAudioSession
let overlayMediaManager = OverlayMediaManager() public let overlayMediaManager = OverlayMediaManager()
let sharedVideoContextManager = SharedVideoContextManager() let sharedVideoContextManager = SharedVideoContextManager()
private var nextPlayerIndex: Int32 = 0 private var nextPlayerIndex: Int32 = 0

View File

@ -90,7 +90,7 @@ public func isInlineControllerForChatNotificationOverlayPresentation(_ controlle
} }
public func isOverlayControllerForChatNotificationOverlayPresentation(_ controller: ContainableController) -> Bool { public func isOverlayControllerForChatNotificationOverlayPresentation(_ controller: ContainableController) -> Bool {
if controller is GalleryController || controller is AvatarGalleryController || controller is WallpaperGalleryController || controller is InstantPageGalleryController || controller is InstantVideoController { if controller is GalleryController || controller is AvatarGalleryController || controller is WallpaperGalleryController || controller is InstantPageGalleryController || controller is InstantVideoController || controller is NavigationController {
return true return true
} }

View File

@ -179,9 +179,9 @@ private struct ApplicationSpecificNoticeKeys {
} }
public struct ApplicationSpecificNotice { public struct ApplicationSpecificNotice {
static func getBotPaymentLiability(postbox: Postbox, peerId: PeerId) -> Signal<Bool, NoError> { static func getBotPaymentLiability(accountManager: AccountManager, peerId: PeerId) -> Signal<Bool, NoError> {
return postbox.transaction { transaction -> Bool in return accountManager.transaction { transaction -> Bool in
if let _ = transaction.getNoticeEntry(key: ApplicationSpecificNoticeKeys.botPaymentLiabilityNotice(peerId: peerId)) as? ApplicationSpecificBoolNotice { if let _ = transaction.getNotice(ApplicationSpecificNoticeKeys.botPaymentLiabilityNotice(peerId: peerId)) as? ApplicationSpecificBoolNotice {
return true return true
} else { } else {
return false return false
@ -189,15 +189,15 @@ public struct ApplicationSpecificNotice {
} }
} }
static func setBotPaymentLiability(postbox: Postbox, peerId: PeerId) -> Signal<Void, NoError> { static func setBotPaymentLiability(accountManager: AccountManager, peerId: PeerId) -> Signal<Void, NoError> {
return postbox.transaction { transaction -> Void in return accountManager.transaction { transaction -> Void in
transaction.setNoticeEntry(key: ApplicationSpecificNoticeKeys.botPaymentLiabilityNotice(peerId: peerId), value: ApplicationSpecificBoolNotice()) transaction.setNotice(ApplicationSpecificNoticeKeys.botPaymentLiabilityNotice(peerId: peerId), ApplicationSpecificBoolNotice())
} }
} }
static func getSecretChatInlineBotUsage(postbox: Postbox) -> Signal<Bool, NoError> { static func getSecretChatInlineBotUsage(accountManager: AccountManager) -> Signal<Bool, NoError> {
return postbox.transaction { transaction -> Bool in return accountManager.transaction { transaction -> Bool in
if let _ = transaction.getNoticeEntry(key: ApplicationSpecificNoticeKeys.secretChatInlineBotUsage()) as? ApplicationSpecificBoolNotice { if let _ = transaction.getNotice(ApplicationSpecificNoticeKeys.secretChatInlineBotUsage()) as? ApplicationSpecificBoolNotice {
return true return true
} else { } else {
return false return false
@ -205,19 +205,19 @@ public struct ApplicationSpecificNotice {
} }
} }
static func setSecretChatInlineBotUsage(postbox: Postbox) -> Signal<Void, NoError> { static func setSecretChatInlineBotUsage(accountManager: AccountManager) -> Signal<Void, NoError> {
return postbox.transaction { transaction -> Void in return accountManager.transaction { transaction -> Void in
transaction.setNoticeEntry(key: ApplicationSpecificNoticeKeys.secretChatInlineBotUsage(), value: ApplicationSpecificBoolNotice()) transaction.setNotice(ApplicationSpecificNoticeKeys.secretChatInlineBotUsage(), ApplicationSpecificBoolNotice())
} }
} }
public static func setSecretChatInlineBotUsage(transaction: Transaction) { public static func setSecretChatInlineBotUsage(transaction: AccountManagerModifier) {
transaction.setNoticeEntry(key: ApplicationSpecificNoticeKeys.secretChatInlineBotUsage(), value: ApplicationSpecificBoolNotice()) transaction.setNotice(ApplicationSpecificNoticeKeys.secretChatInlineBotUsage(), ApplicationSpecificBoolNotice())
} }
static func getSecretChatLinkPreviews(postbox: Postbox) -> Signal<Bool?, NoError> { static func getSecretChatLinkPreviews(accountManager: AccountManager) -> Signal<Bool?, NoError> {
return postbox.transaction { transaction -> Bool? in return accountManager.transaction { transaction -> Bool? in
if let value = transaction.getNoticeEntry(key: ApplicationSpecificNoticeKeys.secretChatLinkPreviews()) as? ApplicationSpecificVariantNotice { if let value = transaction.getNotice(ApplicationSpecificNoticeKeys.secretChatLinkPreviews()) as? ApplicationSpecificVariantNotice {
return value.value return value.value
} else { } else {
return nil return nil
@ -233,23 +233,23 @@ public struct ApplicationSpecificNotice {
} }
} }
static func setSecretChatLinkPreviews(postbox: Postbox, value: Bool) -> Signal<Void, NoError> { static func setSecretChatLinkPreviews(accountManager: AccountManager, value: Bool) -> Signal<Void, NoError> {
return postbox.transaction { transaction -> Void in return accountManager.transaction { transaction -> Void in
transaction.setNoticeEntry(key: ApplicationSpecificNoticeKeys.secretChatLinkPreviews(), value: ApplicationSpecificVariantNotice(value: value)) transaction.setNotice(ApplicationSpecificNoticeKeys.secretChatLinkPreviews(), ApplicationSpecificVariantNotice(value: value))
} }
} }
public static func setSecretChatLinkPreviews(transaction: Transaction, value: Bool) { public static func setSecretChatLinkPreviews(transaction: AccountManagerModifier, value: Bool) {
transaction.setNoticeEntry(key: ApplicationSpecificNoticeKeys.secretChatLinkPreviews(), value: ApplicationSpecificVariantNotice(value: value)) transaction.setNotice(ApplicationSpecificNoticeKeys.secretChatLinkPreviews(), ApplicationSpecificVariantNotice(value: value))
} }
static func secretChatLinkPreviewsKey() -> NoticeEntryKey { static func secretChatLinkPreviewsKey() -> NoticeEntryKey {
return ApplicationSpecificNoticeKeys.secretChatLinkPreviews() return ApplicationSpecificNoticeKeys.secretChatLinkPreviews()
} }
static func getChatMediaMediaRecordingTips(postbox: Postbox) -> Signal<Int32, NoError> { static func getChatMediaMediaRecordingTips(accountManager: AccountManager) -> Signal<Int32, NoError> {
return postbox.transaction { transaction -> Int32 in return accountManager.transaction { transaction -> Int32 in
if let value = transaction.getNoticeEntry(key: ApplicationSpecificNoticeKeys.chatMediaMediaRecordingTips()) as? ApplicationSpecificCounterNotice { if let value = transaction.getNotice(ApplicationSpecificNoticeKeys.chatMediaMediaRecordingTips()) as? ApplicationSpecificCounterNotice {
return value.value return value.value
} else { } else {
return 0 return 0
@ -257,21 +257,21 @@ public struct ApplicationSpecificNotice {
} }
} }
static func incrementChatMediaMediaRecordingTips(postbox: Postbox, count: Int32 = 1) -> Signal<Void, NoError> { static func incrementChatMediaMediaRecordingTips(accountManager: AccountManager, count: Int32 = 1) -> Signal<Void, NoError> {
return postbox.transaction { transaction -> Void in return accountManager.transaction { transaction -> Void in
var currentValue: Int32 = 0 var currentValue: Int32 = 0
if let value = transaction.getNoticeEntry(key: ApplicationSpecificNoticeKeys.chatMediaMediaRecordingTips()) as? ApplicationSpecificCounterNotice { if let value = transaction.getNotice(ApplicationSpecificNoticeKeys.chatMediaMediaRecordingTips()) as? ApplicationSpecificCounterNotice {
currentValue = value.value currentValue = value.value
} }
currentValue += count currentValue += count
transaction.setNoticeEntry(key: ApplicationSpecificNoticeKeys.chatMediaMediaRecordingTips(), value: ApplicationSpecificCounterNotice(value: currentValue)) transaction.setNotice(ApplicationSpecificNoticeKeys.chatMediaMediaRecordingTips(), ApplicationSpecificCounterNotice(value: currentValue))
} }
} }
static func getProfileCallTips(postbox: Postbox) -> Signal<Int32, NoError> { static func getProfileCallTips(accountManager: AccountManager) -> Signal<Int32, NoError> {
return postbox.transaction { transaction -> Int32 in return accountManager.transaction { transaction -> Int32 in
if let value = transaction.getNoticeEntry(key: ApplicationSpecificNoticeKeys.profileCallTips()) as? ApplicationSpecificCounterNotice { if let value = transaction.getNotice(ApplicationSpecificNoticeKeys.profileCallTips()) as? ApplicationSpecificCounterNotice {
return value.value return value.value
} else { } else {
return 0 return 0
@ -279,21 +279,21 @@ public struct ApplicationSpecificNotice {
} }
} }
static func incrementProfileCallTips(postbox: Postbox, count: Int32 = 1) -> Signal<Void, NoError> { static func incrementProfileCallTips(accountManager: AccountManager, count: Int32 = 1) -> Signal<Void, NoError> {
return postbox.transaction { transaction -> Void in return accountManager.transaction { transaction -> Void in
var currentValue: Int32 = 0 var currentValue: Int32 = 0
if let value = transaction.getNoticeEntry(key: ApplicationSpecificNoticeKeys.profileCallTips()) as? ApplicationSpecificCounterNotice { if let value = transaction.getNotice(ApplicationSpecificNoticeKeys.profileCallTips()) as? ApplicationSpecificCounterNotice {
currentValue = value.value currentValue = value.value
} }
currentValue += count currentValue += count
transaction.setNoticeEntry(key: ApplicationSpecificNoticeKeys.profileCallTips(), value: ApplicationSpecificCounterNotice(value: currentValue)) transaction.setNotice(ApplicationSpecificNoticeKeys.profileCallTips(), ApplicationSpecificCounterNotice(value: currentValue))
} }
} }
static func getSetPublicChannelLink(postbox: Postbox) -> Signal<Bool, NoError> { static func getSetPublicChannelLink(accountManager: AccountManager) -> Signal<Bool, NoError> {
return postbox.transaction { transaction -> Bool in return accountManager.transaction { transaction -> Bool in
if let value = transaction.getNoticeEntry(key: ApplicationSpecificNoticeKeys.profileCallTips()) as? ApplicationSpecificCounterNotice { if let value = transaction.getNotice(ApplicationSpecificNoticeKeys.profileCallTips()) as? ApplicationSpecificCounterNotice {
return value.value < 1 return value.value < 1
} else { } else {
return true return true
@ -301,15 +301,15 @@ public struct ApplicationSpecificNotice {
} }
} }
static func markAsSeenSetPublicChannelLink(postbox: Postbox) -> Signal<Void, NoError> { static func markAsSeenSetPublicChannelLink(accountManager: AccountManager) -> Signal<Void, NoError> {
return postbox.transaction { transaction -> Void in return accountManager.transaction { transaction -> Void in
transaction.setNoticeEntry(key: ApplicationSpecificNoticeKeys.profileCallTips(), value: ApplicationSpecificCounterNotice(value: 1)) transaction.setNotice(ApplicationSpecificNoticeKeys.profileCallTips(), ApplicationSpecificCounterNotice(value: 1))
} }
} }
static func getProxyAdsAcknowledgment(postbox: Postbox) -> Signal<Bool, NoError> { static func getProxyAdsAcknowledgment(accountManager: AccountManager) -> Signal<Bool, NoError> {
return postbox.transaction { transaction -> Bool in return accountManager.transaction { transaction -> Bool in
if let _ = transaction.getNoticeEntry(key: ApplicationSpecificNoticeKeys.proxyAdsAcknowledgment()) as? ApplicationSpecificBoolNotice { if let _ = transaction.getNotice(ApplicationSpecificNoticeKeys.proxyAdsAcknowledgment()) as? ApplicationSpecificBoolNotice {
return true return true
} else { } else {
return false return false
@ -317,15 +317,15 @@ public struct ApplicationSpecificNotice {
} }
} }
static func setProxyAdsAcknowledgment(postbox: Postbox) -> Signal<Void, NoError> { static func setProxyAdsAcknowledgment(accountManager: AccountManager) -> Signal<Void, NoError> {
return postbox.transaction { transaction -> Void in return accountManager.transaction { transaction -> Void in
transaction.setNoticeEntry(key: ApplicationSpecificNoticeKeys.proxyAdsAcknowledgment(), value: ApplicationSpecificBoolNotice()) transaction.setNotice(ApplicationSpecificNoticeKeys.proxyAdsAcknowledgment(), ApplicationSpecificBoolNotice())
} }
} }
static func getPasscodeLockTips(postbox: Postbox) -> Signal<Bool, NoError> { static func getPasscodeLockTips(accountManager: AccountManager) -> Signal<Bool, NoError> {
return postbox.transaction { transaction -> Bool in return accountManager.transaction { transaction -> Bool in
if let _ = transaction.getNoticeEntry(key: ApplicationSpecificNoticeKeys.passcodeLockTips()) as? ApplicationSpecificBoolNotice { if let _ = transaction.getNotice(ApplicationSpecificNoticeKeys.passcodeLockTips()) as? ApplicationSpecificBoolNotice {
return true return true
} else { } else {
return false return false
@ -333,9 +333,9 @@ public struct ApplicationSpecificNotice {
} }
} }
static func setPasscodeLockTips(postbox: Postbox) -> Signal<Void, NoError> { static func setPasscodeLockTips(accountManager: AccountManager) -> Signal<Void, NoError> {
return postbox.transaction { transaction -> Void in return accountManager.transaction { transaction -> Void in
transaction.setNoticeEntry(key: ApplicationSpecificNoticeKeys.passcodeLockTips(), value: ApplicationSpecificBoolNotice()) transaction.setNotice(ApplicationSpecificNoticeKeys.passcodeLockTips(), ApplicationSpecificBoolNotice())
} }
} }
@ -343,9 +343,9 @@ public struct ApplicationSpecificNotice {
return ApplicationSpecificNoticeKeys.contactsPermissionWarning() return ApplicationSpecificNoticeKeys.contactsPermissionWarning()
} }
public static func setContactsPermissionWarning(postbox: Postbox, value: Int32) { public static func setContactsPermissionWarning(accountManager: AccountManager, value: Int32) {
let _ = postbox.transaction { transaction -> Void in let _ = accountManager.transaction { transaction -> Void in
transaction.setNoticeEntry(key: ApplicationSpecificNoticeKeys.contactsPermissionWarning(), value: ApplicationSpecificTimestampNotice(value: value)) transaction.setNotice(ApplicationSpecificNoticeKeys.contactsPermissionWarning(), ApplicationSpecificTimestampNotice(value: value))
}.start() }.start()
} }
@ -361,15 +361,14 @@ public struct ApplicationSpecificNotice {
} }
} }
public static func setNotificationsPermissionWarning(postbox: Postbox, value: Int32) { public static func setNotificationsPermissionWarning(accountManager: AccountManager, value: Int32) {
let _ = postbox.transaction { transaction -> Void in let _ = accountManager.transaction { transaction -> Void in
transaction.setNoticeEntry(key: ApplicationSpecificNoticeKeys.notificationsPermissionWarning(), value: ApplicationSpecificTimestampNotice(value: value)) transaction.setNotice(ApplicationSpecificNoticeKeys.notificationsPermissionWarning(), ApplicationSpecificTimestampNotice(value: value))
}.start() }.start()
} }
static func reset(postbox: Postbox) -> Signal<Void, NoError> { static func reset(accountManager: AccountManager) -> Signal<Void, NoError> {
return postbox.transaction { transaction -> Void in return accountManager.transaction { transaction -> Void in
} }
} }
} }

View File

@ -703,7 +703,7 @@ public func notificationsAndSoundsController(context: AccountContext, exceptions
case .denied, .restricted: case .denied, .restricted:
context.sharedContext.applicationBindings.openSettings() context.sharedContext.applicationBindings.openSettings()
case .unreachable: case .unreachable:
ApplicationSpecificNotice.setNotificationsPermissionWarning(postbox: context.account.postbox, value: Int32(Date().timeIntervalSince1970)) ApplicationSpecificNotice.setNotificationsPermissionWarning(accountManager: context.sharedContext.accountManager, value: Int32(Date().timeIntervalSince1970))
context.sharedContext.applicationBindings.openSettings() context.sharedContext.applicationBindings.openSettings()
default: default:
break break
@ -712,7 +712,7 @@ public func notificationsAndSoundsController(context: AccountContext, exceptions
}, suppressWarning: { }, suppressWarning: {
let presentationData = context.sharedContext.currentPresentationData.with { $0 } let presentationData = context.sharedContext.currentPresentationData.with { $0 }
presentControllerImpl?(textAlertController(context: context, title: presentationData.strings.Notifications_PermissionsSuppressWarningTitle, text: presentationData.strings.Notifications_PermissionsSuppressWarningText, actions: [TextAlertAction(type: .genericAction, title: presentationData.strings.Notifications_PermissionsKeepDisabled, action: { presentControllerImpl?(textAlertController(context: context, title: presentationData.strings.Notifications_PermissionsSuppressWarningTitle, text: presentationData.strings.Notifications_PermissionsSuppressWarningText, actions: [TextAlertAction(type: .genericAction, title: presentationData.strings.Notifications_PermissionsKeepDisabled, action: {
ApplicationSpecificNotice.setNotificationsPermissionWarning(postbox: context.account.postbox, value: Int32(Date().timeIntervalSince1970)) ApplicationSpecificNotice.setNotificationsPermissionWarning(accountManager: context.sharedContext.accountManager, value: Int32(Date().timeIntervalSince1970))
}), TextAlertAction(type: .defaultAction, title: presentationData.strings.Notifications_PermissionsEnable, action: { }), TextAlertAction(type: .defaultAction, title: presentationData.strings.Notifications_PermissionsEnable, action: {
context.sharedContext.applicationBindings.openSettings() context.sharedContext.applicationBindings.openSettings()
})]), nil) })]), nil)
@ -910,11 +910,11 @@ public func notificationsAndSoundsController(context: AccountContext, exceptions
let notificationsWarningSuppressed = Promise<Bool>(true) let notificationsWarningSuppressed = Promise<Bool>(true)
if #available(iOSApplicationExtension 10.0, *) { if #available(iOSApplicationExtension 10.0, *) {
let warningKey = PostboxViewKey.noticeEntry(ApplicationSpecificNotice.notificationsPermissionWarningKey())
notificationsWarningSuppressed.set(.single(true) notificationsWarningSuppressed.set(.single(true)
|> then(context.account.postbox.combinedView(keys: [warningKey]) |> then(
|> map { combined -> Bool in context.sharedContext.accountManager.noticeEntry(key: ApplicationSpecificNotice.notificationsPermissionWarningKey())
let timestamp = (combined.views[warningKey] as? NoticeEntryView)?.value.flatMap({ ApplicationSpecificNotice.getTimestampValue($0) }) |> map { noticeView -> Bool in
let timestamp = noticeView.value.flatMap({ ApplicationSpecificNotice.getTimestampValue($0) })
if let timestamp = timestamp, timestamp > 0 { if let timestamp = timestamp, timestamp > 0 {
return true return true
} else { } else {

View File

@ -1,9 +1,9 @@
import Foundation import Foundation
final class OverlayMediaManager { public final class OverlayMediaManager {
var controller: OverlayMediaController? public var controller: OverlayMediaController?
func attachOverlayMediaController(_ controller: OverlayMediaController) { public func attachOverlayMediaController(_ controller: OverlayMediaController) {
self.controller = controller self.controller = controller
} }
} }

View File

@ -11,6 +11,16 @@ public final class PresentationThemeColorPlaceholder {
} }
public final class PresentationThemeAuth {
public let introStartButton: UIColor
public let introDotColor: UIColor
public init(introStartButton: UIColor, introDotColor: UIColor) {
self.introStartButton = introStartButton
self.introDotColor = introDotColor
}
}
public final class PresentationThemeRootTabBar { public final class PresentationThemeRootTabBar {
public let backgroundColor: UIColor public let backgroundColor: UIColor
public let separatorColor: UIColor public let separatorColor: UIColor
@ -880,6 +890,7 @@ public final class PresentationTheme: Equatable {
public let name: PresentationThemeName public let name: PresentationThemeName
public let overallDarkAppearance: Bool public let overallDarkAppearance: Bool
public let allowsCustomWallpapers: Bool public let allowsCustomWallpapers: Bool
public let auth: PresentationThemeAuth
public let rootController: PresentationThemeRootController public let rootController: PresentationThemeRootController
public let list: PresentationThemeList public let list: PresentationThemeList
public let chatList: PresentationThemeChatList public let chatList: PresentationThemeChatList
@ -889,10 +900,11 @@ public final class PresentationTheme: Equatable {
public let resourceCache: PresentationsResourceCache = PresentationsResourceCache() public let resourceCache: PresentationsResourceCache = PresentationsResourceCache()
public init(name: PresentationThemeName, overallDarkAppearance: Bool, allowsCustomWallpapers: Bool, rootController: PresentationThemeRootController, list: PresentationThemeList, chatList: PresentationThemeChatList, chat: PresentationThemeChat, actionSheet: PresentationThemeActionSheet, inAppNotification: PresentationThemeInAppNotification) { public init(name: PresentationThemeName, overallDarkAppearance: Bool, allowsCustomWallpapers: Bool, auth: PresentationThemeAuth, rootController: PresentationThemeRootController, list: PresentationThemeList, chatList: PresentationThemeChatList, chat: PresentationThemeChat, actionSheet: PresentationThemeActionSheet, inAppNotification: PresentationThemeInAppNotification) {
self.name = name self.name = name
self.overallDarkAppearance = overallDarkAppearance self.overallDarkAppearance = overallDarkAppearance
self.allowsCustomWallpapers = allowsCustomWallpapers self.allowsCustomWallpapers = allowsCustomWallpapers
self.auth = auth
self.rootController = rootController self.rootController = rootController
self.list = list self.list = list
self.chatList = chatList self.chatList = chatList

View File

@ -527,8 +527,8 @@ public func privacyAndSecurityController(context: AccountContext, initialSetting
actionsDisposable.add(managedUpdatedRecentPeers(accountPeerId: context.account.peerId, postbox: context.account.postbox, network: context.account.network).start()) actionsDisposable.add(managedUpdatedRecentPeers(accountPeerId: context.account.peerId, postbox: context.account.postbox, network: context.account.network).start())
let signal = combineLatest(context.sharedContext.presentationData, statePromise.get() |> deliverOnMainQueue, privacySettingsPromise.get(), context.account.postbox.combinedView(keys: [.noticeEntry(ApplicationSpecificNotice.secretChatLinkPreviewsKey())]), context.sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.contactSynchronizationSettings]), recentPeers(account: context.account)) let signal = combineLatest(queue: .mainQueue(), context.sharedContext.presentationData, statePromise.get(), privacySettingsPromise.get(), context.sharedContext.accountManager.noticeEntry(key: ApplicationSpecificNotice.secretChatLinkPreviewsKey()), context.sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.contactSynchronizationSettings]), recentPeers(account: context.account))
|> map { presentationData, state, privacySettings, combined, sharedData, recentPeers -> (ItemListControllerState, (ItemListNodeState<PrivacyAndSecurityEntry>, PrivacyAndSecurityEntry.ItemGenerationArguments)) in |> map { presentationData, state, privacySettings, noticeView, sharedData, recentPeers -> (ItemListControllerState, (ItemListNodeState<PrivacyAndSecurityEntry>, PrivacyAndSecurityEntry.ItemGenerationArguments)) in
var rightNavigationButton: ItemListNavigationButton? var rightNavigationButton: ItemListNavigationButton?
if privacySettings == nil || state.updatingAccountTimeoutValue != nil { if privacySettings == nil || state.updatingAccountTimeoutValue != nil {
rightNavigationButton = ItemListNavigationButton(content: .none, style: .activity, enabled: true, action: {}) rightNavigationButton = ItemListNavigationButton(content: .none, style: .activity, enabled: true, action: {})

View File

@ -2285,7 +2285,7 @@ final class SecureIdDocumentFormControllerNode: FormControllerNode<SecureIdDocum
if let strongSelf = self { if let strongSelf = self {
switch field { switch field {
case .country: case .country:
let controller = AuthorizationSequenceCountrySelectionController(strings: strongSelf.strings, theme: AuthorizationSequenceCountrySelectionTheme(presentationTheme: strongSelf.theme), displayCodes: false) let controller = AuthorizationSequenceCountrySelectionController(strings: strongSelf.strings, theme: strongSelf.theme, displayCodes: false)
controller.completeWithCountryCode = { _, id in controller.completeWithCountryCode = { _, id in
if let strongSelf = self, var innerState = strongSelf.innerState { if let strongSelf = self, var innerState = strongSelf.innerState {
innerState.documentState.updateCountryCode(value: id) innerState.documentState.updateCountryCode(value: id)
@ -2311,7 +2311,7 @@ final class SecureIdDocumentFormControllerNode: FormControllerNode<SecureIdDocum
strongSelf.view.endEditing(true) strongSelf.view.endEditing(true)
strongSelf.present(controller, ViewControllerPresentationArguments(presentationAnimation: .modalSheet)) strongSelf.present(controller, ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
case .residenceCountry: case .residenceCountry:
let controller = AuthorizationSequenceCountrySelectionController(strings: strongSelf.strings, theme: AuthorizationSequenceCountrySelectionTheme(presentationTheme: strongSelf.theme), displayCodes: false) let controller = AuthorizationSequenceCountrySelectionController(strings: strongSelf.strings, theme: strongSelf.theme, displayCodes: false)
controller.completeWithCountryCode = { _, id in controller.completeWithCountryCode = { _, id in
if let strongSelf = self, var innerState = strongSelf.innerState { if let strongSelf = self, var innerState = strongSelf.innerState {
innerState.documentState.updateResidenceCountryCode(value: id) innerState.documentState.updateResidenceCountryCode(value: id)

View File

@ -657,7 +657,7 @@ final class SecureIdPlaintextFormControllerNode: FormControllerNode<SecureIdPlai
guard let strongSelf = self else { guard let strongSelf = self else {
return return
} }
let controller = AuthorizationSequenceCountrySelectionController(strings: strongSelf.strings, theme: AuthorizationSequenceCountrySelectionTheme(presentationTheme: strongSelf.theme), displayCodes: true) let controller = AuthorizationSequenceCountrySelectionController(strings: strongSelf.strings, theme: strongSelf.theme, displayCodes: true)
controller.completeWithCountryCode = { code, _ in controller.completeWithCountryCode = { code, _ in
if let strongSelf = self, var innerState = strongSelf.innerState { if let strongSelf = self, var innerState = strongSelf.innerState {
innerState.data.updateTextField(type: .countryCode, value: "+\(code)") innerState.data.updateTextField(type: .countryCode, value: "+\(code)")

View File

@ -608,7 +608,7 @@ public func settingsController(context: AccountContext, accountManager: AccountM
} }
} }
} }
for (_, account) in activeAccounts { for (_, account, _) in activeAccounts {
accounts.append(accountWithPeer(account)) accounts.append(accountWithPeer(account))
} }
@ -1057,15 +1057,14 @@ public func settingsController(context: AccountContext, accountManager: AccountM
let notificationsWarningSuppressed = Promise<Bool>(true) let notificationsWarningSuppressed = Promise<Bool>(true)
if #available(iOSApplicationExtension 10.0, *) { if #available(iOSApplicationExtension 10.0, *) {
let warningKey = PostboxViewKey.noticeEntry(ApplicationSpecificNotice.notificationsPermissionWarningKey())
notificationsWarningSuppressed.set( notificationsWarningSuppressed.set(
.single(true) .single(true)
|> then( |> then(
contextValue.get() contextValue.get()
|> mapToSignal { context -> Signal<Bool, NoError> in |> mapToSignal { context -> Signal<Bool, NoError> in
return context.account.postbox.combinedView(keys: [warningKey]) return context.sharedContext.accountManager.noticeEntry(key: ApplicationSpecificNotice.notificationsPermissionWarningKey())
|> map { combined -> Bool in |> map { noticeView -> Bool in
let timestamp = (combined.views[warningKey] as? NoticeEntryView)?.value.flatMap({ ApplicationSpecificNotice.getTimestampValue($0) }) let timestamp = noticeView.value.flatMap({ ApplicationSpecificNotice.getTimestampValue($0) })
if let timestamp = timestamp, timestamp > 0 { if let timestamp = timestamp, timestamp > 0 {
return true return true
} else { } else {

View File

@ -549,7 +549,7 @@ public final class ShareController: ViewController {
} }
var items: [ActionSheetItem] = [] var items: [ActionSheetItem] = []
for info in strongSelf.switchableAccounts { for info in strongSelf.switchableAccounts {
items.append(ActionSheetPeerItem(account: info.account, peer: info.peer, title: info.peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), strings: presentationData.strings, theme: presentationData.theme, action: { [weak self] in items.append(ActionSheetPeerItem(account: info.account, peer: info.peer, title: info.peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), isSelected: info.account.id == strongSelf.currentAccount.id, strings: presentationData.strings, theme: presentationData.theme, action: { [weak self] in
dismissAction() dismissAction()
self?.switchToAccount(account: info.account, animateIn: true) self?.switchToAccount(account: info.account, animateIn: true)
})) }))
@ -557,6 +557,7 @@ public final class ShareController: ViewController {
controller.setItemGroups([ controller.setItemGroups([
ActionSheetItemGroup(items: items) ActionSheetItemGroup(items: items)
]) ])
strongSelf.view.endEditing(true)
strongSelf.present(controller, in: .window(.root), with: ViewControllerPresentationArguments(presentationAnimation: .modalSheet)) strongSelf.present(controller, in: .window(.root), with: ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
} }
self.displayNodeDidLoad() self.displayNodeDidLoad()

View File

@ -38,6 +38,11 @@ public final class AccountWithInfo: Equatable {
} }
} }
private struct AccountAttributes: Equatable {
let sortIndex: Int32
let isTestingEnvironment: Bool
}
public final class SharedAccountContext { public final class SharedAccountContext {
let mainWindow: Window1? let mainWindow: Window1?
public let applicationBindings: TelegramApplicationBindings public let applicationBindings: TelegramApplicationBindings
@ -48,13 +53,13 @@ public final class SharedAccountContext {
private let apsNotificationToken: Signal<Data?, NoError> private let apsNotificationToken: Signal<Data?, NoError>
private let voipNotificationToken: Signal<Data?, NoError> private let voipNotificationToken: Signal<Data?, NoError>
private var activeAccountsValue: (primary: Account?, accounts: [AccountRecordId: Account], currentAuth: UnauthorizedAccount?)? private var activeAccountsValue: (primary: Account?, accounts: [(AccountRecordId, Account, Int32)], currentAuth: UnauthorizedAccount?)?
private let activeAccountsPromise = Promise<(primary: Account?, accounts: [AccountRecordId: Account], currentAuth: UnauthorizedAccount?)>() private let activeAccountsPromise = Promise<(primary: Account?, accounts: [(AccountRecordId, Account, Int32)], currentAuth: UnauthorizedAccount?)>()
public var activeAccounts: Signal<(primary: Account?, accounts: [AccountRecordId: Account], currentAuth: UnauthorizedAccount?), NoError> { public var activeAccounts: Signal<(primary: Account?, accounts: [(AccountRecordId, Account, Int32)], currentAuth: UnauthorizedAccount?), NoError> {
return self.activeAccountsPromise.get() return self.activeAccountsPromise.get()
} }
private let activeAccountsWithInfoPromise = Promise<(primary: AccountRecordId?, accounts: [AccountRecordId: AccountWithInfo])>() private let activeAccountsWithInfoPromise = Promise<(primary: AccountRecordId?, accounts: [AccountWithInfo])>()
public var activeAccountsWithInfo: Signal<(primary: AccountRecordId?, accounts: [AccountRecordId: AccountWithInfo]), NoError> { public var activeAccountsWithInfo: Signal<(primary: AccountRecordId?, accounts: [AccountWithInfo]), NoError> {
return self.activeAccountsWithInfoPromise.get() return self.activeAccountsWithInfoPromise.get()
} }
@ -231,8 +236,8 @@ public final class SharedAccountContext {
let differenceDisposable = MetaDisposable() let differenceDisposable = MetaDisposable()
let _ = (accountManager.accountRecords() let _ = (accountManager.accountRecords()
|> map { view -> (AccountRecordId?, [AccountRecordId: Bool], (AccountRecordId, Bool)?) in |> map { view -> (AccountRecordId?, [AccountRecordId: AccountAttributes], (AccountRecordId, Bool)?) in
var result: [AccountRecordId: Bool] = [:] var result: [AccountRecordId: AccountAttributes] = [:]
for record in view.records { for record in view.records {
let isLoggedOut = record.attributes.contains(where: { attribute in let isLoggedOut = record.attributes.contains(where: { attribute in
return attribute is LoggedOutAccountAttribute return attribute is LoggedOutAccountAttribute
@ -247,7 +252,13 @@ public final class SharedAccountContext {
return false return false
} }
}) })
result[record.id] = isTestingEnvironment var sortIndex: Int32 = 0
for attribute in record.attributes {
if let attribute = attribute as? AccountSortOrderAttribute {
sortIndex = attribute.order
}
}
result[record.id] = AccountAttributes(sortIndex: sortIndex, isTestingEnvironment: isTestingEnvironment)
} }
let authRecord: (AccountRecordId, Bool)? = view.currentAuthAccount.flatMap({ authAccount in let authRecord: (AccountRecordId, Bool)? = view.currentAuthAccount.flatMap({ authAccount in
let isTestingEnvironment = authAccount.attributes.contains(where: { attribute in let isTestingEnvironment = authAccount.attributes.contains(where: { attribute in
@ -277,17 +288,17 @@ public final class SharedAccountContext {
return true return true
}) })
|> deliverOnMainQueue).start(next: { primaryId, records, authRecord in |> deliverOnMainQueue).start(next: { primaryId, records, authRecord in
var addedSignals: [Signal<(AccountRecordId, Account?), NoError>] = [] var addedSignals: [Signal<(AccountRecordId, Account?, Int32), NoError>] = []
var addedAuthSignal: Signal<UnauthorizedAccount?, NoError> = .single(nil) var addedAuthSignal: Signal<UnauthorizedAccount?, NoError> = .single(nil)
for (id, isTestingEnvironment) in records { for (id, attributes) in records {
if self.activeAccountsValue?.accounts[id] == nil { if self.activeAccountsValue?.accounts.firstIndex(where: { $0.0 == id}) == nil {
addedSignals.append(accountWithId(accountManager: accountManager, networkArguments: networkArguments, id: id, supplementary: false, rootPath: rootPath, beginWithTestingEnvironment: isTestingEnvironment, auxiliaryMethods: telegramAccountAuxiliaryMethods) addedSignals.append(accountWithId(accountManager: accountManager, networkArguments: networkArguments, id: id, supplementary: false, rootPath: rootPath, beginWithTestingEnvironment: attributes.isTestingEnvironment, auxiliaryMethods: telegramAccountAuxiliaryMethods)
|> map { result -> (AccountRecordId, Account?) in |> map { result -> (AccountRecordId, Account?, Int32) in
switch result { switch result {
case let .authorized(account): case let .authorized(account):
return (id, account) return (id, account, attributes.sortIndex)
default: default:
return (id, nil) return (id, nil, attributes.sortIndex)
} }
}) })
} }
@ -307,37 +318,45 @@ public final class SharedAccountContext {
|> deliverOnMainQueue).start(next: { accounts, authAccount in |> deliverOnMainQueue).start(next: { accounts, authAccount in
var hadUpdates = false var hadUpdates = false
if self.activeAccountsValue == nil { if self.activeAccountsValue == nil {
self.activeAccountsValue = (nil, [:], nil) self.activeAccountsValue = (nil, [], nil)
hadUpdates = true hadUpdates = true
} }
for account in accounts { for accountRecord in accounts {
if let account = account.1 { if let account = accountRecord.1 {
self.activeAccountsValue!.accounts[account.id] = account if let index = self.activeAccountsValue?.accounts.firstIndex(where: { $0.0 == account.id }) {
self.activeAccountsValue?.accounts.remove(at: index)
assertionFailure()
}
self.activeAccountsValue!.accounts.append((account.id, account, accountRecord.2))
hadUpdates = true hadUpdates = true
} else { } else {
let _ = accountManager.transaction({ transaction in let _ = accountManager.transaction({ transaction in
transaction.updateRecord(account.0, { _ in transaction.updateRecord(accountRecord.0, { _ in
return nil return nil
}) })
}).start() }).start()
} }
} }
var removedIds: [AccountRecordId] = [] var removedIds: [AccountRecordId] = []
for id in self.activeAccountsValue!.accounts.keys { for id in self.activeAccountsValue!.accounts.map({ $0.0 }) {
if records[id] == nil { if records[id] == nil {
removedIds.append(id) removedIds.append(id)
} }
} }
for id in removedIds { for id in removedIds {
hadUpdates = true hadUpdates = true
self.activeAccountsValue!.accounts.removeValue(forKey: id) if let index = self.activeAccountsValue?.accounts.firstIndex(where: { $0.0 == id }) {
self.activeAccountsValue?.accounts.remove(at: index)
}
} }
var primary: Account? var primary: Account?
if let primaryId = primaryId { if let primaryId = primaryId {
primary = self.activeAccountsValue!.accounts[primaryId] if let index = self.activeAccountsValue?.accounts.firstIndex(where: { $0.0 == primaryId }) {
primary = self.activeAccountsValue?.accounts[index].1
}
} }
if primary == nil && !self.activeAccountsValue!.accounts.isEmpty { if primary == nil && !self.activeAccountsValue!.accounts.isEmpty {
primary = self.activeAccountsValue!.accounts.sorted(by: { lhs, rhs in lhs.key < rhs.key }).first?.1 primary = self.activeAccountsValue!.accounts.first?.1
} }
if primary !== self.activeAccountsValue!.primary { if primary !== self.activeAccountsValue!.primary {
hadUpdates = true hadUpdates = true
@ -354,6 +373,7 @@ public final class SharedAccountContext {
self.activeAccountsValue!.currentAuth = authAccount self.activeAccountsValue!.currentAuth = authAccount
} }
if hadUpdates { if hadUpdates {
self.activeAccountsValue!.accounts.sort(by: { $0.2 < $1.2 })
self.activeAccountsPromise.set(.single(self.activeAccountsValue!)) self.activeAccountsPromise.set(.single(self.activeAccountsValue!))
} }
@ -364,8 +384,8 @@ public final class SharedAccountContext {
}) })
self.activeAccountsWithInfoPromise.set(self.activeAccounts self.activeAccountsWithInfoPromise.set(self.activeAccounts
|> mapToSignal { primary, accounts, _ -> Signal<(primary: AccountRecordId?, accounts: [AccountRecordId: AccountWithInfo]), NoError> in |> mapToSignal { primary, accounts, _ -> Signal<(primary: AccountRecordId?, accounts: [AccountWithInfo]), NoError> in
return combineLatest(accounts.values.map { account -> Signal<AccountWithInfo?, NoError> in return combineLatest(accounts.map { _, account, _ -> Signal<AccountWithInfo?, NoError> in
let peerViewKey: PostboxViewKey = .peer(peerId: account.peerId, components: []) let peerViewKey: PostboxViewKey = .peer(peerId: account.peerId, components: [])
return account.postbox.combinedView(keys: [peerViewKey]) return account.postbox.combinedView(keys: [peerViewKey])
|> map { view -> AccountWithInfo? in |> map { view -> AccountWithInfo? in
@ -376,14 +396,14 @@ public final class SharedAccountContext {
} }
|> distinctUntilChanged |> distinctUntilChanged
}) })
|> map { accountsWithInfo -> (primary: AccountRecordId?, accounts: [AccountRecordId: AccountWithInfo]) in |> map { accountsWithInfo -> (primary: AccountRecordId?, accounts: [AccountWithInfo]) in
var accountsWithInfoDict: [AccountRecordId: AccountWithInfo] = [:] var accountsWithInfoResult: [AccountWithInfo] = []
for info in accountsWithInfo { for info in accountsWithInfo {
if let info = info { if let info = info {
accountsWithInfoDict[info.account.id] = info accountsWithInfoResult.append(info)
} }
} }
return (primary?.id, accountsWithInfoDict) return (primary?.id, accountsWithInfoResult)
} }
}) })
@ -395,7 +415,7 @@ public final class SharedAccountContext {
applicationBindings.openSettings() applicationBindings.openSettings()
}) })
}, audioSession: self.mediaManager.audioSession, activeAccounts: self.activeAccounts |> map { _, accounts, _ in }, audioSession: self.mediaManager.audioSession, activeAccounts: self.activeAccounts |> map { _, accounts, _ in
return Array(accounts.values) return Array(accounts.map({ $0.1 }))
}) })
self.callManager = callManager self.callManager = callManager
@ -515,9 +535,9 @@ public final class SharedAccountContext {
self.registeredNotificationTokensDisposable.set((self.activeAccounts self.registeredNotificationTokensDisposable.set((self.activeAccounts
|> mapToSignal { _, activeAccounts, _ -> Signal<Never, NoError> in |> mapToSignal { _, activeAccounts, _ -> Signal<Never, NoError> in
var applied: [Signal<Never, NoError>] = [] var applied: [Signal<Never, NoError>] = []
let activeProductionUserIds = activeAccounts.values.filter({ !$0.testingEnvironment }).map({ $0.peerId.id }) let activeProductionUserIds = activeAccounts.map({ $0.1 }).filter({ !$0.testingEnvironment }).map({ $0.peerId.id })
let activeTestingUserIds = activeAccounts.values.filter({ $0.testingEnvironment }).map({ $0.peerId.id }) let activeTestingUserIds = activeAccounts.map({ $0.1 }).filter({ $0.testingEnvironment }).map({ $0.peerId.id })
for (_, account) in activeAccounts { for (_, account, _) in activeAccounts {
let appliedAps = self.apsNotificationToken let appliedAps = self.apsNotificationToken
|> distinctUntilChanged(isEqual: { $0 == $1 }) |> distinctUntilChanged(isEqual: { $0 == $1 })
|> mapToSignal { token -> Signal<Never, NoError> in |> mapToSignal { token -> Signal<Never, NoError> in

View File

@ -7,7 +7,7 @@ import TelegramCore
func presentContactsWarningSuppression(context: AccountContext, present: (ViewController, Any?) -> Void) { func presentContactsWarningSuppression(context: AccountContext, present: (ViewController, Any?) -> Void) {
let presentationData = context.sharedContext.currentPresentationData.with { $0 } let presentationData = context.sharedContext.currentPresentationData.with { $0 }
present(textAlertController(context: context, title: presentationData.strings.Contacts_PermissionsSuppressWarningTitle, text: presentationData.strings.Contacts_PermissionsSuppressWarningText, actions: [TextAlertAction(type: .genericAction, title: presentationData.strings.Contacts_PermissionsKeepDisabled, action: { present(textAlertController(context: context, title: presentationData.strings.Contacts_PermissionsSuppressWarningTitle, text: presentationData.strings.Contacts_PermissionsSuppressWarningText, actions: [TextAlertAction(type: .genericAction, title: presentationData.strings.Contacts_PermissionsKeepDisabled, action: {
ApplicationSpecificNotice.setContactsPermissionWarning(postbox: context.account.postbox, value: Int32(Date().timeIntervalSince1970)) ApplicationSpecificNotice.setContactsPermissionWarning(accountManager: context.sharedContext.accountManager, value: Int32(Date().timeIntervalSince1970))
}), TextAlertAction(type: .defaultAction, title: presentationData.strings.Contacts_PermissionsEnable, action: { }), TextAlertAction(type: .defaultAction, title: presentationData.strings.Contacts_PermissionsEnable, action: {
let _ = (DeviceAccess.authorizationStatus(context: context, subject: .contacts) let _ = (DeviceAccess.authorizationStatus(context: context, subject: .contacts)
|> take(1) |> take(1)

View File

@ -283,9 +283,17 @@ final class TabBarAccountSwitchControllerNode: ViewControllerTracingNode {
UIView.animate(withDuration: 0.3, animations: { UIView.animate(withDuration: 0.3, animations: {
if #available(iOS 9.0, *) { if #available(iOS 9.0, *) {
if self.presentationData.theme.chatList.searchBarKeyboardColor == .dark { if self.presentationData.theme.chatList.searchBarKeyboardColor == .dark {
self.effectView.effect = UIBlurEffect(style: .dark) if #available(iOSApplicationExtension 10.0, *) {
self.effectView.effect = UIBlurEffect(style: .regular)
} else {
self.effectView.effect = UIBlurEffect(style: .dark)
}
} else { } else {
self.effectView.effect = UIBlurEffect(style: .light) if #available(iOSApplicationExtension 10.0, *) {
self.effectView.effect = UIBlurEffect(style: .regular)
} else {
self.effectView.effect = UIBlurEffect(style: .light)
}
} }
} else { } else {
self.effectView.alpha = 1.0 self.effectView.alpha = 1.0
@ -300,6 +308,7 @@ final class TabBarAccountSwitchControllerNode: ViewControllerTracingNode {
for sourceNode in self.sourceNodes { for sourceNode in self.sourceNodes {
if let snapshot = sourceNode.view.snapshotContentTree() { if let snapshot = sourceNode.view.snapshotContentTree() {
snapshot.frame = sourceNode.view.convert(sourceNode.bounds, to: self.view) snapshot.frame = sourceNode.view.convert(sourceNode.bounds, to: self.view)
snapshot.isUserInteractionEnabled = false
self.view.addSubview(snapshot) self.view.addSubview(snapshot)
self.snapshotViews.append(snapshot) self.snapshotViews.append(snapshot)
} }

View File

@ -34,19 +34,15 @@ public extension TermsOfServiceControllerTheme {
self.init(statusBarStyle: presentationTheme.rootController.statusBar.style.style, navigationBackground: presentationTheme.rootController.navigationBar.backgroundColor, navigationSeparator: presentationTheme.rootController.navigationBar.separatorColor, listBackground: presentationTheme.list.blocksBackgroundColor, itemBackground: presentationTheme.list.itemBlocksBackgroundColor, itemSeparator: presentationTheme.list.itemBlocksSeparatorColor, primary: presentationTheme.list.itemPrimaryTextColor, accent: presentationTheme.list.itemAccentColor, disabled: presentationTheme.rootController.navigationBar.disabledButtonColor) self.init(statusBarStyle: presentationTheme.rootController.statusBar.style.style, navigationBackground: presentationTheme.rootController.navigationBar.backgroundColor, navigationSeparator: presentationTheme.rootController.navigationBar.separatorColor, listBackground: presentationTheme.list.blocksBackgroundColor, itemBackground: presentationTheme.list.itemBlocksBackgroundColor, itemSeparator: presentationTheme.list.itemBlocksSeparatorColor, primary: presentationTheme.list.itemPrimaryTextColor, accent: presentationTheme.list.itemAccentColor, disabled: presentationTheme.rootController.navigationBar.disabledButtonColor)
} }
convenience init(authTheme: AuthorizationTheme) {
self.init(statusBarStyle: authTheme.statusBarStyle, navigationBackground: authTheme.navigationBarBackgroundColor, navigationSeparator: authTheme.navigationBarSeparatorColor, listBackground: authTheme.listBackgroundColor, itemBackground: authTheme.backgroundColor, itemSeparator: authTheme.separatorColor, primary: authTheme.primaryColor, accent: authTheme.accentColor, disabled: authTheme.accentColor)
}
var presentationTheme: PresentationTheme { var presentationTheme: PresentationTheme {
let theme: PresentationTheme let theme: PresentationTheme
switch itemBackground.argb { switch itemBackground.argb {
case defaultPresentationTheme.list.itemBlocksBackgroundColor.argb: case defaultPresentationTheme.list.itemBlocksBackgroundColor.argb:
theme = defaultPresentationTheme theme = defaultPresentationTheme
case defaultDarkPresentationTheme.list.itemBlocksBackgroundColor.argb: case defaultDarkPresentationTheme.list.itemBlocksBackgroundColor.argb:
theme = defaultDarkPresentationTheme theme = defaultDarkPresentationTheme
case defaultDarkAccentPresentationTheme.list.itemBlocksBackgroundColor.argb: case defaultDarkAccentPresentationTheme.list.itemBlocksBackgroundColor.argb:
theme = defaultDarkAccentPresentationTheme theme = defaultDarkAccentPresentationTheme
default: default:
theme = defaultPresentationTheme theme = defaultPresentationTheme
} }

View File

@ -99,14 +99,15 @@ private let applicationSpecificPreferencesKeyMapping: [LegacyApplicationSpecific
.contactSynchronizationSettings: .contactSynchronizationSettings .contactSynchronizationSettings: .contactSynchronizationSettings
] ]
public func upgradedAccounts(accountManager: AccountManager, rootPath: String) -> Signal<Void, NoError> { public func upgradedAccounts(accountManager: AccountManager, rootPath: String) -> Signal<Never, NoError> {
return accountManager.transaction { transaction -> (Int32, AccountRecordId?) in return accountManager.transaction { transaction -> (Int32, AccountRecordId?) in
return (transaction.getVersion(), transaction.getCurrent()?.0) return (transaction.getVersion(), transaction.getCurrent()?.0)
} }
|> mapToSignal { version, currentId -> Signal<Void, NoError> in |> mapToSignal { version, currentId -> Signal<Never, NoError> in
if version == 0 { var signal: Signal<Never, NoError> = .complete()
if version < 1 {
if let currentId = currentId { if let currentId = currentId {
return accountPreferenceEntries(rootPath: rootPath, id: currentId, keys: Set(preferencesKeyMapping.keys.map({ $0.key }) + applicationSpecificPreferencesKeyMapping.keys.map({ $0.key }))) let upgradePreferences = accountPreferenceEntries(rootPath: rootPath, id: currentId, keys: Set(preferencesKeyMapping.keys.map({ $0.key }) + applicationSpecificPreferencesKeyMapping.keys.map({ $0.key })))
|> mapToSignal { path, values -> Signal<Void, NoError> in |> mapToSignal { path, values -> Signal<Void, NoError> in
return accountManager.transaction { transaction -> Void in return accountManager.transaction { transaction -> Void in
for (key, value) in values { for (key, value) in values {
@ -166,13 +167,50 @@ public func upgradedAccounts(accountManager: AccountManager, rootPath: String) -
transaction.setVersion(1) transaction.setVersion(1)
} }
} }
|> ignoreValues
signal = signal |> then(upgradePreferences)
} else { } else {
return accountManager.transaction { transaction -> Void in let upgradePreferences = accountManager.transaction { transaction -> Void in
transaction.setVersion(1) transaction.setVersion(1)
} }
|> ignoreValues
signal = signal |> then(upgradePreferences)
} }
} else {
return .complete()
} }
if version < 2 {
if let currentId = currentId {
let upgradeNotices = accountNoticeEntries(rootPath: rootPath, id: currentId)
|> mapToSignal { path, values -> Signal<Void, NoError> in
return accountManager.transaction { transaction -> Void in
for (key, value) in values {
transaction.setNotice(NoticeEntryKey(namespace: ValueBoxKey(length: 0), key: key), value)
}
transaction.setVersion(2)
}
}
|> ignoreValues
signal = signal |> then(upgradeNotices)
} else {
let upgradeNotices = accountManager.transaction { transaction -> Void in
transaction.setVersion(2)
}
|> ignoreValues
signal = signal |> then(upgradeNotices)
}
let upgradeSortOrder = accountManager.transaction { transaction -> Void in
var index: Int32 = 0
for record in transaction.getRecords() {
transaction.updateRecord(record.id, { _ in
return AccountRecord(id: record.id, attributes: record.attributes + [AccountSortOrderAttribute(order: index)], temporarySessionId: record.temporarySessionId)
})
index += 1
}
}
|> ignoreValues
signal = signal |> then(upgradeSortOrder)
}
return signal
} }
} }

View File

@ -1384,7 +1384,7 @@ public func userInfoController(context: AccountContext, peerId: PeerId, mode: Us
return false return false
}) })
if let resultItemNode = resultItemNode, let callButtonFrame = resultItemNode.callButtonFrame { if let resultItemNode = resultItemNode, let callButtonFrame = resultItemNode.callButtonFrame {
let _ = (ApplicationSpecificNotice.getProfileCallTips(postbox: context.account.postbox) let _ = (ApplicationSpecificNotice.getProfileCallTips(accountManager: context.sharedContext.accountManager)
|> deliverOnMainQueue).start(next: { [weak controller] counter in |> deliverOnMainQueue).start(next: { [weak controller] counter in
guard let controller = controller else { guard let controller = controller else {
return return
@ -1399,7 +1399,7 @@ public func userInfoController(context: AccountContext, peerId: PeerId, mode: Us
if !displayTip { if !displayTip {
return return
} }
let _ = ApplicationSpecificNotice.incrementProfileCallTips(postbox: context.account.postbox).start() let _ = ApplicationSpecificNotice.incrementProfileCallTips(accountManager: context.sharedContext.accountManager).start()
let presentationData = context.sharedContext.currentPresentationData.with { $0 } let presentationData = context.sharedContext.currentPresentationData.with { $0 }
let text: String = presentationData.strings.UserInfo_TapToCall let text: String = presentationData.strings.UserInfo_TapToCall