Skip to content

知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.

refactor: onboarding step 4's yes/no or checklist is an enum instead of an optional Bool

wqugurub2dd463dc7e3
diff --git a/Sources/Cicada/AppModel.swift b/Sources/Cicada/AppModel.swift
index 000bce3..f5f38fe 100644
--- a/Sources/Cicada/AppModel.swift
+++ b/Sources/Cicada/AppModel.swift
@@ -130,9 +130,10 @@ final class AppModel: ObservableObject {
@Published var onboardingStep = 1
/// Step 3 is showing what skipping the key leaves out (debug: `onboarding:3,skip`).
@Published var onboardingKeySkip = false
- /// Step 4's yes/no (false) or checklist (true); nil follows whether speaking is on
- /// (debug: `onboarding:4,ask` / `onboarding:4,setup`).
- @Published var onboardingSpeakSetup: Bool?
+ /// What step 4 shows (debug: `onboarding:4,ask` / `onboarding:4,setup`).
+ enum SpeakStep { case followSetting, ask, checklist }
+ /// Step 4's yes/no or checklist; until one is chosen, the checklist if speaking is already on.
+ @Published var onboardingSpeakSetup = SpeakStep.followSetting
/// Debug: which meeting and tab the main window shows ("<id>" or "<id>,transcript").
@Published var mainShow: String?
/// Hold right ⌥ is chosen but "输入监控" isn't allowed yet.
@@ -1807,7 +1808,7 @@ final class AppModel: ObservableObject {
let p = arg.split(separator: ",").map(String.init)
onboardingStep = min(max(Int(p.first ?? "") ?? 1, 1), OnboardingView.done)
onboardingKeySkip = p.contains("skip")
- onboardingSpeakSetup = p.contains("setup") ? true : p.contains("ask") ? false : nil
+ onboardingSpeakSetup = p.contains("setup") ? .checklist : p.contains("ask") ? .ask : .followSetting
openOnboarding?()
case "step": onboardingStep = Int(arg) ?? 1
case "samplePlay": ensureListening(); sample.play()
diff --git a/Sources/Cicada/Onboarding.swift b/Sources/Cicada/Onboarding.swift
index a383afe..c7f0369 100644
--- a/Sources/Cicada/Onboarding.swift
+++ b/Sources/Cicada/Onboarding.swift
@@ -433,7 +433,7 @@ struct OnboardingView: View {
HStack(spacing: 16) {
// In the checklist, 先不用了 replaces 上一步, but only when speaking was turned on right here:
// someone re-running the guide with it already on shouldn't have it switched off.
- if step > 1 && !(step == 4 && model.onboardingSpeakSetup == true) {
+ if step > 1 && !(step == 4 && model.onboardingSpeakSetup == .checklist) {
Button("上一步") {
model.onboardingKeySkip = false
step -= 1
@@ -453,9 +453,9 @@ struct OnboardingView: View {
// The two cards above are the choice; nothing to confirm here.
EmptyView()
case 4:
- if model.onboardingSpeakSetup == true {
+ if model.onboardingSpeakSetup == .checklist {
Button("先不用了") {
- model.onboardingSpeakSetup = false
+ model.onboardingSpeakSetup = .ask
model.enableSpeaking(false)
}
.buttonStyle(.plain).foregroundStyle(Palette.secondary)
@@ -604,7 +604,13 @@ struct OnboardingView: View {
// MARK: Step 4: speaking, only for those who want it
/// The checklist shows once speaking is on (or was already on); before that, a yes/no.
- private var speakSetupShown: Bool { model.onboardingSpeakSetup ?? settings.speakEnabled }
+ private var speakSetupShown: Bool {
+ switch model.onboardingSpeakSetup {
+ case .followSetting: settings.speakEnabled
+ case .ask: false
+ case .checklist: true
+ }
+ }
private var speaking: some View {
VStack(alignment: .leading, spacing: 22) {
@@ -620,7 +626,7 @@ struct OnboardingView: View {
private var speakChoice: some View {
HStack(spacing: 14) {
choiceCard(L("要,现在设置"), L("约 2 分钟,会装一个虚拟麦克风")) {
- model.onboardingSpeakSetup = true
+ model.onboardingSpeakSetup = .checklist
model.enableSpeaking(true)
}
choiceCard(L("先不用"), L("以后在设置 › 同声传译里打开")) { step = Self.done }