Browse Source

text files

Marino Faggiana 7 years ago
parent
commit
276a48316a

+ 10 - 17
iOSClient/Create/CCCreateCloud.swift

@@ -570,31 +570,28 @@ class CreateFormUploadAssets: XLFormViewController, CCMoveDelegate {
     
 }
 
-@objc protocol createFormUploadFileDelegate {
-    
-    func dismissFormUploadAssets()
-}
-
 class CreateFormUploadFile: XLFormViewController, CCMoveDelegate {
     
-    var serverUrl : String = ""
-    var titleServerUrl : String?
-    weak var delegate: createFormUploadFileDelegate?
+    var serverUrl = ""
+    var titleServerUrl = ""
+    var fileName = ""
+    var text = ""
     
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
     
-    convenience init(_ titleServerUrl : String?, serverUrl : String, assets : NSMutableArray, cryptated : Bool, session : String, delegate: createFormUploadFileDelegate) {
+    convenience init(_ titleServerUrl: String, serverUrl: String, text: String, fileName: String) {
         
         self.init()
         
-        if titleServerUrl == nil || titleServerUrl?.isEmpty == true {
+        if titleServerUrl.isEmpty == true {
             self.titleServerUrl = "/"
         } else {
             self.titleServerUrl = titleServerUrl
         }
         
+        self.fileName = fileName
         self.serverUrl = serverUrl
-        self.delegate = delegate
+        self.text = text
         
         self.initializeForm()
     }
@@ -620,17 +617,13 @@ class CreateFormUploadFile: XLFormViewController, CCMoveDelegate {
         row.action.formSelector = #selector(changeDestinationFolder(_:))
         section.addFormRow(row)
         
-        // Section: Rename File Name
+        // Section: File Name
         
         section = XLFormSectionDescriptor.formSection()
         form.addFormSection(section)
         
         row = XLFormRowDescriptor(tag: "fileName", rowType: XLFormRowDescriptorTypeAccount, title: NSLocalizedString("_filename_", comment: ""))
-        
-        let fileNameMask : String = CCUtility.getFileNameMask(k_keyFileNameMask)
-        if fileNameMask.characters.count > 0 {
-            row.value = fileNameMask
-        }
+        row.value = fileName
         section.addFormRow(row)
         
         self.form = form

+ 3 - 9
iOSClient/Main/CCMain.m

@@ -923,19 +923,13 @@
             
             NCText *viewController = (NCText *)navigationController.topViewController;
             
-            /*
             viewController.delegate = self;
-            viewController.move.title = NSLocalizedString(@"_move_", nil);
-            viewController.tintColor = [NCBrandColor sharedInstance].navigationBarText;
-            viewController.barTintColor = [NCBrandColor sharedInstance].brand;
-            viewController.tintColorTitle = [NCBrandColor sharedInstance].navigationBarText;
-            viewController.networkingOperationQueue = app.netQueue;
-            */
+            viewController.fileName = NSLocalizedString(@"_untitled_txt_", nil);
+            viewController.serverUrl = _serverUrl;
+            viewController.titleMain = _titleMain;
             
             [navigationController setModalPresentationStyle:UIModalPresentationFormSheet];
             [self presentViewController:navigationController animated:YES completion:nil];
-
-            
         }
             break;
             

+ 2 - 0
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -567,4 +567,6 @@
 // Text File
 
 "_title_new_text_file_"             = "New text file";
+"_untitled_txt_"                    = "Untitled.txt";
+
 

+ 16 - 7
iOSClient/Text/NCText.swift

@@ -15,8 +15,12 @@ class NCText: UIViewController, UITextViewDelegate {
     @IBOutlet weak var textView: UITextView!
 
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    var fileName : String?
-    var loadText : String? = ""
+    
+    weak var delegate: CCMain?
+    var fileName: String?
+    var loadText: String? = ""
+    var serverUrl: String = ""
+    var titleMain: String = ""
     
     override func viewDidLoad() {
         
@@ -49,17 +53,15 @@ class NCText: UIViewController, UITextViewDelegate {
     
     @IBAction func cancelButtonTapped(_ sender: AnyObject) {
         
-        let currentText = textView.text
-        
-        if currentText != loadText {
+        if textView.text != loadText {
             
             let alertController = UIAlertController(title: NSLocalizedString("_info_", comment: ""), message: NSLocalizedString("_save_exit_", comment: ""), preferredStyle: .alert)
             
-            let actionYes = UIAlertAction(title: "_yes_", style: .default) { (action:UIAlertAction) in
+            let actionYes = UIAlertAction(title: NSLocalizedString("_yes_", comment: ""), style: .default) { (action:UIAlertAction) in
                 self.dismiss(animated: true, completion: nil)
             }
             
-            let actionNo = UIAlertAction(title: "_no_", style: .cancel) { (action:UIAlertAction) in
+            let actionNo = UIAlertAction(title: NSLocalizedString("_no_", comment: ""), style: .cancel) { (action:UIAlertAction) in
                 print("You've pressed No button")
             }
             
@@ -76,6 +78,13 @@ class NCText: UIViewController, UITextViewDelegate {
     
     @IBAction func nextButtonTapped(_ sender: AnyObject) {
         
+        self.dismiss(animated: false, completion: {
+        
+            let form = CreateFormUploadFile.init(self.titleMain, serverUrl: self.serverUrl, text: self.textView.text, fileName: self.fileName!)
+            let navigationController = UINavigationController.init(rootViewController: form)
+            navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
         
+            self.delegate?.present(navigationController, animated: true, completion: nil)
+        })
     }
 }