Add a Link New Device screen (behind a feature flag). (#4811)

This commit is contained in:
Doug
2025-12-11 11:45:23 +00:00
committed by GitHub
parent 9ffb9a22e3
commit 4ea1aaecdd
46 changed files with 635 additions and 27 deletions
@@ -25,6 +25,7 @@ enum SettingsScreenCoordinatorAction {
case bugReport
case about
case blockedUsers
case linkNewDevice
case manageAccount(url: URL)
case notifications
case advancedSettings
@@ -59,6 +60,8 @@ final class SettingsScreenCoordinator: CoordinatorProtocol {
actionsSubject.send(.dismiss)
case .userDetails:
actionsSubject.send(.userDetails)
case .linkNewDevice:
actionsSubject.send(.linkNewDevice)
case let .manageAccount(url):
actionsSubject.send(.manageAccount(url: url))
case .analytics:
@@ -12,6 +12,7 @@ import UIKit
enum SettingsScreenViewModelAction: Equatable {
case close
case userDetails
case linkNewDevice
case manageAccount(url: URL)
case analytics
case appLock
@@ -35,6 +36,7 @@ enum SettingsScreenSecuritySectionMode {
struct SettingsScreenViewState: BindableState {
var deviceID: String?
var userID: String
var showLinkNewDeviceButton: Bool
var accountProfileURL: URL?
var accountSessionsListURL: URL?
var showAccountDeactivation: Bool
@@ -66,6 +68,7 @@ enum SettingsScreenViewAction {
case about
case blockedUsers
case secureBackup
case linkNewDevice
case manageAccount(url: URL)
case notifications
case enableDeveloperOptions
@@ -25,6 +25,7 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
super.init(initialViewState: .init(deviceID: userSession.clientProxy.deviceID,
userID: userSession.clientProxy.userID,
showLinkNewDeviceButton: appSettings.linkNewDeviceEnabled,
showAccountDeactivation: userSession.clientProxy.canDeactivateAccount,
showDeveloperOptions: appSettings.developerOptionsEnabled,
showAnalyticsSettings: appSettings.canPromptForAnalytics,
@@ -35,6 +36,10 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
.weakAssign(to: \.state.showDeveloperOptions, on: self)
.store(in: &cancellables)
appSettings.$linkNewDeviceEnabled
.weakAssign(to: \.state.showLinkNewDeviceButton, on: self)
.store(in: &cancellables)
userSession.clientProxy.userAvatarURLPublisher
.receive(on: DispatchQueue.main)
.weakAssign(to: \.state.userAvatarURL, on: self)
@@ -93,6 +98,8 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
actionsSubject.send(.close)
case .userDetails:
actionsSubject.send(.userDetails)
case .linkNewDevice:
actionsSubject.send(.linkNewDevice)
case let .manageAccount(url):
actionsSubject.send(.manageAccount(url: url))
case .analytics:
@@ -108,6 +108,14 @@ struct SettingsScreen: View {
private var manageAccountSection: some View {
Section {
if context.viewState.showLinkNewDeviceButton {
ListRow(label: .default(title: L10n.commonLinkNewDevice,
icon: \.devices),
kind: .navigationLink {
context.send(viewAction: .linkNewDevice)
})
}
if let url = context.viewState.accountProfileURL {
ListRow(label: .default(title: L10n.actionManageAccount,
icon: \.userProfile),