From 322eaba0470c4b2fe6a0f3d8020055a28659b061 Mon Sep 17 00:00:00 2001
From: Mustafa Merza <mustafa.merza95@gmail.com>
Date: Wed, 17 Jul 2024 12:28:20 +0300
Subject: [PATCH] - Changed used strings to use the string keys in the
 extension.

---
 .../Extensions/String+Extensions.swift        |  2 +-
 MiniScanner/Extensions/URL+Extensions.swift   |  6 ++---
 .../DocumentPreviewViewController.swift       | 18 +++++++--------
 .../KNAlert/KNAlertViewController.swift       |  4 ++--
 .../ShareSheet/ShareSheetViewController.swift | 12 +++++-----
 .../DocumentsTableViewController.swift        | 22 +++++++++----------
 .../Scan/ScannerViewController.swift          |  6 ++---
 7 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/MiniScanner/Extensions/String+Extensions.swift b/MiniScanner/Extensions/String+Extensions.swift
index 0cabe0d..ba09149 100644
--- a/MiniScanner/Extensions/String+Extensions.swift
+++ b/MiniScanner/Extensions/String+Extensions.swift
@@ -16,7 +16,7 @@ extension String {
   }
   
   static func getDocumentName() -> String {
-    return "Scan".localized + " " + date() + ".pdf"
+      return .scan.localized + " " + date() + ".pdf"
   }
   
   static func date(_ date: Date = Date()) -> String {
diff --git a/MiniScanner/Extensions/URL+Extensions.swift b/MiniScanner/Extensions/URL+Extensions.swift
index c3b5145..f2c2598 100644
--- a/MiniScanner/Extensions/URL+Extensions.swift
+++ b/MiniScanner/Extensions/URL+Extensions.swift
@@ -37,11 +37,11 @@ extension URL {
     if let attributes = attributes, let fileDate = attributes[FileAttributeKey.creationDate] as? Date {
 
       if Calendar.current.isDateInToday(fileDate) {
-        stringDate = "Today".localized
+          stringDate = .today.localized
       } else if Calendar.current.isDateInYesterday(fileDate) {
-        stringDate = "Yesterday".localized
+          stringDate = .yesterday.localized
       } else if Date().isSameWeekAsDate(fileDate) {
-        stringDate = "This week".localized
+          stringDate = .thisWeek.localized
       } else {
         stringDate = getDateInCurrentLocaleWithHour(fileDate)
       }
diff --git a/MiniScanner/Modules/DocumentPreview/DocumentPreviewViewController.swift b/MiniScanner/Modules/DocumentPreview/DocumentPreviewViewController.swift
index cd2a56c..c8364cc 100644
--- a/MiniScanner/Modules/DocumentPreview/DocumentPreviewViewController.swift
+++ b/MiniScanner/Modules/DocumentPreview/DocumentPreviewViewController.swift
@@ -95,11 +95,11 @@ final class DocumentPreviewViewController: UIViewController {
         let alertController = UIAlertController(title: nil,
                                                 message: nil, preferredStyle: .actionSheet)
         
-        let cameraAction = UIAlertAction(title: "Camera".localized, style: .default, handler: { action in
+        let cameraAction = UIAlertAction(title: .camera.localized, style: .default, handler: { action in
             self.openCamera()
         })
         
-        let galleryAction = UIAlertAction(title: "Gallery".localized, style: .default, handler: { action in
+        let galleryAction = UIAlertAction(title: .gallery.localized, style: .default, handler: { action in
             self.openGallery()
         })
         
@@ -111,7 +111,7 @@ final class DocumentPreviewViewController: UIViewController {
         galleryAction.setValue(UIImage(systemName: "photo"), forKey: "image")
         galleryAction.setValue(CATextLayerAlignmentMode.left, forKey: "titleTextAlignment")
         
-        alertController.addAction(UIAlertAction(title: "Cancel".localized, style: .cancel, handler: nil))
+        alertController.addAction(UIAlertAction(title: .cancel.localized, style: .cancel, handler: nil))
         alertController.popoverPresentationController?.barButtonItem = sender
         present(alertController, animated: true)
     }
@@ -137,11 +137,11 @@ final class DocumentPreviewViewController: UIViewController {
     }
     
     @IBAction func deleteTapped(_ sender: UIBarButtonItem) {
-        let alertController = UIAlertController(title: "Delete".localized,
-                                                message: "Are you sure?".localized, preferredStyle: .actionSheet)
+        let alertController = UIAlertController(title: .delete.localized,
+                                                message: .areYouSure.localized, preferredStyle: .actionSheet)
         
         if pdfView.document?.pageCount == 1 {
-            let currentPageAction = UIAlertAction(title: "Delete document".localized, style: .default, handler: { action in
+            let currentPageAction = UIAlertAction(title: .deleteDocument.localized, style: .default, handler: { action in
                 guard let documentURL = self.file?.fileURL, let pdfView = self.pdfView else { return }
                 if pdfView.document?.pageCount == 1 {
                     try? FileManager.default.removeItem(at: documentURL)
@@ -156,7 +156,7 @@ final class DocumentPreviewViewController: UIViewController {
             
             alertController.addAction(currentPageAction)
         } else {
-            let currentPageAction = UIAlertAction(title: "Current page".localized, style: .default, handler: { action in
+            let currentPageAction = UIAlertAction(title: .currentPage.localized, style: .default, handler: { action in
                 guard let documentURL = self.file?.fileURL, let pdfView = self.pdfView else { return }
                 if pdfView.document?.pageCount == 1 {
                     try? FileManager.default.removeItem(at: documentURL)
@@ -173,7 +173,7 @@ final class DocumentPreviewViewController: UIViewController {
                 }
             })
             
-            let entireDocumentAction = UIAlertAction(title: "Entire document".localized, style: .default, handler: { action in
+            let entireDocumentAction = UIAlertAction(title: .entireDocument.localized, style: .default, handler: { action in
                 guard let documentURL = self.file?.fileURL else { return }
                 try? FileManager.default.removeItem(at: documentURL)
                 self.navigationController?.popViewController(animated: true)
@@ -183,7 +183,7 @@ final class DocumentPreviewViewController: UIViewController {
             alertController.addAction(entireDocumentAction)
         }
         
-        alertController.addAction(UIAlertAction(title: "Cancel".localized, style: .cancel, handler: nil))
+        alertController.addAction(UIAlertAction(title: .cancel.localized, style: .cancel, handler: nil))
         alertController.popoverPresentationController?.barButtonItem = sender
         present(alertController, animated: true)
     }
diff --git a/MiniScanner/Modules/Documents/Customs/CustomViews/KNAlert/KNAlertViewController.swift b/MiniScanner/Modules/Documents/Customs/CustomViews/KNAlert/KNAlertViewController.swift
index 7c26b8b..f13386d 100644
--- a/MiniScanner/Modules/Documents/Customs/CustomViews/KNAlert/KNAlertViewController.swift
+++ b/MiniScanner/Modules/Documents/Customs/CustomViews/KNAlert/KNAlertViewController.swift
@@ -44,8 +44,8 @@ final class KNAlertViewController: BMViewController {
     
     private var message: String = ""
     
-    private var confirmButtonTitle: String = "Yes"
-    private var destructiveButtonTitle: String = "No"
+    private var confirmButtonTitle: String = .yes
+    private var destructiveButtonTitle: String = .no
     
     var shouldDismissAndLogin: Bool = false
     
diff --git a/MiniScanner/Modules/Documents/Customs/CustomViews/ShareSheet/ShareSheetViewController.swift b/MiniScanner/Modules/Documents/Customs/CustomViews/ShareSheet/ShareSheetViewController.swift
index 4b48ecc..6c3827d 100644
--- a/MiniScanner/Modules/Documents/Customs/CustomViews/ShareSheet/ShareSheetViewController.swift
+++ b/MiniScanner/Modules/Documents/Customs/CustomViews/ShareSheet/ShareSheetViewController.swift
@@ -50,18 +50,18 @@ class ShareSheetViewController: UIViewController {
     
     private func setupUI() {
         pagesCountLabel.set(text: "", color: .mainText, font: .regular(16))
-        whatsappLabel.set(localized: "Whatsapp", color: .mainText, font: .regular(12))
-        telegramLabel.set(localized: "Telegram", color: .mainText, font: .regular(12))
-        airdropLabel.set(localized: "Gmail", color: .mainText, font: .regular(12))
-        printLabel.set(localized: "Print", color: .mainText, font: .regular(12))
-        moreLabel.set(localized: "More", color: .mainText, font: .regular(12))
+        whatsappLabel.set(localized: .whatsapp, color: .mainText, font: .regular(12))
+        telegramLabel.set(localized: .telegram, color: .mainText, font: .regular(12))
+        airdropLabel.set(localized: .gmail, color: .mainText, font: .regular(12))
+        printLabel.set(localized: .print, color: .mainText, font: .regular(12))
+        moreLabel.set(localized: .more, color: .mainText, font: .regular(12))
         whatsappLabel.textAlignment = .center
         telegramLabel.textAlignment = .center
         airdropLabel.textAlignment = .center
         printLabel.textAlignment = .center
         moreLabel.textAlignment = .center
         
-        fileNameTextField.placeholder = "File name"
+        fileNameTextField.placeholder = .fileName.localized
         backgroundView.layer.cornerRadius = 30
         backgroundView.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]
         pdfImage.layer.cornerRadius = 10
diff --git a/MiniScanner/Modules/Documents/DocumentsTableViewController.swift b/MiniScanner/Modules/Documents/DocumentsTableViewController.swift
index b828d03..9fd9523 100644
--- a/MiniScanner/Modules/Documents/DocumentsTableViewController.swift
+++ b/MiniScanner/Modules/Documents/DocumentsTableViewController.swift
@@ -255,7 +255,7 @@ final class DocumentsTableViewController: UIViewController, UITableViewDelegate,
         
         // Trash action
         let trash = UIContextualAction(style: .destructive,
-                                       title: "Delete".localized) { [weak self] (_, _, completionHandler) in
+                                       title: .delete.localized) { [weak self] (_, _, completionHandler) in
             self?.deleteFile(at: indexPath)
             completionHandler(true)
         }
@@ -264,7 +264,7 @@ final class DocumentsTableViewController: UIViewController, UITableViewDelegate,
         
         // Rename action
         let rename = UIContextualAction(style: .normal,
-                                        title: "Rename".localized) { [weak self] (_, _, completionHandler) in
+                                        title: .rename.localized) { [weak self] (_, _, completionHandler) in
             self?.renameFile(at: indexPath)
             completionHandler(true)
         }
@@ -272,7 +272,7 @@ final class DocumentsTableViewController: UIViewController, UITableViewDelegate,
         rename.image = UIImage(systemName: "square.and.pencil")?.tint(with: .white)
         
         let move = UIContextualAction(style: .normal,
-                                      title: "Move".localized) { [weak self] (_, _, completionHandler) in
+                                      title: .move.localized) { [weak self] (_, _, completionHandler) in
             if let viewModel = self?.isSearching == true ? self?.searchedViewModel[indexPath.row] : self?.viewModels[indexPath.row] {
                 self?.moveto(file: viewModel)
             }
@@ -318,7 +318,7 @@ final class DocumentsTableViewController: UIViewController, UITableViewDelegate,
     
     private func renameFile(at indexPath: IndexPath) {
         let viewModel = isSearching ? searchedViewModel[indexPath.row] : viewModels[indexPath.row]
-        renameAlertController = UIAlertController(title: "Rename document".localized, message: nil, preferredStyle: .alert)
+        renameAlertController = UIAlertController(title: .renameDocument.localized, message: nil, preferredStyle: .alert)
         
         renameAlertController!.addTextField { [weak self] textField in
             guard let self = self else { return }
@@ -329,7 +329,7 @@ final class DocumentsTableViewController: UIViewController, UITableViewDelegate,
             textField.addTarget(self, action: #selector(self.textFieldDidChange(_:)), for: .editingChanged)
         }
         
-        let continueAction = UIAlertAction(title: "Rename".localized,
+        let continueAction = UIAlertAction(title: .rename.localized,
                                            style: .default) { [weak self] _ in
             guard let self = self else { return }
             guard let textFields = self.renameAlertController?.textFields else { return }
@@ -345,7 +345,7 @@ final class DocumentsTableViewController: UIViewController, UITableViewDelegate,
         }
         
         renameAlertController!.addAction(continueAction)
-        renameAlertController!.addAction(UIAlertAction(title: "Cancel".localized, style: .cancel, handler: nil))
+        renameAlertController!.addAction(UIAlertAction(title: .cancel.localized, style: .cancel, handler: nil))
         renameAlertController?.actions.first?.isEnabled = false
         present(renameAlertController!, animated: true)
     }
@@ -363,9 +363,9 @@ final class DocumentsTableViewController: UIViewController, UITableViewDelegate,
         
         if UserDefaults.standard.askOnSwipeDelete {
             let alertController = UIAlertController(title: Bundle.appName,
-                                                    message: "Are you sure you want to delete this document?".localized, preferredStyle: .alert)
+                                                    message: .deleteDocumentMsg.localized, preferredStyle: .alert)
             
-            let okAction = UIAlertAction(title: "Yes, delete!".localized, style: .destructive, handler: { [weak self] action in
+            let okAction = UIAlertAction(title: .yesDelete.localized, style: .destructive, handler: { [weak self] action in
                 guard let self = self else { return }
                 
                 self.delete(file: viewModel.fileURL, at: indexPath)
@@ -373,7 +373,7 @@ final class DocumentsTableViewController: UIViewController, UITableViewDelegate,
             
             alertController.addAction(okAction)
             
-            alertController.addAction(UIAlertAction(title: "Cancel".localized, style: .cancel, handler: nil))
+            alertController.addAction(UIAlertAction(title: .cancel.localized, style: .cancel, handler: nil))
             alertController.popoverPresentationController?.sourceView = tableView.cellForRow(at: indexPath)
             present(alertController, animated: true)
         } else {
@@ -483,7 +483,7 @@ extension DocumentsTableViewController: ScannerViewControllerDelegate {
 
 extension DocumentsTableViewController: AllFolderTableViewCellDelegate {
     func addFolderTapped() {
-        alert(confirm: "Add Folder", destructive: "Cancel", message: "Add Folder?"){ folderName in
+        alert(confirm: .addFolder, destructive: .cancel, message: .addFolderMessage){ folderName in
             let newFolder = AppConfigurator.Folder(name: folderName, savedName: folderName.replacingOccurrences(of: " ", with: "_"), isSelected: false)
             var currentFolders = AppConfigurator().getFolders()
             currentFolders.append(newFolder)
@@ -595,7 +595,7 @@ extension DocumentsTableViewController: DataScannerViewControllerDelegate {
             let alertController = UIAlertController(title: Bundle.appName,
                                                     message: text.transcript, preferredStyle: .alert)
                         
-            alertController.addAction(UIAlertAction(title: "Cancel".localized, style: .cancel, handler: nil))
+            alertController.addAction(UIAlertAction(title: .cancel.localized, style: .cancel, handler: nil))
             self.dismiss(animated: true) {
                 self.present(alertController, animated: true)
             }
diff --git a/MiniScanner/Supporting Files/Frameworks/CustomWeScan/Scan/ScannerViewController.swift b/MiniScanner/Supporting Files/Frameworks/CustomWeScan/Scan/ScannerViewController.swift
index adab235..1f837ca 100644
--- a/MiniScanner/Supporting Files/Frameworks/CustomWeScan/Scan/ScannerViewController.swift	
+++ b/MiniScanner/Supporting Files/Frameworks/CustomWeScan/Scan/ScannerViewController.swift	
@@ -533,16 +533,16 @@ extension ScannerViewController: CustomTabBarViewDelegate {
             self.navigationController?.popViewController(animated: false)
         } else {
             let alertController = UIAlertController(title: "Alert",
-                                                    message: "You have captured some images, do you want to discard them?".localized, preferredStyle: .alert)
+                                                    message: .discardScannerMsg.localized, preferredStyle: .alert)
             
-            let okAction = UIAlertAction(title: "Discard".localized, style: .destructive, handler: { [weak self] action in
+            let okAction = UIAlertAction(title: .discard.localized, style: .destructive, handler: { [weak self] action in
                 guard let self = self else { return }
                 self.navigationController?.popViewController(animated: false)
             })
             
             alertController.addAction(okAction)
             
-            alertController.addAction(UIAlertAction(title: "Cancel".localized, style: .cancel, handler: nil))
+            alertController.addAction(UIAlertAction(title: .cancel.localized, style: .cancel, handler: nil))
             present(alertController, animated: true)
         }
     }
-- 
GitLab