forked from Blendman974/faceclaw
Onboarding fixes: Stuck state on the Permissions page, some dark-on-dark text in dark mode
This commit is contained in:
1 parent
b866224909
commit
ac68ba5991
6 files changed
+161
-12
No files matched your search
@@ -81,12 +81,6 @@ Button.-primary {
|
||||
font-size: 18;
|
||||
}
|
||||
|
||||
/* The logo art is black-on-transparent; tint it light in dark mode so it
|
||||
* doesn't vanish into the dark page background. */
|
||||
.ns-dark .onboarding-logo {
|
||||
tint-color: #e6e6e6;
|
||||
}
|
||||
|
||||
/* License / privacy-policy links in the onboarding disclaimer footer. The
|
||||
* padding widens the tap target beyond the small text. */
|
||||
.footer-link {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
.body-text { font-size: 18; }
|
||||
.h1 { font-size: 28; font-weight: bold; }
|
||||
.footer-link { color: #285c45; padding: 4 8; text-decoration: underline; }
|
||||
.ns-dark .footer-link { color: #7bc47f; }
|
||||
|
||||
Page {
|
||||
background-color: #f5f5f2;
|
||||
|
||||
@@ -7,6 +7,8 @@ declare const FaceclawKitIosBleCentral: any, FaceclawKitIosProtocolPlatform: any
|
||||
|
||||
/** CBManagerState raw values reported by the Kotlin central. */
|
||||
export const BLE_STATE_UNSUPPORTED = 2, BLE_STATE_UNAUTHORIZED = 3, BLE_STATE_POWERED_OFF = 4, BLE_STATE_POWERED_ON = 5
|
||||
/** CBManagerAuthorization.allowedAlways. */
|
||||
const BLE_AUTHORIZATION_ALLOWED = 3
|
||||
|
||||
export type BluetoothEvent =
|
||||
| { kind: 'state'; state: number; authorization: number }
|
||||
@@ -50,17 +52,21 @@ export class IosBluetooth {
|
||||
}
|
||||
},
|
||||
})
|
||||
this.native.setScanListenerListener(this.scanListener)
|
||||
}
|
||||
onEvent(listener: (event: BluetoothEvent) => void): () => void {
|
||||
this.listeners.add(listener); return () => { this.listeners.delete(listener) }
|
||||
}
|
||||
private emit(event: BluetoothEvent): void { for (const listener of [...this.listeners]) listener(event) }
|
||||
/**
|
||||
* Whether the user has allowed Bluetooth. Unlike `state` this is accurate before the
|
||||
* central exists, and reading it never shows the permission prompt.
|
||||
*/
|
||||
isAuthorized(): boolean { return Number(this.native.authorization()) === BLE_AUTHORIZATION_ALLOWED }
|
||||
/** Creates the central (first use shows the Bluetooth permission prompt) without blocking the JS thread. */
|
||||
private ensureCentral(): void {
|
||||
// A zero timeout returns immediately after creating the central; the state arrives
|
||||
// through the scan listener on the main queue.
|
||||
this.native.waitForPoweredOnTimeoutMs(0)
|
||||
// Registering the listener creates the central, or has an existing one re-report its
|
||||
// state; the state arrives through the listener on the main queue.
|
||||
this.native.setScanListenerListener(this.scanListener)
|
||||
}
|
||||
ensureReady(): Promise<void> {
|
||||
if (this.state === BLE_STATE_POWERED_ON) return Promise.resolve()
|
||||
|
||||
@@ -236,3 +236,10 @@ Button.permissions-primary-dimmed {
|
||||
.ns-dark .permissions-check {
|
||||
color: #7bc47f;
|
||||
}
|
||||
|
||||
/* Onboarding splash (phone-ui/onboarding-page). The logo art is
|
||||
* black-on-transparent; tint it white in dark mode so it doesn't vanish into
|
||||
* the dark page background. */
|
||||
.ns-dark .onboarding-logo {
|
||||
tint-color: #ffffff;
|
||||
}
|
||||
@@ -107,7 +107,7 @@ const ANDROID_PERMISSIONS: PermissionDefinition[] = [
|
||||
const PERMISSIONS: PermissionDefinition[] = global.isIOS ? [{
|
||||
id: "nearby-devices", title: "Nearby Devices",
|
||||
description: "Needed to communicate with your smart glasses over Bluetooth.", optional: false,
|
||||
isGranted: () => iosBluetooth().state === 5,
|
||||
isGranted: () => iosBluetooth().isAuthorized(),
|
||||
request: () => iosBluetooth().ensureReady(),
|
||||
}, {
|
||||
id: "calendar", title: "Calendar",
|
||||
@@ -143,6 +143,7 @@ export class PermissionsViewModel extends Observable {
|
||||
private readonly onboarding: boolean;
|
||||
private _cards: PermissionCardItem[] = [];
|
||||
private requesting = false;
|
||||
private stopWatchingBluetooth: (() => void) | null = null;
|
||||
|
||||
constructor(options?: { onboarding?: boolean }) {
|
||||
super();
|
||||
@@ -159,11 +160,20 @@ export class PermissionsViewModel extends Observable {
|
||||
|
||||
onPageLoaded(): void {
|
||||
Application.on(Application.resumeEvent, this.onAppResume);
|
||||
// The answer to the Bluetooth prompt can arrive after request() has stopped
|
||||
// waiting for it, and with no resume to re-check on.
|
||||
if (global.isIOS) {
|
||||
this.stopWatchingBluetooth = iosBluetooth().onEvent((event) => {
|
||||
if (event.kind === "state") this.refresh();
|
||||
});
|
||||
}
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
onPageUnloaded(): void {
|
||||
Application.off(Application.resumeEvent, this.onAppResume);
|
||||
this.stopWatchingBluetooth?.();
|
||||
this.stopWatchingBluetooth = null;
|
||||
}
|
||||
|
||||
// --- observable properties -------------------------------------------------
|
||||
@@ -177,7 +187,7 @@ export class PermissionsViewModel extends Observable {
|
||||
}
|
||||
|
||||
get instructions(): string {
|
||||
if (global.isIOS) return "Faceclaw uses Bluetooth to communicate with your smart glasses. Calendar and Apple Music access are optional. Tap a card to allow access; a checkmark means it is ready.";
|
||||
if (global.isIOS) return "Faceclaw uses Bluetooth to communicate with your smart glasses. Calendar and Apple Music access are optional. Tap a card to allow access; a checkmark means access is allowed.";
|
||||
return this.onboarding
|
||||
? `Faceclaw uses these ${global.isIOS ? "iOS" : "Android"} permissions. Tap a card to grant one; a checkmark means it is already granted. ` +
|
||||
"Optional permissions can also be granted later, from the Permissions item in the main-screen menu."
|
||||
|
||||
Reference in new issue
Block a user