Fixes #322 - Developer options menu (#581)

This commit is contained in:
Stefan Ceriu
2023-02-15 13:07:06 +02:00
committed by GitHub
parent 6211f121a0
commit 4fd24a6c16
21 changed files with 390 additions and 7 deletions
@@ -52,6 +52,8 @@ final class SettingsScreenCoordinator: CoordinatorProtocol {
self.presentBugReportScreen()
case .sessionVerification:
self.verifySession()
case .developerOptions:
self.presentDeveloperOptions()
case .logout:
self.callback?(.logout)
}
@@ -110,6 +112,11 @@ final class SettingsScreenCoordinator: CoordinatorProtocol {
self?.parameters.navigationStackCoordinator?.setSheetCoordinator(nil)
}
}
private func presentDeveloperOptions() {
let coordinator = DeveloperOptionsScreenCoordinator()
parameters.navigationStackCoordinator?.push(coordinator)
}
private func showSuccess(label: String) {
parameters.userIndicatorController?.submitIndicator(UserIndicator(title: label))
@@ -22,6 +22,7 @@ enum SettingsScreenViewModelAction {
case toggleAnalytics
case reportBug
case sessionVerification
case developerOptions
case logout
}
@@ -32,6 +33,7 @@ struct SettingsScreenViewState: BindableState {
var userAvatarURL: URL?
var userDisplayName: String?
var showSessionVerificationSection: Bool
var showDeveloperOptions: Bool
}
struct SettingsScreenViewStateBindings {
@@ -45,4 +47,5 @@ enum SettingsScreenViewAction {
case sessionVerification
case logout
case changedTimelineStyle
case developerOptions
}
@@ -23,14 +23,15 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
private let userSession: UserSessionProtocol
var callback: ((SettingsScreenViewModelAction) -> Void)?
init(withUserSession userSession: UserSessionProtocol) {
self.userSession = userSession
let bindings = SettingsScreenViewStateBindings(timelineStyle: ServiceLocator.shared.settings.timelineStyle)
super.init(initialViewState: .init(bindings: bindings,
deviceID: userSession.deviceId,
userID: userSession.userID,
showSessionVerificationSection: !(userSession.sessionVerificationController?.isVerified ?? false)),
showSessionVerificationSection: !(userSession.sessionVerificationController?.isVerified ?? false),
showDeveloperOptions: ServiceLocator.shared.settings.canShowDeveloperOptions),
imageProvider: userSession.mediaProvider)
ServiceLocator.shared.settings.$timelineStyle
@@ -78,6 +79,8 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
callback?(.sessionVerification)
case .changedTimelineStyle:
ServiceLocator.shared.settings.timelineStyle = state.bindings.timelineStyle
case .developerOptions:
callback?(.developerOptions)
}
}
}
@@ -18,7 +18,6 @@ import SwiftUI
struct SettingsScreen: View {
@State private var showingLogoutConfirmation = false
@Environment(\.colorScheme) private var colorScheme
@ScaledMetric private var avatarSize = AvatarSize.user(on: .settings).value
@ScaledMetric private var menuIconSize = 30.0
@@ -40,6 +39,11 @@ struct SettingsScreen: View {
simplifiedSection
.listRowBackground(Color.element.formRowBackground)
if context.viewState.showDeveloperOptions {
developerOptionsSection
.listRowBackground(Color.element.formRowBackground)
}
signOutSection
.listRowBackground(Color.element.formRowBackground)
}
@@ -89,6 +93,16 @@ struct SettingsScreen: View {
}
}
private var developerOptionsSection: some View {
Section {
SettingsDefaultRow(title: ElementL10n.settingsDeveloperOptions,
image: Image(systemName: "hammer.circle")) {
context.send(viewAction: .developerOptions)
}
.accessibilityIdentifier("sessionVerificationButton")
}
}
private var simplifiedSection: some View {
Section {
SettingsPickerRow(title: ElementL10n.settingsTimelineStyle,