mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-12-23 07:36:48 +00:00
Lint
This commit is contained in:
parent
b58b49a1c1
commit
8eee1788b6
2 changed files with 44 additions and 45 deletions
|
@ -1,26 +1,26 @@
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
public protocol ColorSet {
|
public protocol ColorSet {
|
||||||
var tintColor: Color { get set }
|
var tintColor: Color { get set }
|
||||||
var primaryBackgroundColor: Color { get set }
|
var primaryBackgroundColor: Color { get set }
|
||||||
var secondaryBackgroundColor: Color { get set }
|
var secondaryBackgroundColor: Color { get set }
|
||||||
var labelColor: Color { get set }
|
var labelColor: Color { get set }
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct DarkSet: ColorSet {
|
public struct DarkSet: ColorSet {
|
||||||
public var tintColor: Color = Color(red: 187/255, green: 59/255, blue: 226/255)
|
public var tintColor: Color = Color(red: 187/255, green: 59/255, blue: 226/255)
|
||||||
public var primaryBackgroundColor: Color = Color(red: 16/255, green: 21/255, blue: 35/255)
|
public var primaryBackgroundColor: Color = Color(red: 16/255, green: 21/255, blue: 35/255)
|
||||||
public var secondaryBackgroundColor: Color = Color(red: 30/255, green: 35/255, blue: 62/255)
|
public var secondaryBackgroundColor: Color = Color(red: 30/255, green: 35/255, blue: 62/255)
|
||||||
public var labelColor: Color = .white
|
public var labelColor: Color = .white
|
||||||
|
|
||||||
public init() {}
|
public init() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct LightSet: ColorSet {
|
public struct LightSet: ColorSet {
|
||||||
public var tintColor: Color = Color(red: 187/255, green: 59/255, blue: 226/255)
|
public var tintColor: Color = Color(red: 187/255, green: 59/255, blue: 226/255)
|
||||||
public var primaryBackgroundColor: Color = .white
|
public var primaryBackgroundColor: Color = .white
|
||||||
public var secondaryBackgroundColor: Color = Color(hex:0xF0F1F2)
|
public var secondaryBackgroundColor: Color = Color(hex:0xF0F1F2)
|
||||||
public var labelColor: Color = .black
|
public var labelColor: Color = .black
|
||||||
|
|
||||||
public init() {}
|
public init() {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,37 +1,36 @@
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
public class Theme: ObservableObject {
|
public class Theme: ObservableObject {
|
||||||
enum ThemeKey: String {
|
enum ThemeKey: String {
|
||||||
case colorScheme, tint, label, primaryBackground, secondaryBackground
|
case colorScheme, tint, label, primaryBackground, secondaryBackground
|
||||||
}
|
}
|
||||||
|
|
||||||
@AppStorage("is_previously_set") var isSet: Bool = false
|
@AppStorage("is_previously_set") var isSet: Bool = false
|
||||||
@AppStorage(ThemeKey.colorScheme.rawValue) public var colorScheme: String = "dark" {
|
@AppStorage(ThemeKey.colorScheme.rawValue) public var colorScheme: String = "dark" {
|
||||||
didSet {
|
didSet {
|
||||||
if colorScheme == "dark" {
|
if colorScheme == "dark" {
|
||||||
setColor(set: DarkSet())
|
setColor(set: DarkSet())
|
||||||
} else {
|
} else {
|
||||||
setColor(set: LightSet())
|
setColor(set: LightSet())
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@AppStorage(ThemeKey.tint.rawValue) public var tintColor: Color = .black
|
}
|
||||||
@AppStorage(ThemeKey.primaryBackground.rawValue) public var primaryBackgroundColor: Color = .white
|
@AppStorage(ThemeKey.tint.rawValue) public var tintColor: Color = .black
|
||||||
@AppStorage(ThemeKey.secondaryBackground.rawValue) public var secondaryBackgroundColor: Color = .gray
|
@AppStorage(ThemeKey.primaryBackground.rawValue) public var primaryBackgroundColor: Color = .white
|
||||||
@AppStorage(ThemeKey.label.rawValue) public var labelColor: Color = .black
|
@AppStorage(ThemeKey.secondaryBackground.rawValue) public var secondaryBackgroundColor: Color = .gray
|
||||||
|
@AppStorage(ThemeKey.label.rawValue) public var labelColor: Color = .black
|
||||||
|
|
||||||
public init() {
|
public init() {
|
||||||
|
if !isSet {
|
||||||
if !isSet {
|
setColor(set: DarkSet())
|
||||||
setColor(set: DarkSet())
|
isSet.toggle()
|
||||||
isSet.toggle()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public func setColor(set: ColorSet) {
|
|
||||||
self.tintColor = set.tintColor
|
|
||||||
self.primaryBackgroundColor = set.primaryBackgroundColor
|
|
||||||
self.secondaryBackgroundColor = set.secondaryBackgroundColor
|
|
||||||
self.labelColor = set.labelColor
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public func setColor(set: ColorSet) {
|
||||||
|
self.tintColor = set.tintColor
|
||||||
|
self.primaryBackgroundColor = set.primaryBackgroundColor
|
||||||
|
self.secondaryBackgroundColor = set.secondaryBackgroundColor
|
||||||
|
self.labelColor = set.labelColor
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue