From 1c519dae1cdc89967c1c86d6b663dfb676271840 Mon Sep 17 00:00:00 2001
From: Mustafa Merza <mustafa.merza95@gmail.com>
Date: Wed, 14 Aug 2024 16:28:27 +0300
Subject: [PATCH] - Refactored code.

---
 .../EditViewController.swift                  | 47 ++++++++++---------
 1 file changed, 26 insertions(+), 21 deletions(-)

diff --git a/MiniScanner/Modules/EditViewController/EditViewController.swift b/MiniScanner/Modules/EditViewController/EditViewController.swift
index c7eb9a1..3305515 100644
--- a/MiniScanner/Modules/EditViewController/EditViewController.swift
+++ b/MiniScanner/Modules/EditViewController/EditViewController.swift
@@ -119,6 +119,32 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess
     public override func viewDidLoad() {
         super.viewDidLoad()
         
+        setupUI()
+    }
+    
+    public override func viewWillAppear(_ animated: Bool) {
+        super.viewWillAppear(animated)
+        
+        deviceOrientationHelper.startDeviceOrientationNotifier { [weak self] (deviceOrientation) in
+            guard let self else { return }
+            
+            print("orientation: \(deviceOrientation)")
+            orientationChanged(deviceOrientation: deviceOrientation)
+        }
+    }
+    
+    init(scanSession: ScanSession) {
+        self.scanSession = scanSession
+        super.init(nibName: nil, bundle: nil)
+    }
+    
+    required init?(coder aDecoder: NSCoder) {
+        scanSession = .newSession()
+        fatalError("init(coder:) should not be called for this class")
+    }
+    
+    private func setupUI() {
+        
         setupColors()
         
         banner.set(session: scanSession)
@@ -197,27 +223,6 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess
         saveCropButton.customTitleColor(.gray0)
     }
     
-    public override func viewWillAppear(_ animated: Bool) {
-        super.viewWillAppear(animated)
-        
-        deviceOrientationHelper.startDeviceOrientationNotifier { [weak self] (deviceOrientation) in
-            guard let self else { return }
-            
-            print("orientation: \(deviceOrientation)")
-            orientationChanged(deviceOrientation: deviceOrientation)
-        }
-    }
-    
-    init(scanSession: ScanSession) {
-        self.scanSession = scanSession
-        super.init(nibName: nil, bundle: nil)
-    }
-    
-    required init?(coder aDecoder: NSCoder) {
-        scanSession = .newSession()
-        fatalError("init(coder:) should not be called for this class")
-    }
-    
     // MARK: - Methods
     @objc func backTapped() {
         if navigationItem.rightBarButtonItem == nil {
-- 
GitLab