From dcbdf1c074aa8eb5313809d74b2a95b7a2e168d2 Mon Sep 17 00:00:00 2001 From: Fernando Martin Garcia Del Angel Date: Wed, 19 Feb 2020 17:37:08 -0600 Subject: [PATCH] Added UIColor Bride Added color bride to improve Dark Mode compatibility --- .../FlinkChallenge.xcodeproj/project.pbxproj | 12 ++ .../Extensions/Color+UIColor.swift | 130 ++++++++++++++++++ .../FlinkChallenge/Views/CardView.swift | 2 +- 3 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 FlinkChallenge/FlinkChallenge/Extensions/Color+UIColor.swift diff --git a/FlinkChallenge/FlinkChallenge.xcodeproj/project.pbxproj b/FlinkChallenge/FlinkChallenge.xcodeproj/project.pbxproj index 2d129bf..2d94bb5 100644 --- a/FlinkChallenge/FlinkChallenge.xcodeproj/project.pbxproj +++ b/FlinkChallenge/FlinkChallenge.xcodeproj/project.pbxproj @@ -26,6 +26,7 @@ BD810CEF23FDB95F00D7853A /* AdvancedFilterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD810CEE23FDB95F00D7853A /* AdvancedFilterView.swift */; }; BD810D3723FDD82B00D7853A /* CharacterFilteringController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD810D3623FDD82B00D7853A /* CharacterFilteringController.swift */; }; BD810D3923FDDC4200D7853A /* CharacterFilterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD810D3823FDDC4200D7853A /* CharacterFilterView.swift */; }; + BD810D3C23FDFDFE00D7853A /* Color+UIColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD810D3B23FDFDFE00D7853A /* Color+UIColor.swift */; }; EB91B40C69510498EB2574BC /* Pods_FlinkChallengeTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DFA73F2EF25F32DFDB17F885 /* Pods_FlinkChallengeTests.framework */; }; /* End PBXBuildFile section */ @@ -67,6 +68,7 @@ BD810CEE23FDB95F00D7853A /* AdvancedFilterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdvancedFilterView.swift; sourceTree = ""; }; BD810D3623FDD82B00D7853A /* CharacterFilteringController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CharacterFilteringController.swift; sourceTree = ""; }; BD810D3823FDDC4200D7853A /* CharacterFilterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CharacterFilterView.swift; sourceTree = ""; }; + BD810D3B23FDFDFE00D7853A /* Color+UIColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Color+UIColor.swift"; sourceTree = ""; }; DFA73F2EF25F32DFDB17F885 /* Pods_FlinkChallengeTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_FlinkChallengeTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -124,6 +126,7 @@ BD6A5E3F23FC7FF7003B1E4D /* FlinkChallenge */ = { isa = PBXGroup; children = ( + BD810D3A23FDFDE000D7853A /* Extensions */, BD6A5E6F23FCEB3A003B1E4D /* Controller */, BD6A5E6723FC8EEC003B1E4D /* Views */, BD6A5E6223FC81E2003B1E4D /* Model */, @@ -187,6 +190,14 @@ path = Controller; sourceTree = ""; }; + BD810D3A23FDFDE000D7853A /* Extensions */ = { + isa = PBXGroup; + children = ( + BD810D3B23FDFDFE00D7853A /* Color+UIColor.swift */, + ); + path = Extensions; + sourceTree = ""; + }; DC42C48C82B2AC45F8F56004 /* Frameworks */ = { isa = PBXGroup; children = ( @@ -372,6 +383,7 @@ BD6A5E7323FCEBA0003B1E4D /* Episode.swift in Sources */, BD6A5E7723FD003A003B1E4D /* SearchBarUIView.swift in Sources */, BD6A5E7123FCEB6C003B1E4D /* EpisodeController.swift in Sources */, + BD810D3C23FDFDFE00D7853A /* Color+UIColor.swift in Sources */, BD6A5E4123FC7FF7003B1E4D /* AppDelegate.swift in Sources */, BD6A5E4323FC7FF7003B1E4D /* SceneDelegate.swift in Sources */, BD6A5E6423FC823D003B1E4D /* APICharacter.swift in Sources */, diff --git a/FlinkChallenge/FlinkChallenge/Extensions/Color+UIColor.swift b/FlinkChallenge/FlinkChallenge/Extensions/Color+UIColor.swift new file mode 100644 index 0000000..a09304b --- /dev/null +++ b/FlinkChallenge/FlinkChallenge/Extensions/Color+UIColor.swift @@ -0,0 +1,130 @@ +// +// Color+UIColor.swift +// FlinkChallenge +// +// Created by Fernando Martin Garcia Del Angel on 19/02/20. +// Copyright © 2020 Fernando Martin Garcia Del Angel. All rights reserved. +// Color bride created by: https://medium.com/@masamichiueta/bridging-uicolor-system-color-to-swiftui-color-ef98f6e21206 +// + +import UIKit +import SwiftUI + +extension Color { + + static var label: Color { + return Color(UIColor.label) + } + + static var secondaryLabel: Color { + return Color(UIColor.secondaryLabel) + } + + static var tertiaryLabel: Color { + return Color(UIColor.tertiaryLabel) + } + + static var quaternaryLabel: Color { + return Color(UIColor.quaternaryLabel) + } + + static var systemFill: Color { + return Color(UIColor.systemFill) + } + + static var secondarySystemFill: Color { + return Color(UIColor.secondarySystemFill) + } + + static var tertiarySystemFill: Color { + return Color(UIColor.tertiarySystemFill) + } + + static var quaternarySystemFill: Color { + return Color(UIColor.quaternarySystemFill) + } + + static var systemBackground: Color { + return Color(UIColor.systemBackground) + } + + static var secondarySystemBackground: Color { + return Color(UIColor.secondarySystemBackground) + } + + static var tertiarySystemBackground: Color { + return Color(UIColor.tertiarySystemBackground) + } + + static var systemGroupedBackground: Color { + return Color(UIColor.systemGroupedBackground) + } + + static var secondarySystemGroupedBackground: Color { + return Color(UIColor.secondarySystemGroupedBackground) + } + + static var tertiarySystemGroupedBackground: Color { + return Color(UIColor.tertiarySystemGroupedBackground) + } + + static var systemRed: Color { + return Color(UIColor.systemRed) + } + + static var systemBlue: Color { + return Color(UIColor.systemBlue) + } + + static var systemPink: Color { + return Color(UIColor.systemPink) + } + + static var systemTeal: Color { + return Color(UIColor.systemTeal) + } + + static var systemGreen: Color { + return Color(UIColor.systemGreen) + } + + static var systemIndigo: Color { + return Color(UIColor.systemIndigo) + } + + static var systemOrange: Color { + return Color(UIColor.systemOrange) + } + + static var systemPurple: Color { + return Color(UIColor.systemPurple) + } + + static var systemYellow: Color { + return Color(UIColor.systemYellow) + } + + static var systemGray: Color { + return Color(UIColor.systemGray) + } + + static var systemGray2: Color { + return Color(UIColor.systemGray2) + } + + static var systemGray3: Color { + return Color(UIColor.systemGray3) + } + + static var systemGray4: Color { + return Color(UIColor.systemGray4) + } + + static var systemGray5: Color { + return Color(UIColor.systemGray5) + } + + static var systemGray6: Color { + return Color(UIColor.systemGray6) + } +} diff --git a/FlinkChallenge/FlinkChallenge/Views/CardView.swift b/FlinkChallenge/FlinkChallenge/Views/CardView.swift index 8c70f40..9bf47b2 100644 --- a/FlinkChallenge/FlinkChallenge/Views/CardView.swift +++ b/FlinkChallenge/FlinkChallenge/Views/CardView.swift @@ -36,7 +36,7 @@ struct Card: View { }.padding(.horizontal) }.padding(.bottom) - .background(Color.white) + .background() .cornerRadius(10) .shadow(radius: 5) }