mirror of
https://github.com/neon443/NearFuture.git
synced 2026-03-11 06:49:12 +00:00
fixed no color selected when having no settings
fix helpview always orange
This commit is contained in:
@@ -74,7 +74,7 @@ struct HelpView: View {
|
|||||||
var body: some View {
|
var body: some View {
|
||||||
List {
|
List {
|
||||||
ZStack {
|
ZStack {
|
||||||
Color(.accent)
|
Color(.tintColor)
|
||||||
.opacity(0.4)
|
.opacity(0.4)
|
||||||
.padding(.horizontal, -15)
|
.padding(.horizontal, -15)
|
||||||
.blur(radius: 5)
|
.blur(radius: 5)
|
||||||
|
|||||||
@@ -45,6 +45,13 @@ struct ColorCodable: Codable, Equatable {
|
|||||||
self.green = Double(g)
|
self.green = Double(g)
|
||||||
self.blue = Double(b)
|
self.blue = Double(b)
|
||||||
}
|
}
|
||||||
|
init(uiColor: UIColor) {
|
||||||
|
var r: CGFloat = 0, g: CGFloat = 0, b: CGFloat = 0, a: CGFloat = 1.0
|
||||||
|
uiColor.getRed(&r, green: &g, blue: &b, alpha: &a)
|
||||||
|
self.red = Double(r)
|
||||||
|
self.green = Double(g)
|
||||||
|
self.blue = Double(b)
|
||||||
|
}
|
||||||
init(red: Double, green: Double, blue: Double) {
|
init(red: Double, green: Double, blue: Double) {
|
||||||
self.red = red
|
self.red = red
|
||||||
self.green = green
|
self.green = green
|
||||||
@@ -104,9 +111,19 @@ struct Settings: Codable, Equatable {
|
|||||||
class SettingsViewModel: ObservableObject {
|
class SettingsViewModel: ObservableObject {
|
||||||
@Published var settings: Settings = Settings(
|
@Published var settings: Settings = Settings(
|
||||||
showCompletedInHome: false,
|
showCompletedInHome: false,
|
||||||
tint: ColorCodable(.blue)
|
tint: ColorCodable(uiColor: UIColor(named: "AccentColor")!)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Published var accentChoices: [Color] = [
|
||||||
|
Color(UIColor(named: "uiColors/red")!),
|
||||||
|
Color(UIColor(named: "uiColors/orange")!),
|
||||||
|
Color(UIColor(named: "uiColors/yellow")!),
|
||||||
|
Color(UIColor(named: "uiColors/green")!),
|
||||||
|
Color(UIColor(named: "uiColors/blue")!),
|
||||||
|
Color(UIColor(named: "uiColors/indigo")!),
|
||||||
|
Color(UIColor(named: "uiColors/basic")!)
|
||||||
|
]
|
||||||
|
|
||||||
init(load: Bool = true) {
|
init(load: Bool = true) {
|
||||||
if load {
|
if load {
|
||||||
loadSettings()
|
loadSettings()
|
||||||
|
|||||||
@@ -39,16 +39,6 @@ struct SettingsView: View {
|
|||||||
return .red
|
return .red
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let rainbow: [Color] = [
|
|
||||||
Color.UiColors.red,
|
|
||||||
Color.UiColors.orange,
|
|
||||||
Color.UiColors.yellow,
|
|
||||||
Color.UiColors.green,
|
|
||||||
Color.UiColors.blue,
|
|
||||||
Color.UiColors.indigo,
|
|
||||||
Color.UiColors.basic
|
|
||||||
]
|
|
||||||
@State private var selectedIndex: Int = 1
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationStack {
|
NavigationStack {
|
||||||
@@ -57,20 +47,20 @@ struct SettingsView: View {
|
|||||||
List {
|
List {
|
||||||
ScrollView(.horizontal) {
|
ScrollView(.horizontal) {
|
||||||
HStack {
|
HStack {
|
||||||
ForEach(0..<rainbow.count, id: \.self) { index in
|
ForEach(settingsModel.accentChoices, id: \.self) { color in
|
||||||
ZStack {
|
ZStack {
|
||||||
Button() {
|
Button() {
|
||||||
selectedIndex = index
|
settingsModel.settings.tint.colorBind = color
|
||||||
settingsModel.settings.tint.colorBind = rainbow[index]
|
|
||||||
settingsModel.saveSettings()
|
settingsModel.saveSettings()
|
||||||
} label: {
|
} label: {
|
||||||
Circle()
|
Circle()
|
||||||
.foregroundStyle(rainbow[index])
|
.foregroundStyle(color)
|
||||||
.frame(width: 30)
|
.frame(width: 30)
|
||||||
}
|
}
|
||||||
if selectedIndex == index {
|
if ColorCodable(color) == settingsModel.settings.tint {
|
||||||
|
let needContrast: Bool = ColorCodable(color) == settingsModel.settings.tint
|
||||||
Circle()
|
Circle()
|
||||||
.foregroundStyle(index == rainbow.count-1 ? .two : .one)
|
.foregroundStyle(needContrast ? .two : .one)
|
||||||
.frame(width: 10)
|
.frame(width: 10)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user