mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Move where the developer options are shown and store them in the app settings.
This commit is contained in:
committed by
Stefan Ceriu
parent
eaa6dd9240
commit
0c5be93a75
@@ -11,6 +11,8 @@ import SwiftUI
|
||||
typealias SettingsScreenViewModelType = StateStoreViewModelV2<SettingsScreenViewState, SettingsScreenViewAction>
|
||||
|
||||
class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewModelProtocol {
|
||||
private let appSettings: AppSettings
|
||||
|
||||
private var actionsSubject: PassthroughSubject<SettingsScreenViewModelAction, Never> = .init()
|
||||
|
||||
var actions: AnyPublisher<SettingsScreenViewModelAction, Never> {
|
||||
@@ -18,14 +20,20 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
|
||||
}
|
||||
|
||||
init(userSession: UserSessionProtocol, appSettings: AppSettings, isBugReportServiceEnabled: Bool) {
|
||||
self.appSettings = appSettings
|
||||
|
||||
super.init(initialViewState: .init(deviceID: userSession.clientProxy.deviceID,
|
||||
userID: userSession.clientProxy.userID,
|
||||
showAccountDeactivation: userSession.clientProxy.canDeactivateAccount,
|
||||
showDeveloperOptions: AppSettings.isDevelopmentBuild,
|
||||
showDeveloperOptions: appSettings.developerOptionsEnabled,
|
||||
showAnalyticsSettings: appSettings.canPromptForAnalytics,
|
||||
isBugReportServiceEnabled: isBugReportServiceEnabled),
|
||||
mediaProvider: userSession.mediaProvider)
|
||||
|
||||
appSettings.$developerOptionsEnabled
|
||||
.weakAssign(to: \.state.showDeveloperOptions, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
userSession.clientProxy.userAvatarURLPublisher
|
||||
.receive(on: DispatchQueue.main)
|
||||
.weakAssign(to: \.state.userAvatarURL, on: self)
|
||||
@@ -105,7 +113,7 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
|
||||
case .advancedSettings:
|
||||
actionsSubject.send(.advancedSettings)
|
||||
case .enableDeveloperOptions:
|
||||
state.showDeveloperOptions = true
|
||||
appSettings.developerOptionsEnabled.toggle()
|
||||
case .developerOptions:
|
||||
actionsSubject.send(.developerOptions)
|
||||
case .deactivateAccount:
|
||||
|
||||
@@ -31,6 +31,10 @@ struct SettingsScreen: View {
|
||||
generalSection
|
||||
|
||||
signOutSection
|
||||
|
||||
if context.viewState.showDeveloperOptions {
|
||||
developerOptionsSection
|
||||
}
|
||||
}
|
||||
.compoundList()
|
||||
.navigationTitle(L10n.commonSettings)
|
||||
@@ -164,15 +168,6 @@ struct SettingsScreen: View {
|
||||
context.send(viewAction: .advancedSettings)
|
||||
})
|
||||
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.advancedSettings)
|
||||
|
||||
if context.viewState.showDeveloperOptions {
|
||||
ListRow(label: .default(title: L10n.commonDeveloperOptions,
|
||||
icon: \.code),
|
||||
kind: .navigationLink {
|
||||
context.send(viewAction: .developerOptions)
|
||||
})
|
||||
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.developerOptions)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,21 +190,40 @@ struct SettingsScreen: View {
|
||||
})
|
||||
}
|
||||
} footer: {
|
||||
VStack(spacing: 0) {
|
||||
versionText
|
||||
.frame(maxWidth: .infinity)
|
||||
|
||||
if let deviceID = context.viewState.deviceID {
|
||||
Text(deviceID)
|
||||
}
|
||||
if !context.viewState.showDeveloperOptions {
|
||||
versionSection
|
||||
}
|
||||
.compoundListSectionFooter()
|
||||
.textSelection(.enabled)
|
||||
.padding(.top, 24)
|
||||
.onTapGesture(count: 7) {
|
||||
context.send(viewAction: .enableDeveloperOptions)
|
||||
}
|
||||
}
|
||||
|
||||
private var developerOptionsSection: some View {
|
||||
Section {
|
||||
ListRow(label: .default(title: L10n.commonDeveloperOptions,
|
||||
icon: \.code),
|
||||
kind: .navigationLink {
|
||||
context.send(viewAction: .developerOptions)
|
||||
})
|
||||
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.developerOptions)
|
||||
} footer: {
|
||||
versionSection
|
||||
}
|
||||
}
|
||||
|
||||
private var versionSection: some View {
|
||||
VStack(spacing: 0) {
|
||||
versionText
|
||||
.frame(maxWidth: .infinity)
|
||||
|
||||
if let deviceID = context.viewState.deviceID {
|
||||
Text(deviceID)
|
||||
}
|
||||
}
|
||||
.compoundListSectionFooter()
|
||||
.textSelection(.enabled)
|
||||
.padding(.top, 24)
|
||||
.onTapGesture(count: 7) {
|
||||
context.send(viewAction: .enableDeveloperOptions)
|
||||
}
|
||||
}
|
||||
|
||||
private var versionText: Text {
|
||||
|
||||
Reference in New Issue
Block a user