Reduce boilerplate in Developer Options Screen (#1378)

* Reduce developer options boilerplate

* Add protocol DeveloperOptions

* Delete timelineDiffableAnimationsEnabled

* Refactor DeveloperOptions -> DeveloperOptionsProtocol
This commit is contained in:
Alfonso Grillo
2023-07-24 10:42:14 +02:00
committed by GitHub
parent 156e33b27c
commit 6fc8c31449
5 changed files with 27 additions and 53 deletions
@@ -26,17 +26,11 @@ struct DeveloperOptionsScreen: View {
Toggle(isOn: $context.shouldCollapseRoomStateEvents) {
Text("Collapse room state events")
}
.onChange(of: context.shouldCollapseRoomStateEvents) { _ in
context.send(viewAction: .changedShouldCollapseRoomStateEvents)
}
Toggle(isOn: $context.readReceiptsEnabled) {
Text("Show read receipts")
Text("Requires app reboot")
}
.onChange(of: context.readReceiptsEnabled) { _ in
context.send(viewAction: .changedReadReceiptsEnabled)
}
}
Section("Notifications") {
@@ -44,25 +38,16 @@ struct DeveloperOptionsScreen: View {
Text("Use notification encryption sync")
Text("Requires app reboot")
}
.onChange(of: context.isEncryptionSyncEnabled) { _ in
context.send(viewAction: .changedIsEncryptionSyncEnabled)
}
Toggle(isOn: $context.notificationSettingsEnabled) {
Text("Show notification settings")
}
.onChange(of: context.notificationSettingsEnabled) { _ in
context.send(viewAction: .changedNotificationSettingsEnabled)
}
}
Section("Room creation") {
Toggle(isOn: $context.userSuggestionsEnabled) {
Text("User suggestions")
}
.onChange(of: context.userSuggestionsEnabled) { _ in
context.send(viewAction: .changedUserSuggestionsEnabled)
}
}
Section {
@@ -116,7 +101,7 @@ struct DeveloperOptionsScreen: View {
// MARK: - Previews
struct DeveloperOptionsScreen_Previews: PreviewProvider {
static let viewModel = DeveloperOptionsScreenViewModel(appSettings: ServiceLocator.shared.settings)
static let viewModel = DeveloperOptionsScreenViewModel(developerOptions: ServiceLocator.shared.settings)
static var previews: some View {
NavigationStack {
DeveloperOptionsScreen(context: viewModel.context)