mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
@@ -61,12 +61,14 @@ final class SettingsScreenCoordinator: CoordinatorProtocol {
|
||||
verifySession()
|
||||
case .accountSessionsList:
|
||||
presentAccountSessionsListURL()
|
||||
case .notifications:
|
||||
presentNotificationSettings()
|
||||
case .advancedSettings:
|
||||
self.presentAdvancedSettings()
|
||||
case .developerOptions:
|
||||
presentDeveloperOptions()
|
||||
case .logout:
|
||||
callback?(.logout)
|
||||
case .notifications:
|
||||
presentNotificationSettings()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -159,6 +161,21 @@ final class SettingsScreenCoordinator: CoordinatorProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
private func presentNotificationSettings() {
|
||||
let notificationParameters = NotificationSettingsScreenCoordinatorParameters(navigationStackCoordinator: parameters.navigationStackCoordinator,
|
||||
userSession: parameters.userSession,
|
||||
userNotificationCenter: UNUserNotificationCenter.current(),
|
||||
notificationSettings: parameters.notificationSettings,
|
||||
isModallyPresented: false)
|
||||
let coordinator = NotificationSettingsScreenCoordinator(parameters: notificationParameters)
|
||||
parameters.navigationStackCoordinator?.push(coordinator)
|
||||
}
|
||||
|
||||
private func presentAdvancedSettings() {
|
||||
let coordinator = AdvancedSettingsScreenCoordinator()
|
||||
parameters.navigationStackCoordinator?.push(coordinator)
|
||||
}
|
||||
|
||||
private func presentDeveloperOptions() {
|
||||
let coordinator = DeveloperOptionsScreenCoordinator()
|
||||
|
||||
@@ -175,14 +192,4 @@ final class SettingsScreenCoordinator: CoordinatorProtocol {
|
||||
private func showSuccess(label: String) {
|
||||
parameters.userIndicatorController?.submitIndicator(UserIndicator(title: label))
|
||||
}
|
||||
|
||||
private func presentNotificationSettings() {
|
||||
let notificationParameters = NotificationSettingsScreenCoordinatorParameters(navigationStackCoordinator: parameters.navigationStackCoordinator,
|
||||
userSession: parameters.userSession,
|
||||
userNotificationCenter: UNUserNotificationCenter.current(),
|
||||
notificationSettings: parameters.notificationSettings,
|
||||
isModallyPresented: false)
|
||||
let coordinator = NotificationSettingsScreenCoordinator(parameters: notificationParameters)
|
||||
parameters.navigationStackCoordinator?.push(coordinator)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,13 +25,13 @@ enum SettingsScreenViewModelAction {
|
||||
case about
|
||||
case sessionVerification
|
||||
case accountSessionsList
|
||||
case developerOptions
|
||||
case notifications
|
||||
case advancedSettings
|
||||
case developerOptions
|
||||
case logout
|
||||
}
|
||||
|
||||
struct SettingsScreenViewState: BindableState {
|
||||
var bindings: SettingsScreenViewStateBindings
|
||||
var deviceID: String?
|
||||
var userID: String
|
||||
var accountProfileURL: URL?
|
||||
@@ -45,10 +45,6 @@ struct SettingsScreenViewState: BindableState {
|
||||
var window: UIWindow?
|
||||
}
|
||||
|
||||
struct SettingsScreenViewStateBindings {
|
||||
var timelineStyle: TimelineStyle
|
||||
}
|
||||
|
||||
enum SettingsScreenViewAction {
|
||||
case close
|
||||
case accountProfile
|
||||
@@ -56,11 +52,11 @@ enum SettingsScreenViewAction {
|
||||
case reportBug
|
||||
case about
|
||||
case sessionVerification
|
||||
case logout
|
||||
case changedTimelineStyle
|
||||
case accountSessionsList
|
||||
case developerOptions
|
||||
case notifications
|
||||
case developerOptions
|
||||
case advancedSettings
|
||||
case logout
|
||||
|
||||
/// Updates the window used for the OIDC account URL anchor.
|
||||
case updateWindow(UIWindow)
|
||||
|
||||
@@ -29,15 +29,12 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
|
||||
self.userSession = userSession
|
||||
self.appSettings = appSettings
|
||||
|
||||
let bindings = SettingsScreenViewStateBindings(timelineStyle: appSettings.timelineStyle)
|
||||
|
||||
var showSessionVerificationSection = false
|
||||
if let sessionVerificationController = userSession.sessionVerificationController {
|
||||
showSessionVerificationSection = !sessionVerificationController.isVerified
|
||||
}
|
||||
|
||||
super.init(initialViewState: .init(bindings: bindings,
|
||||
deviceID: userSession.deviceID,
|
||||
super.init(initialViewState: .init(deviceID: userSession.deviceID,
|
||||
userID: userSession.userID,
|
||||
accountProfileURL: userSession.clientProxy.accountURL(action: .profile),
|
||||
accountSessionsListURL: userSession.clientProxy.accountURL(action: .sessionsList),
|
||||
@@ -45,10 +42,6 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
|
||||
showDeveloperOptions: appSettings.canShowDeveloperOptions),
|
||||
imageProvider: userSession.mediaProvider)
|
||||
|
||||
appSettings.$timelineStyle
|
||||
.weakAssign(to: \.state.bindings.timelineStyle, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
userSession.clientProxy.avatarURLPublisher
|
||||
.weakAssign(to: \.state.userAvatarURL, on: self)
|
||||
.store(in: &cancellables)
|
||||
@@ -94,12 +87,12 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
|
||||
callback?(.logout)
|
||||
case .sessionVerification:
|
||||
callback?(.sessionVerification)
|
||||
case .changedTimelineStyle:
|
||||
appSettings.timelineStyle = state.bindings.timelineStyle
|
||||
case .notifications:
|
||||
callback?(.notifications)
|
||||
case .accountSessionsList:
|
||||
callback?(.accountSessionsList)
|
||||
case .advancedSettings:
|
||||
callback?(.advancedSettings)
|
||||
case .developerOptions:
|
||||
callback?(.developerOptions)
|
||||
|
||||
|
||||
@@ -37,9 +37,7 @@ struct SettingsScreen: View {
|
||||
manageSessionsSection
|
||||
}
|
||||
|
||||
if context.viewState.showDeveloperOptions {
|
||||
developerOptionsSection
|
||||
}
|
||||
advancedOptionsSection
|
||||
|
||||
signOutSection
|
||||
}
|
||||
@@ -89,7 +87,6 @@ struct SettingsScreen: View {
|
||||
|
||||
private var mainSection: some View {
|
||||
Section {
|
||||
// Account
|
||||
if context.viewState.accountProfileURL != nil {
|
||||
ListRow(label: .default(title: L10n.actionManageAccount, systemIcon: .person),
|
||||
kind: .button {
|
||||
@@ -98,17 +95,6 @@ struct SettingsScreen: View {
|
||||
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.account)
|
||||
}
|
||||
|
||||
// Message layout
|
||||
ListRow(label: .default(title: L10n.commonMessageLayout,
|
||||
systemIcon: .rectangleGrid1x2),
|
||||
kind: .picker(selection: $context.timelineStyle,
|
||||
items: TimelineStyle.allCases.map { (title: $0.name, tag: $0) }))
|
||||
.accessibilityIdentifier("timelineStylePicker")
|
||||
.onChange(of: context.timelineStyle) { _ in
|
||||
context.send(viewAction: .changedTimelineStyle)
|
||||
}
|
||||
|
||||
// Notifications
|
||||
ListRow(label: .default(title: L10n.screenNotificationSettingsTitle,
|
||||
systemIcon: .bell),
|
||||
kind: .navigationLink {
|
||||
@@ -116,7 +102,6 @@ struct SettingsScreen: View {
|
||||
})
|
||||
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.notifications)
|
||||
|
||||
// Analytics
|
||||
ListRow(label: .default(title: L10n.commonAnalytics,
|
||||
systemIcon: .chartBar),
|
||||
kind: .navigationLink {
|
||||
@@ -124,7 +109,6 @@ struct SettingsScreen: View {
|
||||
})
|
||||
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.analytics)
|
||||
|
||||
// Report Bug
|
||||
ListRow(label: .default(title: L10n.commonReportABug,
|
||||
systemIcon: .ladybug),
|
||||
kind: .navigationLink {
|
||||
@@ -132,7 +116,6 @@ struct SettingsScreen: View {
|
||||
})
|
||||
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.reportBug)
|
||||
|
||||
// About
|
||||
ListRow(label: .default(title: L10n.commonAbout,
|
||||
systemIcon: .questionmarkCircle),
|
||||
kind: .navigationLink {
|
||||
@@ -161,14 +144,23 @@ struct SettingsScreen: View {
|
||||
}
|
||||
}
|
||||
|
||||
private var developerOptionsSection: some View {
|
||||
private var advancedOptionsSection: some View {
|
||||
Section {
|
||||
ListRow(label: .default(title: L10n.commonDeveloperOptions,
|
||||
systemIcon: .hammerCircle),
|
||||
ListRow(label: .default(title: L10n.commonAdvancedSettings,
|
||||
systemIcon: .gearshape2),
|
||||
kind: .navigationLink {
|
||||
context.send(viewAction: .developerOptions)
|
||||
context.send(viewAction: .advancedSettings)
|
||||
})
|
||||
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.developerOptions)
|
||||
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.advancedSettings)
|
||||
|
||||
if context.viewState.showDeveloperOptions {
|
||||
ListRow(label: .default(title: L10n.commonDeveloperOptions,
|
||||
systemIcon: .hammerCircle),
|
||||
kind: .navigationLink {
|
||||
context.send(viewAction: .developerOptions)
|
||||
})
|
||||
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.developerOptions)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user