@a16n/web-sim 0.0.0-stage → 0.1.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/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 +153 -0
- package/overrides/react-native-web/useElementLayout.ts +140 -0
- package/package.json +78 -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 +113 -0
- package/src/client/app/appFocus.ts +97 -0
- package/src/client/app/console.ts +118 -0
- package/src/client/app/fonts.ts +59 -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 +21 -0
- package/src/devices/catalog.ts +223 -0
- package/src/devices/types.ts +83 -0
- package/src/node/appInfo.ts +186 -0
- package/src/node/appSource.ts +138 -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/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 +166 -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 +253 -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 +513 -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,376 @@
|
|
|
1
|
+
import type { CSSProperties, Ref } from 'react'
|
|
2
|
+
import type { Device, Orientation } from '../../devices/types.ts'
|
|
3
|
+
import type { StatusBarItems } from '../../plugin/types.ts'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The system UI the OS draws over every app: the status bar, the cutout, and the home indicator or navigation bar.
|
|
7
|
+
* It sits over the app's frame and takes no presses, except the navigation bar's buttons.
|
|
8
|
+
*/
|
|
9
|
+
export function SystemBars({
|
|
10
|
+
device,
|
|
11
|
+
orientation,
|
|
12
|
+
screen,
|
|
13
|
+
content,
|
|
14
|
+
navigationContent = content,
|
|
15
|
+
navigationHidden = false,
|
|
16
|
+
homeIndicator,
|
|
17
|
+
statusBarHidden,
|
|
18
|
+
statusBarRef,
|
|
19
|
+
statusAdaptive = false,
|
|
20
|
+
items = {},
|
|
21
|
+
time,
|
|
22
|
+
onBack,
|
|
23
|
+
}: {
|
|
24
|
+
device: Device
|
|
25
|
+
orientation: Orientation
|
|
26
|
+
screen: { width: number; height: number }
|
|
27
|
+
/** The colour of the status bar's and home indicator's content. */
|
|
28
|
+
content: 'light' | 'dark'
|
|
29
|
+
/** Android lets the app colour the navigation bar apart from the status bar. */
|
|
30
|
+
navigationContent?: 'light' | 'dark'
|
|
31
|
+
navigationHidden?: boolean
|
|
32
|
+
/**
|
|
33
|
+
* iOS's home indicator: hidden (it fades out) while auto-hidden, its colour from the content under it, and the
|
|
34
|
+
* element, for reading that content.
|
|
35
|
+
*/
|
|
36
|
+
homeIndicator?: { hidden: boolean; content: 'light' | 'dark' | null; ref?: Ref<HTMLDivElement> }
|
|
37
|
+
statusBarHidden: boolean
|
|
38
|
+
/** The status bar's element, for reading the content under it. */
|
|
39
|
+
statusBarRef?: Ref<HTMLDivElement>
|
|
40
|
+
/** The status bar follows the content under it (iOS's default style), so its colour eases as that changes. */
|
|
41
|
+
statusAdaptive?: boolean
|
|
42
|
+
/** What plugins put in the status bar: the battery, the connection. */
|
|
43
|
+
items?: StatusBarItems
|
|
44
|
+
/** The phone's time, as the status bar shows it. */
|
|
45
|
+
time: string
|
|
46
|
+
onBack: () => void
|
|
47
|
+
}) {
|
|
48
|
+
const color = content === 'light' ? '#ffffff' : '#000000'
|
|
49
|
+
const showStatusBar = !statusBarHidden && orientation === 'portrait'
|
|
50
|
+
return (
|
|
51
|
+
<div className="ws-system" data-adaptive={statusAdaptive ? '' : undefined} style={{ color }}>
|
|
52
|
+
{showStatusBar &&
|
|
53
|
+
(device.platform === 'ios' ? (
|
|
54
|
+
<IosStatusBar ref={statusBarRef} device={device} screen={screen} items={items} time={time} />
|
|
55
|
+
) : (
|
|
56
|
+
<AndroidStatusBar device={device} items={items} time={time} />
|
|
57
|
+
))}
|
|
58
|
+
<Cutout device={device} orientation={orientation} screen={screen} />
|
|
59
|
+
{!navigationHidden && (
|
|
60
|
+
<Navigation
|
|
61
|
+
device={device}
|
|
62
|
+
orientation={orientation}
|
|
63
|
+
color={navigationContent === 'light' ? '#ffffff' : '#000000'}
|
|
64
|
+
homeIndicator={homeIndicator}
|
|
65
|
+
onBack={onBack}
|
|
66
|
+
/>
|
|
67
|
+
)}
|
|
68
|
+
</div>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Where iOS 26 puts the status bar, measured from Xcode's Simulator at 3x (iPhone 17, 17 Pro Max and 17e on iOS 27,
|
|
74
|
+
* whose bar is iOS 26's). The time and the icons sit a fixed distance (`time`, `icons`) either side of the screen's
|
|
75
|
+
* middle, centred `y` below the Dynamic Island's middle, or `y` from the top beside a notch. The Max phones draw the icons
|
|
76
|
+
* 10% larger and the time 5%; the notch phones 5% smaller and higher. `gap` is between icons; `timeY`, `barsY` and
|
|
77
|
+
* `batteryY` nudge each one onto the measured spot.
|
|
78
|
+
*/
|
|
79
|
+
type IosBarsLayout = {
|
|
80
|
+
timeScale: number
|
|
81
|
+
scale: number
|
|
82
|
+
time: number
|
|
83
|
+
icons: number
|
|
84
|
+
gap: number
|
|
85
|
+
timeY: number
|
|
86
|
+
barsY: number
|
|
87
|
+
batteryY: number
|
|
88
|
+
y: number
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const IOS_BARS: Record<'island' | 'islandMax' | 'notch', IosBarsLayout> = {
|
|
92
|
+
island: { timeScale: 1, scale: 1, time: 128, icons: 126, gap: 7.67, y: 2.83, timeY: 0.67, barsY: 0.67, batteryY: -0.33 },
|
|
93
|
+
islandMax: { timeScale: 1.05, scale: 1.1, time: 129.67, icons: 128, gap: 8.4, y: 2.83, timeY: 0.7, barsY: 0.2, batteryY: -0.35 },
|
|
94
|
+
notch: { timeScale: 0.95, scale: 0.95, time: 132.33, icons: 129.5, gap: 6.4, y: 26, timeY: 0.33, barsY: -0.33, batteryY: 0.5 },
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function IosStatusBar({
|
|
98
|
+
ref,
|
|
99
|
+
device,
|
|
100
|
+
screen,
|
|
101
|
+
items,
|
|
102
|
+
time,
|
|
103
|
+
}: {
|
|
104
|
+
ref?: Ref<HTMLDivElement>
|
|
105
|
+
device: Device
|
|
106
|
+
screen: { width: number }
|
|
107
|
+
items: StatusBarItems
|
|
108
|
+
time: string
|
|
109
|
+
}) {
|
|
110
|
+
const { cutout } = device
|
|
111
|
+
if (cutout.kind !== 'island' && cutout.kind !== 'notch') {
|
|
112
|
+
// A device with no cutout has the classic 20-point bar: time in the middle.
|
|
113
|
+
return (
|
|
114
|
+
<div ref={ref} className="ws-status ws-status-classic" style={{ height: device.statusBarHeight }}>
|
|
115
|
+
<span className="ws-status-side">
|
|
116
|
+
<Connection items={items} scale={0.72} platform="ios" />
|
|
117
|
+
</span>
|
|
118
|
+
<span className="ws-status-time ws-ios-time" style={{ fontSize: 12.5 }}>{time}</span>
|
|
119
|
+
<span className="ws-status-side ws-status-right">
|
|
120
|
+
<IosBattery scale={0.75} battery={items.battery} />
|
|
121
|
+
</span>
|
|
122
|
+
</div>
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
const bars = cutout.kind === 'notch' ? IOS_BARS.notch : screen.width >= 430 ? IOS_BARS.islandMax : IOS_BARS.island
|
|
126
|
+
const { scale } = bars
|
|
127
|
+
const centerY = cutout.kind === 'island' ? cutout.top + cutout.height / 2 + bars.y : bars.y
|
|
128
|
+
const nudges = { '--ws-bars-y': `${bars.barsY}px`, '--ws-battery-y': `${bars.batteryY}px` } as CSSProperties
|
|
129
|
+
const middle = screen.width / 2
|
|
130
|
+
// On a narrow resizable screen, keep each cluster off the screen's edge.
|
|
131
|
+
const left = Math.max(middle - bars.time, 30 * scale)
|
|
132
|
+
const right = Math.min(middle + bars.icons, screen.width - 50 * scale)
|
|
133
|
+
return (
|
|
134
|
+
<div ref={ref} className="ws-status ws-status-ios" style={{ height: device.statusBarHeight }}>
|
|
135
|
+
<span className="ws-status-cluster" style={{ left, top: centerY }}>
|
|
136
|
+
<span className="ws-status-time ws-ios-time" style={{ fontSize: 17.8 * bars.timeScale, transform: `translateY(${bars.timeY}px)` }}>{time}</span>
|
|
137
|
+
</span>
|
|
138
|
+
<span className="ws-status-cluster" style={{ left: right, top: centerY, gap: bars.gap, ...nudges }}>
|
|
139
|
+
<Connection items={items} scale={scale} platform="ios" />
|
|
140
|
+
<IosBattery scale={scale} battery={items.battery} />
|
|
141
|
+
</span>
|
|
142
|
+
</div>
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function AndroidStatusBar({ device, items, time }: { device: Device; items: StatusBarItems; time: string }) {
|
|
147
|
+
const centerY = device.cutout.kind === 'punch-hole' ? device.cutout.top + device.cutout.diameter / 2 : device.statusBarHeight / 2
|
|
148
|
+
return (
|
|
149
|
+
<div className="ws-status ws-status-android" style={{ height: device.statusBarHeight }}>
|
|
150
|
+
<span className="ws-android-row" style={{ top: centerY - 10 }}>
|
|
151
|
+
<span className="ws-status-time ws-android-time">{time}</span>
|
|
152
|
+
<span className="ws-status-side" style={{ gap: 4 }}>
|
|
153
|
+
<Connection items={items} size={13} platform="android" />
|
|
154
|
+
<Battery size={13} battery={items.battery} />
|
|
155
|
+
</span>
|
|
156
|
+
</span>
|
|
157
|
+
</div>
|
|
158
|
+
)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function Cutout({ device, orientation, screen }: { device: Device; orientation: Orientation; screen: { width: number; height: number } }) {
|
|
162
|
+
const { cutout } = device
|
|
163
|
+
const turned = orientation === 'landscape'
|
|
164
|
+
if (cutout.kind === 'island' || cutout.kind === 'notch') {
|
|
165
|
+
const top = cutout.kind === 'island' ? cutout.top : 0
|
|
166
|
+
const style: CSSProperties = turned
|
|
167
|
+
? { left: top, top: (screen.height - cutout.width) / 2, width: cutout.height, height: cutout.width }
|
|
168
|
+
: { top, left: (screen.width - cutout.width) / 2, width: cutout.width, height: cutout.height }
|
|
169
|
+
return (
|
|
170
|
+
<div
|
|
171
|
+
className={cutout.kind === 'island' ? 'ws-island' : turned ? 'ws-notch ws-notch-turned' : 'ws-notch'}
|
|
172
|
+
style={{ ...style, borderRadius: cutout.kind === 'island' ? Math.min(cutout.width, cutout.height) / 2 : undefined }}
|
|
173
|
+
/>
|
|
174
|
+
)
|
|
175
|
+
}
|
|
176
|
+
if (cutout.kind === 'punch-hole') {
|
|
177
|
+
const style: CSSProperties = turned
|
|
178
|
+
? { left: cutout.top, top: (screen.height - cutout.diameter) / 2 }
|
|
179
|
+
: { top: cutout.top, left: (screen.width - cutout.diameter) / 2 }
|
|
180
|
+
return <div className="ws-punch-hole" style={{ ...style, width: cutout.diameter, height: cutout.diameter }} />
|
|
181
|
+
}
|
|
182
|
+
return null
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function Navigation({
|
|
186
|
+
device,
|
|
187
|
+
orientation,
|
|
188
|
+
color,
|
|
189
|
+
homeIndicator,
|
|
190
|
+
onBack,
|
|
191
|
+
}: {
|
|
192
|
+
device: Device
|
|
193
|
+
orientation: Orientation
|
|
194
|
+
color: string
|
|
195
|
+
homeIndicator?: { hidden: boolean; content: 'light' | 'dark' | null; ref?: Ref<HTMLDivElement> }
|
|
196
|
+
onBack: () => void
|
|
197
|
+
}) {
|
|
198
|
+
switch (device.navigation) {
|
|
199
|
+
case 'home-indicator': {
|
|
200
|
+
const content = homeIndicator?.content
|
|
201
|
+
return (
|
|
202
|
+
<div
|
|
203
|
+
ref={homeIndicator?.ref}
|
|
204
|
+
className="ws-home-indicator"
|
|
205
|
+
data-hidden={homeIndicator?.hidden ? '' : undefined}
|
|
206
|
+
style={{ background: content == null ? color : content === 'light' ? '#ffffff' : '#000000', width: orientation === 'portrait' ? 139 : 200 }}
|
|
207
|
+
/>
|
|
208
|
+
)
|
|
209
|
+
}
|
|
210
|
+
case 'gesture':
|
|
211
|
+
return <div className="ws-gesture-bar" style={{ background: color }} />
|
|
212
|
+
case 'three-button':
|
|
213
|
+
return (
|
|
214
|
+
<div className={`ws-nav-buttons ws-nav-${orientation}`} style={{ height: orientation === 'portrait' ? device.insets.portrait.bottom : undefined, width: orientation === 'landscape' ? device.insets.landscape.right : undefined }}>
|
|
215
|
+
<button type="button" className="ws-nav-button" onClick={onBack} aria-label="Back">
|
|
216
|
+
<svg width="18" height="18" viewBox="0 0 18 18" fill="currentColor"><path d="M14 2.5v13L3.5 9z" /></svg>
|
|
217
|
+
</button>
|
|
218
|
+
<button type="button" className="ws-nav-button" aria-label="Home">
|
|
219
|
+
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" stroke="currentColor" strokeWidth="2"><circle cx="9" cy="9" r="6.5" /></svg>
|
|
220
|
+
</button>
|
|
221
|
+
<button type="button" className="ws-nav-button" aria-label="Recents">
|
|
222
|
+
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" stroke="currentColor" strokeWidth="2"><rect x="3" y="3" width="12" height="12" rx="2" /></svg>
|
|
223
|
+
</button>
|
|
224
|
+
</div>
|
|
225
|
+
)
|
|
226
|
+
default:
|
|
227
|
+
return null
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Signal bars and Wi-Fi, as the connection is: airplane mode replaces the bars; cellular shows its generation
|
|
233
|
+
* where Wi-Fi would be; no connection dims the bars. iOS draws them at `scale` (1 is a 402-point iPhone);
|
|
234
|
+
* Android at `size` points tall, Wi-Fi first.
|
|
235
|
+
*/
|
|
236
|
+
function Connection(props: { items: StatusBarItems } & ({ platform: 'ios'; scale: number } | { platform: 'android'; size: number })) {
|
|
237
|
+
const { items } = props
|
|
238
|
+
const connection = items.connection ?? 'wifi'
|
|
239
|
+
if (props.platform === 'ios') {
|
|
240
|
+
const { scale } = props
|
|
241
|
+
return (
|
|
242
|
+
<>
|
|
243
|
+
{items.airplaneMode ? <Airplane size={15 * scale} /> : <IosSignal scale={scale} dim={connection === 'none'} />}
|
|
244
|
+
{connection === 'wifi' ? (
|
|
245
|
+
<IosWifi scale={scale} />
|
|
246
|
+
) : connection === 'cellular' && !items.airplaneMode ? (
|
|
247
|
+
<span className="ws-status-generation ws-ios-time" style={{ fontSize: 15 * scale }}>5G</span>
|
|
248
|
+
) : null}
|
|
249
|
+
</>
|
|
250
|
+
)
|
|
251
|
+
}
|
|
252
|
+
const { size } = props
|
|
253
|
+
return (
|
|
254
|
+
<>
|
|
255
|
+
{connection === 'wifi' ? <Wifi size={size} /> : connection === 'cellular' && !items.airplaneMode ? <span className="ws-status-generation" style={{ fontSize: size * 0.95 }}>5G</span> : null}
|
|
256
|
+
{items.airplaneMode ? <Airplane size={size * 1.2} /> : <Signal size={size} dim={connection === 'none'} />}
|
|
257
|
+
</>
|
|
258
|
+
)
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function Airplane({ size }: { size: number }) {
|
|
262
|
+
return (
|
|
263
|
+
<svg width={size} height={size} viewBox="0 0 24 24" fill="currentColor" aria-hidden>
|
|
264
|
+
<path d="M21 16v-2l-8-5V3.5a1.5 1.5 0 0 0-3 0V9l-8 5v2l8-2.5V19l-2 1.5V22l3.5-1 3.5 1v-1.5L13 19v-5.5z" />
|
|
265
|
+
</svg>
|
|
266
|
+
)
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/** The empty part of iOS's bars, arcs and battery: the content colour, faint. */
|
|
270
|
+
const IOS_EMPTY = 0.25
|
|
271
|
+
const IOS_BATTERY_EMPTY = 0.3
|
|
272
|
+
|
|
273
|
+
/** iOS's four rounded bars, rising to the height of the time's digits. */
|
|
274
|
+
function IosSignal({ scale, dim = false }: { scale: number; dim?: boolean }) {
|
|
275
|
+
const heights = [6.67, 8.67, 11.33, 13.67]
|
|
276
|
+
return (
|
|
277
|
+
<svg width={20.6 * scale} height={13.67 * scale} viewBox="0 0 20.6 13.67" fill="currentColor" aria-hidden opacity={dim ? IOS_EMPTY : 1} className="ws-ios-signal" style={{ marginRight: 0.33 * scale }}>
|
|
278
|
+
{heights.map((h, i) => (
|
|
279
|
+
<rect key={i} x={i * 5.75} y={13.67 - h} width="3.35" height={h} rx="1.5" />
|
|
280
|
+
))}
|
|
281
|
+
</svg>
|
|
282
|
+
)
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/** iOS's Wi-Fi: a rounded wedge and two thick arcs around the same point, a quarter-turn wide. */
|
|
286
|
+
function IosWifi({ scale }: { scale: number }) {
|
|
287
|
+
const cx = 9.6
|
|
288
|
+
const cy = 13.45
|
|
289
|
+
const arc = (r: number) => {
|
|
290
|
+
const d = r * Math.SQRT1_2
|
|
291
|
+
return `M${cx - d} ${cy - d}A${r} ${r} 0 0 1 ${cx + d} ${cy - d}`
|
|
292
|
+
}
|
|
293
|
+
const w = 3.35 * Math.SQRT1_2
|
|
294
|
+
return (
|
|
295
|
+
<svg width={19.2 * scale} height={14.3 * scale} viewBox="0 0 19.2 14.3" aria-hidden fill="none" stroke="currentColor" strokeLinecap="round">
|
|
296
|
+
<path d={arc(11.6)} strokeWidth="2.55" />
|
|
297
|
+
<path d={arc(7.1)} strokeWidth="2.55" />
|
|
298
|
+
<path
|
|
299
|
+
d={`M${cx} ${cy}L${cx - w} ${cy - w}A3.35 3.35 0 0 1 ${cx + w} ${cy - w}Z`}
|
|
300
|
+
fill="currentColor"
|
|
301
|
+
strokeWidth="1.3"
|
|
302
|
+
strokeLinejoin="round"
|
|
303
|
+
/>
|
|
304
|
+
</svg>
|
|
305
|
+
)
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* iOS 26's battery: a solid rounded body, its level filled in from the left and the rest faint. Red at 20% and below,
|
|
310
|
+
* yellow in Low Power Mode, green while charging, when a bolt is cut into it.
|
|
311
|
+
*/
|
|
312
|
+
function IosBattery({ scale, battery }: { scale: number; battery?: StatusBarItems['battery'] }) {
|
|
313
|
+
const level = Math.min(1, Math.max(0, battery?.level ?? 1))
|
|
314
|
+
const charging = battery?.charging ?? false
|
|
315
|
+
const color = charging ? '#34c759' : battery?.lowPower ? '#ffcc00' : level <= 0.2 ? '#ff383c' : 'currentColor'
|
|
316
|
+
const id = `ws-battery-${charging ? 'c' : 'n'}`
|
|
317
|
+
const body = 'M4.4 0h17.53a4.4 4.4 0 0 1 4.4 4.4v4.87a4.4 4.4 0 0 1-4.4 4.4H4.4A4.4 4.4 0 0 1 0 9.27V4.4A4.4 4.4 0 0 1 4.4 0Z'
|
|
318
|
+
const bolt = 'M15 .4 8.4 8.2h4.3l-1.2 5.4 6.8-7.9H14Z'
|
|
319
|
+
return (
|
|
320
|
+
<svg width={29 * scale} height={13.67 * scale} viewBox="0 0 29 13.67" aria-hidden overflow="visible" className="ws-ios-battery" style={{ marginLeft: 0.33 * scale }}>
|
|
321
|
+
<defs>
|
|
322
|
+
<clipPath id={`${id}-body`}>
|
|
323
|
+
<path d={body} />
|
|
324
|
+
</clipPath>
|
|
325
|
+
{charging && (
|
|
326
|
+
<mask id={`${id}-cut`} maskUnits="userSpaceOnUse" x="-2" y="-2" width="33" height="18">
|
|
327
|
+
<rect x="-2" y="-2" width="33" height="18" fill="#fff" />
|
|
328
|
+
<path d={bolt} fill="#000" stroke="#000" strokeWidth="2.6" strokeLinejoin="round" />
|
|
329
|
+
</mask>
|
|
330
|
+
)}
|
|
331
|
+
</defs>
|
|
332
|
+
<g mask={charging ? `url(#${id}-cut)` : undefined}>
|
|
333
|
+
<path d={body} fill="currentColor" opacity={level >= 1 ? 0 : IOS_BATTERY_EMPTY} />
|
|
334
|
+
<rect x="0" y="0" width={26.33 * level} height="13.67" fill={color} clipPath={`url(#${id}-body)`} />
|
|
335
|
+
<path d="M27 4.33a2 2.5 0 0 1 0 5Z" fill={level >= 1 ? color : 'currentColor'} opacity={level >= 1 ? 1 : IOS_BATTERY_EMPTY} />
|
|
336
|
+
</g>
|
|
337
|
+
{charging && <path d={bolt} fill="currentColor" stroke="currentColor" strokeWidth="0.7" strokeLinejoin="round" />}
|
|
338
|
+
</svg>
|
|
339
|
+
)
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function Signal({ size, dim = false }: { size: number; dim?: boolean }) {
|
|
343
|
+
return (
|
|
344
|
+
<svg width={size * 1.5} height={size} viewBox="0 0 18 12" fill="currentColor" aria-hidden opacity={dim ? 0.35 : 1}>
|
|
345
|
+
<rect x="0" y="8" width="3" height="4" rx="0.8" />
|
|
346
|
+
<rect x="5" y="5.5" width="3" height="6.5" rx="0.8" />
|
|
347
|
+
<rect x="10" y="3" width="3" height="9" rx="0.8" />
|
|
348
|
+
<rect x="15" y="0" width="3" height="12" rx="0.8" />
|
|
349
|
+
</svg>
|
|
350
|
+
)
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function Wifi({ size }: { size: number }) {
|
|
354
|
+
return (
|
|
355
|
+
<svg width={size * 1.4} height={size} viewBox="0 0 17 12" fill="currentColor" aria-hidden>
|
|
356
|
+
<path d="M8.5 2.3c2.4 0 4.6.9 6.3 2.5l1.2-1.2A10.5 10.5 0 0 0 8.5.6 10.5 10.5 0 0 0 1 3.6l1.2 1.2a8.8 8.8 0 0 1 6.3-2.5Z" />
|
|
357
|
+
<path d="M8.5 5.6c1.5 0 2.9.6 3.9 1.5l1.2-1.2a7.3 7.3 0 0 0-10.2 0l1.2 1.2c1-1 2.4-1.5 3.9-1.5Z" />
|
|
358
|
+
<path d="M8.5 8.9c.6 0 1.2.2 1.6.6L8.5 11.2 6.9 9.5c.4-.4 1-.6 1.6-.6Z" />
|
|
359
|
+
</svg>
|
|
360
|
+
)
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/** Android's battery: an upright cell filled to its level, with a bolt while charging. */
|
|
364
|
+
function Battery({ size, battery }: { size: number; battery?: StatusBarItems['battery'] }) {
|
|
365
|
+
const level = Math.min(1, Math.max(0, battery?.level ?? 1))
|
|
366
|
+
const charging = battery?.charging ?? false
|
|
367
|
+
const fill = 11.5 * level
|
|
368
|
+
return (
|
|
369
|
+
<svg width={size * 0.6} height={size} viewBox="0 0 8 13" aria-hidden>
|
|
370
|
+
<rect x="2.5" y="0" width="3" height="1.5" rx="0.5" fill="currentColor" opacity={level >= 1 ? 1 : 0.35} />
|
|
371
|
+
<rect x="0" y="1.5" width="8" height="11.5" rx="1.5" fill="currentColor" opacity="0.35" />
|
|
372
|
+
<rect x="0" y={13 - fill} width="8" height={fill} rx="1.5" fill={level <= 0.15 && !charging ? '#ff3b30' : 'currentColor'} />
|
|
373
|
+
{charging && <path d="M4.6 3.5 2 8h2l-.6 3.5L6 7H4z" fill={level > 0.5 ? '#000' : '#fff'} style={{ mixBlendMode: 'difference' }} />}
|
|
374
|
+
</svg>
|
|
375
|
+
)
|
|
376
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { ArrowCounterClockwiseIcon, CameraRotateIcon, CheckIcon, FingerprintIcon, LightningIcon, XIcon } from '@phosphor-icons/react'
|
|
2
|
+
import { useEffect, useRef, useState } from 'react'
|
|
3
|
+
import type { DialogResult, Orientation, Platform } from '../../runtime/index.ts'
|
|
4
|
+
import { capturePhoto, drawCameraFrame, type CameraFacing, type CameraFeed as Feed, type CapturedPhoto } from '../../runtime/media.ts'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A camera feed on a canvas that fills its parent, redrawn every frame. The front camera's preview is
|
|
8
|
+
* mirrored, as phones show it.
|
|
9
|
+
*/
|
|
10
|
+
export function CameraFeed({ facing, feed, zoom = 0, paused = false }: { facing: CameraFacing; feed: Feed; zoom?: number; paused?: boolean }) {
|
|
11
|
+
const canvas = useRef<HTMLCanvasElement>(null)
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
const element = canvas.current
|
|
14
|
+
if (element === null || paused) {
|
|
15
|
+
return
|
|
16
|
+
}
|
|
17
|
+
let frame = 0
|
|
18
|
+
const draw = () => {
|
|
19
|
+
const ratio = Math.min(window.devicePixelRatio || 1, 2)
|
|
20
|
+
const width = Math.round(element.clientWidth * ratio)
|
|
21
|
+
const height = Math.round(element.clientHeight * ratio)
|
|
22
|
+
if (width > 0 && height > 0) {
|
|
23
|
+
if (element.width !== width || element.height !== height) {
|
|
24
|
+
element.width = width
|
|
25
|
+
element.height = height
|
|
26
|
+
}
|
|
27
|
+
drawCameraFrame(element.getContext('2d')!, width, height, performance.now() / 1000, feed, { zoom })
|
|
28
|
+
}
|
|
29
|
+
frame = requestAnimationFrame(draw)
|
|
30
|
+
}
|
|
31
|
+
draw()
|
|
32
|
+
return () => cancelAnimationFrame(frame)
|
|
33
|
+
}, [feed, zoom, paused])
|
|
34
|
+
return <canvas ref={canvas} className="ws-camera-feed" style={{ transform: facing === 'front' ? 'scaleX(-1)' : undefined }} />
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The system camera that `launchCameraAsync` opens: iOS's camera with Retake / Use Photo, or Android's camera with
|
|
39
|
+
* its review step.
|
|
40
|
+
*/
|
|
41
|
+
export function SystemCamera({
|
|
42
|
+
platform,
|
|
43
|
+
initialFacing,
|
|
44
|
+
feeds,
|
|
45
|
+
orientation,
|
|
46
|
+
respond,
|
|
47
|
+
}: {
|
|
48
|
+
platform: Platform
|
|
49
|
+
initialFacing: CameraFacing
|
|
50
|
+
feeds: Record<CameraFacing, Feed>
|
|
51
|
+
orientation: Orientation
|
|
52
|
+
respond: (result: DialogResult) => void
|
|
53
|
+
}) {
|
|
54
|
+
const [facing, setFacing] = useState(initialFacing)
|
|
55
|
+
const [photo, setPhoto] = useState<CapturedPhoto | null>(null)
|
|
56
|
+
const [shutter, setShutter] = useState(0)
|
|
57
|
+
const take = () => {
|
|
58
|
+
setShutter((count) => count + 1)
|
|
59
|
+
setPhoto(capturePhoto({ facing, feed: feeds[facing], orientation }))
|
|
60
|
+
}
|
|
61
|
+
const flip = () => setFacing((current) => (current === 'back' ? 'front' : 'back'))
|
|
62
|
+
const cancel = () => respond({ button: 0 })
|
|
63
|
+
const use = () => photo && respond({ button: 1, photo })
|
|
64
|
+
const view = (
|
|
65
|
+
<div className="ws-camera-view">
|
|
66
|
+
{photo === null ? <CameraFeed facing={facing} feed={feeds[facing]} /> : <img src={photo.uri} alt="" className="ws-camera-feed" draggable={false} />}
|
|
67
|
+
{shutter > 0 && <div key={shutter} className="ws-camera-shutter" />}
|
|
68
|
+
</div>
|
|
69
|
+
)
|
|
70
|
+
if (platform === 'android') {
|
|
71
|
+
return (
|
|
72
|
+
<div className="ws-camera ws-camera-android">
|
|
73
|
+
{view}
|
|
74
|
+
<div className="ws-camera-controls">
|
|
75
|
+
{photo === null ? (
|
|
76
|
+
<>
|
|
77
|
+
<button type="button" className="ws-camera-round" aria-label="Close" onClick={cancel}>
|
|
78
|
+
<XIcon size={22} />
|
|
79
|
+
</button>
|
|
80
|
+
<button type="button" className="ws-shutter" aria-label="Take photo" onClick={take} />
|
|
81
|
+
<button type="button" className="ws-camera-round" aria-label="Switch camera" onClick={flip}>
|
|
82
|
+
<CameraRotateIcon size={22} />
|
|
83
|
+
</button>
|
|
84
|
+
</>
|
|
85
|
+
) : (
|
|
86
|
+
<>
|
|
87
|
+
<button type="button" className="ws-camera-round" aria-label="Retake" onClick={() => setPhoto(null)}>
|
|
88
|
+
<ArrowCounterClockwiseIcon size={22} />
|
|
89
|
+
</button>
|
|
90
|
+
<button type="button" className="ws-camera-round ws-camera-done" aria-label="Done" onClick={use}>
|
|
91
|
+
<CheckIcon size={28} />
|
|
92
|
+
</button>
|
|
93
|
+
<button type="button" className="ws-camera-round" aria-label="Cancel" onClick={cancel}>
|
|
94
|
+
<XIcon size={22} />
|
|
95
|
+
</button>
|
|
96
|
+
</>
|
|
97
|
+
)}
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
return (
|
|
103
|
+
<div className="ws-camera ws-camera-ios">
|
|
104
|
+
<div className="ws-camera-top">
|
|
105
|
+
{photo === null && (
|
|
106
|
+
<button type="button" className="ws-camera-flash" aria-label="Flash">
|
|
107
|
+
<LightningIcon size={18} />
|
|
108
|
+
</button>
|
|
109
|
+
)}
|
|
110
|
+
</div>
|
|
111
|
+
{view}
|
|
112
|
+
<div className="ws-camera-bottom">
|
|
113
|
+
{photo === null ? (
|
|
114
|
+
<>
|
|
115
|
+
<div className="ws-camera-mode">PHOTO</div>
|
|
116
|
+
<div className="ws-camera-row">
|
|
117
|
+
<button type="button" className="ws-camera-text" onClick={cancel}>
|
|
118
|
+
Cancel
|
|
119
|
+
</button>
|
|
120
|
+
<button type="button" className="ws-shutter" aria-label="Take Picture" onClick={take} />
|
|
121
|
+
<button type="button" className="ws-camera-round" aria-label="Switch Camera" onClick={flip}>
|
|
122
|
+
<CameraRotateIcon size={22} />
|
|
123
|
+
</button>
|
|
124
|
+
</div>
|
|
125
|
+
</>
|
|
126
|
+
) : (
|
|
127
|
+
<div className="ws-camera-row ws-camera-review">
|
|
128
|
+
<button type="button" className="ws-camera-text" onClick={() => setPhoto(null)}>
|
|
129
|
+
Retake
|
|
130
|
+
</button>
|
|
131
|
+
<button type="button" className="ws-camera-text" onClick={use}>
|
|
132
|
+
Use Photo
|
|
133
|
+
</button>
|
|
134
|
+
</div>
|
|
135
|
+
)}
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* iOS's Touch ID prompt, for iPhones with a home button, with the simulator's controls for what the sensor feels.
|
|
143
|
+
*/
|
|
144
|
+
export function TouchId({
|
|
145
|
+
app,
|
|
146
|
+
reason,
|
|
147
|
+
cancelLabel,
|
|
148
|
+
respond,
|
|
149
|
+
}: {
|
|
150
|
+
app: string
|
|
151
|
+
reason?: string
|
|
152
|
+
cancelLabel?: string
|
|
153
|
+
respond: (result: DialogResult) => void
|
|
154
|
+
}) {
|
|
155
|
+
return (
|
|
156
|
+
<div className="ws-scrim ws-scrim-center">
|
|
157
|
+
<div className="ws-ios-alert" role="alertdialog">
|
|
158
|
+
<div className="ws-ios-alert-text">
|
|
159
|
+
<div className="ws-touchid-icon">
|
|
160
|
+
<FingerprintIcon size={52} weight="light" />
|
|
161
|
+
</div>
|
|
162
|
+
<div className="ws-ios-alert-title">Touch ID for “{app}”</div>
|
|
163
|
+
{reason && <div className="ws-ios-alert-message">{reason}</div>}
|
|
164
|
+
</div>
|
|
165
|
+
<div className="ws-ios-alert-buttons">
|
|
166
|
+
<button type="button" className="ws-ios-alert-button" onClick={() => respond({ button: 2 })}>
|
|
167
|
+
{cancelLabel ?? 'Cancel'}
|
|
168
|
+
</button>
|
|
169
|
+
</div>
|
|
170
|
+
</div>
|
|
171
|
+
<div className="ws-sim-controls">
|
|
172
|
+
<button type="button" onClick={() => respond({ button: 0 })}>
|
|
173
|
+
Matching finger
|
|
174
|
+
</button>
|
|
175
|
+
<button type="button" onClick={() => respond({ button: 1 })}>
|
|
176
|
+
Non-matching finger
|
|
177
|
+
</button>
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
)
|
|
181
|
+
}
|