diff --git a/TelegramUI/ContactListNode.swift b/TelegramUI/ContactListNode.swift index e86f673d1f..a81ceeb2db 100644 --- a/TelegramUI/ContactListNode.swift +++ b/TelegramUI/ContactListNode.swift @@ -592,8 +592,7 @@ final class ContactListNode: ASDisplayNode { self.selectionStateValue = selectionState self.selectionStatePromise.set(.single(selectionState)) - //self.addSubnode(self.listNode) - self.addSubnode(self.authorizationNode) + self.addSubnode(self.listNode) let processingQueue = Queue() let previousEntries = Atomic<[ContactListNodeEntry]?>(value: nil) @@ -837,11 +836,6 @@ final class ContactListNode: ASDisplayNode { } } - override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { - let result = super.hitTest(point, with: event) - return result - } - func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) { var insets = layout.insets(options: [.input]) insets.left += layout.safeInsets.left diff --git a/TelegramUI/ItemListController.swift b/TelegramUI/ItemListController.swift index 11d8ac799a..4b02f74056 100644 --- a/TelegramUI/ItemListController.swift +++ b/TelegramUI/ItemListController.swift @@ -217,6 +217,7 @@ class ItemListController: ViewController { strongSelf.tabBarItem.title = tabBarItemInfo.title strongSelf.tabBarItem.image = tabBarItemInfo.image strongSelf.tabBarItem.selectedImage = tabBarItemInfo.selectedImage + strongSelf.tabBarItem.badgeValue = tabBarItemInfo.badgeValue } } }) diff --git a/TelegramUI/PermissionController.swift b/TelegramUI/PermissionController.swift index bc34f3bfdb..b97bca6e94 100644 --- a/TelegramUI/PermissionController.swift +++ b/TelegramUI/PermissionController.swift @@ -13,12 +13,16 @@ final class PermissionController : ViewController { private let strings: PresentationStrings private let theme: AuthorizationTheme + private var animatedIn = false + + private var allow: (() -> Void)? + init(account: Account) { self.account = account self.strings = account.telegramApplicationContext.currentPresentationData.with { $0 }.strings self.theme = defaultLightAuthorizationTheme - super.init(navigationBarPresentationData: NavigationBarPresentationData(theme: AuthorizationSequenceController.navigationBarTheme(theme), strings: NavigationBarStrings(presentationStrings: strings))) + super.init(navigationBarPresentationData: nil) self.supportedOrientations = ViewControllerSupportedOrientations(regularSize: .all, compactSize: .portrait) @@ -37,13 +41,24 @@ final class PermissionController : ViewController { self?.presentingViewController?.dismiss(animated: false, completion: nil) } self.controllerNode.allow = { [weak self] in - self?.account.telegramApplicationContext.applicationBindings.openSettings() + self?.allow?() } self.controllerNode.next = { [weak self] in self?.dismiss(completion: nil) } - self.controllerNode.openPrivacyPolicy = { - + self.controllerNode.openPrivacyPolicy = { [weak self] in + if let strongSelf = self { + openExternalUrl(account: strongSelf.account, context: .generic, url: "https://telegram.org/privacy", forceExternal: true, presentationData: strongSelf.account.telegramApplicationContext.currentPresentationData.with { $0 }, applicationContext: strongSelf.account.telegramApplicationContext, navigationController: nil, dismissInput: {}) + } + } + } + + override public func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + + if !self.animatedIn { + self.animatedIn = true + self.controllerNode.animateIn() } } @@ -51,7 +66,8 @@ final class PermissionController : ViewController { self.controllerNode.animateOut(completion: completion) } - func updateData(subject: DeviceAccessSubject, currentStatus: AccessType) { + func updateData(subject: DeviceAccessSubject, currentStatus: AccessType, allow: @escaping () -> Void) { + self.allow = allow self.controllerNode.updateData(subject: .notifications, currentStatus: currentStatus) } diff --git a/TelegramUI/PermissionControllerNode.swift b/TelegramUI/PermissionControllerNode.swift index 150cc663a9..98e6ad3e0e 100644 --- a/TelegramUI/PermissionControllerNode.swift +++ b/TelegramUI/PermissionControllerNode.swift @@ -47,9 +47,6 @@ final class PermissionControllerNode: ASDisplayNode { self.textNode.textAlignment = .center self.textNode.maximumNumberOfLines = 0 self.textNode.displaysAsynchronously = false - let body = MarkdownAttributeSet(font: Font.regular(16.0), textColor: theme.primaryColor) - let link = MarkdownAttributeSet(font: Font.regular(16.0), textColor: theme.accentColor, additionalAttributes: [TelegramTextAttributes.URL: ""]) - self.textNode.attributedText = parseMarkdownIntoAttributedString(strings.Login_TermsOfServiceLabel.replacingOccurrences(of: "]", with: "]()"), attributes: MarkdownAttributes(body: body, bold: body, link: link, linkAttribute: { _ in nil }), textAlignment: .center) self.buttonNode = SolidRoundedButtonNode(theme: self.theme, height: 48.0, cornerRadius: 9.0) @@ -77,6 +74,7 @@ final class PermissionControllerNode: ASDisplayNode { self.buttonNode.pressed = { [weak self] in self?.allow?() + self?.dismiss?() } self.privacyPolicyNode.addTarget(self, action: #selector(self.privacyPolicyPressed), forControlEvents: .touchUpInside) @@ -158,7 +156,7 @@ final class PermissionControllerNode: ASDisplayNode { } let nextSize = self.nextNode.measure(layout.size) - transition.updateFrame(node: self.nextNode, frame: CGRect(x: layout.size.width - insets.right - nextSize.width - 16.0, y: insets.top + 10.0 + 60.0, width: nextSize.width, height: nextSize.height)) + transition.updateFrame(node: self.nextNode, frame: CGRect(x: layout.size.width - insets.right - nextSize.width - 16.0, y: insets.top + 10.0, width: nextSize.width, height: nextSize.height)) self.titleNode.attributedText = NSAttributedString(string: self.title ?? "", font: Font.semibold(fontSize), textColor: self.theme.primaryColor) @@ -192,6 +190,10 @@ final class PermissionControllerNode: ASDisplayNode { self.next?() } + func animateIn(completion: (() -> Void)? = nil) { + self.layer.animatePosition(from: CGPoint(x: self.layer.position.x, y: self.layer.position.y + self.layer.bounds.size.height), to: self.layer.position, duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring) + } + func animateOut(completion: (() -> Void)? = nil) { self.layer.animatePosition(from: self.layer.position, to: CGPoint(x: self.layer.position.x, y: self.layer.position.y + self.layer.bounds.size.height), duration: 0.2, timingFunction: kCAMediaTimingFunctionEaseInEaseOut, removeOnCompletion: false, completion: { [weak self] _ in if let strongSelf = self { diff --git a/TelegramUI/SettingsController.swift b/TelegramUI/SettingsController.swift index de65270ffb..25e4419462 100644 --- a/TelegramUI/SettingsController.swift +++ b/TelegramUI/SettingsController.swift @@ -674,7 +674,8 @@ public func settingsController(account: Account, accountManager: AccountManager) updatePassport() let notificationAuthorizationStatus = Promise(.allowed) - notificationAuthorizationStatus.set(DeviceAccess.authorizationStatus(account: account, subject: .notifications)) + notificationAuthorizationStatus.set(.single(.allowed) + |> then(DeviceAccess.authorizationStatus(account: account, subject: .notifications))) let notifyExceptions = Promise(nil) let updateNotifyExceptions: () -> Void = { diff --git a/TelegramUI/TelegramRootController.swift b/TelegramUI/TelegramRootController.swift index f03c360aec..01fca1a068 100644 --- a/TelegramUI/TelegramRootController.swift +++ b/TelegramUI/TelegramRootController.swift @@ -122,12 +122,22 @@ public final class TelegramRootController: NavigationController { return } - let _ = (DeviceAccess.authorizationStatus(account: self.account, subject: .notifications) + let account = self.account + let _ = (DeviceAccess.authorizationStatus(account: account, subject: .notifications) |> take(1) |> deliverOnMainQueue).start(next: { status in if status != .allowed { let controller = PermissionController(account: self.account) - controller.updateData(subject: .notifications, currentStatus: status) + controller.updateData(subject: .notifications, currentStatus: status, allow: { + switch status { + case .notDetermined: + account.telegramApplicationContext.applicationBindings.registerForNotifications() + case .denied: + account.telegramApplicationContext.applicationBindings.openSettings() + default: + break + } + }) parentController.present(controller, in: .window(.root)) } })