@bloxwap/hig 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +5 -0
- package/README.md +44 -2
- package/chart/README.md +23 -0
- package/chart/dist/index.d.ts +8 -0
- package/chart/dist/index.js +12 -0
- package/contracts/README.md +3 -0
- package/contracts/dist/announcements.d.ts +12 -0
- package/contracts/dist/announcements.js +8 -0
- package/contracts/dist/feedback.d.ts +40 -0
- package/contracts/dist/feedback.js +1 -0
- package/contracts/dist/index.d.ts +41 -0
- package/contracts/dist/index.js +52 -0
- package/contracts/dist/messages.d.ts +162 -0
- package/contracts/dist/messages.js +68 -0
- package/feedback/README.md +7 -0
- package/feedback/assets/error.wav +0 -0
- package/feedback/assets/manifest.json +68 -0
- package/feedback/assets/success.wav +0 -0
- package/feedback/assets/tick.wav +0 -0
- package/feedback/assets/toggle.wav +0 -0
- package/feedback/dist/browser-haptic.d.ts +23 -0
- package/feedback/dist/browser-haptic.js +41 -0
- package/feedback/dist/contract.d.ts +96 -0
- package/feedback/dist/contract.js +58 -0
- package/feedback/dist/native.d.ts +27 -0
- package/feedback/dist/native.js +63 -0
- package/feedback/dist/preferences.d.ts +8 -0
- package/feedback/dist/preferences.js +24 -0
- package/feedback/dist/react.d.ts +19 -0
- package/feedback/dist/react.js +23 -0
- package/feedback/dist/web-haptic.d.ts +6 -0
- package/feedback/dist/web-haptic.js +6 -0
- package/feedback/dist/web-sound.d.ts +5 -0
- package/feedback/dist/web-sound.js +32 -0
- package/feedback/dist/web.d.ts +3 -0
- package/feedback/dist/web.js +4 -0
- package/native/README.md +11 -0
- package/native/android/build.gradle +28 -0
- package/native/android/src/main/java/com/bloxwap/hig/HIGAdjustableView.java +173 -0
- package/native/android/src/main/java/com/bloxwap/hig/HIGAdjustableViewManager.java +23 -0
- package/native/android/src/main/java/com/bloxwap/hig/HIGPackage.java +24 -0
- package/native/dist/animated-number-model.d.ts +24 -0
- package/native/dist/animated-number-model.js +110 -0
- package/native/dist/animated-number.d.ts +9 -0
- package/native/dist/animated-number.js +93 -0
- package/native/dist/brand.d.ts +7 -0
- package/native/dist/brand.js +6 -0
- package/native/dist/button.d.ts +29 -0
- package/native/dist/button.js +34 -0
- package/native/dist/checkbox.d.ts +3 -0
- package/native/dist/checkbox.js +11 -0
- package/native/dist/data.d.ts +40 -0
- package/native/dist/data.js +27 -0
- package/native/dist/field.d.ts +15 -0
- package/native/dist/field.js +13 -0
- package/native/dist/gesture-sheet.d.ts +73 -0
- package/native/dist/gesture-sheet.js +151 -0
- package/native/dist/navigation.d.ts +47 -0
- package/native/dist/navigation.js +16 -0
- package/native/dist/overlay.d.ts +36 -0
- package/native/dist/overlay.js +65 -0
- package/native/dist/provider.d.ts +43 -0
- package/native/dist/provider.js +52 -0
- package/native/dist/radio-group.d.ts +5 -0
- package/native/dist/radio-group.js +53 -0
- package/native/dist/recipes.d.ts +42 -0
- package/native/dist/recipes.js +19 -0
- package/native/dist/roles.d.ts +6 -0
- package/native/dist/roles.js +4 -0
- package/native/dist/select.d.ts +3 -0
- package/native/dist/select.js +9 -0
- package/native/dist/selection-types.d.ts +22 -0
- package/native/dist/selection-types.js +1 -0
- package/native/dist/selection.d.ts +7 -0
- package/native/dist/selection.js +6 -0
- package/native/dist/slider.d.ts +11 -0
- package/native/dist/slider.js +41 -0
- package/native/dist/status.d.ts +75 -0
- package/native/dist/status.js +72 -0
- package/native/dist/surface.d.ts +18 -0
- package/native/dist/surface.js +41 -0
- package/native/dist/switch-row.d.ts +8 -0
- package/native/dist/switch-row.js +18 -0
- package/native/dist/switch.d.ts +10 -0
- package/native/dist/switch.js +23 -0
- package/native/dist/text-content.d.ts +5 -0
- package/native/dist/text-content.js +6 -0
- package/native-fonts/README.md +17 -0
- package/native-fonts/dist/index.d.ts +164 -0
- package/native-fonts/dist/index.js +164 -0
- package/native-fonts/fonts/BloxwapMono-Bold.ttf +0 -0
- package/native-fonts/fonts/BloxwapMono-ExtraBold.ttf +0 -0
- package/native-fonts/fonts/BloxwapMono-Medium.ttf +0 -0
- package/native-fonts/fonts/BloxwapMono-SemiBold.ttf +0 -0
- package/native-fonts/fonts/BloxwapMono.ttf +0 -0
- package/native-fonts/fonts/BloxwapSans-Black.ttf +0 -0
- package/native-fonts/fonts/BloxwapSans-Bold.ttf +0 -0
- package/native-fonts/fonts/BloxwapSans-ExtraBold.ttf +0 -0
- package/native-fonts/fonts/BloxwapSans-Medium.ttf +0 -0
- package/native-fonts/fonts/BloxwapSans-SemiBold.ttf +0 -0
- package/native-fonts/fonts/BloxwapSans.ttf +0 -0
- package/native-fonts/fonts/BloxwapSansKR-SemiBold.ttf +0 -0
- package/native-fonts/fonts/BloxwapSansKR.ttf +0 -0
- package/native-fonts/fonts/BloxwapSansSC-SemiBold.ttf +0 -0
- package/native-fonts/fonts/BloxwapSansSC.ttf +0 -0
- package/native-fonts/fonts/OFL.txt +93 -0
- package/native-fonts/fonts/manifest.json +164 -0
- package/og-fonts/README.md +34 -0
- package/og-fonts/dist/index.d.ts +116 -0
- package/og-fonts/dist/index.js +102 -0
- package/og-fonts/dist/node.d.ts +11 -0
- package/og-fonts/dist/node.js +39 -0
- package/og-fonts/fonts/BloxwapMono-Medium.ttf +0 -0
- package/og-fonts/fonts/BloxwapSans-Black.ttf +0 -0
- package/og-fonts/fonts/BloxwapSans-Bold.ttf +0 -0
- package/og-fonts/fonts/BloxwapSans-Medium.ttf +0 -0
- package/og-fonts/fonts/BloxwapSans.ttf +0 -0
- package/og-fonts/fonts/OFL.txt +93 -0
- package/og-fonts/fonts/manifest.json +65 -0
- package/package.json +358 -4
- package/react/README.md +9 -0
- package/react/dist/animated-number-model.d.ts +20 -0
- package/react/dist/animated-number-model.js +92 -0
- package/react/dist/animated-number.d.ts +8 -0
- package/react/dist/animated-number.js +71 -0
- package/react/dist/base.css +9 -0
- package/react/dist/brand.d.ts +7 -0
- package/react/dist/brand.js +4 -0
- package/react/dist/button.d.ts +14 -0
- package/react/dist/button.js +20 -0
- package/react/dist/data.d.ts +63 -0
- package/react/dist/data.js +23 -0
- package/react/dist/dialog.d.ts +29 -0
- package/react/dist/dialog.js +21 -0
- package/react/dist/field.d.ts +15 -0
- package/react/dist/field.js +19 -0
- package/react/dist/gesture-sheet.d.ts +41 -0
- package/react/dist/gesture-sheet.js +128 -0
- package/react/dist/navigation.d.ts +48 -0
- package/react/dist/navigation.js +69 -0
- package/react/dist/overlay.d.ts +17 -0
- package/react/dist/overlay.js +18 -0
- package/react/dist/provider.d.ts +25 -0
- package/react/dist/provider.js +50 -0
- package/react/dist/recipes/activity-list.d.ts +8 -0
- package/react/dist/recipes/activity-list.js +6 -0
- package/react/dist/recipes/balance-card.d.ts +6 -0
- package/react/dist/recipes/balance-card.js +5 -0
- package/react/dist/recipes/code-window.d.ts +4 -0
- package/react/dist/recipes/code-window.js +4 -0
- package/react/dist/recipes/install-command.d.ts +5 -0
- package/react/dist/recipes/install-command.js +8 -0
- package/react/dist/recipes/market-row.d.ts +25 -0
- package/react/dist/recipes/market-row.js +8 -0
- package/react/dist/recipes/marketing-hero.d.ts +7 -0
- package/react/dist/recipes/marketing-hero.js +5 -0
- package/react/dist/recipes/trade-entry.d.ts +11 -0
- package/react/dist/recipes/trade-entry.js +12 -0
- package/react/dist/recipes.d.ts +8 -0
- package/react/dist/recipes.js +9 -0
- package/react/dist/select.d.ts +4 -0
- package/react/dist/select.js +172 -0
- package/react/dist/selection.d.ts +27 -0
- package/react/dist/selection.js +16 -0
- package/react/dist/slider.d.ts +11 -0
- package/react/dist/slider.js +10 -0
- package/react/dist/status.d.ts +53 -0
- package/react/dist/status.js +43 -0
- package/react/dist/styles.css +228 -0
- package/react/dist/surface.d.ts +291 -0
- package/react/dist/surface.js +9 -0
- package/tokens/README.md +9 -0
- package/tokens/assets/bloxwap-icon.svg +1 -0
- package/tokens/dist/index.d.ts +429 -0
- package/tokens/dist/index.js +507 -0
- package/tokens/dist/manifest.json +197 -0
- package/tokens/dist/theme.d.ts +11 -0
- package/tokens/dist/theme.js +22 -0
- package/tokens/dist/tokens.css +119 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { presets } from './contract.js';
|
|
2
|
+
const vibrationPatterns = { selection: [8], success: [30, 60, 40], warning: [40, 100, 40], error: [40, 40, 40, 40, 40] };
|
|
3
|
+
/** Browser vibration for accepted semantic events. iOS imperative haptics remain unavailable. */
|
|
4
|
+
export function createBrowserHapticAdapter(backend) {
|
|
5
|
+
let dead = false;
|
|
6
|
+
const imperative = backend && 'canTriggerHaptic' in backend ? backend : undefined;
|
|
7
|
+
const target = backend && 'vibrate' in backend ? backend : typeof navigator !== 'undefined' && typeof navigator.vibrate === 'function' ? navigator : undefined;
|
|
8
|
+
const capability = () => {
|
|
9
|
+
if (dead)
|
|
10
|
+
return { available: false, mechanism: 'none', observed: false, reason: 'Adapter disposed' };
|
|
11
|
+
if (imperative) {
|
|
12
|
+
try {
|
|
13
|
+
return { ...imperative.canTriggerHaptic(), observed: false };
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return { available: false, mechanism: 'none', observed: false, reason: 'Imperative capability probe failed' };
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return { available: !!target, mechanism: target ? 'browser-vibration' : 'none', observed: false, reason: target ? 'Patterns approximate native cues; physical observation pending' : 'Imperative iOS feedback is unavailable; use an eligible physical-tap target' };
|
|
20
|
+
};
|
|
21
|
+
const cancel = () => { target?.vibrate(0); };
|
|
22
|
+
return { get capability() { return capability(); }, play(event, prefs) {
|
|
23
|
+
if (dead || !prefs.haptics)
|
|
24
|
+
return;
|
|
25
|
+
const cue = presets[event.intent].haptic;
|
|
26
|
+
if (!cue)
|
|
27
|
+
return;
|
|
28
|
+
if (imperative) {
|
|
29
|
+
if (!capability().available)
|
|
30
|
+
return;
|
|
31
|
+
try {
|
|
32
|
+
return imperative.triggerHaptic(cue).then(() => { }, () => { });
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
target?.vibrate([...vibrationPatterns[cue]]);
|
|
39
|
+
}, cancel, dispose() { if (dead)
|
|
40
|
+
return; dead = true; cancel(); } };
|
|
41
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { FeedbackAdapter, FeedbackEvent, FeedbackPreferences, FeedbackSink } from '@bloxwap/hig/contracts/feedback';
|
|
2
|
+
export type { FeedbackAdapter, FeedbackEvent, FeedbackPreferences, FeedbackSink, FeedbackCapability, PreferenceStorage, FeedbackIntent } from '@bloxwap/hig/contracts/feedback';
|
|
3
|
+
export declare const defaultPreferences: FeedbackPreferences;
|
|
4
|
+
export declare const presets: {
|
|
5
|
+
readonly press: {
|
|
6
|
+
readonly sound: null;
|
|
7
|
+
readonly haptic: null;
|
|
8
|
+
readonly cooldown: 0;
|
|
9
|
+
};
|
|
10
|
+
readonly activate: {
|
|
11
|
+
readonly sound: 'tick';
|
|
12
|
+
readonly haptic: 'selection';
|
|
13
|
+
readonly cooldown: 80;
|
|
14
|
+
};
|
|
15
|
+
readonly release: {
|
|
16
|
+
readonly sound: null;
|
|
17
|
+
readonly haptic: null;
|
|
18
|
+
readonly cooldown: 0;
|
|
19
|
+
};
|
|
20
|
+
readonly cancel: {
|
|
21
|
+
readonly sound: null;
|
|
22
|
+
readonly haptic: null;
|
|
23
|
+
readonly cooldown: 0;
|
|
24
|
+
};
|
|
25
|
+
readonly selection: {
|
|
26
|
+
readonly sound: 'tick';
|
|
27
|
+
readonly haptic: 'selection';
|
|
28
|
+
readonly cooldown: 80;
|
|
29
|
+
};
|
|
30
|
+
readonly toggle: {
|
|
31
|
+
readonly sound: 'toggle';
|
|
32
|
+
readonly haptic: 'selection';
|
|
33
|
+
readonly cooldown: 80;
|
|
34
|
+
};
|
|
35
|
+
readonly disclosure: {
|
|
36
|
+
readonly sound: null;
|
|
37
|
+
readonly haptic: null;
|
|
38
|
+
readonly cooldown: 120;
|
|
39
|
+
};
|
|
40
|
+
readonly success: {
|
|
41
|
+
readonly sound: 'success';
|
|
42
|
+
readonly haptic: 'success';
|
|
43
|
+
readonly cooldown: 400;
|
|
44
|
+
};
|
|
45
|
+
readonly warning: {
|
|
46
|
+
readonly sound: null;
|
|
47
|
+
readonly haptic: 'warning';
|
|
48
|
+
readonly cooldown: 400;
|
|
49
|
+
};
|
|
50
|
+
readonly error: {
|
|
51
|
+
readonly sound: 'error';
|
|
52
|
+
readonly haptic: 'error';
|
|
53
|
+
readonly cooldown: 400;
|
|
54
|
+
};
|
|
55
|
+
readonly notification: {
|
|
56
|
+
readonly sound: null;
|
|
57
|
+
readonly haptic: null;
|
|
58
|
+
readonly cooldown: 800;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export interface ControllerOptions {
|
|
62
|
+
sound?: FeedbackAdapter;
|
|
63
|
+
haptics?: FeedbackAdapter;
|
|
64
|
+
preferences?: Partial<FeedbackPreferences>;
|
|
65
|
+
now?: () => number;
|
|
66
|
+
policy?: {
|
|
67
|
+
sound?: boolean;
|
|
68
|
+
haptics?: boolean;
|
|
69
|
+
};
|
|
70
|
+
maxRemembered?: number;
|
|
71
|
+
}
|
|
72
|
+
export declare class FeedbackController implements FeedbackSink {
|
|
73
|
+
private options;
|
|
74
|
+
private preferences;
|
|
75
|
+
private seen;
|
|
76
|
+
private cadence;
|
|
77
|
+
private dead;
|
|
78
|
+
private background;
|
|
79
|
+
private clock;
|
|
80
|
+
constructor(options?: ControllerOptions);
|
|
81
|
+
getPreferences(): {
|
|
82
|
+
version: 1;
|
|
83
|
+
sound: boolean;
|
|
84
|
+
haptics: boolean;
|
|
85
|
+
volume: number;
|
|
86
|
+
motion: boolean;
|
|
87
|
+
};
|
|
88
|
+
getCapabilities(): {
|
|
89
|
+
sound: import("@bloxwap/hig/contracts/feedback").FeedbackCapability;
|
|
90
|
+
haptics: import("@bloxwap/hig/contracts/feedback").FeedbackCapability;
|
|
91
|
+
};
|
|
92
|
+
updatePreferences(next: Partial<FeedbackPreferences>): void;
|
|
93
|
+
setBackground(value: boolean): void;
|
|
94
|
+
emit: (event: FeedbackEvent) => void;
|
|
95
|
+
dispose(): void;
|
|
96
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export const defaultPreferences = { version: 1, sound: false, haptics: false, volume: 0.3, motion: true };
|
|
2
|
+
export const presets = { press: { sound: null, haptic: null, cooldown: 0 }, activate: { sound: 'tick', haptic: 'selection', cooldown: 80 }, release: { sound: null, haptic: null, cooldown: 0 }, cancel: { sound: null, haptic: null, cooldown: 0 }, selection: { sound: 'tick', haptic: 'selection', cooldown: 80 }, toggle: { sound: 'toggle', haptic: 'selection', cooldown: 80 }, disclosure: { sound: null, haptic: null, cooldown: 120 }, success: { sound: 'success', haptic: 'success', cooldown: 400 }, warning: { sound: null, haptic: 'warning', cooldown: 400 }, error: { sound: 'error', haptic: 'error', cooldown: 400 }, notification: { sound: null, haptic: null, cooldown: 800 } };
|
|
3
|
+
function attempt(fn) { if (!fn)
|
|
4
|
+
return; try {
|
|
5
|
+
Promise.resolve(fn()).catch(() => { });
|
|
6
|
+
}
|
|
7
|
+
catch { /* Feedback never changes the primary action. */ } }
|
|
8
|
+
export class FeedbackController {
|
|
9
|
+
options;
|
|
10
|
+
preferences;
|
|
11
|
+
seen = new Map();
|
|
12
|
+
cadence = new Map();
|
|
13
|
+
dead = false;
|
|
14
|
+
background = false;
|
|
15
|
+
clock;
|
|
16
|
+
constructor(options = {}) {
|
|
17
|
+
this.options = options;
|
|
18
|
+
this.preferences = { ...defaultPreferences, ...options.preferences };
|
|
19
|
+
this.clock = options.now ?? Date.now;
|
|
20
|
+
this.updatePreferences(this.preferences);
|
|
21
|
+
}
|
|
22
|
+
getPreferences() { return { ...this.preferences }; }
|
|
23
|
+
getCapabilities() { return { sound: this.options.sound?.capability ?? { available: false, mechanism: 'none', observed: false }, haptics: this.options.haptics?.capability ?? { available: false, mechanism: 'none', observed: false } }; }
|
|
24
|
+
updatePreferences(next) { this.preferences = { ...this.preferences, ...next, version: 1 }; this.preferences.volume = Number.isFinite(this.preferences.volume) ? Math.max(0, Math.min(1, this.preferences.volume)) : defaultPreferences.volume; if (!this.preferences.sound || this.preferences.volume <= 0)
|
|
25
|
+
attempt(this.options.sound?.cancel?.bind(this.options.sound)); if (!this.preferences.haptics)
|
|
26
|
+
attempt(this.options.haptics?.cancel?.bind(this.options.haptics)); }
|
|
27
|
+
setBackground(value) { this.background = value; if (value) {
|
|
28
|
+
attempt(this.options.sound?.cancel?.bind(this.options.sound));
|
|
29
|
+
attempt(this.options.haptics?.cancel?.bind(this.options.haptics));
|
|
30
|
+
} }
|
|
31
|
+
emit = (event) => {
|
|
32
|
+
if (this.dead || this.background || event.cancelled || event.disabled || event.busy || event.suppressed)
|
|
33
|
+
return;
|
|
34
|
+
if (event.intent === 'cancel') {
|
|
35
|
+
attempt(this.options.sound?.cancel?.bind(this.options.sound));
|
|
36
|
+
attempt(this.options.haptics?.cancel?.bind(this.options.haptics));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const now = this.clock(), key = `${event.source}/${event.id}/${event.intent}`, cadenceKey = `${event.source}/${event.intent}`;
|
|
40
|
+
if (this.seen.has(key) || now - (this.cadence.get(cadenceKey) ?? -Infinity) < presets[event.intent].cooldown)
|
|
41
|
+
return;
|
|
42
|
+
this.seen.set(key, now);
|
|
43
|
+
this.cadence.set(cadenceKey, now);
|
|
44
|
+
const requestedCap = this.options.maxRemembered ?? 256;
|
|
45
|
+
const cap = Number.isFinite(requestedCap) ? Math.max(1, Math.trunc(requestedCap)) : 256;
|
|
46
|
+
while (this.seen.size > cap)
|
|
47
|
+
this.seen.delete(this.seen.keys().next().value);
|
|
48
|
+
while (this.cadence.size > cap)
|
|
49
|
+
this.cadence.delete(this.cadence.keys().next().value);
|
|
50
|
+
const prefs = this.getPreferences();
|
|
51
|
+
if (prefs.sound && prefs.volume > 0 && this.options.policy?.sound !== false && this.options.sound?.capability.available && presets[event.intent].sound)
|
|
52
|
+
attempt(() => this.options.sound.play(event, prefs));
|
|
53
|
+
if (prefs.haptics && this.options.policy?.haptics !== false && this.options.haptics?.capability.available && (presets[event.intent].haptic || event.impact))
|
|
54
|
+
attempt(() => this.options.haptics.play(event, prefs));
|
|
55
|
+
};
|
|
56
|
+
dispose() { if (this.dead)
|
|
57
|
+
return; this.dead = true; attempt(this.options.sound?.dispose?.bind(this.options.sound)); attempt(this.options.haptics?.dispose?.bind(this.options.haptics)); this.seen.clear(); this.cadence.clear(); }
|
|
58
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { FeedbackAdapter } from '@bloxwap/hig/contracts/feedback';
|
|
2
|
+
export interface NativePlayer {
|
|
3
|
+
play: () => void;
|
|
4
|
+
pause: () => void;
|
|
5
|
+
seekTo: (seconds: number) => Promise<void>;
|
|
6
|
+
remove: () => void;
|
|
7
|
+
volume: number;
|
|
8
|
+
}
|
|
9
|
+
export interface NativeAudioBackend {
|
|
10
|
+
create: (asset: unknown) => NativePlayer;
|
|
11
|
+
configure?: () => Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export type CueAssets = Readonly<Partial<Record<'tick' | 'toggle' | 'success' | 'error', unknown>>>;
|
|
14
|
+
/** Host provides packaged Metro asset ids and lifecycle hooks; no browser audio at module load.
|
|
15
|
+
* After preload() settles, play() dispatches synchronously: no bridge round trip (configure, seek) precedes player.play(). */
|
|
16
|
+
export declare function createNativeSoundAdapter(backend: NativeAudioBackend, assets: CueAssets): FeedbackAdapter & {
|
|
17
|
+
preload: () => Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
/** Host imports Expo only in its native feedback setup. This bridge keeps the contract injectable. */
|
|
20
|
+
export declare function expoAudioBackend(expo: Pick<typeof import('expo-audio'), 'createAudioPlayer' | 'setAudioModeAsync'>): NativeAudioBackend;
|
|
21
|
+
export interface NativeHapticBackend {
|
|
22
|
+
selection: () => Promise<void>;
|
|
23
|
+
impact: (style: 'light' | 'medium' | 'heavy') => Promise<void>;
|
|
24
|
+
notification: (type: 'success' | 'warning' | 'error') => Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
export declare function createNativeHapticAdapter(backend: NativeHapticBackend, available?: boolean): FeedbackAdapter;
|
|
27
|
+
export declare function expoHapticBackend(expo: typeof import('expo-haptics')): NativeHapticBackend;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { presets } from './contract.js';
|
|
2
|
+
/** Host provides packaged Metro asset ids and lifecycle hooks; no browser audio at module load.
|
|
3
|
+
* After preload() settles, play() dispatches synchronously: no bridge round trip (configure, seek) precedes player.play(). */
|
|
4
|
+
export function createNativeSoundAdapter(backend, assets) {
|
|
5
|
+
const players = new Map();
|
|
6
|
+
let dead = false, ready = false, epoch = 0;
|
|
7
|
+
let configured;
|
|
8
|
+
let active;
|
|
9
|
+
const preload = async () => { if (dead)
|
|
10
|
+
return; configured ??= backend.configure?.() ?? Promise.resolve(); try {
|
|
11
|
+
await configured;
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
configured = undefined;
|
|
15
|
+
throw error;
|
|
16
|
+
} if (dead)
|
|
17
|
+
return; for (const [name, asset] of Object.entries(assets))
|
|
18
|
+
if (asset != null && !players.has(name))
|
|
19
|
+
players.set(name, backend.create(asset)); ready = true; };
|
|
20
|
+
const stopActive = () => { const previous = active; active = undefined; if (previous)
|
|
21
|
+
try {
|
|
22
|
+
previous.pause();
|
|
23
|
+
}
|
|
24
|
+
catch { /* A failed pause cannot block the next cue. */ } };
|
|
25
|
+
// One active cue: stop the previous player, restart this one and play without awaiting the seek; native players apply calls in order.
|
|
26
|
+
const dispatch = (player, volume) => { if (active !== player)
|
|
27
|
+
stopActive(); active = player; player.volume = volume; try {
|
|
28
|
+
void player.seekTo(0).catch(() => { });
|
|
29
|
+
}
|
|
30
|
+
catch { /* Playing from the current position beats dropping the cue. */ } player.play(); };
|
|
31
|
+
const cancel = () => { epoch++; active = undefined; for (const player of players.values())
|
|
32
|
+
try {
|
|
33
|
+
player.pause();
|
|
34
|
+
}
|
|
35
|
+
catch { /* Continue cleaning other players. */ } };
|
|
36
|
+
return { capability: { available: true, mechanism: 'native-audio', observed: false, reason: 'Backend supplied; playback latency/silent mode/interruption observations pending' }, preload,
|
|
37
|
+
play(event, prefs) {
|
|
38
|
+
if (dead || !prefs.sound || prefs.volume <= 0)
|
|
39
|
+
return;
|
|
40
|
+
const cue = presets[event.intent].sound;
|
|
41
|
+
if (!cue || assets[cue] == null)
|
|
42
|
+
return;
|
|
43
|
+
const generation = ++epoch;
|
|
44
|
+
const cached = ready ? players.get(cue) : undefined;
|
|
45
|
+
if (cached)
|
|
46
|
+
return dispatch(cached, prefs.volume);
|
|
47
|
+
stopActive();
|
|
48
|
+
return preload().then(() => { const player = players.get(cue); if (!dead && generation === epoch && player)
|
|
49
|
+
dispatch(player, prefs.volume); });
|
|
50
|
+
}, cancel,
|
|
51
|
+
dispose() { if (dead)
|
|
52
|
+
return; dead = true; cancel(); for (const player of players.values())
|
|
53
|
+
try {
|
|
54
|
+
player.remove();
|
|
55
|
+
}
|
|
56
|
+
catch { /* Release all remaining players. */ } players.clear(); } };
|
|
57
|
+
}
|
|
58
|
+
/** Host imports Expo only in its native feedback setup. This bridge keeps the contract injectable. */
|
|
59
|
+
export function expoAudioBackend(expo) { return { create: asset => expo.createAudioPlayer(asset), configure: () => expo.setAudioModeAsync({ playsInSilentMode: false, shouldPlayInBackground: false, interruptionMode: 'doNotMix' }) }; }
|
|
60
|
+
export function createNativeHapticAdapter(backend, available = true) { let dead = false; return { capability: { available, mechanism: available ? 'native-haptics' : 'none', observed: false, reason: 'Native backend supplied; OS settings/hardware may suppress output' }, play(event, prefs) { if (dead || !available || !prefs.haptics)
|
|
61
|
+
return; if (event.impact)
|
|
62
|
+
return backend.impact(event.impact); const cue = presets[event.intent].haptic; return cue === 'selection' ? backend.selection() : cue ? backend.notification(cue) : undefined; }, dispose() { dead = true; } }; }
|
|
63
|
+
export function expoHapticBackend(expo) { return { selection: () => expo.selectionAsync(), impact: style => expo.impactAsync(style === 'light' ? expo.ImpactFeedbackStyle.Light : style === 'medium' ? expo.ImpactFeedbackStyle.Medium : expo.ImpactFeedbackStyle.Heavy), notification: type => expo.notificationAsync(type === 'success' ? expo.NotificationFeedbackType.Success : type === 'warning' ? expo.NotificationFeedbackType.Warning : expo.NotificationFeedbackType.Error) }; }
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FeedbackPreferences, PreferenceStorage } from '@bloxwap/hig/contracts/feedback';
|
|
2
|
+
export declare function migratePreferences(value: unknown): FeedbackPreferences;
|
|
3
|
+
export declare function jsonStorage(storage: {
|
|
4
|
+
getItem: (key: string) => string | null | Promise<string | null>;
|
|
5
|
+
setItem: (key: string, value: string) => void | Promise<void>;
|
|
6
|
+
}, key?: string): PreferenceStorage;
|
|
7
|
+
/** Avoid overwriting a user's new local choice with a delayed saved read. */
|
|
8
|
+
export declare function loadPreferences(storage: PreferenceStorage | undefined, revision: () => number, apply: (value: FeedbackPreferences) => void): Promise<void>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { defaultPreferences } from './contract.js';
|
|
2
|
+
export function migratePreferences(value) {
|
|
3
|
+
if (!value || typeof value !== 'object')
|
|
4
|
+
return { ...defaultPreferences };
|
|
5
|
+
const saved = value;
|
|
6
|
+
const sound = saved.sound ?? saved.soundEnabled, haptics = saved.haptics ?? saved.hapticsEnabled;
|
|
7
|
+
const volume = typeof saved.volume === 'number' && Number.isFinite(saved.volume) ? Math.max(0, Math.min(1, saved.volume)) : defaultPreferences.volume;
|
|
8
|
+
return { version: 1, sound: typeof sound === 'boolean' ? sound : defaultPreferences.sound, haptics: typeof haptics === 'boolean' ? haptics : defaultPreferences.haptics, volume, motion: typeof saved.motion === 'boolean' ? saved.motion : typeof saved.reducedMotion === 'boolean' ? !saved.reducedMotion : defaultPreferences.motion };
|
|
9
|
+
}
|
|
10
|
+
export function jsonStorage(storage, key = 'bloxwap.hig.feedback.v1') { return { read: async () => { try {
|
|
11
|
+
const raw = await storage.getItem(key);
|
|
12
|
+
return raw ? JSON.parse(raw) : undefined;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return undefined;
|
|
16
|
+
} }, write: value => storage.setItem(key, JSON.stringify(value)) }; }
|
|
17
|
+
/** Avoid overwriting a user's new local choice with a delayed saved read. */
|
|
18
|
+
export async function loadPreferences(storage, revision, apply) { if (!storage)
|
|
19
|
+
return; const initial = revision(); try {
|
|
20
|
+
const value = await storage.read();
|
|
21
|
+
if (revision() === initial)
|
|
22
|
+
apply(migratePreferences(value));
|
|
23
|
+
}
|
|
24
|
+
catch { /* Storage is optional. */ } }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { FeedbackPreferences, FeedbackSink, PreferenceStorage } from '@bloxwap/hig/contracts/feedback';
|
|
3
|
+
import { FeedbackController } from './contract.js';
|
|
4
|
+
interface FeedbackContext {
|
|
5
|
+
preferences: FeedbackPreferences;
|
|
6
|
+
update: (next: Partial<FeedbackPreferences>) => void;
|
|
7
|
+
sink: FeedbackSink;
|
|
8
|
+
controller: () => FeedbackController | null;
|
|
9
|
+
}
|
|
10
|
+
export declare function FeedbackProvider({ children, createController, storage, initialPreferences }: React.PropsWithChildren<{
|
|
11
|
+
initialPreferences?: Partial<FeedbackPreferences>;
|
|
12
|
+
createController: (prefs: FeedbackPreferences) => FeedbackController;
|
|
13
|
+
storage?: PreferenceStorage;
|
|
14
|
+
}>): React.JSX.Element;
|
|
15
|
+
export declare const useFeedback: () => FeedbackContext;
|
|
16
|
+
export declare function FeedbackPreferencesControl({ children }: {
|
|
17
|
+
children: (context: Pick<FeedbackContext, 'preferences' | 'update'>) => React.ReactNode;
|
|
18
|
+
}): React.JSX.Element;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useEffect, useRef, useState, useCallback } from 'react';
|
|
4
|
+
import { defaultPreferences } from './contract.js';
|
|
5
|
+
import { loadPreferences, migratePreferences } from './preferences.js';
|
|
6
|
+
const Context = createContext({ preferences: defaultPreferences, update: () => { }, sink: { emit: () => { } }, controller: () => null });
|
|
7
|
+
export function FeedbackProvider({ children, createController, storage, initialPreferences }) {
|
|
8
|
+
const [preferences, setPreferences] = useState(() => migratePreferences({ ...defaultPreferences, ...initialPreferences }));
|
|
9
|
+
const current = useRef(preferences);
|
|
10
|
+
const revision = useRef(0);
|
|
11
|
+
const controller = useRef(null);
|
|
12
|
+
const [sink] = useState(() => ({ emit: event => controller.current?.emit(event) }));
|
|
13
|
+
useEffect(() => { const instance = createController(current.current); controller.current = instance; let alive = true; void loadPreferences(storage, () => revision.current, value => { if (!alive)
|
|
14
|
+
return; current.current = value; setPreferences(value); instance.updatePreferences(value); }); return () => { alive = false; controller.current = null; instance.dispose(); }; }, [createController, storage]);
|
|
15
|
+
const update = useCallback((next) => { revision.current++; const value = migratePreferences({ ...current.current, ...next }); current.current = value; setPreferences(value); controller.current?.updatePreferences(value); try {
|
|
16
|
+
Promise.resolve(storage?.write(value)).catch(() => { });
|
|
17
|
+
}
|
|
18
|
+
catch { /* Preferences remain live without storage. */ } }, [storage]);
|
|
19
|
+
const getController = useCallback(() => controller.current, []);
|
|
20
|
+
return _jsx(Context.Provider, { value: { preferences, update, sink, controller: getController }, children: children });
|
|
21
|
+
}
|
|
22
|
+
export const useFeedback = () => useContext(Context);
|
|
23
|
+
export function FeedbackPreferencesControl({ children }) { const { preferences, update } = useFeedback(); return _jsx(_Fragment, { children: children({ preferences, update }) }); }
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type HapticTargetProps } from '@bloxwap/haptic';
|
|
3
|
+
/** Physical-tap opt-in. Pre-approval is required because an iOS tick precedes delegated cancellation. */
|
|
4
|
+
export declare function HapticFeedbackTarget({ eligible, children, ...props }: Omit<HapticTargetProps, 'enabled' | 'webHapticsOptions'> & {
|
|
5
|
+
eligible?: boolean;
|
|
6
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { HapticTarget, useIOSNativeHaptics } from '@bloxwap/haptic';
|
|
4
|
+
import { useFeedback } from './react.js';
|
|
5
|
+
/** Physical-tap opt-in. Pre-approval is required because an iOS tick precedes delegated cancellation. */
|
|
6
|
+
export function HapticFeedbackTarget({ eligible = false, children, ...props }) { const { preferences } = useFeedback(); const physicalTap = useIOSNativeHaptics(); return _jsx(HapticTarget, { ...props, enabled: physicalTap && eligible && preferences.haptics, webHapticsOptions: { debug: false, showSwitch: false }, children: children }); }
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FeedbackAdapter } from '@bloxwap/hig/contracts/feedback';
|
|
2
|
+
type SfxEngine = Pick<typeof import('@bloxwap/sfx'), 'unlock' | 'play' | 'preload' | 'dispose'>;
|
|
3
|
+
/** No import/AudioContext until an enabled semantic request follows a trusted gesture. */
|
|
4
|
+
export declare function createWebSoundAdapter(load?: () => Promise<SfxEngine>): FeedbackAdapter;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { presets } from './contract.js';
|
|
2
|
+
let shared;
|
|
3
|
+
let users = 0;
|
|
4
|
+
/** No import/AudioContext until an enabled semantic request follows a trusted gesture. */
|
|
5
|
+
export function createWebSoundAdapter(load = () => import('@bloxwap/sfx')) {
|
|
6
|
+
let dead = false, generation = 0, used = false;
|
|
7
|
+
let scope;
|
|
8
|
+
const defaultEngine = arguments.length === 0;
|
|
9
|
+
const cancel = () => { generation++; scope?.abort(); scope = undefined; };
|
|
10
|
+
return { capability: { available: typeof window !== 'undefined', mechanism: 'web-audio', observed: false, reason: 'Shared engine with per-root abort where supported; API readiness is not observed playback' },
|
|
11
|
+
async play(event, prefs) { if (dead || !prefs.sound || prefs.volume <= 0)
|
|
12
|
+
return; const recipe = presets[event.intent].sound; if (!recipe)
|
|
13
|
+
return; const epoch = ++generation; const signal = (scope ??= new AbortController()).signal; if (!used) {
|
|
14
|
+
used = true;
|
|
15
|
+
if (defaultEngine)
|
|
16
|
+
users++;
|
|
17
|
+
} const engine = await (defaultEngine ? (shared ??= load()) : load()); if (dead || epoch !== generation)
|
|
18
|
+
return; if (await engine.unlock()) {
|
|
19
|
+
if (!dead && epoch === generation) {
|
|
20
|
+
const options = { volume: prefs.volume, minInterval: presets[event.intent].cooldown, signal };
|
|
21
|
+
engine.play(recipe, options);
|
|
22
|
+
}
|
|
23
|
+
} },
|
|
24
|
+
cancel,
|
|
25
|
+
dispose() { if (dead)
|
|
26
|
+
return; dead = true; cancel(); if (used && defaultEngine && --users === 0) {
|
|
27
|
+
const last = shared;
|
|
28
|
+
shared = undefined;
|
|
29
|
+
void last?.then(engine => { if (users === 0)
|
|
30
|
+
engine.dispose(); }).catch(() => { });
|
|
31
|
+
} } };
|
|
32
|
+
}
|
package/native/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# @bloxwap/hig/native
|
|
2
|
+
|
|
3
|
+
Version 0.2.0, an entry of `@bloxwap/hig`. Import individual entries; see docs/components for platform and accessibility contracts.
|
|
4
|
+
|
|
5
|
+
Set a brand accent with `<HIGProvider primaryColor='#ff0000'>` from
|
|
6
|
+
`@bloxwap/hig/native/provider`. It accepts opaque sRGB hex (`#RGB` or `#RRGGBB`),
|
|
7
|
+
sets action/focus colours, and selects black or white text on primary fills.
|
|
8
|
+
Omit it to keep Bloxwap green. Nested providers inherit the accent, and `useColors()`
|
|
9
|
+
returns the resolved roles. With `colorSpace='display-p3'` on iOS, HIG converts
|
|
10
|
+
the sRGB input to P3 channels. Status, buy/sell colours, and the Bloxwap mark retain
|
|
11
|
+
their defaults. See [the colour guide](../../../docs/foundations/platform.md#primary-brand-colour).
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Android support for @bloxwap/hig/native: the Slider's set-progress accessibility action (#71).
|
|
2
|
+
// Autolinked by React Native / Expo; the host app's React Native Gradle plugin supplies react-android.
|
|
3
|
+
apply plugin: 'com.android.library'
|
|
4
|
+
|
|
5
|
+
def safeExtGet(prop, fallback) {
|
|
6
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
android {
|
|
10
|
+
namespace 'com.bloxwap.hig'
|
|
11
|
+
compileSdkVersion safeExtGet('compileSdkVersion', 35)
|
|
12
|
+
defaultConfig {
|
|
13
|
+
minSdkVersion safeExtGet('minSdkVersion', 24)
|
|
14
|
+
}
|
|
15
|
+
compileOptions {
|
|
16
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
17
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
repositories {
|
|
22
|
+
google()
|
|
23
|
+
mavenCentral()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
dependencies {
|
|
27
|
+
implementation 'com.facebook.react:react-android'
|
|
28
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
package com.bloxwap.hig;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.os.Bundle;
|
|
5
|
+
import android.view.View;
|
|
6
|
+
import android.view.ViewGroup;
|
|
7
|
+
import android.view.accessibility.AccessibilityEvent;
|
|
8
|
+
import android.view.accessibility.AccessibilityNodeInfo;
|
|
9
|
+
import android.view.accessibility.AccessibilityNodeProvider;
|
|
10
|
+
import androidx.annotation.NonNull;
|
|
11
|
+
import androidx.annotation.Nullable;
|
|
12
|
+
import com.facebook.react.bridge.Arguments;
|
|
13
|
+
import com.facebook.react.bridge.ReactContext;
|
|
14
|
+
import com.facebook.react.bridge.WritableMap;
|
|
15
|
+
import com.facebook.react.uimanager.UIManagerHelper;
|
|
16
|
+
import com.facebook.react.uimanager.events.Event;
|
|
17
|
+
import com.facebook.react.uimanager.events.EventDispatcher;
|
|
18
|
+
import com.facebook.react.views.view.ReactViewGroup;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* React Native maps accessibilityActions names to fixed or synthetic action ids and drops action
|
|
22
|
+
* arguments, so an adjustable View cannot offer AccessibilityNodeInfo.ACTION_SET_PROGRESS (Voice
|
|
23
|
+
* Access, Switch Access). This view wraps whichever delegate React Native installs and adds
|
|
24
|
+
* set-progress while the node is enabled and carries range info (accessibilityValue min/max/now).
|
|
25
|
+
* The requested value reaches JS as onAccessibilityAction({actionName: 'setProgress', value}).
|
|
26
|
+
*/
|
|
27
|
+
public class HIGAdjustableView extends ReactViewGroup {
|
|
28
|
+
public static final String SET_PROGRESS = "setProgress";
|
|
29
|
+
|
|
30
|
+
public HIGAdjustableView(Context context) {
|
|
31
|
+
super(context);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@Override
|
|
35
|
+
public void setAccessibilityDelegate(@Nullable View.AccessibilityDelegate delegate) {
|
|
36
|
+
// Only wrap a delegate React Native installed: an always-present delegate would stop
|
|
37
|
+
// ReactAccessibilityDelegate.setDelegate from attaching role/state/value semantics.
|
|
38
|
+
super.setAccessibilityDelegate(
|
|
39
|
+
delegate == null || delegate instanceof SetProgressDelegate
|
|
40
|
+
? delegate
|
|
41
|
+
: new SetProgressDelegate(delegate));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static boolean acceptsSetProgress(@NonNull AccessibilityNodeInfo info) {
|
|
45
|
+
return info.isEnabled() && info.getRangeInfo() != null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private void dispatchSetProgress(float value) {
|
|
49
|
+
Context context = getContext();
|
|
50
|
+
if (!(context instanceof ReactContext)) return;
|
|
51
|
+
int tag = getId();
|
|
52
|
+
EventDispatcher dispatcher =
|
|
53
|
+
UIManagerHelper.getEventDispatcherForReactTag((ReactContext) context, tag);
|
|
54
|
+
if (dispatcher == null) return;
|
|
55
|
+
dispatcher.dispatchEvent(new SetProgressEvent(UIManagerHelper.getSurfaceId(this), tag, value));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
private final class SetProgressDelegate extends View.AccessibilityDelegate {
|
|
59
|
+
private final View.AccessibilityDelegate inner;
|
|
60
|
+
|
|
61
|
+
SetProgressDelegate(View.AccessibilityDelegate inner) {
|
|
62
|
+
this.inner = inner;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@Override
|
|
66
|
+
public void onInitializeAccessibilityNodeInfo(
|
|
67
|
+
@NonNull View host, @NonNull AccessibilityNodeInfo info) {
|
|
68
|
+
inner.onInitializeAccessibilityNodeInfo(host, info);
|
|
69
|
+
if (acceptsSetProgress(info)) {
|
|
70
|
+
info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SET_PROGRESS);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@Override
|
|
75
|
+
public boolean performAccessibilityAction(
|
|
76
|
+
@NonNull View host, int action, @Nullable Bundle args) {
|
|
77
|
+
if (action != android.R.id.accessibilityActionSetProgress) {
|
|
78
|
+
return inner.performAccessibilityAction(host, action, args);
|
|
79
|
+
}
|
|
80
|
+
// Re-read the current semantics: disabled sliders and sliders without a range reject it.
|
|
81
|
+
AccessibilityNodeInfo info = host.createAccessibilityNodeInfo();
|
|
82
|
+
boolean accepted = acceptsSetProgress(info);
|
|
83
|
+
if (android.os.Build.VERSION.SDK_INT < 33) info.recycle();
|
|
84
|
+
if (!accepted || args == null
|
|
85
|
+
|| !args.containsKey(AccessibilityNodeInfo.ACTION_ARGUMENT_PROGRESS_VALUE)) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
float value = args.getFloat(AccessibilityNodeInfo.ACTION_ARGUMENT_PROGRESS_VALUE);
|
|
89
|
+
if (Float.isNaN(value) || Float.isInfinite(value)) return false;
|
|
90
|
+
dispatchSetProgress(value);
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@Override
|
|
95
|
+
public void sendAccessibilityEvent(@NonNull View host, int eventType) {
|
|
96
|
+
inner.sendAccessibilityEvent(host, eventType);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@Override
|
|
100
|
+
public void sendAccessibilityEventUnchecked(
|
|
101
|
+
@NonNull View host, @NonNull AccessibilityEvent event) {
|
|
102
|
+
inner.sendAccessibilityEventUnchecked(host, event);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@Override
|
|
106
|
+
public boolean dispatchPopulateAccessibilityEvent(
|
|
107
|
+
@NonNull View host, @NonNull AccessibilityEvent event) {
|
|
108
|
+
return inner.dispatchPopulateAccessibilityEvent(host, event);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@Override
|
|
112
|
+
public void onPopulateAccessibilityEvent(
|
|
113
|
+
@NonNull View host, @NonNull AccessibilityEvent event) {
|
|
114
|
+
inner.onPopulateAccessibilityEvent(host, event);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@Override
|
|
118
|
+
public void onInitializeAccessibilityEvent(
|
|
119
|
+
@NonNull View host, @NonNull AccessibilityEvent event) {
|
|
120
|
+
inner.onInitializeAccessibilityEvent(host, event);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@Override
|
|
124
|
+
public boolean onRequestSendAccessibilityEvent(
|
|
125
|
+
@NonNull ViewGroup host, @NonNull View child, @NonNull AccessibilityEvent event) {
|
|
126
|
+
return inner.onRequestSendAccessibilityEvent(host, child, event);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
@Nullable
|
|
130
|
+
@Override
|
|
131
|
+
public AccessibilityNodeProvider getAccessibilityNodeProvider(@NonNull View host) {
|
|
132
|
+
return inner.getAccessibilityNodeProvider(host);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
@Override
|
|
136
|
+
public void addExtraDataToAccessibilityNodeInfo(
|
|
137
|
+
@NonNull View host,
|
|
138
|
+
@NonNull AccessibilityNodeInfo info,
|
|
139
|
+
@NonNull String extraDataKey,
|
|
140
|
+
@Nullable Bundle arguments) {
|
|
141
|
+
inner.addExtraDataToAccessibilityNodeInfo(host, info, extraDataKey, arguments);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
private static final class SetProgressEvent extends Event<SetProgressEvent> {
|
|
146
|
+
private final float value;
|
|
147
|
+
|
|
148
|
+
SetProgressEvent(int surfaceId, int viewTag, float value) {
|
|
149
|
+
super(surfaceId, viewTag);
|
|
150
|
+
this.value = value;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@NonNull
|
|
154
|
+
@Override
|
|
155
|
+
public String getEventName() {
|
|
156
|
+
return "topAccessibilityAction";
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
@Override
|
|
160
|
+
public boolean canCoalesce() {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
@Nullable
|
|
165
|
+
@Override
|
|
166
|
+
protected WritableMap getEventData() {
|
|
167
|
+
WritableMap data = Arguments.createMap();
|
|
168
|
+
data.putString("actionName", SET_PROGRESS);
|
|
169
|
+
data.putDouble("value", value);
|
|
170
|
+
return data;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|