Implemented remove app protection
This commit is contained in:
parent
5e07a900a9
commit
d197346cfc
|
@ -166,11 +166,14 @@ Unfortunately, Bankmeister cannot know whether a bank charges for instant paymen
|
|||
|
||||
/* ProtectAppSettingsDialog */
|
||||
|
||||
"Protect App Settings Dialog title" = "Security settings";
|
||||
"Protect App Settings Dialog title" = "Select app protection";
|
||||
"FaceID" = "FaceID";
|
||||
"TouchID" = "TouchID";
|
||||
"Password" = "Password";
|
||||
"None" = "Unprotected";
|
||||
"Authenticate with TouchID" = "Authenticate with TouchID";
|
||||
"Enter new password" = "Enter new password";
|
||||
"Confirm password" = "Confirm password";
|
||||
"Confirm new password" = "Confirm new password";
|
||||
"Do you really want to remove app protection?" = "Do you really want to remove app protection?";
|
||||
"Remove app protection" = "Remove app protection";
|
||||
|
|
|
@ -166,11 +166,14 @@ Ob eine Bank Gebühren für Echtzeitüberweisungen erhebt, kann Bankmeister leid
|
|||
|
||||
/* ProtectAppSettingsDialog */
|
||||
|
||||
"Protect App Settings Dialog title" = "Sicherheitseinstellungen"; // TODO: find a better title
|
||||
"Protect App Settings Dialog title" = "Appzugangsschutz festlegen";
|
||||
"FaceID" = "FaceID";
|
||||
"TouchID" = "TouchID";
|
||||
"Password" = "Passwort";
|
||||
"None" = "Ungeschützt";
|
||||
"Authenticate with TouchID" = "Mit TouchID authentifizieren";
|
||||
"Enter new password" = "Neues Passwort eingeben";
|
||||
"Confirm password" = "Bestätigen";
|
||||
"Confirm new password" = "Neues Passwort bestätigen";
|
||||
"Do you really want to remove app protection?" = "Möchten Sie den Appzugangsschutz wirklich entfernen?";
|
||||
"Remove app protection" = "Appzugangsschutz entfernen";
|
||||
|
|
|
@ -110,6 +110,18 @@ extension Color {
|
|||
static let systemBackground = Color(UIColor.systemBackground)
|
||||
static let secondarySystemBackground = Color(UIColor.secondarySystemBackground)
|
||||
static let tertiarySystemBackground = Color(UIColor.tertiarySystemBackground)
|
||||
|
||||
static let systemGroupedBackground = Color(UIColor.systemGroupedBackground)
|
||||
|
||||
static var destructive: Color {
|
||||
if UIColor.responds(to: Selector(("_systemDestructiveTintColor"))) {
|
||||
if let red = UIColor.perform(Selector(("_systemDestructiveTintColor")))?.takeUnretainedValue() as? UIColor {
|
||||
return Color(red)
|
||||
}
|
||||
}
|
||||
|
||||
return Color.red
|
||||
}
|
||||
|
||||
// There are more..
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ struct BankSettingsDialog: View {
|
|||
Spacer()
|
||||
|
||||
Button("Delete account", action: askUserToDeleteAccount)
|
||||
.foregroundColor(Color.red)
|
||||
.foregroundColor(Color.destructive)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ struct ProtectAppSettingsDialog: View {
|
|||
|
||||
@State private var isPasswordSelected: Bool = false
|
||||
|
||||
@State private var isNoAppProtectionSelected: Bool = false
|
||||
|
||||
@State private var selectedAuthenticationTypeIndex = 0
|
||||
|
||||
private var selectedAuthenticationTypeIndexBinding: Binding<Int> {
|
||||
|
@ -40,6 +42,8 @@ struct ProtectAppSettingsDialog: View {
|
|||
|
||||
|
||||
init() {
|
||||
let currentAuthenticationType = authenticationService.authenticationType
|
||||
|
||||
var authenticationTypes = [AuthenticationType]()
|
||||
|
||||
if authenticationService.deviceSupportsFaceID {
|
||||
|
@ -51,10 +55,13 @@ struct ProtectAppSettingsDialog: View {
|
|||
|
||||
authenticationTypes.append(.password)
|
||||
|
||||
if currentAuthenticationType != .none {
|
||||
authenticationTypes.append(.none)
|
||||
}
|
||||
|
||||
self.supportedAuthenticationTypes = authenticationTypes
|
||||
|
||||
|
||||
let currentAuthenticationType = authenticationService.authenticationType
|
||||
if currentAuthenticationType == .faceID || (currentAuthenticationType != .password && authenticationService.deviceSupportsFaceID) {
|
||||
_isFaceIDSelected = State(initialValue: true)
|
||||
_selectedAuthenticationTypeIndex = State(initialValue: 0)
|
||||
|
@ -109,12 +116,20 @@ struct ProtectAppSettingsDialog: View {
|
|||
}
|
||||
}
|
||||
|
||||
if isNoAppProtectionSelected {
|
||||
Section {
|
||||
Text("Do you really want to remove app protection?")
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
}
|
||||
|
||||
Section {
|
||||
HStack {
|
||||
Spacer()
|
||||
|
||||
Button("OK") { self.setAuthenticationType() }
|
||||
Button(isNoAppProtectionSelected ? "Remove app protection" : "OK") { self.setAuthenticationType() }
|
||||
.alignVertically(.center)
|
||||
.foregroundColor(isNoAppProtectionSelected ? Color.destructive : nil)
|
||||
.disabled( !self.authenticatedWithNewAuthenticationType)
|
||||
|
||||
Spacer()
|
||||
|
@ -131,6 +146,7 @@ struct ProtectAppSettingsDialog: View {
|
|||
isFaceIDSelected = false
|
||||
isTouchIDSelected = false
|
||||
isPasswordSelected = false
|
||||
isNoAppProtectionSelected = false
|
||||
|
||||
if type == .faceID {
|
||||
isFaceIDSelected = true
|
||||
|
@ -138,9 +154,12 @@ struct ProtectAppSettingsDialog: View {
|
|||
else if type == .touchID {
|
||||
isTouchIDSelected = true
|
||||
}
|
||||
else {
|
||||
else if type == .password {
|
||||
isPasswordSelected = true
|
||||
}
|
||||
else if type == .none {
|
||||
isNoAppProtectionSelected = true
|
||||
}
|
||||
|
||||
if isPasswordSelected == false {
|
||||
UIApplication.hideKeyboard()
|
||||
|
@ -159,7 +178,8 @@ struct ProtectAppSettingsDialog: View {
|
|||
|
||||
private var authenticatedWithNewAuthenticationType: Bool {
|
||||
((isFaceIDSelected || isTouchIDSelected) && successfullyAuthenticatedWithBiometricAuthentication) ||
|
||||
(isPasswordSelected && successfullyAuthenticatedWithPassword)
|
||||
(isPasswordSelected && successfullyAuthenticatedWithPassword) ||
|
||||
isNoAppProtectionSelected
|
||||
}
|
||||
|
||||
func handleReturnKeyPress() -> Bool {
|
||||
|
@ -179,9 +199,12 @@ struct ProtectAppSettingsDialog: View {
|
|||
else if isTouchIDSelected {
|
||||
authenticationService.setAuthenticationType(.touchID)
|
||||
}
|
||||
else {
|
||||
else if isPasswordSelected {
|
||||
authenticationService.setAuthenticationTypeToPassword(newPassword)
|
||||
}
|
||||
else if isNoAppProtectionSelected {
|
||||
authenticationService.setAuthenticationType(.none)
|
||||
}
|
||||
|
||||
presentation.wrappedValue.dismiss()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue