Skip to content

Commit

Permalink
coding
Browse files Browse the repository at this point in the history
Signed-off-by: Marino Faggiana <[email protected]>
  • Loading branch information
marinofaggiana committed May 30, 2024
1 parent d882818 commit 9d57dd4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 26 deletions.
35 changes: 10 additions & 25 deletions iOSClient/Settings/Settings/E2EE/NCManageE2EE.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,15 @@

import SwiftUI
import NextcloudKit
import TOPasscodeViewController
import LocalAuthentication

struct NCViewE2EE: View {
@ObservedObject var manageE2EE: NCManageE2EE
@State var account: String
@State var controller: UITabBarController?

init(account: String, controller: UITabBarController?) {
self.manageE2EE = NCManageE2EE(controller: controller)
self.account = account
self.controller = controller
}
@ObservedObject var model: NCManageE2EE

var body: some View {
VStack {
if manageE2EE.isEndToEndEnabled {
if model.isEndToEndEnabled {
List {
Section(header: Text(""), footer: Text(manageE2EE.statusOfService + "\n\n" + "End-to-End Encryption " + NCGlobal.shared.capabilityE2EEApiVersion)) {
Section(header: Text(""), footer: Text(model.statusOfService + "\n\n" + "End-to-End Encryption " + NCGlobal.shared.capabilityE2EEApiVersion)) {
Label {
Text(NSLocalizedString("_e2e_settings_activated_", comment: ""))
} icon: {
Expand All @@ -67,7 +57,7 @@ struct NCViewE2EE: View {
.contentShape(Rectangle())
.onTapGesture {
if NCKeychain().passcode != nil {
manageE2EE.requestPasscodeType("readPassphrase")
model.requestPasscodeType("readPassphrase")
} else {
NCContentPresenter().showInfo(error: NKError(errorCode: 0, errorDescription: "_e2e_settings_lock_not_active_"))
}
Expand All @@ -87,7 +77,7 @@ struct NCViewE2EE: View {
.contentShape(Rectangle())
.onTapGesture {
if NCKeychain().passcode != nil {
manageE2EE.requestPasscodeType("removeLocallyEncryption")
model.requestPasscodeType("removeLocallyEncryption")
} else {
NCContentPresenter().showInfo(error: NKError(errorCode: 0, errorDescription: "_e2e_settings_lock_not_active_"))
}
Expand All @@ -98,7 +88,7 @@ struct NCViewE2EE: View {
}
} else {
List {
Section(header: Text(""), footer: Text(manageE2EE.statusOfService + "\n\n" + "End-to-End Encryption " + NCGlobal.shared.capabilityE2EEApiVersion)) {
Section(header: Text(""), footer: Text(model.statusOfService + "\n\n" + "End-to-End Encryption " + NCGlobal.shared.capabilityE2EEApiVersion)) {
HStack {
Label {
Text(NSLocalizedString("_e2e_settings_start_", comment: ""))
Expand All @@ -114,7 +104,7 @@ struct NCViewE2EE: View {
.contentShape(Rectangle())
.onTapGesture {
if NCKeychain().passcode != nil {
manageE2EE.requestPasscodeType("startE2E")
model.requestPasscodeType("startE2E")
} else {
NCContentPresenter().showInfo(error: NKError(errorCode: 0, errorDescription: "_e2e_settings_lock_not_active_"))
}
Expand All @@ -128,7 +118,7 @@ struct NCViewE2EE: View {
}
.navigationBarTitle(NSLocalizedString("_e2e_settings_", comment: ""))
.background(Color(UIColor.systemGroupedBackground))
.defaultViewModifier(manageE2EE)
.defaultViewModifier(model)
}
}

Expand Down Expand Up @@ -230,11 +220,6 @@ struct NCViewE2EETest: View {
}
}

struct NCViewE2EE_Previews: PreviewProvider {
static var previews: some View {
// swiftlint:disable force_cast
let account = (UIApplication.shared.delegate as! AppDelegate).account
NCViewE2EE(account: account, controller: nil)
// swiftlint:enable force_cast
}
#Preview {
NCViewE2EE(model: NCManageE2EE(controller: nil))
}
2 changes: 1 addition & 1 deletion iOSClient/Settings/Settings/NCSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ struct E2EESection: View {

var body: some View {
Section(header: Text(NSLocalizedString("_e2e_settings_title_", comment: "")), content: {
NavigationLink(destination: NCViewE2EE(account: model.appDelegate.account, controller: model.controller)) {
NavigationLink(destination: NCViewE2EE(model: NCManageE2EE(controller: model.controller))) {
HStack {
Image(systemName: "lock")
.resizable()
Expand Down

0 comments on commit 9d57dd4

Please sign in to comment.