mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Add a link to the global settings in the room notifications settings (#1433)
This commit is contained in:
+24
-1
@@ -18,13 +18,29 @@ import Combine
|
||||
import SwiftUI
|
||||
|
||||
struct RoomNotificationSettingsScreenCoordinatorParameters {
|
||||
weak var navigationStackCoordinator: NavigationStackCoordinator?
|
||||
let notificationSettingsProxy: NotificationSettingsProxyProtocol
|
||||
let roomProxy: RoomProxyProtocol
|
||||
}
|
||||
|
||||
enum RoomNotificationSettingsScreenCoordinatorAction {
|
||||
case presentNotificationSettingsScreen
|
||||
}
|
||||
|
||||
final class RoomNotificationSettingsScreenCoordinator: CoordinatorProtocol {
|
||||
private let parameters: RoomNotificationSettingsScreenCoordinatorParameters
|
||||
private var viewModel: RoomNotificationSettingsScreenViewModelProtocol
|
||||
|
||||
private let actionsSubject: PassthroughSubject<RoomNotificationSettingsScreenCoordinatorAction, Never> = .init()
|
||||
private var cancellables: Set<AnyCancellable> = .init()
|
||||
|
||||
var actions: AnyPublisher<RoomNotificationSettingsScreenCoordinatorAction, Never> {
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
private var navigationStackCoordinator: NavigationStackCoordinator? {
|
||||
parameters.navigationStackCoordinator
|
||||
}
|
||||
|
||||
init(parameters: RoomNotificationSettingsScreenCoordinatorParameters) {
|
||||
self.parameters = parameters
|
||||
@@ -32,7 +48,14 @@ final class RoomNotificationSettingsScreenCoordinator: CoordinatorProtocol {
|
||||
roomProxy: parameters.roomProxy)
|
||||
}
|
||||
|
||||
func start() { }
|
||||
func start() {
|
||||
viewModel.actions.sink { [weak self] action in
|
||||
switch action {
|
||||
case .openGlobalSettings:
|
||||
self?.actionsSubject.send(.presentNotificationSettingsScreen)
|
||||
}
|
||||
}.store(in: &cancellables)
|
||||
}
|
||||
|
||||
func toPresentable() -> AnyView {
|
||||
AnyView(RoomNotificationSettingsScreen(context: viewModel.context))
|
||||
|
||||
+8
-1
@@ -16,7 +16,9 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
enum RoomNotificationSettingsScreenViewModelAction { }
|
||||
enum RoomNotificationSettingsScreenViewModelAction {
|
||||
case openGlobalSettings
|
||||
}
|
||||
|
||||
enum RoomNotificationSettingsState {
|
||||
case loading
|
||||
@@ -66,15 +68,20 @@ struct RoomNotificationSettingsScreenViewStateBindings {
|
||||
enum RoomNotificationSettingsScreenViewAction {
|
||||
case changedAllowCustomSettings
|
||||
case setCustomMode(RoomNotificationModeProxy)
|
||||
case customSettingFootnoteLinkTapped
|
||||
}
|
||||
|
||||
struct RoomNotificationSettingsScreenStrings {
|
||||
let customSettingFootnote: AttributedString
|
||||
let customSettingFootnoteLink: URL?
|
||||
|
||||
init() {
|
||||
customSettingFootnoteLink = URL(string: "element://openGlobalSettings")
|
||||
|
||||
let linkPlaceholder = "{link}"
|
||||
var customSettingFootnote = AttributedString(L10n.screenRoomNotificationSettingsDefaultSettingFootnote(linkPlaceholder))
|
||||
var linkString = AttributedString(L10n.screenRoomNotificationSettingsDefaultSettingFootnoteContentLink)
|
||||
linkString.link = customSettingFootnoteLink
|
||||
linkString.bold()
|
||||
customSettingFootnote.replace(linkPlaceholder, with: linkString)
|
||||
|
||||
|
||||
+2
@@ -48,6 +48,8 @@ class RoomNotificationSettingsScreenViewModel: RoomNotificationSettingsScreenVie
|
||||
toogleCustomSetting()
|
||||
case .setCustomMode(let mode):
|
||||
setCustomMode(mode)
|
||||
case .customSettingFootnoteLinkTapped:
|
||||
actionsSubject.send(.openGlobalSettings)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -71,6 +71,11 @@ struct RoomNotificationSettingsScreen: View {
|
||||
.compoundFormSectionHeader()
|
||||
} footer: {
|
||||
Text(context.viewState.strings.customSettingFootnote)
|
||||
.environment(\.openURL, OpenURLAction { url in
|
||||
guard url == context.viewState.strings.customSettingFootnoteLink else { return .discarded }
|
||||
context.send(viewAction: .customSettingFootnoteLinkTapped)
|
||||
return .handled
|
||||
})
|
||||
.compoundFormSectionFooter()
|
||||
}
|
||||
.compoundFormSection()
|
||||
|
||||
Reference in New Issue
Block a user