mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-17 23:18:27 +02:00
MESSENGER-2762 Initial Merge
This commit is contained in:
84
bwi/DeveloperSettings/DeveloperSettingsView.swift
Normal file
84
bwi/DeveloperSettings/DeveloperSettingsView.swift
Normal file
@@ -0,0 +1,84 @@
|
||||
//
|
||||
/*
|
||||
* Copyright (c) 2021 BWI GmbH
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import SwiftUI
|
||||
|
||||
/// Helper class for making our SwiftUI view available to ObjectiveC
|
||||
@objcMembers class DeveloperSettingsViewController: NSObject {
|
||||
|
||||
@available(iOS 14.0, *)
|
||||
class func makeViewController(session: MXSession) -> UIViewController {
|
||||
return UIHostingController(rootView: DeveloperSettingsView(session: session))
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 14.0, *)
|
||||
struct DeveloperSettingsView: View {
|
||||
let session: MXSession?
|
||||
|
||||
@State private var showAlert = false
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
Button(action: { showAlert = createNewPersonalNotesRoom(mxSession: session) }) {
|
||||
Text(NSLocalizedString("bwi_settings_developer_create_new_personal_notes_room", tableName: "Vector", comment: ""))
|
||||
.foregroundColor(Color(ThemeService.shared().theme.tintColor))
|
||||
.font(.system(size: 17))
|
||||
}
|
||||
.alert(isPresented: $showAlert) {
|
||||
Alert(title: Text(NSLocalizedString("bwi_settings_developer", tableName: "Vector", comment: "")), message: Text(NSLocalizedString("bwi_settings_developer_new_personal_notes_room_created", tableName: "Vector", comment: "")), dismissButton: .default(Text("Ok")))
|
||||
}
|
||||
|
||||
Button(action: { showAlert = resetMatomoInfoScreen() }) {
|
||||
Text(NSLocalizedString("bwi_settings_developer_reset_matomo_info", tableName: "Vector", comment: ""))
|
||||
.foregroundColor(Color(ThemeService.shared().theme.tintColor))
|
||||
.font(.system(size: 17))
|
||||
}
|
||||
.alert(isPresented: $showAlert) {
|
||||
Alert(title: Text(NSLocalizedString("bwi_settings_developer", tableName: "Vector", comment: "")), message: Text(NSLocalizedString("bwi_settings_developer_show_matomo_privacy_notes_resetted", tableName: "Vector", comment: "")), dismissButton: .default(Text("Ok")))
|
||||
}
|
||||
}
|
||||
.navigationTitle(NSLocalizedString("bwi_settings_developer", tableName: "Vector", comment: ""))
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@available(iOS 14.0, *)
|
||||
struct DeveloperSettingsView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
DeveloperSettingsView(session: nil)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Button Actions
|
||||
|
||||
fileprivate func createNewPersonalNotesRoom(mxSession: MXSession?) -> Bool {
|
||||
guard let mxSession = mxSession else {
|
||||
return false
|
||||
}
|
||||
|
||||
let service = PersonalNotesDefaultService(mxSession: mxSession)
|
||||
service.resetPersonalNotesRoom()
|
||||
service.createPersonalNotesRoomIfNeeded()
|
||||
return true
|
||||
}
|
||||
|
||||
fileprivate func resetMatomoInfoScreen() -> Bool {
|
||||
UserDefaults.standard.set(false, forKey: "bwi_matomo_info_screen_shown")
|
||||
return true
|
||||
}
|
||||
Reference in New Issue
Block a user