MESSENGER-3425 permalink prefix developer settings screen

This commit is contained in:
Arnfried Griesert
2023-03-08 13:28:11 +00:00
parent ac491f573e
commit 51e73c71df
4 changed files with 66 additions and 38 deletions

View File

@@ -567,6 +567,10 @@ class BWIBuildSettings: NSObject {
// MARK: User Search
var sortUserSearchResultsAlphabetically = true
// MARK: Permalinks
var permalinkPrefixSettings = false
var permalinkPrefixes: [String] = []
// MARK: Client error search term
var clientErrorSearchTerm = "Request failed: client error"
}

View File

@@ -585,6 +585,9 @@
// MARK: - Chat creation
"room_creation_title" = "Neue Direktnachricht";
// MARK: - Permalink
"settings_permalink_prefix_picker_title" = "Permalink Prefix";
// MARK: - Notification Settings
"settings_notify_me_for" = "Benachrichtige mich für";
"room_notifs_settings_encrypted_room_notice" = "";

View File

@@ -465,6 +465,9 @@
// MARK: - Chat creation
"room_creation_title" = "New chat";
// MARK: - Permalink
"settings_permalink_prefix_picker_title" = "Permalink Prefix";
// MARK: - Notification Settings
"settings_notify_me_for" = "Notify me for";
"room_notifs_settings_encrypted_room_notice" = "";

View File

@@ -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)
}