MESSENGER-3425 permalink prefix developer settings screen

This commit is contained in:
Arnfried Griesert
2023-03-08 13:28:11 +00:00
parent b27f71e24e
commit ca8901bade
4 changed files with 66 additions and 38 deletions
@@ -34,50 +34,68 @@ struct DeveloperSettingsView: View {
@State private var showAlert = false
@State private var showAlertBirthdayCampaign = false
@State private var permalinkPrefix: String? = UserDefaults.standard.string(forKey: "bwi_permalink_prefix")
var body: some View {
List {
Button(action: { showAlert = createNewPersonalNotesRoom(mxSession: session) }) {
Text(BWIL10n.bwiSettingsDeveloperCreateNewPersonalNotesRoom)
.foregroundColor(Color(ThemeService.shared().theme.tintColor))
.font(.system(size: 17))
}
.alert(isPresented: $showAlert) {
Alert(title: Text(BWIL10n.bwiSettingsDeveloper), dismissButton: .default(Text("Ok")))
}
Button(action: { showAlert = resetMatomoInfoScreen() }) {
Text(BWIL10n.bwiSettingsDeveloperResetMatomoInfo)
.foregroundColor(Color(ThemeService.shared().theme.tintColor))
.font(.system(size: 17))
}
.alert(isPresented: $showAlert) {
Alert(title: Text(BWIL10n.bwiSettingsDeveloperShowMatomoPrivacyNotesResetted), message: Text(BWIL10n.bwiSettingsDeveloperShowMatomoPrivacyNotesResetted), dismissButton: .default(Text("Ok")))
}
Button(action: { showAlertBirthdayCampaign = resetBirthdayCampaignScreen(mxSession: session) }) {
Text(BWIL10n.bwiSettingsDeveloperSettingsResetBirthdayBanner)
.foregroundColor(Color(ThemeService.shared().theme.tintColor))
.font(.system(size: 17))
}
.alert(isPresented: $showAlertBirthdayCampaign) {
Alert(title: Text(BWIL10n.bwiSettingsDeveloperSettingsBirthdayBannerResettetTitle), message: Text(BWIL10n.bwiSettingsDeveloperSettingsBirthdayBannerResettetMessage), dismissButton: .default(Text("Ok")))
}
Button(action: { _ = restrictUser(mxSession: session) }) {
Text(BWIL10n.bwiSettingsDeveloperRestrictUser)
.foregroundColor(Color(ThemeService.shared().theme.tintColor))
.font(.system(size: 17))
}
Button(action: { _ = unrestrictUser(mxSession: session) }) {
Form {
SwiftUI.Section {
Button(action: { showAlert = createNewPersonalNotesRoom(mxSession: session) }) {
Text(BWIL10n.bwiSettingsDeveloperCreateNewPersonalNotesRoom)
.foregroundColor(Color(ThemeService.shared().theme.tintColor))
.font(.system(size: 17))
}
.alert(isPresented: $showAlert) {
Alert(title: Text(BWIL10n.bwiSettingsDeveloper), dismissButton: .default(Text("Ok")))
}
Button(action: { showAlert = resetMatomoInfoScreen() }) {
Text(BWIL10n.bwiSettingsDeveloperResetMatomoInfo)
.foregroundColor(Color(ThemeService.shared().theme.tintColor))
.font(.system(size: 17))
}
.alert(isPresented: $showAlert) {
Alert(title: Text(BWIL10n.bwiSettingsDeveloperShowMatomoPrivacyNotesResetted), message: Text(BWIL10n.bwiSettingsDeveloperShowMatomoPrivacyNotesResetted), dismissButton: .default(Text("Ok")))
}
Button(action: { showAlertBirthdayCampaign = resetBirthdayCampaignScreen(mxSession: session) }) {
Text(BWIL10n.bwiSettingsDeveloperSettingsResetBirthdayBanner)
.foregroundColor(Color(ThemeService.shared().theme.tintColor))
.font(.system(size: 17))
}
.alert(isPresented: $showAlertBirthdayCampaign) {
Alert(title: Text(BWIL10n.bwiSettingsDeveloperSettingsBirthdayBannerResettetTitle), message: Text(BWIL10n.bwiSettingsDeveloperSettingsBirthdayBannerResettetMessage), dismissButton: .default(Text("Ok")))
}
Button(action: { _ = restrictUser(mxSession: session) }) {
Text(BWIL10n.bwiSettingsDeveloperRestrictUser)
.foregroundColor(Color(ThemeService.shared().theme.tintColor))
.font(.system(size: 17))
}
Button(action: { _ = unrestrictUser(mxSession: session) }) {
Text(BWIL10n.bwiSettingsDeveloperUnrestrictUser)
.foregroundColor(Color(ThemeService.shared().theme.tintColor))
.font(.system(size: 17))
.foregroundColor(Color(ThemeService.shared().theme.tintColor))
.font(.system(size: 17))
}
Button(action: { _ = unmarkBannerVersion(mxSession: session) }) {
Text(BWIL10n.bwiSettingsDeveloperUnmarkBanner)
.foregroundColor(Color(ThemeService.shared().theme.tintColor))
.font(.system(size: 17))
}
}
Button(action: { _ = unmarkBannerVersion(mxSession: session) }) {
Text(BWIL10n.bwiSettingsDeveloperUnmarkBanner)
.foregroundColor(Color(ThemeService.shared().theme.tintColor))
.font(.system(size: 17))
if BWIBuildSettings.shared.permalinkPrefixSettings && !BWIBuildSettings.shared.permalinkPrefixes.isEmpty {
SwiftUI.Section(header: Text(BWIL10n.settingsPermalinkPrefixPickerTitle)) {
Picker("", selection: $permalinkPrefix) {
ForEach(BWIBuildSettings.shared.permalinkPrefixes, id: \.self) { prefix in
Text(prefix)
.tag(String?.some(prefix))
}
}
.id(UUID())
.onChange(of: permalinkPrefix) { newValue in
UserDefaults.standard.set(newValue, forKey: "bwi_permalink_prefix")
}
}
}
}
.listStyle(.grouped)
.navigationTitle(BWIL10n.bwiSettingsDeveloper)
.navigationBarTitleDisplayMode(.inline)
}