refactor mobile onboarding config
Replace the onboarding step ternary chain with a typed step config so the screen is easier to read and lint can highlight the remaining hotspots more clearly.pull/19545/head
parent
ec27518eca
commit
785635caef
|
|
@ -2920,90 +2920,82 @@ export default function DictationScreen() {
|
||||||
}, [devicePushToken, relayServersKey])
|
}, [devicePushToken, relayServersKey])
|
||||||
|
|
||||||
const defaultModelInstalled = installedWhisperModels.includes(defaultWhisperModel)
|
const defaultModelInstalled = installedWhisperModels.includes(defaultWhisperModel)
|
||||||
const onboardingProgressRaw = downloadingModelID
|
let onboardingProgressRaw = 0
|
||||||
? downloadProgress
|
if (downloadingModelID) {
|
||||||
: defaultModelInstalled || activeWhisperModel === defaultWhisperModel
|
onboardingProgressRaw = downloadProgress
|
||||||
? 1
|
} else if (defaultModelInstalled || activeWhisperModel === defaultWhisperModel) {
|
||||||
: isPreparingWhisperModel
|
onboardingProgressRaw = 1
|
||||||
? 0.12
|
} else if (isPreparingWhisperModel) {
|
||||||
: 0
|
onboardingProgressRaw = 0.12
|
||||||
|
}
|
||||||
const onboardingProgress = Math.max(0, Math.min(1, onboardingProgressRaw))
|
const onboardingProgress = Math.max(0, Math.min(1, onboardingProgressRaw))
|
||||||
const onboardingProgressPct = Math.round(onboardingProgress * 100)
|
const onboardingProgressPct = Math.round(onboardingProgress * 100)
|
||||||
const onboardingModelStatus = downloadingModelID
|
let onboardingModelStatus = "Downloading model in background"
|
||||||
? `Downloading model in background ${onboardingProgressPct}%`
|
if (downloadingModelID) {
|
||||||
: onboardingProgress >= 1
|
onboardingModelStatus = `Downloading model in background ${onboardingProgressPct}%`
|
||||||
? "Model ready in background"
|
} else if (onboardingProgress >= 1) {
|
||||||
: "Downloading model in background"
|
onboardingModelStatus = "Model ready in background"
|
||||||
const onboardingStepCount = 4
|
}
|
||||||
|
const onboardingSteps = [
|
||||||
|
{
|
||||||
|
title: "Allow mic access.",
|
||||||
|
body: "Control only listens while you hold the record button.",
|
||||||
|
primaryLabel: microphonePermissionState === "pending" ? "Requesting microphone..." : "Allow microphone",
|
||||||
|
primaryDisabled: microphonePermissionState === "pending",
|
||||||
|
secondaryLabel: "Continue without granting",
|
||||||
|
visualTag: "MIC",
|
||||||
|
visualSurfaceStyle: styles.onboardingVisualSurfaceMic,
|
||||||
|
visualOrbStyle: styles.onboardingVisualOrbMic,
|
||||||
|
visualTagStyle: styles.onboardingVisualTagMic,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Turn on notifications.",
|
||||||
|
body: "Get alerts when your OpenCode run finishes, fails, or needs your attention.",
|
||||||
|
primaryLabel: notificationPermissionState === "pending" ? "Requesting notifications..." : "Allow notifications",
|
||||||
|
primaryDisabled: notificationPermissionState === "pending",
|
||||||
|
secondaryLabel: "Continue without granting",
|
||||||
|
visualTag: "PUSH",
|
||||||
|
visualSurfaceStyle: styles.onboardingVisualSurfaceNotifications,
|
||||||
|
visualOrbStyle: styles.onboardingVisualOrbNotifications,
|
||||||
|
visualTagStyle: styles.onboardingVisualTagNotifications,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Enable local network.",
|
||||||
|
body: "This lets Control discover your machine on the same network.",
|
||||||
|
primaryLabel: localNetworkPermissionState === "pending" ? "Requesting local network..." : "Allow local network",
|
||||||
|
primaryDisabled: localNetworkPermissionState === "pending",
|
||||||
|
secondaryLabel: "Continue without granting",
|
||||||
|
visualTag: "LAN",
|
||||||
|
visualSurfaceStyle: styles.onboardingVisualSurfaceNetwork,
|
||||||
|
visualOrbStyle: styles.onboardingVisualOrbNetwork,
|
||||||
|
visualTagStyle: styles.onboardingVisualTagNetwork,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Pair your computer.",
|
||||||
|
body: "Start `opencode serve` on your computer, then scan the QR code to pair.",
|
||||||
|
primaryLabel: "Scan OpenCode QR",
|
||||||
|
primaryDisabled: false,
|
||||||
|
secondaryLabel: "I will do this later",
|
||||||
|
visualTag: "PAIR",
|
||||||
|
visualSurfaceStyle: styles.onboardingVisualSurfacePair,
|
||||||
|
visualOrbStyle: styles.onboardingVisualOrbPair,
|
||||||
|
visualTagStyle: styles.onboardingVisualTagPair,
|
||||||
|
},
|
||||||
|
] as const
|
||||||
|
const onboardingStepCount = onboardingSteps.length
|
||||||
const clampedOnboardingStep = Math.max(0, Math.min(onboardingStep, onboardingStepCount - 1))
|
const clampedOnboardingStep = Math.max(0, Math.min(onboardingStep, onboardingStepCount - 1))
|
||||||
const onboardingTitle =
|
const onboardingCurrentStep = onboardingSteps[clampedOnboardingStep]
|
||||||
clampedOnboardingStep === 0
|
const {
|
||||||
? "Allow mic access."
|
title: onboardingTitle,
|
||||||
: clampedOnboardingStep === 1
|
body: onboardingBody,
|
||||||
? "Turn on notifications."
|
primaryLabel: onboardingPrimaryLabel,
|
||||||
: clampedOnboardingStep === 2
|
primaryDisabled: onboardingPrimaryDisabled,
|
||||||
? "Enable local network."
|
secondaryLabel: onboardingSecondaryLabel,
|
||||||
: "Pair your computer."
|
visualTag: onboardingVisualTag,
|
||||||
const onboardingBody =
|
visualSurfaceStyle: onboardingVisualSurfaceStyle,
|
||||||
clampedOnboardingStep === 0
|
visualOrbStyle: onboardingVisualOrbStyle,
|
||||||
? "Control only listens while you hold the record button."
|
visualTagStyle: onboardingVisualTagStyle,
|
||||||
: clampedOnboardingStep === 1
|
} = onboardingCurrentStep
|
||||||
? "Get alerts when your OpenCode run finishes, fails, or needs your attention."
|
|
||||||
: clampedOnboardingStep === 2
|
|
||||||
? "This lets Control discover your machine on the same network."
|
|
||||||
: "Start `opencode serve` on your computer, then scan the QR code to pair."
|
|
||||||
const onboardingPrimaryLabel =
|
|
||||||
clampedOnboardingStep === 0
|
|
||||||
? microphonePermissionState === "pending"
|
|
||||||
? "Requesting microphone..."
|
|
||||||
: "Allow microphone"
|
|
||||||
: clampedOnboardingStep === 1
|
|
||||||
? notificationPermissionState === "pending"
|
|
||||||
? "Requesting notifications..."
|
|
||||||
: "Allow notifications"
|
|
||||||
: clampedOnboardingStep === 2
|
|
||||||
? localNetworkPermissionState === "pending"
|
|
||||||
? "Requesting local network..."
|
|
||||||
: "Allow local network"
|
|
||||||
: "Scan OpenCode QR"
|
|
||||||
const onboardingPrimaryDisabled =
|
|
||||||
(clampedOnboardingStep === 0 && microphonePermissionState === "pending") ||
|
|
||||||
(clampedOnboardingStep === 1 && notificationPermissionState === "pending") ||
|
|
||||||
(clampedOnboardingStep === 2 && localNetworkPermissionState === "pending")
|
|
||||||
const onboardingSecondaryLabel =
|
|
||||||
clampedOnboardingStep === onboardingStepCount - 1 ? "I will do this later" : "Continue without granting"
|
|
||||||
const onboardingVisualTag =
|
|
||||||
clampedOnboardingStep === 0
|
|
||||||
? "MIC"
|
|
||||||
: clampedOnboardingStep === 1
|
|
||||||
? "PUSH"
|
|
||||||
: clampedOnboardingStep === 2
|
|
||||||
? "LAN"
|
|
||||||
: "PAIR"
|
|
||||||
const onboardingVisualSurfaceStyle =
|
|
||||||
clampedOnboardingStep === 0
|
|
||||||
? styles.onboardingVisualSurfaceMic
|
|
||||||
: clampedOnboardingStep === 1
|
|
||||||
? styles.onboardingVisualSurfaceNotifications
|
|
||||||
: clampedOnboardingStep === 2
|
|
||||||
? styles.onboardingVisualSurfaceNetwork
|
|
||||||
: styles.onboardingVisualSurfacePair
|
|
||||||
const onboardingVisualOrbStyle =
|
|
||||||
clampedOnboardingStep === 0
|
|
||||||
? styles.onboardingVisualOrbMic
|
|
||||||
: clampedOnboardingStep === 1
|
|
||||||
? styles.onboardingVisualOrbNotifications
|
|
||||||
: clampedOnboardingStep === 2
|
|
||||||
? styles.onboardingVisualOrbNetwork
|
|
||||||
: styles.onboardingVisualOrbPair
|
|
||||||
const onboardingVisualTagStyle =
|
|
||||||
clampedOnboardingStep === 0
|
|
||||||
? styles.onboardingVisualTagMic
|
|
||||||
: clampedOnboardingStep === 1
|
|
||||||
? styles.onboardingVisualTagNotifications
|
|
||||||
: clampedOnboardingStep === 2
|
|
||||||
? styles.onboardingVisualTagNetwork
|
|
||||||
: styles.onboardingVisualTagPair
|
|
||||||
const onboardingSafeStyle = useMemo(
|
const onboardingSafeStyle = useMemo(
|
||||||
() => [styles.onboardingRoot, { paddingTop: insets.top + 8, paddingBottom: Math.max(insets.bottom, 16) }],
|
() => [styles.onboardingRoot, { paddingTop: insets.top + 8, paddingBottom: Math.max(insets.bottom, 16) }],
|
||||||
[insets.bottom, insets.top],
|
[insets.bottom, insets.top],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue