Skip to content

Commit 89ef3dd

Browse files
committed
idk
1 parent 696d495 commit 89ef3dd

File tree

4 files changed

+34
-25
lines changed

4 files changed

+34
-25
lines changed

ControlConfig/Control Center/ModuleOperations.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,12 @@ func applyChanges(customisations: CustomisationList) -> Bool {
138138
success.append(PlistHelpers.writeDictToPlist(dict: new, path: CCMappings().dmsPath))
139139
}
140140

141-
success.append(ColorTools.applyMaterialRecipe(filePath: CCMappings.moduleMaterialRecipePath, color: customisations.otherCustomisations.moduleColor, blur: customisations.otherCustomisations.moduleBlur, includeSpecificsForCCModules: true))
142-
143-
success.append(ColorTools.applyMaterialRecipe(filePath: CCMappings.moduleBackgroundMaterialRecipePath, color: customisations.otherCustomisations.moduleBGColor, blur: customisations.otherCustomisations.moduleBGBlur, includeSpecificsForCCModules: false))
141+
if let c = customisations.otherCustomisations.moduleColor, let b = customisations.otherCustomisations.moduleBlur {
142+
success.append(ColorTools.applyMaterialRecipe(filePath: CCMappings.moduleMaterialRecipePath, color: c, blur: b, includeSpecificsForCCModules: true))
143+
}
144+
if let cB = customisations.otherCustomisations.moduleBGColor, let bB = customisations.otherCustomisations.moduleBGBlur {
145+
success.append(ColorTools.applyMaterialRecipe(filePath: CCMappings.moduleBackgroundMaterialRecipePath, color: cB, blur: bB, includeSpecificsForCCModules: false))
146+
}
144147

145148
print("successmap", success)
146149
return !success.contains { $0 == false }

ControlConfig/Models/CustomisationsList.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import Foundation
1010
import SwiftUI
1111

1212
class OtherCustomisations: ObservableObject, Codable {
13-
@Published var moduleColor: Color
14-
@Published var moduleBlur: Int
15-
@Published var moduleBGColor: Color
16-
@Published var moduleBGBlur: Int
13+
@Published var moduleColor: Color?
14+
@Published var moduleBlur: Int?
15+
@Published var moduleBGColor: Color?
16+
@Published var moduleBGBlur: Int?
1717

1818
init(moduleColor: Color, moduleBlur: Int, moduleBGColor: Color, moduleBGBlur: Int) {
1919
self.moduleColor = moduleColor
@@ -22,6 +22,8 @@ class OtherCustomisations: ObservableObject, Codable {
2222
self.moduleBGBlur = moduleBGBlur
2323
}
2424

25+
init() {}
26+
2527
enum CodingKeys: String, CodingKey {
2628
case moduleColor
2729
case moduleBlur
@@ -31,10 +33,10 @@ class OtherCustomisations: ObservableObject, Codable {
3133

3234
required init(from decoder: Decoder) throws {
3335
let container = try decoder.container(keyedBy: CodingKeys.self)
34-
self.moduleColor = try container.decode(Color.self, forKey: .moduleColor)
35-
self.moduleBlur = try container.decode(Int.self, forKey: .moduleBlur)
36-
self.moduleBGColor = try container.decode(Color.self, forKey: .moduleBGColor)
37-
self.moduleBGBlur = try container.decode(Int.self, forKey: .moduleBGBlur)
36+
self.moduleColor = try? container.decode(Color.self, forKey: .moduleColor)
37+
self.moduleBlur = try? container.decode(Int.self, forKey: .moduleBlur)
38+
self.moduleBGColor = try? container.decode(Color.self, forKey: .moduleBGColor)
39+
self.moduleBGBlur = try? container.decode(Int.self, forKey: .moduleBGBlur)
3840
}
3941

4042
func encode(to encoder: Encoder) throws {

ControlConfig/Views/EditCCColorsView.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ import SwiftUI
1111
struct SingleBlurModule: View {
1212
let cornerR: CGFloat = 17.5
1313
let oneSide: CGFloat = 68
14-
let color: Color
14+
let color: Color?
1515
let image: String
16-
@Binding var intensity: Int
16+
@Binding var intensity: Int?
1717

1818
var body: some View {
1919
ZStack {
20-
CIVisualEffectView(effect: UIBlurEffect(style: .light), intensity: $intensity.doubleBinding)
20+
CIVisualEffectView(effect: UIBlurEffect(style: .light), intensity: $intensity.toUnwrapped(defaultValue: 50).doubleBinding)
2121
.frame(width: oneSide, height: oneSide)
2222
.cornerRadius(cornerR)
23-
color
23+
(color ?? Color.gray)
2424
.cornerRadius(cornerR)
2525
.frame(width: oneSide, height: oneSide)
2626

@@ -37,7 +37,7 @@ struct EditCCColorsView: View {
3737
var body: some View {
3838
let _ = saveOCToUserDefaults()
3939
List {
40-
Section(header: Label("Preview", systemImage: "eye")) {
40+
Section(header: Label("Preview", systemImage: "eye"), footer: Text("Note: This preview isn't 100% accurate to what the actual control center will look like.")) {
4141
HStack {
4242
Spacer()
4343
// Spacer(minLength: 0)
@@ -53,7 +53,7 @@ struct EditCCColorsView: View {
5353
Image("PreviewWall \(selectedWallpaper)")
5454
.resizable()
5555
.scaledToFill()
56-
.blur(radius: CGFloat(state.moduleBGBlur))
56+
.blur(radius: CGFloat(state.moduleBGBlur ?? 50))
5757
state.moduleBGColor
5858

5959
})
@@ -65,26 +65,26 @@ struct EditCCColorsView: View {
6565
}
6666
}.listRowSeparator(.hidden)
6767
Section(header: Label("Control Center Background", systemImage: "paintbrush")) {
68-
ColorPicker("Colour (with opacity)", selection: $state.moduleBGColor)
68+
ColorPicker("Colour (with opacity)", selection: $state.moduleBGColor.toUnwrapped(defaultValue: .gray))
6969
HStack {
70-
Text("Blur (\(state.moduleBGBlur))")
70+
Text("Blur (\(state.moduleBGBlur ?? 50))")
7171
Spacer()
72-
Slider(value: $state.moduleBGBlur.doubleBinding, in: 0 ... 100, step: 1) {
72+
Slider(value: $state.moduleBGBlur.toUnwrapped(defaultValue: 50).doubleBinding, in: 0 ... 100, step: 1) {
7373
Text("Blur")
7474
} minimumValueLabel: { Text("0") } maximumValueLabel: { Text("100") }.frame(width: 150)
7575
}
7676
}
7777

7878
Section(header: Label("Module Colour", systemImage: "paintbrush")) {
79-
ColorPicker("Colour (with opacity)", selection: $state.moduleColor)
79+
ColorPicker("Colour (with opacity)", selection: $state.moduleColor.toUnwrapped(defaultValue: .gray))
8080
HStack {
81-
Text("Blur (\(state.moduleBlur))")
81+
Text("Blur (\(state.moduleBlur ?? 50))")
8282
Spacer()
83-
Slider(value: $state.moduleBlur.doubleBinding, in: 0 ... 100, step: 1) {
83+
Slider(value: $state.moduleBlur.toUnwrapped(defaultValue: 50).doubleBinding, in: 0 ... 100, step: 1) {
8484
Text("Blur")
8585
} minimumValueLabel: { Text("0") } maximumValueLabel: { Text("100") }.frame(width: 150)
8686
}
8787
}
88-
}.navigationBarTitle("Edit CC Colours")
88+
}.navigationBarTitle("Edit CC Colours").navigationBarTitleDisplayMode(.inline)
8989
}
9090
}

ControlConfig/Views/MainModuleView.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ struct MainModuleView: View {
7575
Text("Apply")
7676

7777
})
78-
.disabled(customisations.list.filter { c in c.isEnabled }.isEmpty)
78+
// .disabled(
79+
// customisations.list.filter { c in c.isEnabled }.isEmpty &&
80+
// [customisations.otherCustomisations.moduleBlur, customisations.otherCustomisations.moduleBGBlur].allSatisfy { ($0 as Int?) == nil } &&
81+
// [customisations.otherCustomisations.moduleColor, customisations.otherCustomisations.moduleBGColor].allSatisfy { ($0 as Color?) == nil }
82+
// )
7983

8084
Spacer()
8185

0 commit comments

Comments
 (0)