mirror of
https://github.com/bulwarkmail/native.git
synced 2026-11-01 00:07:01 +00:00
fix: keep toasts working where the accessibility bridge is missing
This commit is contained in:
+10
-1
@@ -18,8 +18,17 @@ export interface AnnounceOptions {
|
||||
assertive?: boolean;
|
||||
}
|
||||
|
||||
function isIos(): boolean {
|
||||
try {
|
||||
return Platform.OS === 'ios';
|
||||
} catch {
|
||||
// A react-native stand-in without Platform (tests).
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function announce(message: string, options: AnnounceOptions = {}): void {
|
||||
if (Platform.OS !== 'ios') return;
|
||||
if (!isIos()) return;
|
||||
const text = message.replace(/\s+/g, ' ').trim();
|
||||
if (!text) return;
|
||||
const now = Date.now();
|
||||
|
||||
@@ -10,8 +10,8 @@ let watching = false;
|
||||
function watch(): void {
|
||||
if (watching) return;
|
||||
watching = true;
|
||||
const info = AccessibilityInfo as typeof AccessibilityInfo | undefined;
|
||||
try {
|
||||
const info = AccessibilityInfo as typeof AccessibilityInfo | undefined;
|
||||
void info?.isScreenReaderEnabled?.().then((on) => { screenReaderOn = on; }).catch(() => undefined);
|
||||
info?.addEventListener?.('screenReaderChanged', (on: boolean) => { screenReaderOn = on; });
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user