Marino Faggiana 7 жил өмнө
parent
commit
e8bdba0cc2

+ 16 - 4
iOSClient/Text/NCText.storyboard

@@ -37,8 +37,16 @@
                         </constraints>
                     </view>
                     <navigationItem key="navigationItem" id="LYL-SD-Ayv">
-                        <barButtonItem key="leftBarButtonItem" title="Item" id="brk-EO-iNZ"/>
-                        <barButtonItem key="rightBarButtonItem" title="Item" id="Hyb-2c-5Hb"/>
+                        <barButtonItem key="leftBarButtonItem" title="Item" id="brk-EO-iNZ">
+                            <connections>
+                                <action selector="cancelButtonTapped:" destination="oRF-nm-GrS" id="bZ7-ow-Bbq"/>
+                            </connections>
+                        </barButtonItem>
+                        <barButtonItem key="rightBarButtonItem" title="Item" id="Hyb-2c-5Hb">
+                            <connections>
+                                <action selector="nextButtonTapped:" destination="oRF-nm-GrS" id="tzB-m8-8BJ"/>
+                            </connections>
+                        </barButtonItem>
                     </navigationItem>
                     <connections>
                         <outlet property="cancelButton" destination="brk-EO-iNZ" id="8gM-f2-AtV"/>
@@ -48,7 +56,7 @@
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="r2i-QZ-Y8W" userLabel="First Responder" sceneMemberID="firstResponder"/>
             </objects>
-            <point key="canvasLocation" x="592.79999999999995" y="-39.130434782608695"/>
+            <point key="canvasLocation" x="785" y="-68"/>
         </scene>
         <!--Navigation Controller-->
         <scene sceneID="lyP-Qo-Lgl">
@@ -60,13 +68,17 @@
                         <autoresizingMask key="autoresizingMask"/>
                     </navigationBar>
                     <nil name="viewControllers"/>
+                    <toolbar key="toolbar" opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="d3Q-mu-6g7">
+                        <rect key="frame" x="0.0" y="623" width="375" height="44"/>
+                        <autoresizingMask key="autoresizingMask"/>
+                    </toolbar>
                     <connections>
                         <segue destination="oRF-nm-GrS" kind="relationship" relationship="rootViewController" id="gPZ-9Y-e4E"/>
                     </connections>
                 </navigationController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="jdZ-ZN-JEs" userLabel="First Responder" sceneMemberID="firstResponder"/>
             </objects>
-            <point key="canvasLocation" x="-346.39999999999998" y="-39.130434782608695"/>
+            <point key="canvasLocation" x="5" y="-67"/>
         </scene>
     </scenes>
 </document>

+ 43 - 0
iOSClient/Text/NCText.swift

@@ -14,6 +14,9 @@ class NCText: UIViewController, UITextViewDelegate {
     @IBOutlet weak var nextButton: UIBarButtonItem!
     @IBOutlet weak var textView: UITextView!
 
+    let appDelegate = UIApplication.shared.delegate as! AppDelegate
+    var fileName : String?
+    var loadText : String? = ""
     
     override func viewDidLoad() {
         
@@ -30,9 +33,49 @@ class NCText: UIViewController, UITextViewDelegate {
     }
 
     override func viewWillAppear(_ animated: Bool) {
+
         super.viewWillAppear(animated)
         
+        textView.becomeFirstResponder()
+        
+        if let fileName = fileName {
+            let path = "\(appDelegate.directoryUser!)/\(fileName)"
+            loadText = try? String(contentsOfFile: path, encoding: String.Encoding.utf8)
+            if loadText == nil {
+                loadText = ""
+            }
+        }
+    }
+    
+    @IBAction func cancelButtonTapped(_ sender: AnyObject) {
+        
+        let currentText = textView.text
         
+        if currentText != 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
+                self.dismiss(animated: true, completion: nil)
+            }
+            
+            let actionNo = UIAlertAction(title: "_no_", style: .cancel) { (action:UIAlertAction) in
+                print("You've pressed No button")
+            }
+            
+            alertController.addAction(actionYes)
+            alertController.addAction(actionNo)
+            
+            self.present(alertController, animated: true, completion:nil)
+            
+        } else {
+            
+            self.dismiss(animated: true, completion: nil)
+        }
     }
     
+    @IBAction func nextButtonTapped(_ sender: AnyObject) {
+        
+        
+    }
 }