Labels can toggle views (#15)

Labels can toggle views.

It's a bit verbose. I tried to use a DisclosureGroupStyle but couldn't
exactly mimic the chevrons presented by the system.
pull/24/head
Pedro Cuenca 2 years ago committed by GitHub
parent d4f3fa6da4
commit fdb1388e07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -25,7 +25,10 @@ struct ControlsView: View {
static let modelNames = models.map { $0.modelVersion }
@State private var model = Settings.shared.currentModel.modelVersion
@State private var disclosedModel = true
@State private var disclosedPrompt = true
@State private var disclosedSteps = false
@State private var disclosedSeed = false
// TODO: refactor download with similar code in Loading.swift (iOS)
@State private var stateSubscriber: Cancellable?
@ -72,7 +75,7 @@ struct ControlsView: View {
ScrollView {
Group {
DisclosureGroup {
DisclosureGroup(isExpanded: $disclosedModel) {
Picker("", selection: $model) {
ForEach(Self.modelNames, id: \.self) {
Text($0)
@ -83,7 +86,11 @@ struct ControlsView: View {
modelDidChange(model: model)
}
} label: {
Label("Model", systemImage: "cpu").foregroundColor(.secondary)
Label("Model from Hub", systemImage: "cpu").foregroundColor(.secondary).onTapGesture {
withAnimation {
disclosedModel.toggle()
}
}
}
Divider()
@ -99,19 +106,27 @@ struct ControlsView: View {
.textFieldStyle(.squareBorder)
}.padding(.leading, 10)
} label: {
Label("Prompts", systemImage: "text.quote").foregroundColor(.secondary)
Label("Prompts", systemImage: "text.quote").foregroundColor(.secondary).onTapGesture {
withAnimation {
disclosedPrompt.toggle()
}
}
}
Divider()
DisclosureGroup {
DisclosureGroup(isExpanded: $disclosedSteps) {
CompactSlider(value: $generation.steps, in: 0...150, step: 5) {
Text("Steps")
Spacer()
Text("\(Int(generation.steps))")
}.padding(.leading, 10)
} label: {
Label("Step count", systemImage: "square.3.layers.3d.down.left").foregroundColor(.secondary)
Label("Step count", systemImage: "square.3.layers.3d.down.left").foregroundColor(.secondary).onTapGesture {
withAnimation {
disclosedSteps.toggle()
}
}
}
Divider()
@ -126,7 +141,7 @@ struct ControlsView: View {
// }
// Divider()
DisclosureGroup() {
DisclosureGroup(isExpanded: $disclosedSeed) {
let sliderLabel = generation.seed < 0 ? "Random Seed" : "Seed"
CompactSlider(value: $generation.seed, in: -1...1000, step: 1) {
Text(sliderLabel)
@ -134,7 +149,11 @@ struct ControlsView: View {
Text("\(Int(generation.seed))")
}.padding(.leading, 10)
} label: {
Label("Seed", systemImage: "leaf").foregroundColor(.secondary)
Label("Seed", systemImage: "leaf").foregroundColor(.secondary).onTapGesture {
withAnimation {
disclosedSeed.toggle()
}
}
}
}
}

Loading…
Cancel
Save