From 5c9e91533fb54a82ad7fc07707ba3fbc85d1ea18 Mon Sep 17 00:00:00 2001
From: Mustafa Merza <mustafa.merza95@gmail.com>
Date: Sun, 21 Jul 2024 11:36:11 +0300
Subject: [PATCH] - Fixed back button icon when changing language in settings
 screen.

---
 .../Presentation/SettingsViewModel.swift       | 15 +++++++++++++++
 .../DocumentsTableViewController.swift         | 18 ++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/MiniScanner/Features/Settings/Presentation/SettingsViewModel.swift b/MiniScanner/Features/Settings/Presentation/SettingsViewModel.swift
index a3d0f29..ba32961 100644
--- a/MiniScanner/Features/Settings/Presentation/SettingsViewModel.swift
+++ b/MiniScanner/Features/Settings/Presentation/SettingsViewModel.swift
@@ -94,5 +94,20 @@ extension SettingsViewModel2 {
         
         navigationController.tabBarController?.tabBar.semanticContentAttribute = semanticContentAttribute
         navigationController.navigationBar.semanticContentAttribute = semanticContentAttribute
+        
+        handleBackIcon()
+    }
+    
+    private func handleBackIcon() {
+        
+        let navigationController = coordinator.navigationController
+        
+        let chevronLeft = UIImage(systemName: "chevron.left")
+        let chevronRight = UIImage(systemName: "chevron.right")
+        
+        let backImage = SupportedLanguage.currentLanguage.layoutDirection == .leftToRight ? chevronLeft : chevronRight
+        
+        navigationController.navigationBar.backIndicatorImage = backImage
+        navigationController.navigationBar.backIndicatorTransitionMaskImage = backImage
     }
 }
diff --git a/MiniScanner/Modules/Documents/DocumentsTableViewController.swift b/MiniScanner/Modules/Documents/DocumentsTableViewController.swift
index 23fab39..39b93ae 100644
--- a/MiniScanner/Modules/Documents/DocumentsTableViewController.swift
+++ b/MiniScanner/Modules/Documents/DocumentsTableViewController.swift
@@ -121,6 +121,8 @@ final class DocumentsTableViewController: UIViewController, UITableViewDelegate,
         scanSession?.removeAll()
         self.tabBarController?.tabBar.isHidden = false
         fetchViewModels()
+        
+        handleBackIcon()
     }
     
     deinit {
@@ -623,3 +625,19 @@ extension DocumentsTableViewController: FoldersViewControllerDelegate {
         }
     }
 }
+
+extension DocumentsTableViewController {
+    
+    private func handleBackIcon() {
+        
+        let navigationController = navigationController!
+        
+        let chevronLeft = UIImage(systemName: "chevron.left")
+        let chevronRight = UIImage(systemName: "chevron.right")
+        
+        let backImage = SupportedLanguage.currentLanguage.layoutDirection == .leftToRight ? chevronLeft : chevronRight
+        
+        navigationController.navigationBar.backIndicatorImage = backImage
+        navigationController.navigationBar.backIndicatorTransitionMaskImage = backImage
+    }
+}
-- 
GitLab