mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Add a DeveloperOptionsScreenHook.
This commit is contained in:
@@ -38,6 +38,11 @@ class AppHooks: AppHooksProtocol {
|
||||
func registerRoomScreenHook(_ hook: RoomScreenHookProtocol) {
|
||||
roomScreenHook = hook
|
||||
}
|
||||
|
||||
private(set) var developerOptionsScreenHook: DeveloperOptionsScreenHookProtocol = DefaultDeveloperOptionsScreenHook()
|
||||
func registerDeveloperOptionsScreenHook(_ hook: DeveloperOptionsScreenHookProtocol) {
|
||||
developerOptionsScreenHook = hook
|
||||
}
|
||||
#endif
|
||||
|
||||
private(set) var tracingHook: TracingHookProtocol = DefaultTracingHook()
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// Copyright 2025 Element Creations Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
protocol DeveloperOptionsScreenHookProtocol {
|
||||
func generalSectionRows() -> AnyView?
|
||||
}
|
||||
|
||||
struct DefaultDeveloperOptionsScreenHook: DeveloperOptionsScreenHookProtocol {
|
||||
func generalSectionRows() -> AnyView? { nil }
|
||||
}
|
||||
@@ -215,7 +215,7 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
|
||||
}
|
||||
|
||||
private func presentDeveloperOptions() {
|
||||
let coordinator = DeveloperOptionsScreenCoordinator(appSettings: flowParameters.appSettings)
|
||||
let coordinator = DeveloperOptionsScreenCoordinator(appSettings: flowParameters.appSettings, appHooks: flowParameters.appHooks)
|
||||
|
||||
coordinator.actions
|
||||
.sink { [weak self] action in
|
||||
|
||||
+3
-2
@@ -23,9 +23,10 @@ final class DeveloperOptionsScreenCoordinator: CoordinatorProtocol {
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init(appSettings: AppSettings) {
|
||||
init(appSettings: AppSettings, appHooks: AppHooks) {
|
||||
viewModel = DeveloperOptionsScreenViewModel(developerOptions: appSettings,
|
||||
elementCallBaseURL: appSettings.elementCallBaseURL)
|
||||
elementCallBaseURL: appSettings.elementCallBaseURL,
|
||||
appHooks: appHooks)
|
||||
|
||||
viewModel.actions
|
||||
.sink { [weak self] action in
|
||||
|
||||
+1
@@ -14,6 +14,7 @@ enum DeveloperOptionsScreenViewModelAction {
|
||||
|
||||
struct DeveloperOptionsScreenViewState: BindableState {
|
||||
let elementCallBaseURL: URL
|
||||
let appHooks: AppHooks
|
||||
var bindings: DeveloperOptionsScreenViewStateBindings
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -18,9 +18,9 @@ class DeveloperOptionsScreenViewModel: DeveloperOptionsScreenViewModelType, Deve
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init(developerOptions: DeveloperOptionsProtocol, elementCallBaseURL: URL) {
|
||||
init(developerOptions: DeveloperOptionsProtocol, elementCallBaseURL: URL, appHooks: AppHooks) {
|
||||
let bindings = DeveloperOptionsScreenViewStateBindings(developerOptions: developerOptions)
|
||||
let state = DeveloperOptionsScreenViewState(elementCallBaseURL: elementCallBaseURL, bindings: bindings)
|
||||
let state = DeveloperOptionsScreenViewState(elementCallBaseURL: elementCallBaseURL, appHooks: appHooks, bindings: bindings)
|
||||
|
||||
super.init(initialViewState: state)
|
||||
}
|
||||
|
||||
+7
-3
@@ -33,10 +33,14 @@ struct DeveloperOptionsScreen: View {
|
||||
}
|
||||
}
|
||||
|
||||
Section("Spaces") {
|
||||
Section("General") {
|
||||
Toggle(isOn: $context.spaceSettingsEnabled) {
|
||||
Text("Space settings")
|
||||
}
|
||||
|
||||
context.viewState.appHooks
|
||||
.developerOptionsScreenHook
|
||||
.generalSectionRows()
|
||||
}
|
||||
|
||||
Section("Room List") {
|
||||
@@ -146,7 +150,6 @@ struct DeveloperOptionsScreen: View {
|
||||
}
|
||||
}
|
||||
.overlay(effectsView)
|
||||
.compoundList()
|
||||
.navigationTitle(L10n.commonDeveloperOptions)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
}
|
||||
@@ -205,7 +208,8 @@ private extension Set<TraceLogPack> {
|
||||
|
||||
struct DeveloperOptionsScreen_Previews: PreviewProvider {
|
||||
static let viewModel = DeveloperOptionsScreenViewModel(developerOptions: ServiceLocator.shared.settings,
|
||||
elementCallBaseURL: ServiceLocator.shared.settings.elementCallBaseURL)
|
||||
elementCallBaseURL: ServiceLocator.shared.settings.elementCallBaseURL,
|
||||
appHooks: AppHooks())
|
||||
static var previews: some View {
|
||||
NavigationStack {
|
||||
DeveloperOptionsScreen(context: viewModel.context)
|
||||
|
||||
Reference in New Issue
Block a user