Skip to content

Commit

Permalink
Edit Planet / Site Settings: Highlight Color
Browse files Browse the repository at this point in the history
  • Loading branch information
livid committed Mar 20, 2024
1 parent 7e99627 commit 1482d0c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
38 changes: 37 additions & 1 deletion Planet/Views/My/MyPlanetEditView.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import SwiftUI

struct MyPlanetEditView: View {
let CONTROL_CAPTION_WIDTH: CGFloat = 100
let CONTROL_CAPTION_WIDTH: CGFloat = 120
let SOCIAL_CONTROL_CAPTION_WIDTH: CGFloat = 120

@Environment(\.dismiss) var dismiss
Expand Down Expand Up @@ -50,6 +50,13 @@ struct MyPlanetEditView: View {
@State private var filebasePinStatusMessage: String? = nil
@State private var filebasePinCID: String? = nil

// Template Settings
@State private var currentSettings: [String: String] = [:]
@State private var userSettings: [String: String] = [:]

// Highlight Color (Currently only for Croptop)
@State private var selectedColor: Color = Color(hex: "#F056C1")

init(planet: MyPlanetModel) {
self.planet = planet
_name = State(wrappedValue: planet.name)
Expand Down Expand Up @@ -568,6 +575,24 @@ struct MyPlanetEditView: View {
}
.pickerStyle(.menu)
}

if planetStore.app == .lite {
HStack {
HStack {
Text("Highlight Color")
Spacer()
}
.frame(width: CONTROL_CAPTION_WIDTH - 10)

ColorPicker("", selection: $selectedColor)
.onChange(of: selectedColor) { color in
let hex = color.toHexString()
userSettings["highlightColor"] = hex
}

Spacer()
}
}
}
.padding(16)
.tabItem {
Expand Down Expand Up @@ -736,6 +761,8 @@ struct MyPlanetEditView: View {
planet.filebasePinName = filebasePinName
planet.filebaseAPIToken = filebaseAPIToken
Task {
planet.updateTemplateSettings(settings: userSettings)
try? planet.copyTemplateSettings()
try planet.save()
Task(priority: .background) {
try await planet.rebuild()
Expand All @@ -753,6 +780,15 @@ struct MyPlanetEditView: View {
}
.padding(0)
.frame(width: 520, height: nil, alignment: .top)
.onAppear {
currentSettings = planet.templateSettings()
for (key, value) in currentSettings {
userSettings[key] = value
if key == "highlightColor" {
selectedColor = Color(hex: value)
}
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion Planet/versioning.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CURRENT_PROJECT_VERSION = 1917
CURRENT_PROJECT_VERSION = 1918
4 changes: 2 additions & 2 deletions PlanetLite/Croptop/AggregationSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ struct AggregationSettings: View {
planet.reuseOriginalID = reuseOriginalID

Task {
planet.save()
try planet.save()
Task(priority: .background) {
try await planet.aggregate()
await planet.aggregate()
}
}
dismiss()
Expand Down

0 comments on commit 1482d0c

Please sign in to comment.