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

Loading…
Cancel
Save