2023-01-13 13:37:01 +01:00
|
|
|
//
|
|
|
|
// https://mczachurski.dev
|
|
|
|
// Copyright © 2023 Marcin Czachurski and the repository contributors.
|
2023-03-28 10:35:38 +02:00
|
|
|
// Licensed under the Apache License 2.0.
|
2023-01-13 13:37:01 +01:00
|
|
|
//
|
|
|
|
|
|
|
|
import SwiftUI
|
2023-04-07 16:59:18 +02:00
|
|
|
import EnvironmentKit
|
2023-01-13 13:37:01 +01:00
|
|
|
|
2023-02-21 07:05:06 +01:00
|
|
|
struct AccentsSectionView: View {
|
2023-01-13 13:37:01 +01:00
|
|
|
@EnvironmentObject var applicationState: ApplicationState
|
2023-04-01 12:10:59 +02:00
|
|
|
|
2023-01-13 13:37:01 +01:00
|
|
|
private let accentColors1: [TintColor] = [.accentColor1, .accentColor2, .accentColor3, .accentColor4, .accentColor5]
|
|
|
|
private let accentColors2: [TintColor] = [.accentColor6, .accentColor7, .accentColor8, .accentColor9, .accentColor10]
|
2023-04-01 12:10:59 +02:00
|
|
|
|
2023-01-13 13:37:01 +01:00
|
|
|
var body: some View {
|
2023-03-13 13:53:36 +01:00
|
|
|
Section("settings.title.accent") {
|
2023-01-13 13:37:01 +01:00
|
|
|
VStack(alignment: .leading) {
|
|
|
|
HStack(alignment: .center) {
|
|
|
|
ForEach(accentColors1, id: \.self) { color in
|
|
|
|
ZStack {
|
|
|
|
Circle()
|
|
|
|
.fill(color.color())
|
|
|
|
.frame(width: 36, height: 36)
|
|
|
|
.onTapGesture {
|
|
|
|
self.applicationState.tintColor = color
|
2023-03-15 14:27:59 +01:00
|
|
|
ApplicationSettingsHandler.shared.set(tintColor: color)
|
2023-01-13 13:37:01 +01:00
|
|
|
}
|
|
|
|
if color == self.applicationState.tintColor {
|
|
|
|
Image(systemName: "checkmark")
|
|
|
|
.foregroundColor(Color.white)
|
|
|
|
.fontWeight(.bold)
|
|
|
|
}
|
|
|
|
}
|
2023-04-01 12:10:59 +02:00
|
|
|
|
2023-01-13 13:37:01 +01:00
|
|
|
if color != accentColors1.last {
|
|
|
|
Spacer()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.padding(.vertical, 8)
|
2023-04-01 12:10:59 +02:00
|
|
|
|
2023-01-13 13:37:01 +01:00
|
|
|
HStack(alignment: .center) {
|
|
|
|
ForEach(accentColors2, id: \.self) { color in
|
|
|
|
ZStack {
|
|
|
|
Circle()
|
|
|
|
.fill(color.color())
|
|
|
|
.frame(width: 36, height: 36)
|
|
|
|
.onTapGesture {
|
|
|
|
self.applicationState.tintColor = color
|
2023-03-15 14:27:59 +01:00
|
|
|
ApplicationSettingsHandler.shared.set(tintColor: color)
|
2023-01-13 13:37:01 +01:00
|
|
|
}
|
|
|
|
if color == self.applicationState.tintColor {
|
|
|
|
Image(systemName: "checkmark")
|
|
|
|
.foregroundColor(Color.white)
|
|
|
|
.fontWeight(.bold)
|
|
|
|
}
|
|
|
|
}
|
2023-04-01 12:10:59 +02:00
|
|
|
|
2023-01-13 13:37:01 +01:00
|
|
|
if color != accentColors2.last {
|
|
|
|
Spacer()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.padding(.vertical, 8)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|