@a16n/web-sim 0.0.0-stage → 0.1.1
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/README.md +13 -2
- package/bin/cli.ts +255 -0
- package/bin/web-sim.js +39 -0
- package/overrides/@backpackapp-io/react-native-toast/overrides.ts +15 -0
- package/overrides/@react-native-firebase/app/overrides.ts +34 -0
- package/overrides/@tiktok-for-business/react-native-sdk/NativeTiktokSdk.ts +29 -0
- package/overrides/@tiktok-for-business/react-native-sdk/overrides.ts +9 -0
- package/overrides/expo-application/ExpoApplication.ts +81 -0
- package/overrides/expo-application/overrides.ts +16 -0
- package/overrides/expo-background-task/ExpoBackgroundTaskModule.ts +30 -0
- package/overrides/expo-background-task/overrides.ts +9 -0
- package/overrides/expo-constants/ExponentConstants.ts +66 -0
- package/overrides/expo-constants/overrides.ts +9 -0
- package/overrides/expo-device/ExpoDevice.ts +104 -0
- package/overrides/expo-device/overrides.ts +9 -0
- package/overrides/expo-glass-effect/GlassContainer.tsx +9 -0
- package/overrides/expo-glass-effect/GlassView.tsx +95 -0
- package/overrides/expo-glass-effect/availability.ts +14 -0
- package/overrides/expo-glass-effect/overrides.ts +14 -0
- package/overrides/expo-haptics/Haptics.ts +67 -0
- package/overrides/expo-haptics/overrides.ts +5 -0
- package/overrides/expo-mail-composer/ExpoMailComposer.ts +40 -0
- package/overrides/expo-mail-composer/overrides.ts +9 -0
- package/overrides/expo-mesh-gradient/MeshGradientView.tsx +44 -0
- package/overrides/expo-mesh-gradient/overrides.ts +9 -0
- package/overrides/expo-modules-core/overrides.ts +12 -0
- package/overrides/expo-navigation-bar/ExpoNavigationBar.ts +29 -0
- package/overrides/expo-navigation-bar/NavigationBar.ts +43 -0
- package/overrides/expo-navigation-bar/overrides.ts +12 -0
- package/overrides/expo-router/NativeStackView.tsx +74 -0
- package/overrides/expo-router/NativeTabsView.tsx +263 -0
- package/overrides/expo-router/SafeAreaProvider.ts +6 -0
- package/overrides/expo-router/overrides.ts +23 -0
- package/overrides/expo-router/statusBarRequests.ts +51 -0
- package/overrides/expo-screen-orientation/ExpoScreenOrientation.ts +173 -0
- package/overrides/expo-screen-orientation/overrides.ts +21 -0
- package/overrides/expo-sharing/SharingNativeModule.ts +21 -0
- package/overrides/expo-sharing/overrides.ts +9 -0
- package/overrides/expo-sms/ExpoSMS.ts +24 -0
- package/overrides/expo-sms/overrides.ts +9 -0
- package/overrides/expo-splash-screen/SplashScreen.ts +25 -0
- package/overrides/expo-splash-screen/overrides.ts +5 -0
- package/overrides/expo-status-bar/StatusBar.tsx +44 -0
- package/overrides/expo-status-bar/overrides.ts +5 -0
- package/overrides/expo-store-review/ExpoStoreReview.ts +18 -0
- package/overrides/expo-store-review/overrides.ts +9 -0
- package/overrides/expo-symbols/SymbolView.tsx +192 -0
- package/overrides/expo-symbols/overrides.ts +9 -0
- package/overrides/expo-system-ui/ExpoSystemUI.ts +34 -0
- package/overrides/expo-system-ui/overrides.ts +9 -0
- package/overrides/expo-task-manager/ExpoTaskManager.ts +39 -0
- package/overrides/expo-task-manager/overrides.ts +9 -0
- package/overrides/expo-tracking-transparency/ExpoTrackingTransparency.ts +30 -0
- package/overrides/expo-tracking-transparency/overrides.ts +11 -0
- package/overrides/expo-video/ExpoVideo.ts +16 -0
- package/overrides/expo-video/overrides.ts +9 -0
- package/overrides/lottie-react-native/LottieView.tsx +87 -0
- package/overrides/lottie-react-native/overrides.ts +9 -0
- package/overrides/react-native-pager-view/PagerViewNativeComponent.tsx +254 -0
- package/overrides/react-native-pager-view/overrides.ts +9 -0
- package/overrides/react-native-reanimated/overrides.ts +28 -0
- package/overrides/react-native-safe-area-context/NativeSafeAreaProvider.tsx +40 -0
- package/overrides/react-native-safe-area-context/overrides.ts +12 -0
- package/overrides/react-native-share/NativeRNShare.ts +22 -0
- package/overrides/react-native-share/overrides.ts +12 -0
- package/overrides/react-native-share/platform.ts +14 -0
- package/overrides/react-native-turbo-image/TurboImage.tsx +101 -0
- package/overrides/react-native-turbo-image/overrides.ts +9 -0
- package/overrides/react-native-web/RefreshControl.tsx +57 -0
- package/overrides/react-native-web/overrides.ts +157 -0
- package/overrides/react-native-web/useElementLayout.ts +152 -0
- package/package.json +80 -4
- package/plugins/battery/overrides/expo-battery/ExpoBattery.ts +57 -0
- package/plugins/battery/overrides/expo-battery/overrides.ts +9 -0
- package/plugins/battery/plugin.ts +8 -0
- package/plugins/battery/shell.tsx +56 -0
- package/plugins/battery/state.ts +11 -0
- package/plugins/biometrics/overrides/expo-local-authentication/ExpoLocalAuthentication.ts +90 -0
- package/plugins/biometrics/overrides/expo-local-authentication/overrides.ts +11 -0
- package/plugins/biometrics/plugin.ts +8 -0
- package/plugins/biometrics/shell.tsx +88 -0
- package/plugins/biometrics/state.ts +41 -0
- package/plugins/brightness/app.ts +5 -0
- package/plugins/brightness/overrides/expo-brightness/Brightness.ts +98 -0
- package/plugins/brightness/overrides/expo-brightness/overrides.ts +10 -0
- package/plugins/brightness/plugin.ts +9 -0
- package/plugins/brightness/shell.tsx +55 -0
- package/plugins/brightness/state.ts +19 -0
- package/plugins/calendar/calendar.ts +299 -0
- package/plugins/calendar/overrides/expo-calendar/ExpoCalendar.ts +358 -0
- package/plugins/calendar/overrides/expo-calendar/LegacyExpoCalendar.ts +163 -0
- package/plugins/calendar/overrides/expo-calendar/overrides.ts +14 -0
- package/plugins/calendar/plugin.ts +8 -0
- package/plugins/calendar/shell.tsx +123 -0
- package/plugins/camera/overrides/expo-camera/ExpoCamera.tsx +269 -0
- package/plugins/camera/overrides/expo-camera/ExpoCameraManager.ts +56 -0
- package/plugins/camera/overrides/expo-camera/overrides.ts +12 -0
- package/plugins/camera/plugin.ts +9 -0
- package/plugins/camera/shell.tsx +107 -0
- package/plugins/camera/state.ts +61 -0
- package/plugins/clipboard/overrides/expo-clipboard/ExpoClipboard.ts +138 -0
- package/plugins/clipboard/overrides/expo-clipboard/overrides.ts +9 -0
- package/plugins/clipboard/plugin.ts +8 -0
- package/plugins/clipboard/shell.tsx +122 -0
- package/plugins/clipboard/state.ts +93 -0
- package/plugins/clock/app.ts +25 -0
- package/plugins/clock/plugin.ts +8 -0
- package/plugins/clock/shell.tsx +225 -0
- package/plugins/clock/state.ts +12 -0
- package/plugins/contacts/contacts.ts +125 -0
- package/plugins/contacts/overrides/expo-contacts/ExpoContacts.ts +153 -0
- package/plugins/contacts/overrides/expo-contacts/ExpoContactsNext.ts +232 -0
- package/plugins/contacts/overrides/expo-contacts/overrides.ts +12 -0
- package/plugins/contacts/plugin.ts +8 -0
- package/plugins/contacts/shell.tsx +109 -0
- package/plugins/home-indicator/app.ts +5 -0
- package/plugins/home-indicator/plugin.ts +9 -0
- package/plugins/home-indicator/requests.ts +48 -0
- package/plugins/home-indicator/shell.tsx +68 -0
- package/plugins/home-indicator/state.ts +31 -0
- package/plugins/keep-awake/app.ts +5 -0
- package/plugins/keep-awake/overrides/expo-keep-awake/ExpoKeepAwake.ts +27 -0
- package/plugins/keep-awake/overrides/expo-keep-awake/overrides.ts +9 -0
- package/plugins/keep-awake/plugin.ts +9 -0
- package/plugins/keep-awake/shell.tsx +80 -0
- package/plugins/keep-awake/state.ts +12 -0
- package/plugins/keyboard/Keyboard.tsx +354 -0
- package/plugins/keyboard/app.ts +90 -0
- package/plugins/keyboard/controller.ts +384 -0
- package/plugins/keyboard/fields.ts +244 -0
- package/plugins/keyboard/icons.tsx +283 -0
- package/plugins/keyboard/keyboard.css +362 -0
- package/plugins/keyboard/layouts/android.ts +175 -0
- package/plugins/keyboard/layouts/index.ts +10 -0
- package/plugins/keyboard/layouts/ios.ts +219 -0
- package/plugins/keyboard/layouts/types.ts +80 -0
- package/plugins/keyboard/overrides/react-native-keyboard-controller/KeyboardController.tsx +470 -0
- package/plugins/keyboard/overrides/react-native-keyboard-controller/overrides.ts +9 -0
- package/plugins/keyboard/plugin.ts +13 -0
- package/plugins/keyboard/shell.tsx +133 -0
- package/plugins/keyboard/state.ts +92 -0
- package/plugins/keyboard/suggestions.ts +63 -0
- package/plugins/keyboard/taps.ts +77 -0
- package/plugins/keyboard/typing.ts +112 -0
- package/plugins/locale/app.ts +232 -0
- package/plugins/locale/locale.ts +143 -0
- package/plugins/locale/overrides/expo-localization/ExpoLocalization.ts +41 -0
- package/plugins/locale/overrides/expo-localization/overrides.ts +9 -0
- package/plugins/locale/plugin.ts +9 -0
- package/plugins/locale/shell.tsx +147 -0
- package/plugins/locale/state.ts +36 -0
- package/plugins/location/geo.ts +56 -0
- package/plugins/location/overrides/expo-location/ExpoLocation.ts +235 -0
- package/plugins/location/overrides/expo-location/overrides.ts +11 -0
- package/plugins/location/places.ts +38 -0
- package/plugins/location/plugin.ts +8 -0
- package/plugins/location/shell.tsx +188 -0
- package/plugins/location/state.ts +51 -0
- package/plugins/motion/overrides/expo-sensors/DeviceSensor.ts +169 -0
- package/plugins/motion/overrides/expo-sensors/ExponentPedometer.ts +54 -0
- package/plugins/motion/overrides/expo-sensors/overrides.ts +14 -0
- package/plugins/motion/plugin.ts +8 -0
- package/plugins/motion/sensors.ts +116 -0
- package/plugins/motion/shell.tsx +136 -0
- package/plugins/motion/state.ts +46 -0
- package/plugins/network/app.ts +400 -0
- package/plugins/network/overrides/expo-network/ExpoNetwork.ts +51 -0
- package/plugins/network/overrides/expo-network/overrides.ts +9 -0
- package/plugins/network/plugin.ts +8 -0
- package/plugins/network/shell.tsx +67 -0
- package/plugins/network/state.ts +29 -0
- package/plugins/notifications/center.ts +255 -0
- package/plugins/notifications/content.ts +36 -0
- package/plugins/notifications/overrides/expo-notifications/NotificationsModule.ts +175 -0
- package/plugins/notifications/overrides/expo-notifications/channels.ts +108 -0
- package/plugins/notifications/overrides/expo-notifications/getDevicePushTokenAsync.ts +19 -0
- package/plugins/notifications/overrides/expo-notifications/getExpoPushTokenAsync.ts +16 -0
- package/plugins/notifications/overrides/expo-notifications/overrides.ts +36 -0
- package/plugins/notifications/plugin.ts +8 -0
- package/plugins/notifications/shell.tsx +192 -0
- package/plugins/notifications/state.ts +56 -0
- package/plugins/notifications/tokens.ts +47 -0
- package/plugins/notifications/trigger.ts +107 -0
- package/plugins/permissions/plugin.ts +6 -0
- package/plugins/permissions/shell.tsx +50 -0
- package/plugins/permissions/state.ts +38 -0
- package/plugins/photos/appLibrary.ts +114 -0
- package/plugins/photos/library.ts +322 -0
- package/plugins/photos/overrides/expo-image-picker/ExponentImagePicker.ts +153 -0
- package/plugins/photos/overrides/expo-image-picker/overrides.ts +13 -0
- package/plugins/photos/overrides/expo-media-library/ExpoMediaLibrary.ts +235 -0
- package/plugins/photos/overrides/expo-media-library/NativeMediaLibraryModule.ts +318 -0
- package/plugins/photos/overrides/expo-media-library/overrides.ts +19 -0
- package/plugins/photos/plugin.ts +8 -0
- package/plugins/photos/samples.ts +367 -0
- package/plugins/photos/shell.tsx +164 -0
- package/plugins/photos/state.ts +88 -0
- package/plugins/storage/files.ts +351 -0
- package/plugins/storage/overrides/expo-file-system/ExpoFileSystem.ts +770 -0
- package/plugins/storage/overrides/expo-file-system/ExponentFileSystem.ts +196 -0
- package/plugins/storage/overrides/expo-file-system/overrides.ts +13 -0
- package/plugins/storage/overrides/expo-secure-store/ExpoSecureStore.ts +75 -0
- package/plugins/storage/overrides/expo-secure-store/overrides.ts +9 -0
- package/plugins/storage/plugin.ts +8 -0
- package/plugins/storage/reset.ts +136 -0
- package/plugins/storage/secure.ts +71 -0
- package/plugins/storage/shell.tsx +365 -0
- package/plugins/storage/state.ts +13 -0
- package/src/client/app/appDocument.ts +129 -0
- package/src/client/app/appFocus.ts +97 -0
- package/src/client/app/console.ts +118 -0
- package/src/client/app/fonts.ts +76 -0
- package/src/client/app/main.tsx +99 -0
- package/src/client/app/routeContext.ts +45 -0
- package/src/client/app/touch.ts +640 -0
- package/src/client/entry.ts +20 -0
- package/src/client/modules.d.ts +8 -0
- package/src/client/react-native/app.ts +57 -0
- package/src/client/react-native/deep.ts +13 -0
- package/src/client/react-native/keyboard.tsx +192 -0
- package/src/client/react-native/library.ts +256 -0
- package/src/client/shell/Cookies.tsx +95 -0
- package/src/client/shell/LogDrawer.tsx +415 -0
- package/src/client/shell/PhotoPicker.tsx +174 -0
- package/src/client/shell/PluginOverlays.tsx +42 -0
- package/src/client/shell/PluginPanels.tsx +82 -0
- package/src/client/shell/ResetApp.tsx +87 -0
- package/src/client/shell/Resizer.tsx +99 -0
- package/src/client/shell/Shell.tsx +531 -0
- package/src/client/shell/SystemBars.tsx +376 -0
- package/src/client/shell/SystemCamera.tsx +181 -0
- package/src/client/shell/SystemOverlay.tsx +422 -0
- package/src/client/shell/SystemSheets.tsx +462 -0
- package/src/client/shell/backdrop.ts +229 -0
- package/src/client/shell/control.ts +91 -0
- package/src/client/shell/events.ts +226 -0
- package/src/client/shell/geometry.ts +68 -0
- package/src/client/shell/host.ts +492 -0
- package/src/client/shell/icons.tsx +34 -0
- package/src/client/shell/logFeed.ts +102 -0
- package/src/client/shell/main.tsx +22 -0
- package/src/client/shell/permissionCopy.ts +169 -0
- package/src/client/shell/plugins.ts +266 -0
- package/src/client/shell/popout.ts +185 -0
- package/src/client/shell/popover.ts +27 -0
- package/src/client/shell/shell.css +878 -0
- package/src/client/shell/statusTime.ts +31 -0
- package/src/client/shell/tooltips.ts +104 -0
- package/src/client/virtual.d.ts +23 -0
- package/src/devices/catalog.ts +223 -0
- package/src/devices/types.ts +83 -0
- package/src/node/appInfo.ts +188 -0
- package/src/node/appSource.ts +140 -0
- package/src/node/config.ts +180 -0
- package/src/node/control.ts +144 -0
- package/src/node/doctor.ts +199 -0
- package/src/node/events/cli.ts +206 -0
- package/src/node/events/shared.ts +238 -0
- package/src/node/events/store.ts +266 -0
- package/src/node/fonts.ts +377 -0
- package/src/node/index.ts +5 -0
- package/src/node/overrides/define.ts +56 -0
- package/src/node/overrides/packages.ts +136 -0
- package/src/node/overrides/platformPatch.ts +56 -0
- package/src/node/overrides/plugin.ts +169 -0
- package/src/node/overrides/registry.ts +258 -0
- package/src/node/paths.ts +18 -0
- package/src/node/platform.ts +171 -0
- package/src/node/plugins.ts +98 -0
- package/src/node/proxy.ts +421 -0
- package/src/node/server.ts +254 -0
- package/src/node/worklets.ts +86 -0
- package/src/plugin/index.ts +33 -0
- package/src/plugin/types.ts +127 -0
- package/src/plugin/ui.tsx +562 -0
- package/src/runtime/clock.ts +112 -0
- package/src/runtime/draw.ts +196 -0
- package/src/runtime/index.ts +519 -0
- package/src/runtime/media.ts +379 -0
- package/src/runtime/records.ts +76 -0
- package/src/runtime/timezone.ts +81 -0
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
import type { Appearance, Device, DialogButton, DialogResult, Orientation, Platform } from '../../runtime/index.ts'
|
|
3
|
+
import type { HostStore, QueuedDialog, QueuedNotification, SystemUi } from './host.ts'
|
|
4
|
+
import { permissionPrompt, type PromptButton } from './permissionCopy.ts'
|
|
5
|
+
import { SystemSheet } from './SystemSheets.tsx'
|
|
6
|
+
import { PhotoPicker } from './PhotoPicker.tsx'
|
|
7
|
+
import { SystemCamera, TouchId } from './SystemCamera.tsx'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The system UI an OS draws over apps: the splash screen, alerts, action sheets, permission prompts, biometric
|
|
11
|
+
* prompts and notification banners. Each is drawn in the device platform's style.
|
|
12
|
+
*/
|
|
13
|
+
export function SystemOverlay({
|
|
14
|
+
host,
|
|
15
|
+
ui,
|
|
16
|
+
device,
|
|
17
|
+
appearance,
|
|
18
|
+
topInset,
|
|
19
|
+
}: {
|
|
20
|
+
host: HostStore
|
|
21
|
+
ui: SystemUi
|
|
22
|
+
device: Device
|
|
23
|
+
appearance: Appearance
|
|
24
|
+
topInset: number
|
|
25
|
+
}) {
|
|
26
|
+
const dialog = ui.dialogs[0]
|
|
27
|
+
const platform = device.platform
|
|
28
|
+
return (
|
|
29
|
+
<div className={`ws-overlay ws-${platform} ws-${appearance}`}>
|
|
30
|
+
<Splash host={host} ui={ui} appearance={appearance} />
|
|
31
|
+
{dialog !== undefined && (
|
|
32
|
+
<DialogView
|
|
33
|
+
key={dialog.id}
|
|
34
|
+
queued={dialog}
|
|
35
|
+
platform={platform}
|
|
36
|
+
app={host.app.name}
|
|
37
|
+
usageDescriptions={host.app.usageDescriptions}
|
|
38
|
+
device={device}
|
|
39
|
+
topInset={topInset}
|
|
40
|
+
orientation={host.getState().orientation}
|
|
41
|
+
respond={(result) => host.respondToDialog(dialog.id, result)}
|
|
42
|
+
/>
|
|
43
|
+
)}
|
|
44
|
+
<div className="ws-banners" style={{ top: platform === 'ios' ? Math.max(topInset - 4, 8) : topInset }}>
|
|
45
|
+
{ui.notifications.slice(-3).map((notification) => (
|
|
46
|
+
<Banner
|
|
47
|
+
key={notification.key}
|
|
48
|
+
notification={notification}
|
|
49
|
+
platform={platform}
|
|
50
|
+
app={host.app.name}
|
|
51
|
+
icon={host.app.icon}
|
|
52
|
+
dismiss={(tapped) => host.dismissNotification(notification.key, tapped)}
|
|
53
|
+
/>
|
|
54
|
+
))}
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function Splash({ host, ui, appearance }: { host: HostStore; ui: SystemUi; appearance: Appearance }) {
|
|
61
|
+
const splash = host.app.splash
|
|
62
|
+
const [rendered, setRendered] = useState(ui.splash.visible)
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (ui.splash.visible) {
|
|
65
|
+
setRendered(true)
|
|
66
|
+
return
|
|
67
|
+
}
|
|
68
|
+
const timer = setTimeout(() => setRendered(false), ui.splash.fadeMs)
|
|
69
|
+
return () => clearTimeout(timer)
|
|
70
|
+
}, [ui.splash])
|
|
71
|
+
if (splash === null || !rendered) {
|
|
72
|
+
return null
|
|
73
|
+
}
|
|
74
|
+
return (
|
|
75
|
+
<div
|
|
76
|
+
className="ws-splash"
|
|
77
|
+
style={{
|
|
78
|
+
background: appearance === 'dark' ? (splash.darkBackgroundColor ?? splash.backgroundColor) : splash.backgroundColor,
|
|
79
|
+
opacity: ui.splash.visible ? 1 : 0,
|
|
80
|
+
transition: `opacity ${ui.splash.fadeMs}ms ease`,
|
|
81
|
+
}}
|
|
82
|
+
>
|
|
83
|
+
{splash.image !== undefined && <img src={splash.image} alt="" style={{ width: splash.imageWidth }} />}
|
|
84
|
+
</div>
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function DialogView({
|
|
89
|
+
queued,
|
|
90
|
+
platform,
|
|
91
|
+
app,
|
|
92
|
+
usageDescriptions,
|
|
93
|
+
device,
|
|
94
|
+
topInset,
|
|
95
|
+
orientation,
|
|
96
|
+
respond,
|
|
97
|
+
}: {
|
|
98
|
+
queued: QueuedDialog
|
|
99
|
+
platform: Platform
|
|
100
|
+
app: string
|
|
101
|
+
usageDescriptions: Record<string, string>
|
|
102
|
+
device: Device
|
|
103
|
+
topInset: number
|
|
104
|
+
orientation: Orientation
|
|
105
|
+
respond: (result: DialogResult) => void
|
|
106
|
+
}) {
|
|
107
|
+
const { dialog } = queued
|
|
108
|
+
switch (dialog.kind) {
|
|
109
|
+
case 'alert':
|
|
110
|
+
return (
|
|
111
|
+
<Alert
|
|
112
|
+
platform={platform}
|
|
113
|
+
title={dialog.title}
|
|
114
|
+
message={dialog.message}
|
|
115
|
+
buttons={alertButtons(dialog.buttons)}
|
|
116
|
+
stacked={dialog.buttons.length > 2}
|
|
117
|
+
input={dialog.input}
|
|
118
|
+
respond={respond}
|
|
119
|
+
/>
|
|
120
|
+
)
|
|
121
|
+
case 'permission': {
|
|
122
|
+
const prompt = permissionPrompt(platform, dialog.permission, app, usageDescriptions, dialog.message)
|
|
123
|
+
return (
|
|
124
|
+
<Alert
|
|
125
|
+
platform={platform}
|
|
126
|
+
title={prompt.title}
|
|
127
|
+
message={prompt.message}
|
|
128
|
+
buttons={prompt.buttons}
|
|
129
|
+
stacked={prompt.stacked}
|
|
130
|
+
permission
|
|
131
|
+
respond={respond}
|
|
132
|
+
/>
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
case 'action-sheet':
|
|
136
|
+
return <ActionSheet platform={platform} title={dialog.title} message={dialog.message} buttons={dialog.buttons} respond={respond} />
|
|
137
|
+
case 'biometric': {
|
|
138
|
+
const sensor = dialog.sensor ?? (platform === 'android' ? 'fingerprint' : device.navigation === 'home-button' ? 'touch' : 'face')
|
|
139
|
+
if (platform === 'ios' && sensor !== 'face') {
|
|
140
|
+
return <TouchId app={app} reason={dialog.reason} cancelLabel={dialog.cancelLabel} respond={respond} />
|
|
141
|
+
}
|
|
142
|
+
return <Biometric platform={platform} face={sensor === 'face'} app={app} reason={dialog.reason} cancelLabel={dialog.cancelLabel} respond={respond} />
|
|
143
|
+
}
|
|
144
|
+
case 'store-review':
|
|
145
|
+
case 'share':
|
|
146
|
+
case 'compose':
|
|
147
|
+
return <SystemSheet dialog={dialog} platform={platform} respond={respond} />
|
|
148
|
+
case 'photo-picker':
|
|
149
|
+
return <PhotoPicker dialog={dialog} platform={platform} topInset={topInset} respond={respond} />
|
|
150
|
+
case 'camera':
|
|
151
|
+
return <SystemCamera platform={platform} initialFacing={dialog.facing} feeds={dialog.feeds} orientation={orientation} respond={respond} />
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** iOS shows the cancel button bold; with two buttons it sits on the left. */
|
|
156
|
+
function alertButtons(buttons: DialogButton[]): PromptButton[] {
|
|
157
|
+
const list = (buttons.length > 0 ? buttons : [{ text: 'OK' }]).map((button, index) => ({
|
|
158
|
+
text: button.text,
|
|
159
|
+
result: index,
|
|
160
|
+
bold: button.style === 'cancel',
|
|
161
|
+
destructive: button.style === 'destructive',
|
|
162
|
+
}))
|
|
163
|
+
return list
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function Alert({
|
|
167
|
+
platform,
|
|
168
|
+
title,
|
|
169
|
+
message,
|
|
170
|
+
buttons,
|
|
171
|
+
stacked,
|
|
172
|
+
input,
|
|
173
|
+
permission = false,
|
|
174
|
+
respond,
|
|
175
|
+
}: {
|
|
176
|
+
platform: Platform
|
|
177
|
+
title: string
|
|
178
|
+
message?: string
|
|
179
|
+
buttons: (PromptButton & { destructive?: boolean })[]
|
|
180
|
+
stacked: boolean
|
|
181
|
+
input?: { secure?: boolean; defaultValue?: string; placeholder?: string }
|
|
182
|
+
permission?: boolean
|
|
183
|
+
respond: (result: DialogResult) => void
|
|
184
|
+
}) {
|
|
185
|
+
const [text, setText] = useState(input?.defaultValue ?? '')
|
|
186
|
+
const press = (result: number) => respond({ button: result, text: input ? text : undefined })
|
|
187
|
+
if (platform === 'android') {
|
|
188
|
+
return (
|
|
189
|
+
<div className="ws-scrim ws-scrim-center">
|
|
190
|
+
<div className={`ws-m3-dialog ${permission ? 'ws-m3-permission' : ''}`} role="alertdialog">
|
|
191
|
+
{permission && <div className="ws-m3-permission-icon">●</div>}
|
|
192
|
+
<div className="ws-m3-title">{title}</div>
|
|
193
|
+
{message && <div className="ws-m3-message">{message}</div>}
|
|
194
|
+
{input && (
|
|
195
|
+
<input
|
|
196
|
+
className="ws-m3-input"
|
|
197
|
+
autoFocus
|
|
198
|
+
type={input.secure ? 'password' : 'text'}
|
|
199
|
+
placeholder={input.placeholder}
|
|
200
|
+
value={text}
|
|
201
|
+
onChange={(event) => setText(event.target.value)}
|
|
202
|
+
/>
|
|
203
|
+
)}
|
|
204
|
+
<div className={stacked || permission ? 'ws-m3-actions-stacked' : 'ws-m3-actions'}>
|
|
205
|
+
{(stacked || permission ? buttons : [...buttons].reverse()).map((button) => (
|
|
206
|
+
<button key={button.text} type="button" className="ws-m3-button" onClick={() => press(button.result)}>
|
|
207
|
+
{button.text}
|
|
208
|
+
</button>
|
|
209
|
+
))}
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
</div>
|
|
213
|
+
)
|
|
214
|
+
}
|
|
215
|
+
return (
|
|
216
|
+
<div className="ws-scrim ws-scrim-center">
|
|
217
|
+
<div className="ws-ios-alert" role="alertdialog">
|
|
218
|
+
<div className="ws-ios-alert-text">
|
|
219
|
+
<div className="ws-ios-alert-title">{title}</div>
|
|
220
|
+
{message && <div className="ws-ios-alert-message">{message}</div>}
|
|
221
|
+
{input && (
|
|
222
|
+
<input
|
|
223
|
+
className="ws-ios-alert-input"
|
|
224
|
+
autoFocus
|
|
225
|
+
type={input.secure ? 'password' : 'text'}
|
|
226
|
+
placeholder={input.placeholder}
|
|
227
|
+
value={text}
|
|
228
|
+
onChange={(event) => setText(event.target.value)}
|
|
229
|
+
/>
|
|
230
|
+
)}
|
|
231
|
+
</div>
|
|
232
|
+
<div className={stacked ? 'ws-ios-alert-buttons-stacked' : 'ws-ios-alert-buttons'}>
|
|
233
|
+
{buttons.map((button) => (
|
|
234
|
+
<button
|
|
235
|
+
key={button.text}
|
|
236
|
+
type="button"
|
|
237
|
+
className={`ws-ios-alert-button ${button.bold ? 'ws-bold' : ''} ${button.destructive ? 'ws-destructive' : ''}`}
|
|
238
|
+
onClick={() => press(button.result)}
|
|
239
|
+
>
|
|
240
|
+
{button.text}
|
|
241
|
+
</button>
|
|
242
|
+
))}
|
|
243
|
+
</div>
|
|
244
|
+
</div>
|
|
245
|
+
</div>
|
|
246
|
+
)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function ActionSheet({
|
|
250
|
+
platform,
|
|
251
|
+
title,
|
|
252
|
+
message,
|
|
253
|
+
buttons,
|
|
254
|
+
respond,
|
|
255
|
+
}: {
|
|
256
|
+
platform: Platform
|
|
257
|
+
title?: string
|
|
258
|
+
message?: string
|
|
259
|
+
buttons: DialogButton[]
|
|
260
|
+
respond: (result: DialogResult) => void
|
|
261
|
+
}) {
|
|
262
|
+
const cancelIndex = buttons.findIndex((button) => button.style === 'cancel')
|
|
263
|
+
if (platform === 'android') {
|
|
264
|
+
return (
|
|
265
|
+
<div className="ws-scrim ws-scrim-bottom" onClick={() => respond({ button: cancelIndex })}>
|
|
266
|
+
<div className="ws-m3-sheet" onClick={(event) => event.stopPropagation()}>
|
|
267
|
+
<div className="ws-m3-sheet-handle" />
|
|
268
|
+
{title && <div className="ws-m3-sheet-title">{title}</div>}
|
|
269
|
+
{message && <div className="ws-m3-message">{message}</div>}
|
|
270
|
+
{buttons.map((button, index) =>
|
|
271
|
+
index === cancelIndex ? null : (
|
|
272
|
+
<button key={index} type="button" className={`ws-m3-sheet-item ${button.style === 'destructive' ? 'ws-destructive' : ''}`} onClick={() => respond({ button: index })}>
|
|
273
|
+
{button.text}
|
|
274
|
+
</button>
|
|
275
|
+
),
|
|
276
|
+
)}
|
|
277
|
+
</div>
|
|
278
|
+
</div>
|
|
279
|
+
)
|
|
280
|
+
}
|
|
281
|
+
return (
|
|
282
|
+
<div className="ws-scrim ws-scrim-bottom" onClick={() => respond({ button: cancelIndex })}>
|
|
283
|
+
<div className="ws-ios-sheet" onClick={(event) => event.stopPropagation()}>
|
|
284
|
+
<div className="ws-ios-sheet-group">
|
|
285
|
+
{(title || message) && (
|
|
286
|
+
<div className="ws-ios-sheet-header">
|
|
287
|
+
{title && <div className="ws-ios-sheet-title">{title}</div>}
|
|
288
|
+
{message && <div className="ws-ios-sheet-message">{message}</div>}
|
|
289
|
+
</div>
|
|
290
|
+
)}
|
|
291
|
+
{buttons.map((button, index) =>
|
|
292
|
+
index === cancelIndex ? null : (
|
|
293
|
+
<button key={index} type="button" className={`ws-ios-sheet-button ${button.style === 'destructive' ? 'ws-destructive' : ''}`} onClick={() => respond({ button: index })}>
|
|
294
|
+
{button.text}
|
|
295
|
+
</button>
|
|
296
|
+
),
|
|
297
|
+
)}
|
|
298
|
+
</div>
|
|
299
|
+
{cancelIndex >= 0 && (
|
|
300
|
+
<button type="button" className="ws-ios-sheet-group ws-ios-sheet-button ws-bold" onClick={() => respond({ button: cancelIndex })}>
|
|
301
|
+
{buttons[cancelIndex].text}
|
|
302
|
+
</button>
|
|
303
|
+
)}
|
|
304
|
+
</div>
|
|
305
|
+
</div>
|
|
306
|
+
)
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* The OS's biometric prompt, with the simulator's controls for what the sensor sees under it.
|
|
311
|
+
*/
|
|
312
|
+
function Biometric({
|
|
313
|
+
platform,
|
|
314
|
+
face,
|
|
315
|
+
app,
|
|
316
|
+
reason,
|
|
317
|
+
cancelLabel,
|
|
318
|
+
respond,
|
|
319
|
+
}: {
|
|
320
|
+
platform: Platform
|
|
321
|
+
face: boolean
|
|
322
|
+
app: string
|
|
323
|
+
reason?: string
|
|
324
|
+
cancelLabel?: string
|
|
325
|
+
respond: (result: DialogResult) => void
|
|
326
|
+
}) {
|
|
327
|
+
const controls = (
|
|
328
|
+
<div className="ws-sim-controls">
|
|
329
|
+
<button type="button" onClick={() => respond({ button: 0 })}>
|
|
330
|
+
{face ? 'Matching face' : 'Matching finger'}
|
|
331
|
+
</button>
|
|
332
|
+
<button type="button" onClick={() => respond({ button: 1 })}>
|
|
333
|
+
{face ? 'Non-matching face' : 'Non-matching finger'}
|
|
334
|
+
</button>
|
|
335
|
+
</div>
|
|
336
|
+
)
|
|
337
|
+
if (platform === 'android') {
|
|
338
|
+
return (
|
|
339
|
+
<div className="ws-scrim ws-scrim-bottom">
|
|
340
|
+
<div className="ws-m3-sheet ws-biometric-sheet">
|
|
341
|
+
<div className="ws-m3-sheet-title">{app}</div>
|
|
342
|
+
{reason && <div className="ws-m3-message">{reason}</div>}
|
|
343
|
+
<div className="ws-fingerprint">{face ? <FaceIdIcon size={40} /> : <FingerprintIcon />}</div>
|
|
344
|
+
<div className="ws-m3-message">{face ? 'Look at your phone' : 'Touch the fingerprint sensor'}</div>
|
|
345
|
+
<div className="ws-m3-actions">
|
|
346
|
+
<button type="button" className="ws-m3-button" onClick={() => respond({ button: 2 })}>
|
|
347
|
+
{cancelLabel ?? 'Cancel'}
|
|
348
|
+
</button>
|
|
349
|
+
</div>
|
|
350
|
+
{controls}
|
|
351
|
+
</div>
|
|
352
|
+
</div>
|
|
353
|
+
)
|
|
354
|
+
}
|
|
355
|
+
return (
|
|
356
|
+
<div className="ws-scrim ws-scrim-center ws-scrim-clear">
|
|
357
|
+
<div className="ws-faceid">
|
|
358
|
+
<FaceIdIcon />
|
|
359
|
+
<span>Face ID</span>
|
|
360
|
+
</div>
|
|
361
|
+
{controls}
|
|
362
|
+
</div>
|
|
363
|
+
)
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function Banner({
|
|
367
|
+
notification,
|
|
368
|
+
platform,
|
|
369
|
+
app,
|
|
370
|
+
icon,
|
|
371
|
+
dismiss,
|
|
372
|
+
}: {
|
|
373
|
+
notification: QueuedNotification
|
|
374
|
+
platform: Platform
|
|
375
|
+
app: string
|
|
376
|
+
icon?: string
|
|
377
|
+
dismiss: (tapped: boolean) => void
|
|
378
|
+
}) {
|
|
379
|
+
useEffect(() => {
|
|
380
|
+
const timer = setTimeout(() => dismiss(false), 5000)
|
|
381
|
+
return () => clearTimeout(timer)
|
|
382
|
+
}, [dismiss])
|
|
383
|
+
return (
|
|
384
|
+
<button type="button" className={`ws-banner ws-banner-${platform}`} onClick={() => dismiss(true)}>
|
|
385
|
+
{icon ? <img className="ws-banner-icon" src={icon} alt="" /> : <span className="ws-banner-icon" />}
|
|
386
|
+
<span className="ws-banner-text">
|
|
387
|
+
<span className="ws-banner-meta">
|
|
388
|
+
<span>{platform === 'ios' ? (notification.title ?? app) : `${app} • now`}</span>
|
|
389
|
+
{platform === 'ios' && <span className="ws-banner-time">now</span>}
|
|
390
|
+
</span>
|
|
391
|
+
{platform === 'android' && notification.title && <span className="ws-banner-title">{notification.title}</span>}
|
|
392
|
+
{notification.subtitle && <span className="ws-banner-title">{notification.subtitle}</span>}
|
|
393
|
+
{notification.body && <span className="ws-banner-body">{notification.body}</span>}
|
|
394
|
+
</span>
|
|
395
|
+
</button>
|
|
396
|
+
)
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
function FaceIdIcon({ size = 64 }: { size?: number }) {
|
|
400
|
+
return (
|
|
401
|
+
<svg width={size} height={size} viewBox="0 0 64 64" fill="none" stroke="currentColor" strokeWidth="3.5" strokeLinecap="round" aria-hidden>
|
|
402
|
+
<path d="M4 18V12a8 8 0 0 1 8-8h6M46 4h6a8 8 0 0 1 8 8v6M60 46v6a8 8 0 0 1-8 8h-6M18 60h-6a8 8 0 0 1-8-8v-6" />
|
|
403
|
+
<path d="M22 24v4M42 24v4M32 24v12h-3M24 44c4.5 4 11.5 4 16 0" />
|
|
404
|
+
</svg>
|
|
405
|
+
)
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
function FingerprintIcon() {
|
|
409
|
+
return (
|
|
410
|
+
<svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" aria-hidden>
|
|
411
|
+
<path d="M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4" />
|
|
412
|
+
<path d="M14 13.12c0 2.38 0 6.38-1 8.88" />
|
|
413
|
+
<path d="M17.29 21.02c.12-.6.43-2.3.5-3.02" />
|
|
414
|
+
<path d="M2 12a10 10 0 0 1 18-6" />
|
|
415
|
+
<path d="M2 16h.01" />
|
|
416
|
+
<path d="M21.8 16c.2-2 .131-5.354 0-6" />
|
|
417
|
+
<path d="M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2" />
|
|
418
|
+
<path d="M8.65 22c.21-.66.45-1.32.57-2" />
|
|
419
|
+
<path d="M9 6.8a6 6 0 0 1 9 5.2v2" />
|
|
420
|
+
</svg>
|
|
421
|
+
)
|
|
422
|
+
}
|