Browse Source

coding

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 năm trước cách đây
mục cha
commit
eaac983564
2 tập tin đã thay đổi với 65 bổ sung13 xóa
  1. 60 8
      iOSClient/Settings/NCManageE2EE.swift
  2. 5 5
      iOSClient/Settings/NCSettings.m

+ 60 - 8
iOSClient/Settings/NCManageE2EE.swift

@@ -27,8 +27,10 @@ import TOPasscodeViewController
 import LocalAuthentication
 
 @objc class NCManageE2EEInterface: NSObject {
+
     @objc func makeShipDetailsUI(account: String) -> UIViewController {
-        let details = NCViewE2EE()
+        let account = (UIApplication.shared.delegate as! AppDelegate).account
+        let details = NCViewE2EE(account: account)
         return UIHostingController(rootView: details)
     }
 }
@@ -138,10 +140,13 @@ class NCManageE2EE: NSObject, ObservableObject, NCEndToEndInitializeDelegate, TO
 
 struct NCViewE2EE: View {
 
-    //@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
     @ObservedObject var manageE2EE = NCManageE2EE()
+    @State var account: String = ""
 
     var body: some View {
+
+        let versionE2EE = NCManageDatabase.shared.getCapabilitiesServerString(account: account, elements: NCElementsJSON.shared.capabilitiesE2EEApiVersion) ?? ""
+
         VStack {
             VStack {
 
@@ -149,6 +154,59 @@ struct NCViewE2EE: View {
                     .frame(height: 100)
                     .padding()
 
+                if manageE2EE.isEndToEndEnabled {
+
+                    List {
+                        
+                        Section(footer:Text("End-to-End Encription " + versionE2EE)) {
+                            Label {
+                                Text(NSLocalizedString("_e2e_settings_activated_", comment: ""))
+                            } icon: {
+                                Image(systemName: "checkmark.circle.fill")
+                                    .resizable()
+                                    .scaledToFit()
+                                    .frame(width: 25, height: 25)
+                                    .foregroundColor(.green)
+                            }
+                        }
+
+                        Label {
+                            Text(NSLocalizedString("_e2e_settings_read_passphrase_", comment: "")).onTapGesture {
+                                if CCUtility.getPasscode().isEmpty {
+                                    NCContentPresenter.shared.showInfo(error: NKError(errorCode: 0, errorDescription: "_e2e_settings_lock_not_active_"))
+                                } else {
+                                    manageE2EE.requestPasscodeType("readPassphrase")
+                                }
+                            }
+                        } icon: {
+                            Image(systemName: "text.word.spacing")
+                                .resizable()
+                                .scaledToFit()
+                                .frame(width: 25, height: 25)
+                        }
+
+                        Label {
+                            Text(NSLocalizedString("_e2e_settings_remove_", comment: "")).onTapGesture {
+                                if CCUtility.getPasscode().isEmpty {
+                                    NCContentPresenter.shared.showInfo(error: NKError(errorCode: 0, errorDescription: "_e2e_settings_lock_not_active_"))
+                                } else {
+                                    manageE2EE.requestPasscodeType("removeLocallyEncryption")
+                                }
+                            }
+                        } icon: {
+                            Image(systemName: "xmark.circle")
+                                .resizable()
+                                .scaledToFit()
+                                .frame(width: 25, height: 25)
+                        }
+                    }
+
+                } else {
+
+
+                }
+
+
                 /*
                 Button(action: {}) {
                     HStack{
@@ -236,9 +294,3 @@ struct NCViewE2EE: View {
         .navigationTitle("Cifratura End-To-End")
     }
 }
-
-struct SignatureView_Previews: PreviewProvider {
-    static var previews: some View {
-        NCViewE2EE()
-    }
- }

+ 5 - 5
iOSClient/Settings/NCSettings.m

@@ -127,24 +127,24 @@
         [form addFormSection:section];
 
         // EndToEnd Encryption
-        row = [XLFormRowDescriptor formRowDescriptorWithTag:@"e2eEncryption" rowType:XLFormRowDescriptorTypeButton title:@"OLD"];
+        NSString *title = [NSString stringWithFormat:@"%@",NSLocalizedString(@"_e2e_settings_", nil)];
+        row = [XLFormRowDescriptor formRowDescriptorWithTag:@"e2eEncryption" rowType:XLFormRowDescriptorTypeButton title:title];
         row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
         [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
         [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
         [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
         [row.cellConfig setObject:[[UIImage imageNamed:@"lock"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
-        row.action.viewControllerClass = [NCManageEndToEndEncryption class];
+        row.action.formSelector = @selector(manageE2EE:);
         [section addFormRow:row];
 
         // EndToEnd Encryption
-        NSString *title = [NSString stringWithFormat:@"%@",NSLocalizedString(@"_e2e_settings_", nil)];
-        row = [XLFormRowDescriptor formRowDescriptorWithTag:@"e2eEncryption" rowType:XLFormRowDescriptorTypeButton title:title];
+        row = [XLFormRowDescriptor formRowDescriptorWithTag:@"e2eEncryption" rowType:XLFormRowDescriptorTypeButton title:@"OLD"];
         row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
         [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
         [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
         [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
         [row.cellConfig setObject:[[UIImage imageNamed:@"lock"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
-        row.action.formSelector = @selector(manageE2EE:);
+        row.action.viewControllerClass = [NCManageEndToEndEncryption class];
         [section addFormRow:row];
     }