From 600f4c9c76c865f9249a2efdd833f7e3b0075b96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Mu=CC=88ller?= Date: Thu, 8 Jul 2021 18:27:49 +0200 Subject: [PATCH] :lipstick: Refactoring color management and extending to all views - Thanks to @liza-kl for the color scheme <3 --- .../DarkColor.colorset/Contents.json | 38 +++++++++++++++++++ .../LightColor.colorset/Contents.json | 38 +++++++++++++++++++ .../PrimaryColor.colorset/Contents.json | 38 +++++++++++++++++++ DHBW-Service/Utility/ColorExtension.swift | 11 ++---- DHBW-Service/Views/Tabs/HomeView.swift | 8 ++-- DHBW-Service/Views/Tabs/LecturePlanItem.swift | 4 +- DHBW-Service/Views/Tabs/LecturePlanList.swift | 4 +- 7 files changed, 125 insertions(+), 16 deletions(-) create mode 100644 DHBW-Service/Supporting Files/Assets.xcassets/DarkColor.colorset/Contents.json create mode 100644 DHBW-Service/Supporting Files/Assets.xcassets/LightColor.colorset/Contents.json create mode 100644 DHBW-Service/Supporting Files/Assets.xcassets/PrimaryColor.colorset/Contents.json diff --git a/DHBW-Service/Supporting Files/Assets.xcassets/DarkColor.colorset/Contents.json b/DHBW-Service/Supporting Files/Assets.xcassets/DarkColor.colorset/Contents.json new file mode 100644 index 0000000..030a2d0 --- /dev/null +++ b/DHBW-Service/Supporting Files/Assets.xcassets/DarkColor.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "174", + "green" : "174", + "red" : "174" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.153", + "green" : "0.125", + "red" : "0.063" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/DHBW-Service/Supporting Files/Assets.xcassets/LightColor.colorset/Contents.json b/DHBW-Service/Supporting Files/Assets.xcassets/LightColor.colorset/Contents.json new file mode 100644 index 0000000..3b5da6e --- /dev/null +++ b/DHBW-Service/Supporting Files/Assets.xcassets/LightColor.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "255", + "green" : "255", + "red" : "255" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "123", + "green" : "114", + "red" : "98" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/DHBW-Service/Supporting Files/Assets.xcassets/PrimaryColor.colorset/Contents.json b/DHBW-Service/Supporting Files/Assets.xcassets/PrimaryColor.colorset/Contents.json new file mode 100644 index 0000000..c51d020 --- /dev/null +++ b/DHBW-Service/Supporting Files/Assets.xcassets/PrimaryColor.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "224", + "green" : "224", + "red" : "224" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "79", + "green" : "71", + "red" : "55" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/DHBW-Service/Utility/ColorExtension.swift b/DHBW-Service/Utility/ColorExtension.swift index 86cca87..770026a 100644 --- a/DHBW-Service/Utility/ColorExtension.swift +++ b/DHBW-Service/Utility/ColorExtension.swift @@ -7,12 +7,7 @@ import SwiftUI import Foundation extension Color { - // For Darkmode - static let darkModeDarkColor = Color(red: 16 / 255, green: 32 / 255, blue: 39 / 255) - static let darkModePrimaryColor = Color(red: 55 / 255, green: 71 / 255, blue: 79 / 255) - static let darkModeLightColor = Color(red: 98 / 255, green: 114 / 255, blue: 123 / 255) - // For Lightmode - static let lightkModeDarkColor = Color(red: 174 / 255, green: 174 / 255, blue: 174 / 255) - static let lightModePrimaryColor = Color(red: 224 / 255, green: 224 / 255, blue: 224 / 255) - static let lightModeLightColor = Color(red: 255 / 255, green: 255 / 255, blue: 255 / 255) + static let primaryColor = Color("PrimaryColor") + static let darkColor = Color("DarkColor") + static let lightColor = Color("LightColor") } diff --git a/DHBW-Service/Views/Tabs/HomeView.swift b/DHBW-Service/Views/Tabs/HomeView.swift index facf4d1..38c971f 100644 --- a/DHBW-Service/Views/Tabs/HomeView.swift +++ b/DHBW-Service/Views/Tabs/HomeView.swift @@ -33,7 +33,7 @@ struct HomeView: View { .padding() .background( RoundedRectangle(cornerRadius: 10) - .fill(Color.darkModePrimaryColor) + .fill(Color.primaryColor) ) Spacer() } @@ -60,7 +60,7 @@ struct HomeView: View { .padding() .background( RoundedRectangle(cornerRadius: 10) - .fill(Color.darkModePrimaryColor) + .fill(Color.primaryColor) ) Spacer() } @@ -247,7 +247,7 @@ struct UpcomingLecturesBlock: View { .padding() .background( RoundedRectangle(cornerRadius: 10) - .fill(Color.darkModePrimaryColor) + .fill(Color.primaryColor) ) } } @@ -276,7 +276,7 @@ struct UpcomingExamsBlock: View { .padding() .background( RoundedRectangle(cornerRadius: 10) - .fill(Color.darkModePrimaryColor) + .fill(Color.primaryColor) ) .overlay( RoundedRectangle(cornerRadius: 10) diff --git a/DHBW-Service/Views/Tabs/LecturePlanItem.swift b/DHBW-Service/Views/Tabs/LecturePlanItem.swift index ac1edd0..269c5df 100644 --- a/DHBW-Service/Views/Tabs/LecturePlanItem.swift +++ b/DHBW-Service/Views/Tabs/LecturePlanItem.swift @@ -54,7 +54,7 @@ struct LecturePlanItem: View { } } .padding() - .foregroundColor(.white) + .foregroundColor(.primary) .background(Color.blue) .cornerRadius(15) Spacer() @@ -63,7 +63,7 @@ struct LecturePlanItem: View { .padding() .background( RoundedRectangle(cornerRadius: 10) - .fill(Color.gray) + .fill(Color.primaryColor) ) Spacer() } diff --git a/DHBW-Service/Views/Tabs/LecturePlanList.swift b/DHBW-Service/Views/Tabs/LecturePlanList.swift index ec29b6b..0ac0d48 100644 --- a/DHBW-Service/Views/Tabs/LecturePlanList.swift +++ b/DHBW-Service/Views/Tabs/LecturePlanList.swift @@ -198,7 +198,7 @@ struct DayWithEventsBlock: View { .padding() .background( RoundedRectangle(cornerRadius: 10) - .fill(Color(#colorLiteral(red: 0.2549019754, green: 0.2745098174, blue: 0.3019607961, alpha: 1))) + .fill(Color.darkColor) ) } // When an event gets updated from child view, reload it here as this will not trigger the onAppear() function @@ -228,7 +228,7 @@ struct DayWithEventsBlock: View { .padding() .background( RoundedRectangle(cornerRadius: 10) - .fill(Color.gray) + .fill(Color.primaryColor) ) } }