Skip to content

Commit 2e279e8

Browse files
author
Isaac
committed
Temp
1 parent 0ac2602 commit 2e279e8

File tree

7 files changed

+68
-3
lines changed

7 files changed

+68
-3
lines changed

submodules/AccountContext/Sources/AccountContext.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,6 +1475,7 @@ public protocol SharedAccountContext: AnyObject {
14751475
func makeNewContactScreen(context: AccountContext, peer: EnginePeer?, phoneNumber: String?, shareViaException: Bool, completion: @escaping (EnginePeer?, DeviceContactStableId?, DeviceContactExtendedData?) -> Void) -> ViewController
14761476

14771477
func makeLoginEmailSetupController(context: AccountContext, blocking: Bool, emailPattern: String?, canAutoDismissIfNeeded: Bool, navigationController: NavigationController?, completion: @escaping () -> Void, dismiss: @escaping () -> Void) -> ViewController
1478+
public func makePasskeySetupController(context: AccountContext, displaySkip: Bool, navigationController: NavigationController?, completion: @escaping () -> Void, dismiss: completion: @escaping () -> Void) -> ViewController
14781479

14791480
func navigateToCurrentCall()
14801481
var hasOngoingCall: ValuePromise<Bool> { get }

submodules/ChatListUI/Sources/ChatListController.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
137137
private let dismissAutoarchiveDisposable = MetaDisposable()
138138
private var didSuggestAutoarchive = false
139139
private var didSuggestLoginEmailSetup = false
140+
private var didSuggestLoginPasskeySetup = false
140141

141142
private var presentationData: PresentationData
142143
private let presentationDataValue = Promise<PresentationData>()
@@ -2586,6 +2587,35 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
25862587
return
25872588
}
25882589

2590+
if values.contains(.setupPasskey) {
2591+
if strongSelf.didSuggestLoginPasskeySetup {
2592+
return
2593+
}
2594+
strongSelf.didSuggestLoginPasskeySetup = true
2595+
2596+
let _ = (context.engine.notices.getServerProvidedSuggestions(reload: true)
2597+
|> deliverOnMainQueue).start(next: { [weak strongSelf] currentValues in
2598+
guard let strongSelf, currentValues.contains(.setupPasskey) else {
2599+
return
2600+
}
2601+
if let navigationController = strongSelf.navigationController as? NavigationController {
2602+
let controller = strongSelf.context.sharedContext.makePasskeySetupController(context: strongSelf.context, displaySkip: true, navigationController: navigationController, completion: {
2603+
let _ = context.engine.notices.dismissServerProvidedSuggestion(suggestion: ServerProvidedSuggestion.setupPasskey.id).startStandalone()
2604+
}, dismiss: {
2605+
let _ = context.engine.notices.dismissServerProvidedSuggestion(suggestion: ServerProvidedSuggestion.setupPasskey.id).startStandalone()
2606+
})
2607+
if let layout = strongSelf.validLayout, layout.metrics.isTablet {
2608+
controller.navigationPresentation = .standaloneFlatModal
2609+
} else {
2610+
controller.navigationPresentation = .flatModal
2611+
}
2612+
navigationController.pushViewController(controller)
2613+
}
2614+
})
2615+
2616+
return
2617+
}
2618+
25892619
if strongSelf.didSuggestAutoarchive {
25902620
return
25912621
}

submodules/TelegramCore/Sources/Suggestions.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public enum ServerProvidedSuggestion: Equatable {
2020
case setupPhoto
2121
case setupLoginEmail
2222
case setupLoginEmailBlocking
23+
case setupPasskey
2324
case link(id: String, url: String, title: ServerSuggestionInfo.Item.Text, subtitle: ServerSuggestionInfo.Item.Text)
2425

2526
init?(string: String) {
@@ -56,6 +57,8 @@ public enum ServerProvidedSuggestion: Equatable {
5657
self = .setupLoginEmail
5758
case "SETUP_LOGIN_EMAIL_NOSKIP":
5859
self = .setupLoginEmailBlocking
60+
case "SETUP_PASSKEY":
61+
self = .setupPasskey
5962
default:
6063
return nil
6164
}
@@ -95,6 +98,8 @@ public enum ServerProvidedSuggestion: Equatable {
9598
return "SETUP_LOGIN_EMAIL"
9699
case .setupLoginEmailBlocking:
97100
return "SETUP_LOGIN_EMAIL_NOSKIP"
101+
case .setupPasskey:
102+
return "SETUP_PASSKEY"
98103
case let .link(id, _, _, _):
99104
return id
100105
}

submodules/TelegramUI/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ swift_library(
498498
"//submodules/TelegramUI/Components/AttachmentFileController",
499499
"//submodules/TelegramUI/Components/Contacts/NewContactScreen",
500500
"//submodules/TelegramUI/Components/Chat/ChatSendAsContextMenu",
501+
"//submodules/TelegramUI/Components/Settings/PasskeysScreen",
501502
] + select({
502503
"@build_bazel_rules_apple//apple:ios_arm64": appcenter_targets,
503504
"//build-system:ios_sim_arm64": [],

submodules/TelegramUI/Components/Settings/PasskeysScreen/Sources/PasskeysScreen.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,26 @@ final class PasskeysScreenComponent: Component {
1919
typealias EnvironmentType = ViewControllerComponentContainer.Environment
2020

2121
let context: AccountContext
22+
let displaySkip: Bool
2223
let initialPasskeysData: [TelegramPasskey]?
2324
let passkeysDataUpdated: ([TelegramPasskey]) -> Void
25+
let completion: () -> Void
26+
let cancel: () -> Void
2427

2528
init(
2629
context: AccountContext,
30+
displaySkip: Bool,
2731
initialPasskeysData: [TelegramPasskey]?,
28-
passkeysDataUpdated: @escaping ([TelegramPasskey]) -> Void
32+
passkeysDataUpdated: @escaping ([TelegramPasskey]) -> Void,
33+
completion: @escaping () -> Void,
34+
cancel: @escaping () -> Void
2935
) {
3036
self.context = context
37+
self.displaySkip = displaySkip
3138
self.initialPasskeysData = initialPasskeysData
3239
self.passkeysDataUpdated = passkeysDataUpdated
40+
self.completion = completion
41+
self.cancel = cancel
3342
}
3443

3544
static func ==(lhs: PasskeysScreenComponent, rhs: PasskeysScreenComponent) -> Bool {
@@ -353,10 +362,10 @@ final class PasskeysScreenComponent: Component {
353362
public final class PasskeysScreen: ViewControllerComponentContainer {
354363
private let context: AccountContext
355364

356-
public init(context: AccountContext, initialPasskeysData: [TelegramPasskey]?, passkeysDataUpdated: @escaping ([TelegramPasskey]) -> Void) async {
365+
public init(context: AccountContext, displaySkip: Bool, initialPasskeysData: [TelegramPasskey]?, passkeysDataUpdated: @escaping ([TelegramPasskey]) -> Void, completion: @escaping () -> Void, cancel: @escaping () -> Void) async {
357366
self.context = context
358367

359-
super.init(context: context, component: PasskeysScreenComponent(context: context, initialPasskeysData: initialPasskeysData, passkeysDataUpdated: passkeysDataUpdated), navigationBarAppearance: .transparent)
368+
super.init(context: context, component: PasskeysScreenComponent(context: context, displaySkip: displaySkip, initialPasskeysData: initialPasskeysData, passkeysDataUpdated: passkeysDataUpdated), navigationBarAppearance: .transparent)
360369
}
361370

362371
required public init(coder aDecoder: NSCoder) {

submodules/TelegramUI/Components/Settings/PasskeysScreen/Sources/PasskeysScreenIntroComponent.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,20 @@ final class PasskeysScreenIntroComponent: Component {
1414
let context: AccountContext
1515
let theme: PresentationTheme
1616
let insets: UIEdgeInsets
17+
let displaySkip: Bool
1718
let createPasskeyAction: () -> Void
1819

1920
init(
2021
context: AccountContext,
2122
theme: PresentationTheme,
2223
insets: UIEdgeInsets,
24+
displaySkip: Bool,
2325
createPasskeyAction: @escaping () -> Void
2426
) {
2527
self.context = context
2628
self.theme = theme
2729
self.insets = insets
30+
self.displaySkip = displaySkip
2831
self.createPasskeyAction = createPasskeyAction
2932
}
3033

@@ -38,6 +41,9 @@ final class PasskeysScreenIntroComponent: Component {
3841
if lhs.insets != rhs.insets {
3942
return false
4043
}
44+
if lhs.displaySkip != rhs.displaySkip {
45+
return false
46+
}
4147
return true
4248
}
4349

@@ -64,6 +70,7 @@ final class PasskeysScreenIntroComponent: Component {
6470
private let title = ComponentView<Empty>()
6571
private let subtitle = ComponentView<Empty>()
6672
private let actionButton = ComponentView<Empty>()
73+
private var skipButton: ComponentView<Empty>?
6774

6875
private var items: [Item] = []
6976

@@ -292,6 +299,13 @@ final class PasskeysScreenIntroComponent: Component {
292299
environment: {},
293300
containerSize: CGSize(width: availableSize.width - buttonInsets.left - buttonInsets.right, height: 52.0)
294301
)
302+
303+
if component.displaySkip {
304+
let skipButton: ComponentView<Empty>
305+
} else if let skipButton = self.skipButton {
306+
self.skipButton = nil
307+
skipButton.view?.removeFromSuperview()
308+
}
295309

296310
let buttonFrame = CGRect(origin: CGPoint(x: buttonInsets.left, y: availableSize.height - buttonInsets.bottom - actionButtonSize.height), size: actionButtonSize)
297311

submodules/TelegramUI/Sources/SharedAccountContext.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ import ForumCreateTopicScreen
9090
import GlassBackgroundComponent
9191
import AttachmentFileController
9292
import NewContactScreen
93+
import PasskeysScreen
9394

9495
private final class AccountUserInterfaceInUseContext {
9596
let subscribers = Bag<(Bool) -> Void>()
@@ -4063,6 +4064,10 @@ public final class SharedAccountContextImpl: SharedAccountContext {
40634064
public func makeLoginEmailSetupController(context: AccountContext, blocking: Bool, emailPattern: String?, canAutoDismissIfNeeded: Bool, navigationController: NavigationController?, completion: @escaping () -> Void, dismiss: @escaping () -> Void) -> ViewController {
40644065
return loginEmailSetupController(context: context, blocking: blocking, emailPattern: emailPattern, canAutoDismissIfNeeded: canAutoDismissIfNeeded, navigationController: navigationController, completion: completion, dismiss: dismiss)
40654066
}
4067+
4068+
public func makePasskeySetupController(context: AccountContext, displaySkip: Bool, navigationController: NavigationController?, completion: @escaping () -> Void, dismiss: completion: @escaping () -> Void) -> ViewController {
4069+
return PasskeysScreen(context: context, displaySkip: displaySkip, initialPasskeysData: nil, passkeysDataUpdated: { _ in }, completion: completion, cancel: dismiss)
4070+
}
40664071
}
40674072

40684073
private func peerInfoControllerImpl(context: AccountContext, updatedPresentationData: (PresentationData, Signal<PresentationData, NoError>)?, peer: Peer, mode: PeerInfoControllerMode, avatarInitiallyExpanded: Bool, isOpenedFromChat: Bool, requestsContext: PeerInvitationImportersContext? = nil) -> ViewController? {

0 commit comments

Comments
 (0)