mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
New notifications section in settings (#1273)
This commit is contained in:
@@ -59,6 +59,8 @@ final class SettingsScreenCoordinator: CoordinatorProtocol {
|
||||
self.presentDeveloperOptions()
|
||||
case .logout:
|
||||
self.callback?(.logout)
|
||||
case .notifications:
|
||||
self.presentNotificationSettings()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,4 +138,12 @@ final class SettingsScreenCoordinator: CoordinatorProtocol {
|
||||
private func showSuccess(label: String) {
|
||||
parameters.userIndicatorController?.submitIndicator(UserIndicator(title: label))
|
||||
}
|
||||
|
||||
private func presentNotificationSettings() {
|
||||
let notificationParameters = NotificationSettingsScreenCoordinatorParameters(
|
||||
userNotificationCenter: UNUserNotificationCenter.current()
|
||||
)
|
||||
let coordinator = NotificationSettingsScreenCoordinator(parameters: notificationParameters)
|
||||
parameters.navigationStackCoordinator?.push(coordinator)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ enum SettingsScreenViewModelAction {
|
||||
case about
|
||||
case sessionVerification
|
||||
case developerOptions
|
||||
case notifications
|
||||
case logout
|
||||
}
|
||||
|
||||
@@ -34,6 +35,7 @@ struct SettingsScreenViewState: BindableState {
|
||||
var userAvatarURL: URL?
|
||||
var userDisplayName: String?
|
||||
var showSessionVerificationSection: Bool
|
||||
var showNotificationSettings: Bool
|
||||
var showDeveloperOptions: Bool
|
||||
}
|
||||
|
||||
@@ -50,4 +52,5 @@ enum SettingsScreenViewAction {
|
||||
case logout
|
||||
case changedTimelineStyle
|
||||
case developerOptions
|
||||
case notifications
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
|
||||
deviceID: userSession.deviceID,
|
||||
userID: userSession.userID,
|
||||
showSessionVerificationSection: showSessionVerificationSection,
|
||||
showNotificationSettings: appSettings.notificationSettingsEnabled,
|
||||
showDeveloperOptions: appSettings.canShowDeveloperOptions),
|
||||
imageProvider: userSession.mediaProvider)
|
||||
|
||||
@@ -51,6 +52,10 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
|
||||
.weakAssign(to: \.state.userAvatarURL, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
appSettings.$notificationSettingsEnabled
|
||||
.weakAssign(to: \.state.showNotificationSettings, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
Task {
|
||||
await userSession.clientProxy.loadUserAvatarURL()
|
||||
}
|
||||
@@ -92,6 +97,8 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
|
||||
callback?(.sessionVerification)
|
||||
case .changedTimelineStyle:
|
||||
appSettings.timelineStyle = state.bindings.timelineStyle
|
||||
case .notifications:
|
||||
callback?(.notifications)
|
||||
case .developerOptions:
|
||||
callback?(.developerOptions)
|
||||
}
|
||||
|
||||
@@ -113,6 +113,15 @@ struct SettingsScreen: View {
|
||||
context.send(viewAction: .changedTimelineStyle)
|
||||
}
|
||||
|
||||
// Notifications
|
||||
if context.viewState.showNotificationSettings {
|
||||
Button { context.send(viewAction: .notifications) } label: {
|
||||
Label(L10n.screenNotificationSettingsTitle, systemImage: "bell")
|
||||
}
|
||||
.buttonStyle(.compoundForm(accessory: .navigationLink))
|
||||
.accessibilityIdentifier("notificationsButton")
|
||||
}
|
||||
|
||||
// Analytics
|
||||
Button { context.send(viewAction: .analytics) } label: {
|
||||
Label(L10n.commonAnalytics, systemImage: "chart.bar")
|
||||
@@ -194,6 +203,7 @@ struct SettingsScreen_Previews: PreviewProvider {
|
||||
static let viewModel = {
|
||||
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "@userid:example.com"),
|
||||
mediaProvider: MockMediaProvider())
|
||||
ServiceLocator.shared.settings.notificationSettingsEnabled = true
|
||||
return SettingsScreenViewModel(userSession: userSession,
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user