From 83b90200316bfeb6278454033941e3c2f0e4bd83 Mon Sep 17 00:00:00 2001
From: Mustafa Merza <mustafa.merza95@gmail.com>
Date: Wed, 14 Aug 2024 11:34:23 +0300
Subject: [PATCH] - Added using color style in custom colors modifiers and in
 SwiftUI views.

---
 .../Core/Extensions/View/View+CustomColor.swift        | 10 +++++-----
 .../Core/Presentation/Controls/CustomMenuPicker.swift  |  1 +
 .../Core/Presentation/Controls/CustomPicker.swift      |  4 ++--
 .../Core/Presentation/Controls/PrimaryButton.swift     |  4 ++--
 .../Features/Common/Presentation/MainView.swift        |  2 +-
 .../Features/Settings/Presentation/SettingButton.swift |  7 ++++---
 .../Settings/Presentation/SettingSheetView.swift       |  2 +-
 7 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/MiniScanner/Core/Extensions/View/View+CustomColor.swift b/MiniScanner/Core/Extensions/View/View+CustomColor.swift
index 75ea55e..e150f7b 100644
--- a/MiniScanner/Core/Extensions/View/View+CustomColor.swift
+++ b/MiniScanner/Core/Extensions/View/View+CustomColor.swift
@@ -10,7 +10,7 @@ import SwiftUI
 
 struct CustomColorModifier: ViewModifier {
     
-    var color: Color
+    var color: ColorStyle
     var place: ColorPlace
     
     func body(content: Content) -> some View {
@@ -19,23 +19,23 @@ struct CustomColorModifier: ViewModifier {
         case .background:
             
             content
-                .background(color)
+                .background(color.color)
             
         case .foreground:
             
             content
-                .foregroundStyle(color)
+                .foregroundStyle(color.color)
         }
     }
 }
 
 extension View {
     
-    func customForeground(_ color: Color) -> some View {
+    func customForeground(_ color: ColorStyle) -> some View {
         ModifiedContent(content: self, modifier: CustomColorModifier(color: color, place: .foreground))
     }
     
-    func customBackground(_ color: Color) -> some View {
+    func customBackground(_ color: ColorStyle) -> some View {
         ModifiedContent(content: self, modifier: CustomColorModifier(color: color, place: .background))
     }
 }
diff --git a/MiniScanner/Core/Presentation/Controls/CustomMenuPicker.swift b/MiniScanner/Core/Presentation/Controls/CustomMenuPicker.swift
index cb8c8f9..29d1e74 100644
--- a/MiniScanner/Core/Presentation/Controls/CustomMenuPicker.swift
+++ b/MiniScanner/Core/Presentation/Controls/CustomMenuPicker.swift
@@ -22,6 +22,7 @@ struct CustomMenuPicker<Item: CustomMenuPickerItem, Label: View>: View {
                 ForEach(items) { item in
                     
                     Text(item.displayedName)
+                        .customForeground(.gray600)
                         .tag(item)
                 }
             }
diff --git a/MiniScanner/Core/Presentation/Controls/CustomPicker.swift b/MiniScanner/Core/Presentation/Controls/CustomPicker.swift
index 433fee4..9003592 100644
--- a/MiniScanner/Core/Presentation/Controls/CustomPicker.swift
+++ b/MiniScanner/Core/Presentation/Controls/CustomPicker.swift
@@ -31,7 +31,7 @@ struct CustomPicker<Item: CustomMenuPickerItem>: View {
             HStack {
                 
                 Text(item.displayedName)
-                    .customForeground(.mainText)
+                    .customForeground(.gray600)
                 
                 Spacer()
                 
@@ -41,7 +41,7 @@ struct CustomPicker<Item: CustomMenuPickerItem>: View {
                         .resizable()
                         .aspectRatio(contentMode: .fit)
                         .frame(width: 12, height: 12)
-                        .customForeground(.mainBlue)
+                        .customForeground(.primary)
                 }
             }
             .frame(maxWidth: .infinity)
diff --git a/MiniScanner/Core/Presentation/Controls/PrimaryButton.swift b/MiniScanner/Core/Presentation/Controls/PrimaryButton.swift
index 9e1a879..d34ef9f 100644
--- a/MiniScanner/Core/Presentation/Controls/PrimaryButton.swift
+++ b/MiniScanner/Core/Presentation/Controls/PrimaryButton.swift
@@ -26,13 +26,13 @@ struct PrimaryButton: View {
             .frame(height: 54)
             .frame(maxWidth: .infinity)
         })
-        .customBackground(.buttonsBlue)
+        .customBackground(.primary)
         .customCornerRadius(12)
     }
     
     private var titleView: some View {
         Text(title)
-            .customForeground(.mainText)
+            .customForeground(.gray0)
     }
 }
 
diff --git a/MiniScanner/Features/Common/Presentation/MainView.swift b/MiniScanner/Features/Common/Presentation/MainView.swift
index 15b8989..ff04045 100644
--- a/MiniScanner/Features/Common/Presentation/MainView.swift
+++ b/MiniScanner/Features/Common/Presentation/MainView.swift
@@ -24,7 +24,7 @@ struct MainView<ViewModel: MainViewModel, Content: View>: View {
         
         content()
             .frame(maxWidth: .infinity, maxHeight: .infinity)
-            .background(Color.mainBackground)
+            .customBackground(.base)
             .onAppear {
                 viewModel.onAppear()
             }
diff --git a/MiniScanner/Features/Settings/Presentation/SettingButton.swift b/MiniScanner/Features/Settings/Presentation/SettingButton.swift
index ae10da9..d692607 100644
--- a/MiniScanner/Features/Settings/Presentation/SettingButton.swift
+++ b/MiniScanner/Features/Settings/Presentation/SettingButton.swift
@@ -45,16 +45,17 @@ struct SettingButton: View {
             .resizable()
             .aspectRatio(contentMode: .fit)
             .frame(width: 20, height: 20)
+            .customForeground(.gray600)
     }
     
     private var titleView: some View {
         Text(title)
-            .customForeground(.mainText)
+            .customForeground(.gray600)
     }
     
     private var valueView: some View {
         Text(value)
-            .customForeground(.mainText)
+            .customForeground(.gray350)
     }
     
     private var changeButton: some View {
@@ -63,7 +64,7 @@ struct SettingButton: View {
         }, label: {
             
             Text(String.change.localized)
-                .customForeground(.mainText)
+                .customForeground(.gray600)
         })
     }
 }
diff --git a/MiniScanner/Features/Settings/Presentation/SettingSheetView.swift b/MiniScanner/Features/Settings/Presentation/SettingSheetView.swift
index 28dc36f..0ba8a21 100644
--- a/MiniScanner/Features/Settings/Presentation/SettingSheetView.swift
+++ b/MiniScanner/Features/Settings/Presentation/SettingSheetView.swift
@@ -39,7 +39,7 @@ extension SettingSheetView {
     
     private var titleView: some View {
         Text(title)
-            .customForeground(.mainText)
+            .customForeground(.gray600)
     }
     
     private var picker: some View {
-- 
GitLab