mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 19:44:05 +00:00
Add a link to the global settings in the room notifications settings (#1433)
This commit is contained in:
+15
-3
@@ -20,16 +20,19 @@ import SwiftUI
|
||||
struct NotificationSettingsScreenCoordinatorParameters {
|
||||
let userNotificationCenter: UserNotificationCenterProtocol
|
||||
let notificationSettings: NotificationSettingsProxyProtocol
|
||||
let isModallyPresented: Bool
|
||||
}
|
||||
|
||||
enum NotificationSettingsScreenCoordinatorAction { }
|
||||
enum NotificationSettingsScreenCoordinatorAction {
|
||||
case close
|
||||
}
|
||||
|
||||
final class NotificationSettingsScreenCoordinator: CoordinatorProtocol {
|
||||
private let parameters: NotificationSettingsScreenCoordinatorParameters
|
||||
private var viewModel: NotificationSettingsScreenViewModelProtocol
|
||||
private let actionsSubject: PassthroughSubject<NotificationSettingsScreenCoordinatorAction, Never> = .init()
|
||||
private var cancellables: Set<AnyCancellable> = .init()
|
||||
|
||||
|
||||
var actions: AnyPublisher<NotificationSettingsScreenCoordinatorAction, Never> {
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
@@ -39,11 +42,20 @@ final class NotificationSettingsScreenCoordinator: CoordinatorProtocol {
|
||||
|
||||
viewModel = NotificationSettingsScreenViewModel(appSettings: ServiceLocator.shared.settings,
|
||||
userNotificationCenter: parameters.userNotificationCenter,
|
||||
notificationSettingsProxy: parameters.notificationSettings)
|
||||
notificationSettingsProxy: parameters.notificationSettings,
|
||||
isModallyPresented: parameters.isModallyPresented)
|
||||
}
|
||||
|
||||
func start() {
|
||||
viewModel.fetchInitialContent()
|
||||
|
||||
viewModel.actions.sink { [weak self] action in
|
||||
switch action {
|
||||
case .close:
|
||||
self?.actionsSubject.send(.close)
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
func toPresentable() -> AnyView {
|
||||
|
||||
+5
-1
@@ -17,11 +17,14 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
enum NotificationSettingsScreenViewModelAction { }
|
||||
enum NotificationSettingsScreenViewModelAction {
|
||||
case close
|
||||
}
|
||||
|
||||
struct NotificationSettingsScreenViewState: BindableState {
|
||||
var bindings: NotificationSettingsScreenViewStateBindings
|
||||
var strings = NotificationSettingsScreenStrings()
|
||||
let isModallyPresented: Bool
|
||||
var isUserPermissionGranted: Bool?
|
||||
var allowedNotificationModes: [RoomNotificationModeProxy] = [.allMessages, .mentionsAndKeywordsOnly]
|
||||
|
||||
@@ -82,6 +85,7 @@ enum NotificationSettingsScreenViewAction {
|
||||
case directChatsTapped
|
||||
case roomMentionChanged
|
||||
case callsChanged
|
||||
case close
|
||||
}
|
||||
|
||||
enum NotificationSettingsScreenErrorType: Hashable {
|
||||
|
||||
+4
-2
@@ -30,13 +30,13 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init(appSettings: AppSettings, userNotificationCenter: UserNotificationCenterProtocol, notificationSettingsProxy: NotificationSettingsProxyProtocol) {
|
||||
init(appSettings: AppSettings, userNotificationCenter: UserNotificationCenterProtocol, notificationSettingsProxy: NotificationSettingsProxyProtocol, isModallyPresented: Bool) {
|
||||
self.appSettings = appSettings
|
||||
self.userNotificationCenter = userNotificationCenter
|
||||
self.notificationSettingsProxy = notificationSettingsProxy
|
||||
|
||||
let bindings = NotificationSettingsScreenViewStateBindings(enableNotifications: appSettings.enableNotifications)
|
||||
super.init(initialViewState: NotificationSettingsScreenViewState(bindings: bindings))
|
||||
super.init(initialViewState: NotificationSettingsScreenViewState(bindings: bindings, isModallyPresented: isModallyPresented))
|
||||
|
||||
// Listen for changes to AppSettings.enableNotifications
|
||||
appSettings.$enableNotifications
|
||||
@@ -73,6 +73,8 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy
|
||||
return
|
||||
}
|
||||
Task { await enableCalls(state.bindings.callsEnabled) }
|
||||
case .close:
|
||||
actionsSubject.send(.close)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+16
-2
@@ -37,12 +37,25 @@ struct NotificationSettingsScreen: View {
|
||||
}
|
||||
.compoundForm()
|
||||
.navigationTitle(L10n.screenNotificationSettingsTitle)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar { toolbar }
|
||||
.alert(item: $context.alertInfo)
|
||||
.track(screen: .settingsNotifications)
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
|
||||
@ToolbarContentBuilder
|
||||
private var toolbar: some ToolbarContent {
|
||||
if context.viewState.isModallyPresented {
|
||||
ToolbarItem(placement: .confirmationAction) {
|
||||
Button(L10n.actionClose) {
|
||||
context.send(viewAction: .close)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var userPermissionSection: some View {
|
||||
Section {
|
||||
HStack(alignment: .firstTextBaseline, spacing: 13) {
|
||||
@@ -183,7 +196,8 @@ struct NotificationSettingsScreen_Previews: PreviewProvider {
|
||||
|
||||
var viewModel = NotificationSettingsScreenViewModel(appSettings: appSettings,
|
||||
userNotificationCenter: notificationCenter,
|
||||
notificationSettingsProxy: notificationSettingsProxy)
|
||||
notificationSettingsProxy: notificationSettingsProxy,
|
||||
isModallyPresented: true)
|
||||
viewModel.fetchInitialContent()
|
||||
return viewModel
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user