@vvedantb/native-ui 0.37.2 → 0.39.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 +8 -7
- package/dist/Avatar.jsx +22 -19
- package/dist/BottomSheetContainer.jsx +0 -6
- package/dist/BulkActionBar.jsx +0 -24
- package/dist/Button.jsx +92 -116
- package/dist/Card.jsx +56 -50
- package/dist/ColorSwatches.jsx +0 -6
- package/dist/Dialog.jsx +0 -12
- package/dist/DropdownMenu.jsx +0 -10
- package/dist/EmptyState.jsx +0 -3
- package/dist/ExpoWebRoot.jsx +0 -6
- package/dist/Field.jsx +0 -17
- package/dist/FloatingSurface.jsx +95 -80
- package/dist/FloatingTabBar.jsx +0 -23
- package/dist/IconButton.jsx +0 -1
- package/dist/LoadingState.jsx +0 -6
- package/dist/PasswordInput.jsx +0 -15
- package/dist/PillTabs.jsx +39 -36
- package/dist/SearchInput.jsx +0 -13
- package/dist/SectionLabel.jsx +0 -1
- package/dist/SharedTransition.jsx +0 -3
- package/dist/Skeleton.jsx +0 -2
- package/dist/Spinner.jsx +0 -2
- package/dist/StatusDot.jsx +0 -5
- package/dist/Switch.jsx +32 -22
- package/dist/Tabs.jsx +27 -26
- package/dist/Textarea.jsx +0 -1
- package/dist/ThemeToggle.jsx +0 -1
- package/dist/Toast.jsx +80 -91
- package/dist/UpdateChecker.jsx +0 -1
- package/dist/ai/activity-question.jsx +0 -6
- package/dist/ai/activity-step-label.js +0 -6
- package/dist/ai/activity-step-types.js +0 -4
- package/dist/ai/activity-tasks-utils.js +0 -17
- package/dist/ai/activity-timeline.js +0 -8
- package/dist/ai/attachments.jsx +0 -2
- package/dist/ai/chain-of-thought.jsx +0 -3
- package/dist/ai/chat-text.js +0 -1
- package/dist/ai/chat-thread.jsx +0 -1
- package/dist/ai/choice-question.jsx +0 -10
- package/dist/ai/code-block.jsx +0 -31
- package/dist/ai/collapsible.jsx +0 -14
- package/dist/ai/conversation-context.js +0 -3
- package/dist/ai/conversation.jsx +2 -48
- package/dist/ai/file-chip.jsx +0 -2
- package/dist/ai/icon-button.jsx +0 -8
- package/dist/ai/index.js +0 -5
- package/dist/ai/message-context-menu.jsx +0 -7
- package/dist/ai/message.jsx +0 -21
- package/dist/ai/prompt-input-menu.jsx +0 -3
- package/dist/ai/prompt-input.jsx +0 -27
- package/dist/ai/response-text.jsx +0 -6
- package/dist/ai/sources.jsx +0 -1
- package/dist/ai/suggestion.jsx +0 -1
- package/dist/ai/trace.jsx +0 -11
- package/dist/ai/unified-diff.jsx +0 -4
- package/dist/app-root/AuthGroupGate.jsx +65 -0
- package/dist/app-root/SsoCallbackScreen.jsx +97 -0
- package/dist/app-root/fonts.js +88 -0
- package/dist/app-root/index.js +3 -0
- package/dist/auth/AuthScreen.jsx +250 -77
- package/dist/auth/GoogleSignInButton.jsx +0 -3
- package/dist/auth/SecondFactorScreen.jsx +18 -14
- package/dist/auth/SignInScreen.jsx +40 -34
- package/dist/auth/authErrors.js +0 -4
- package/dist/auth/clerkCore3.js +0 -7
- package/dist/auth/index.js +0 -4
- package/dist/auth/totp.js +0 -2
- package/dist/brand/GoogleMark.jsx +0 -1
- package/dist/brand/ProviderIcon.jsx +0 -2
- package/dist/brand/index.js +0 -3
- package/dist/brand/svg.js +0 -6
- package/dist/configureTheme.js +0 -9
- package/dist/controlStyles.js +0 -14
- package/dist/crash/LastCrashDialog.jsx +56 -0
- package/dist/crash/lastCrash.js +192 -0
- package/dist/entries/ai.js +0 -3
- package/dist/entries/ambient.js +0 -2
- package/dist/entries/app-root.js +1 -0
- package/dist/entries/auth.js +0 -4
- package/dist/entries/bottom-sheet.js +0 -2
- package/dist/entries/brand.js +0 -1
- package/dist/entries/button.js +0 -1
- package/dist/entries/crash.js +2 -0
- package/dist/entries/date-time.js +0 -2
- package/dist/entries/expo-router.js +0 -3
- package/dist/entries/expo-web-root.js +0 -2
- package/dist/entries/floating.js +0 -2
- package/dist/entries/generative-ui.js +0 -4
- package/dist/entries/gesture-handler.js +0 -3
- package/dist/entries/keyboard-controller.js +0 -3
- package/dist/entries/layout.js +0 -2
- package/dist/entries/markdown.js +0 -3
- package/dist/entries/marketing.js +0 -1
- package/dist/entries/page-title.js +0 -5
- package/dist/entries/password-input.js +0 -2
- package/dist/entries/paste-input.js +0 -3
- package/dist/entries/primitives.js +0 -6
- package/dist/entries/search-input.js +0 -2
- package/dist/entries/tab-bar.js +0 -2
- package/dist/entries/theme.js +4 -2
- package/dist/entries/toast.js +0 -3
- package/dist/entries/video.js +0 -2
- package/dist/entries/webview.js +0 -2
- package/dist/examples/AiChatGallery.jsx +0 -11
- package/dist/examples/ParityGallery.jsx +0 -12
- package/dist/floating.js +0 -8
- package/dist/generative-ui/GenerativeUiPanel.jsx +0 -2
- package/dist/generative-ui/components.jsx +0 -8
- package/dist/glass.js +55 -0
- package/dist/glassBlur.jsx +0 -12
- package/dist/highlight.js +0 -26
- package/dist/index.js +4 -2
- package/dist/loadingGrid.js +0 -13
- package/dist/markdown/Markdown.jsx +0 -59
- package/dist/markdown/MarkdownTable.jsx +0 -18
- package/dist/markdown/tableText.js +0 -5
- package/dist/marketing/UpgradeToProCard.jsx +0 -5
- package/dist/marketing/pricing.js +0 -3
- package/dist/media/ImageGallery.jsx +0 -16
- package/dist/media/imageZoom.js +0 -4
- package/dist/media/zoom-image-gesture.jsx +0 -8
- package/dist/media/zoomImage.js +0 -3
- package/dist/motion.js +0 -3
- package/dist/neutralTheme.js +158 -0
- package/dist/pagerSwipe.js +0 -16
- package/dist/palette.js +0 -10
- package/dist/primitives/button.jsx +0 -5
- package/dist/primitives/icon.jsx +0 -4
- package/dist/primitives/keyboard-controller.jsx +0 -27
- package/dist/primitives/native-only-animated-view.jsx +0 -5
- package/dist/primitives/overlay.jsx +0 -2
- package/dist/primitives/pager-gesture.jsx +3 -29
- package/dist/primitives/paste-input.jsx +0 -5
- package/dist/primitives/select.jsx +0 -10
- package/dist/primitives/sheet-drag.jsx +0 -3
- package/dist/primitives/sheet-gesture.jsx +0 -8
- package/dist/primitives/swipe-row-gesture.jsx +3 -45
- package/dist/primitives/text.jsx +0 -5
- package/dist/primitives/toast-drag-gesture.jsx +4 -24
- package/dist/primitives/web-click-guard.js +0 -3
- package/dist/primitives/window-layer.jsx +0 -14
- package/dist/push.js +0 -6
- package/dist/relativeTime.js +0 -13
- package/dist/settings/MoreFromProjectV.jsx +0 -5
- package/dist/settings/ThemeModePicker.jsx +2 -9
- package/dist/settings/projectVMobileApps.js +1 -6
- package/dist/sheetDrag.js +0 -10
- package/dist/swipeRow.js +0 -15
- package/dist/tabBarRoutes.js +0 -4
- package/dist/tabIndicator.js +0 -4
- package/dist/tailwind-preset.cjs +0 -54
- package/dist/tailwind-preset.d.cts +0 -8
- package/dist/theme.jsx +29 -21
- package/dist/themeModeStore.js +62 -0
- package/dist/themeModes.js +9 -0
- package/dist/toastChrome.js +0 -6
- package/dist/toastDrag.js +0 -14
- package/dist/toastStore.js +0 -4
- package/dist/updateCheck.js +0 -7
- package/dist/video/InlineVideo.jsx +0 -2
- package/dist/webview/htmlView.js +0 -5
- package/package.json +47 -19
- package/src/ArtifactList.tsx +0 -2
- package/src/Avatar.tsx +3 -3
- package/src/Badge.tsx +0 -1
- package/src/BottomSheetContainer.tsx +0 -11
- package/src/BulkActionBar.tsx +0 -66
- package/src/Button.tsx +4 -40
- package/src/CaptureButton.tsx +0 -1
- package/src/Card.tsx +3 -15
- package/src/Checkbox.tsx +0 -2
- package/src/ColorSwatches.tsx +0 -9
- package/src/ConfirmDialog.tsx +0 -7
- package/src/DateTimeField.tsx +0 -5
- package/src/Dialog.tsx +0 -27
- package/src/DividedList.tsx +0 -1
- package/src/DropdownMenu.tsx +0 -51
- package/src/EmptyState.tsx +0 -5
- package/src/ExpoWebRoot.tsx +0 -10
- package/src/Field.tsx +0 -14
- package/src/FloatingFAB.tsx +0 -3
- package/src/FloatingSurface.tsx +11 -8
- package/src/FloatingTabBar.tsx +0 -25
- package/src/IconButton.tsx +0 -5
- package/src/Input.tsx +0 -1
- package/src/Label.tsx +0 -1
- package/src/LabeledSwitchRow.tsx +0 -2
- package/src/ListRow.tsx +0 -12
- package/src/LoadingState.tsx +0 -12
- package/src/MenuSheet.tsx +0 -2
- package/src/PageIndicator.tsx +0 -2
- package/src/PageTitle.tsx +0 -15
- package/src/Pager.tsx +0 -9
- package/src/PasswordInput.tsx +0 -24
- package/src/PillTabs.tsx +3 -11
- package/src/PinnedBotTile.tsx +0 -6
- package/src/Progress.tsx +0 -3
- package/src/ReactionRow.tsx +0 -8
- package/src/ScreenContainer.tsx +0 -4
- package/src/SearchInput.tsx +0 -25
- package/src/SectionLabel.tsx +0 -2
- package/src/Select.tsx +0 -6
- package/src/Separator.tsx +0 -2
- package/src/SharedTransition.tsx +0 -7
- package/src/Sheet.tsx +0 -3
- package/src/SheetRow.tsx +0 -12
- package/src/Skeleton.tsx +0 -10
- package/src/Spinner.tsx +0 -6
- package/src/StackPageHeader.tsx +0 -16
- package/src/StatGrid.tsx +0 -1
- package/src/StatusDot.tsx +0 -6
- package/src/SurfaceRow.tsx +0 -12
- package/src/SwipeableRow.tsx +0 -4
- package/src/Switch.tsx +3 -4
- package/src/Tabs.tsx +3 -27
- package/src/Textarea.tsx +0 -2
- package/src/ThemeToggle.tsx +0 -1
- package/src/Toast.tsx +3 -19
- package/src/UpdateChecker.tsx +0 -46
- package/src/ai/activity-question.tsx +0 -8
- package/src/ai/activity-step-detail.tsx +0 -5
- package/src/ai/activity-step-label.ts +0 -5
- package/src/ai/activity-step-types.ts +0 -24
- package/src/ai/activity-step.tsx +0 -4
- package/src/ai/activity-tasks-utils.ts +0 -13
- package/src/ai/activity-timeline.ts +0 -6
- package/src/ai/attachments.tsx +0 -13
- package/src/ai/chain-of-thought.tsx +0 -5
- package/src/ai/chat-jump-rail.tsx +0 -2
- package/src/ai/chat-text.ts +0 -1
- package/src/ai/chat-thread.tsx +0 -9
- package/src/ai/choice-question.tsx +0 -36
- package/src/ai/code-block.tsx +0 -52
- package/src/ai/collapsible.tsx +0 -12
- package/src/ai/conversation-context.ts +0 -14
- package/src/ai/conversation.tsx +0 -58
- package/src/ai/file-chip.tsx +0 -1
- package/src/ai/icon-button.tsx +0 -17
- package/src/ai/index.ts +0 -5
- package/src/ai/message-action-sheet.tsx +0 -8
- package/src/ai/message-context-menu.tsx +0 -22
- package/src/ai/message-quote.tsx +0 -4
- package/src/ai/message.tsx +0 -66
- package/src/ai/prompt-input-menu.tsx +0 -19
- package/src/ai/prompt-input.tsx +0 -97
- package/src/ai/reasoning.tsx +0 -6
- package/src/ai/reply-quote-chip.tsx +0 -5
- package/src/ai/response-text.tsx +0 -8
- package/src/ai/shimmer.tsx +0 -2
- package/src/ai/sources.tsx +0 -3
- package/src/ai/subagent-cards.tsx +0 -13
- package/src/ai/suggestion.tsx +0 -4
- package/src/ai/tool-approval-card.tsx +0 -14
- package/src/ai/trace.tsx +0 -23
- package/src/ai/unified-diff.tsx +0 -16
- package/src/ai/use-streaming-disclosure.ts +0 -4
- package/src/app-root/AuthGroupGate.tsx +38 -0
- package/src/app-root/SsoCallbackScreen.tsx +52 -0
- package/src/app-root/fonts.ts +53 -0
- package/src/app-root/index.ts +6 -0
- package/src/auth/AccountScreens.tsx +0 -16
- package/src/auth/AuthProviders.tsx +0 -13
- package/src/auth/AuthScreen.tsx +95 -6
- package/src/auth/GoogleSignInButton.tsx +0 -12
- package/src/auth/SecondFactorScreen.tsx +17 -15
- package/src/auth/SignInScreen.tsx +103 -105
- package/src/auth/authErrors.ts +0 -6
- package/src/auth/clerkCore3.ts +0 -6
- package/src/auth/index.ts +0 -4
- package/src/auth/totp.ts +0 -13
- package/src/brand/AppIcons.tsx +0 -6
- package/src/brand/AppMark.tsx +0 -5
- package/src/brand/AppWordmark.tsx +0 -7
- package/src/brand/GoogleMark.tsx +0 -4
- package/src/brand/ProviderIcon.tsx +0 -6
- package/src/brand/familyApps.ts +0 -2
- package/src/brand/index.ts +0 -3
- package/src/brand/svg.ts +0 -9
- package/src/configureTheme.ts +0 -10
- package/src/controlStyles.ts +0 -12
- package/src/crash/LastCrashDialog.tsx +36 -0
- package/src/crash/lastCrash.ts +218 -0
- package/src/entries/ai.ts +0 -3
- package/src/entries/ambient.ts +0 -2
- package/src/entries/app-root.ts +1 -0
- package/src/entries/auth.ts +0 -4
- package/src/entries/bottom-sheet.ts +0 -2
- package/src/entries/brand.ts +0 -1
- package/src/entries/button.ts +0 -1
- package/src/entries/crash.ts +13 -0
- package/src/entries/date-time.ts +0 -2
- package/src/entries/expo-router.ts +0 -3
- package/src/entries/expo-web-root.ts +0 -2
- package/src/entries/floating.ts +0 -2
- package/src/entries/generative-ui.ts +0 -4
- package/src/entries/gesture-handler.ts +0 -3
- package/src/entries/keyboard-controller.ts +0 -3
- package/src/entries/layout.ts +0 -2
- package/src/entries/markdown.ts +0 -3
- package/src/entries/marketing.ts +0 -1
- package/src/entries/page-title.ts +0 -5
- package/src/entries/password-input.ts +0 -2
- package/src/entries/paste-input.ts +0 -3
- package/src/entries/primitives.ts +0 -6
- package/src/entries/search-input.ts +0 -2
- package/src/entries/tab-bar.ts +0 -2
- package/src/entries/theme.ts +8 -2
- package/src/entries/toast.ts +0 -3
- package/src/entries/video.ts +0 -2
- package/src/entries/webview.ts +0 -2
- package/src/examples/AiChatGallery.tsx +0 -11
- package/src/examples/ParityGallery.tsx +0 -25
- package/src/floating.ts +0 -6
- package/src/generative-ui/GenerativeUiPanel.tsx +0 -15
- package/src/generative-ui/components.tsx +0 -9
- package/src/generative-ui/context.ts +0 -2
- package/src/glass.ts +31 -0
- package/src/glassBlur.tsx +0 -15
- package/src/highlight.ts +1 -21
- package/src/index.ts +7 -2
- package/src/loadingGrid.ts +0 -12
- package/src/markdown/Markdown.tsx +0 -71
- package/src/markdown/MarkdownTable.tsx +0 -23
- package/src/markdown/tableText.ts +0 -3
- package/src/marketing/PricingModal.tsx +0 -13
- package/src/marketing/UpgradeToProCard.tsx +0 -14
- package/src/marketing/pricing.ts +0 -12
- package/src/media/ImageGallery.tsx +0 -18
- package/src/media/MediaCard.tsx +0 -8
- package/src/media/imageZoom.ts +0 -4
- package/src/media/zoom-image-gesture.tsx +0 -9
- package/src/media/zoomImage.ts +0 -5
- package/src/motion.ts +0 -3
- package/src/neutralTheme.ts +127 -0
- package/src/pagerSwipe.ts +0 -13
- package/src/palette.ts +0 -10
- package/src/pressScale.ts +0 -7
- package/src/primitives/button.tsx +0 -4
- package/src/primitives/card.tsx +0 -1
- package/src/primitives/icon.tsx +0 -2
- package/src/primitives/input.tsx +0 -4
- package/src/primitives/keyboard-controller.tsx +0 -25
- package/src/primitives/keyboard-parts.tsx +0 -27
- package/src/primitives/native-only-animated-view.tsx +0 -5
- package/src/primitives/overlay.tsx +0 -25
- package/src/primitives/pager-gesture.tsx +0 -20
- package/src/primitives/paste-input.tsx +0 -4
- package/src/primitives/paste-parts.tsx +0 -1
- package/src/primitives/select.tsx +0 -18
- package/src/primitives/sheet-drag.tsx +0 -19
- package/src/primitives/sheet-gesture.tsx +0 -22
- package/src/primitives/swipe-row-gesture.tsx +0 -33
- package/src/primitives/switch.tsx +0 -4
- package/src/primitives/text.tsx +0 -4
- package/src/primitives/toast-drag-gesture.tsx +0 -13
- package/src/primitives/web-click-guard.ts +0 -2
- package/src/primitives/window-layer.tsx +0 -18
- package/src/push.ts +0 -15
- package/src/relativeTime.ts +0 -21
- package/src/router/RouterStackPageHeader.tsx +0 -1
- package/src/settings/MoreFromProjectV.tsx +0 -8
- package/src/settings/SettingsEmptyState.tsx +0 -2
- package/src/settings/SettingsSection.tsx +0 -3
- package/src/settings/SettingsToggleRow.tsx +0 -4
- package/src/settings/ThemeModePicker.tsx +2 -16
- package/src/settings/projectVMobileApps.ts +0 -8
- package/src/sheetDrag.ts +0 -9
- package/src/swipeRow.ts +0 -23
- package/src/tabBarRoutes.ts +0 -13
- package/src/tabIndicator.ts +0 -5
- package/src/tailwind-preset.cjs +0 -54
- package/src/tailwind-preset.d.cts +0 -8
- package/src/theme.tsx +11 -2
- package/src/themeModeStore.ts +85 -0
- package/src/themeModes.ts +10 -0
- package/src/toastChrome.ts +0 -6
- package/src/toastDrag.ts +0 -13
- package/src/toastStore.ts +0 -7
- package/src/updateCheck.ts +0 -15
- package/src/video/InlineVideo.tsx +0 -5
- package/src/webview/HtmlView.tsx +0 -23
- package/src/webview/HtmlView.web.tsx +0 -1
- package/src/webview/htmlView.ts +0 -5
- package/types/prism-react-renderer.d.ts +22 -0
|
@@ -7,19 +7,13 @@ import { palette, withAlpha } from "../palette";
|
|
|
7
7
|
import { useLargerText } from "../theme";
|
|
8
8
|
import { tokens } from "../tokens";
|
|
9
9
|
import { useScheme } from "../useScheme";
|
|
10
|
+
import { THEME_MODES, type ThemeMode } from "../themeModes";
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
export type ThemeMode = "light" | "neutral" | "dark" | "system";
|
|
13
|
-
|
|
14
|
-
/** Default order: light to dark, then system. */
|
|
15
|
-
export const THEME_MODES = ["light", "neutral", "dark", "system"] as const satisfies readonly ThemeMode[];
|
|
12
|
+
export { THEME_MODES, type ThemeMode };
|
|
16
13
|
|
|
17
14
|
const LABELS: Record<ThemeMode, string> = { light: "Light", neutral: "Neutral", dark: "Dark", system: "System" };
|
|
18
15
|
const ICONS = { light: IconSun, neutral: IconCircleHalf, dark: IconMoon, system: IconDeviceDesktop };
|
|
19
|
-
/** Web `bg-zinc-900`. */
|
|
20
16
|
const ZINC_900 = "#18181b";
|
|
21
|
-
// Swatches and icons show the theme itself, so they use the web's fixed colours, not tokens.
|
|
22
|
-
// System has no swatch colour (it is a hard split) and a muted icon.
|
|
23
17
|
const SWATCHES: Record<ThemeMode, string | null> = {
|
|
24
18
|
light: "#ffffff",
|
|
25
19
|
neutral: "#3f3f46",
|
|
@@ -34,20 +28,15 @@ const ICON_COLOURS: Record<ThemeMode, string | null> = {
|
|
|
34
28
|
};
|
|
35
29
|
|
|
36
30
|
export type ThemeModePickerProps = {
|
|
37
|
-
/** The stored choice, not the resolved scheme. */
|
|
38
31
|
value: string | undefined;
|
|
39
32
|
onChange: (mode: ThemeMode) => void;
|
|
40
|
-
/** Themes to show, in order. Default `THEME_MODES`. */
|
|
41
33
|
modes?: readonly ThemeMode[];
|
|
42
34
|
className?: string;
|
|
43
|
-
/** Each tile gets `${testID}-${mode}`. */
|
|
44
35
|
testID?: string;
|
|
45
36
|
};
|
|
46
37
|
|
|
47
|
-
/** The System swatch: white with a hard diagonal half in zinc-900, no gradient. */
|
|
48
38
|
function SplitSwatch() {
|
|
49
39
|
return (
|
|
50
|
-
// Sized by props: an unsized Svg is 300 wide and widens the tile.
|
|
51
40
|
<Svg width="100%" height="100%" viewBox="0 0 1 1" preserveAspectRatio="none" style={StyleSheet.absoluteFill}>
|
|
52
41
|
<Rect width="1" height="1" fill="#ffffff" />
|
|
53
42
|
<Path d="M1 0 L1 1 L0 1 Z" fill={ZINC_900} />
|
|
@@ -92,12 +81,10 @@ export function ThemeModePicker({ value, onChange, modes = THEME_MODES, classNam
|
|
|
92
81
|
style={swatch ? { backgroundColor: swatch } : undefined}
|
|
93
82
|
>
|
|
94
83
|
{swatch ? null : <SplitSwatch />}
|
|
95
|
-
{/* Positioned, so the web build paints it over the positioned swatch. */}
|
|
96
84
|
<View className="absolute inset-0 items-center justify-center">
|
|
97
85
|
<Icon size={22} color={ICON_COLOURS[mode] ?? tokens.color.muted[scheme]} />
|
|
98
86
|
</View>
|
|
99
87
|
</View>
|
|
100
|
-
{/* After the swatch, so it draws over the swatch corner. */}
|
|
101
88
|
{active ? (
|
|
102
89
|
<View
|
|
103
90
|
className="absolute right-2 top-2 h-4 w-4 items-center justify-center rounded-full"
|
|
@@ -106,7 +93,6 @@ export function ThemeModePicker({ value, onChange, modes = THEME_MODES, classNam
|
|
|
106
93
|
<IconCheck size={10} strokeWidth={3} color={palette.primaryForeground[scheme]} />
|
|
107
94
|
</View>
|
|
108
95
|
) : null}
|
|
109
|
-
{/* On a narrow phone at a large font scale, "Neutral" shrinks to fit, not wraps. */}
|
|
110
96
|
<Text
|
|
111
97
|
numberOfLines={1}
|
|
112
98
|
adjustsFontSizeToFit
|
|
@@ -5,15 +5,10 @@ export type ProjectVMobileAppId = "vibot" | "verve" | "velth" | "vmem" | "vstore
|
|
|
5
5
|
|
|
6
6
|
export type ProjectVMobileApp = {
|
|
7
7
|
id: ProjectVMobileAppId;
|
|
8
|
-
/** Display name. */
|
|
9
8
|
name: string;
|
|
10
|
-
/** One line for a settings row. */
|
|
11
9
|
description: string;
|
|
12
|
-
/** Android application id. */
|
|
13
10
|
androidPackage: string;
|
|
14
|
-
/** The app's URL scheme, without `://`. */
|
|
15
11
|
scheme: string;
|
|
16
|
-
/** Home page of the app: the fallback when neither the app nor V Store is installed. */
|
|
17
12
|
website: string;
|
|
18
13
|
};
|
|
19
14
|
|
|
@@ -24,8 +19,6 @@ export type ProjectVMobileApp = {
|
|
|
24
19
|
*/
|
|
25
20
|
export const VSTORE_HOME_URL = "vstore://";
|
|
26
21
|
|
|
27
|
-
// Names and sites come from `FAMILY_APPS` where it has the app. V Store is not
|
|
28
|
-
// a family app there (that file is a byte-identical copy of `@vvedantb/ui`).
|
|
29
22
|
const vibot = familyApp("vibot");
|
|
30
23
|
const verve = familyApp("verve");
|
|
31
24
|
const velth = familyApp("velth");
|
|
@@ -138,7 +131,6 @@ export async function openProjectVApp(
|
|
|
138
131
|
await linking.openURL(step.url);
|
|
139
132
|
return step.target;
|
|
140
133
|
} catch {
|
|
141
|
-
// Not installed, or no handler: try the next URL.
|
|
142
134
|
}
|
|
143
135
|
}
|
|
144
136
|
return null;
|
package/src/sheetDrag.ts
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The rules of a bottom sheet's drag to dismiss, as plain numbers, so they
|
|
3
|
-
* stay testable apart from the gesture. Distances are in points, `vy` in
|
|
4
|
-
* points per millisecond (the React Native `PanResponder` unit). Each is a
|
|
5
|
-
* worklet, so the Gesture Handler drag runs them on the UI thread.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/** How far ahead (ms) the release velocity carries the sheet when deciding to close. */
|
|
9
1
|
const PROJECTION_MS = 200;
|
|
10
2
|
|
|
11
|
-
/** A flick down at this speed (pt/ms, so 1000 pt/s) closes the sheet however short the drag. */
|
|
12
3
|
const FLICK_VELOCITY = 1;
|
|
13
4
|
|
|
14
5
|
/** How far an upward pull may lift the sheet: less than the corner radius hidden below the screen. */
|
package/src/swipeRow.ts
CHANGED
|
@@ -1,32 +1,13 @@
|
|
|
1
1
|
import type { IconProps } from "@tabler/icons-react-native";
|
|
2
2
|
import type { ComponentType } from "react";
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* The rules of a swipeable list row (`SwipeableRow`), as plain numbers, so
|
|
6
|
-
* they stay testable apart from the gesture. The offset is in points:
|
|
7
|
-
* positive when the row moves right (it reveals the leading actions),
|
|
8
|
-
* negative when it moves left (the trailing actions). Velocities are in
|
|
9
|
-
* points per second, the Gesture Handler unit. Each rule is a worklet, so the
|
|
10
|
-
* drag runs it on the UI thread.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
4
|
/** One action a swipe reveals behind a row. */
|
|
14
5
|
export type SwipeAction = {
|
|
15
|
-
/** Unique in the row; also the accessibility action name. */
|
|
16
6
|
key: string;
|
|
17
|
-
/** What the action does ("Archive"): the accessibility label of its button and of its row action. */
|
|
18
7
|
label: string;
|
|
19
|
-
/** A Tabler icon, drawn in the tone's foreground. */
|
|
20
8
|
icon: ComponentType<IconProps>;
|
|
21
|
-
/** The fill: `default` the primary fill, `warning` (such as Archive), `danger` for a destructive action. */
|
|
22
9
|
tone?: "default" | "warning" | "danger";
|
|
23
|
-
/**
|
|
24
|
-
* Runs the action. With `exits`, a returned promise that settles while
|
|
25
|
-
* the row is still on screen (it failed, or the row stays) brings the row
|
|
26
|
-
* back.
|
|
27
|
-
*/
|
|
28
10
|
onPress: () => void | Promise<unknown>;
|
|
29
|
-
/** The action takes the row out of the list (Archive): a full swipe slides it out. Else the row springs back. */
|
|
30
11
|
exits?: boolean;
|
|
31
12
|
};
|
|
32
13
|
|
|
@@ -57,16 +38,13 @@ export function swipeRowActivation(
|
|
|
57
38
|
if (!insidePager || (sides.leading > 0 && sides.trailing > 0)) {
|
|
58
39
|
return { activeOffsetX: [-SWIPE_ACTIVE_OFFSET_X, SWIPE_ACTIVE_OFFSET_X] };
|
|
59
40
|
}
|
|
60
|
-
// Left (negative) reveals the trailing actions; right the leading ones.
|
|
61
41
|
return sides.trailing > 0
|
|
62
42
|
? { activeOffsetX: -SWIPE_ACTIVE_OFFSET_X, failOffsetX: SWIPE_ACTIVE_OFFSET_X }
|
|
63
43
|
: { activeOffsetX: SWIPE_ACTIVE_OFFSET_X, failOffsetX: -SWIPE_ACTIVE_OFFSET_X };
|
|
64
44
|
}
|
|
65
45
|
|
|
66
|
-
/** How far ahead (s) the release velocity carries the row when deciding where it settles. */
|
|
67
46
|
const PROJECTION_S = 0.2;
|
|
68
47
|
|
|
69
|
-
/** How far a row moves past its reach: less and less the further the finger goes. */
|
|
70
48
|
function rubberband(overshoot: number): number {
|
|
71
49
|
"worklet";
|
|
72
50
|
const constant = 0.55;
|
|
@@ -116,7 +94,6 @@ export function swipeRowSettle(x: number, vx: number, sides: SwipeSides): SwipeS
|
|
|
116
94
|
const side: SwipeSide = x > 0 ? "leading" : "trailing";
|
|
117
95
|
const reveal = sides[side];
|
|
118
96
|
if (reveal === 0) return { kind: "close" };
|
|
119
|
-
// The projected travel toward this side: negative after a flick back past rest.
|
|
120
97
|
const reach = Math.sign(x) * (x + vx * PROJECTION_S);
|
|
121
98
|
if (Math.abs(x) > reveal && reach >= swipeFullAt(reveal, sides.width)) return { kind: "commit", side };
|
|
122
99
|
if (reach > reveal / 2) return { kind: "open", side };
|
package/src/tabBarRoutes.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// Which routes `FloatingTabBar` draws. No React Native runtime import, so the
|
|
2
|
-
// tests can load this file.
|
|
3
1
|
import type { ReactNode } from "react";
|
|
4
2
|
import type { ColorValue, StyleProp, ViewStyle } from "react-native";
|
|
5
3
|
|
|
@@ -19,22 +17,11 @@ export type FloatingTabOptions = {
|
|
|
19
17
|
tabBarInactiveTintColor?: ColorValue;
|
|
20
18
|
tabBarButtonTestID?: string;
|
|
21
19
|
tabBarAccessibilityLabel?: string;
|
|
22
|
-
/** Expo Router's `href`. `null` hides the tab. */
|
|
23
20
|
href?: string | null;
|
|
24
|
-
/** Only `display: "none"` is read: it hides the tab, as in React Navigation's own bar. */
|
|
25
21
|
tabBarItemStyle?: StyleProp<ViewStyle>;
|
|
26
|
-
/**
|
|
27
|
-
* Only `display: "none"` is read: on the focused route it hides the whole
|
|
28
|
-
* bar, as in React Navigation's own bar (for example while a screen is in
|
|
29
|
-
* select mode and shows its `BulkActionBar` in the bar's place). Typed
|
|
30
|
-
* loosely: Expo Router's own type is an animated style, each member of
|
|
31
|
-
* which is an object, a falsy value or `void` (a mapped animated field).
|
|
32
|
-
* `displayOf` reads only `display`.
|
|
33
|
-
*/
|
|
34
22
|
tabBarStyle?: object | false | "" | null | void;
|
|
35
23
|
};
|
|
36
24
|
|
|
37
|
-
/** The `display` a style resolves to: in an array the last one set wins, as in `StyleSheet.flatten`. */
|
|
38
25
|
function displayOf(style: unknown): unknown {
|
|
39
26
|
if (Array.isArray(style)) {
|
|
40
27
|
let display: unknown;
|
package/src/tabIndicator.ts
CHANGED
|
@@ -3,9 +3,6 @@ import { useState } from "react";
|
|
|
3
3
|
import type { LayoutChangeEvent } from "react-native";
|
|
4
4
|
import Animated, { interpolate, interpolateColor, useAnimatedStyle, type SharedValue } from "react-native-reanimated";
|
|
5
5
|
|
|
6
|
-
// The tab labels are `Animated.Text`s (their colour follows `progress`).
|
|
7
|
-
// NativeWind maps `className` only for components it knows, so it is told
|
|
8
|
-
// about this one, or the labels lose their font and size classes.
|
|
9
6
|
cssInterop(Animated.Text, { className: "style" });
|
|
10
7
|
|
|
11
8
|
/** A tab's box in its row, from its layout. */
|
|
@@ -21,7 +18,6 @@ export type TabBox = { x: number; y: number; width: number; height: number };
|
|
|
21
18
|
* measured (with or without `progress`), else empty.
|
|
22
19
|
*/
|
|
23
20
|
export function useTabIndicator(progress: SharedValue<number> | undefined, count: number) {
|
|
24
|
-
// Each tab's box, measured on layout (not per frame).
|
|
25
21
|
const [layouts, setLayouts] = useState<ReadonlyArray<TabBox | undefined>>([]);
|
|
26
22
|
const found = layouts.slice(0, count).filter((box) => box !== undefined);
|
|
27
23
|
const boxes = found.length === count ? found : [];
|
|
@@ -40,7 +36,6 @@ export function useTabIndicator(progress: SharedValue<number> | undefined, count
|
|
|
40
36
|
transform: [{ translateX: at((box) => box.x) }],
|
|
41
37
|
};
|
|
42
38
|
});
|
|
43
|
-
/** The `onLayout` of tab `index`. */
|
|
44
39
|
const onLayout = (index: number) => (event: LayoutChangeEvent) => {
|
|
45
40
|
const box = event.nativeEvent.layout;
|
|
46
41
|
setLayouts((current) => {
|
package/src/tailwind-preset.cjs
CHANGED
|
@@ -1,41 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `@vvedantb/native-ui/tailwind-preset`: the NativeWind / Tailwind preset the
|
|
3
|
-
* Expo apps share. CommonJS, because `tailwind.config.js` `require`s it and
|
|
4
|
-
* Tailwind loads it outside Metro.
|
|
5
|
-
*
|
|
6
|
-
* const { nativeUiPreset, nativeUiContent } = require("@vvedantb/native-ui/tailwind-preset");
|
|
7
|
-
* module.exports = {
|
|
8
|
-
* content: ["./app/**\/*.{js,ts,tsx}", nativeUiContent()],
|
|
9
|
-
* presets: [nativeUiPreset()],
|
|
10
|
-
* };
|
|
11
|
-
*
|
|
12
|
-
* It nests `nativewind/preset`, so callers pass only this one. It sets
|
|
13
|
-
* `darkMode`, the `font-instrument-sans*` font classes (Instrument Sans unless
|
|
14
|
-
* `font` names other families), the colour keys native-ui
|
|
15
|
-
* classes use, `borderWidth.hairline` and, when asked, `borderRadius` from
|
|
16
|
-
* `--radius`.
|
|
17
|
-
* App colours, display fonts, keyframes and font-weight plugins stay in the
|
|
18
|
-
* app config.
|
|
19
|
-
*
|
|
20
|
-
* `color` maps a CSS variable name (without `--`) to a Tailwind colour, as the
|
|
21
|
-
* web `tokensPreset({ color })` of `@vvedantb/ui`. With `injectCssVariables`,
|
|
22
|
-
* the preset also writes those variables (light and dark) from `tokens.ts` and
|
|
23
|
-
* `palette.ts`, as space-separated RGB channels, and the default `color` is
|
|
24
|
-
* `rgbAlpha`.
|
|
25
|
-
*/
|
|
26
1
|
"use strict";
|
|
27
2
|
|
|
28
3
|
const fs = require("node:fs");
|
|
29
4
|
const path = require("node:path");
|
|
30
5
|
|
|
31
|
-
/** `var(--name)`. */
|
|
32
6
|
const cssVar = (name) => `var(--${name})`;
|
|
33
|
-
/** `hsl(var(--name))`, for variables that hold `h s% l%` channels. */
|
|
34
7
|
const hslVar = (name) => `hsl(var(--${name}))`;
|
|
35
|
-
/** `rgb(var(--name) / <alpha-value>)`, for variables that hold `r g b` channels. Keeps opacity modifiers. */
|
|
36
8
|
const rgbAlpha = (name) => `rgb(var(--${name}) / <alpha-value>)`;
|
|
37
9
|
|
|
38
|
-
/** The default families of the four font classes, as `fontFamily` in `typography.ts`. */
|
|
39
10
|
const INSTRUMENT_SANS = {
|
|
40
11
|
regular: "InstrumentSans_400Regular",
|
|
41
12
|
medium: "InstrumentSans_500Medium",
|
|
@@ -43,16 +14,10 @@ const INSTRUMENT_SANS = {
|
|
|
43
14
|
bold: "InstrumentSans_700Bold",
|
|
44
15
|
};
|
|
45
16
|
|
|
46
|
-
/** The glob Tailwind scans for native-ui class names: this package's `src`, at its real path (pnpm symlinks resolve). */
|
|
47
17
|
function nativeUiContent() {
|
|
48
18
|
return path.join(__dirname, "**/*.{js,ts,tsx}").split(path.sep).join("/");
|
|
49
19
|
}
|
|
50
20
|
|
|
51
|
-
/**
|
|
52
|
-
* Reads one `export const name = { … } as const;` object from a sibling
|
|
53
|
-
* `.ts` file. Plain object literals only, so no TypeScript loader is needed:
|
|
54
|
-
* `tokens.ts` and `palette.ts` stay the single source of the colours.
|
|
55
|
-
*/
|
|
56
21
|
function readConst(file, name) {
|
|
57
22
|
const source = fs.readFileSync(path.join(__dirname, file), "utf8");
|
|
58
23
|
const match = source.match(new RegExp(`export const ${name} = (\\{[\\s\\S]*?\\n\\}) as const;`));
|
|
@@ -62,7 +27,6 @@ function readConst(file, name) {
|
|
|
62
27
|
|
|
63
28
|
let cachedSchemeColors = null;
|
|
64
29
|
|
|
65
|
-
/** CSS variable name → `{ light, dark }` hex, from `tokens.ts` and `palette.ts`. */
|
|
66
30
|
function schemeColors() {
|
|
67
31
|
if (cachedSchemeColors) return cachedSchemeColors;
|
|
68
32
|
const tokens = readConst("tokens.ts", "tokens");
|
|
@@ -110,25 +74,21 @@ function schemeColors() {
|
|
|
110
74
|
return cachedSchemeColors;
|
|
111
75
|
}
|
|
112
76
|
|
|
113
|
-
/** `#rrggbb` as `r g b`. */
|
|
114
77
|
function channels(hex) {
|
|
115
78
|
const n = Number.parseInt(hex.slice(1, 7), 16);
|
|
116
79
|
return `${(n >> 16) & 255} ${(n >> 8) & 255} ${n & 255}`;
|
|
117
80
|
}
|
|
118
81
|
|
|
119
|
-
/** `--name: r g b` for every colour in one scheme. */
|
|
120
82
|
function cssVariables(scheme) {
|
|
121
83
|
return Object.fromEntries(
|
|
122
84
|
Object.entries(schemeColors()).map(([name, value]) => [`--${name}`, channels(value[scheme])]),
|
|
123
85
|
);
|
|
124
86
|
}
|
|
125
87
|
|
|
126
|
-
/** `--radius` from `tokens.radius.lg` (16), so `rounded-lg`, `-md` and `-sm` are 16, 14 and 12 as in `tokens.radius`. */
|
|
127
88
|
function radiusVariable() {
|
|
128
89
|
return { "--radius": `${readConst("tokens.ts", "tokens").radius.lg}px` };
|
|
129
90
|
}
|
|
130
91
|
|
|
131
|
-
/** The Tailwind colour keys native-ui classes and the apps share. */
|
|
132
92
|
function themeColors(v) {
|
|
133
93
|
return {
|
|
134
94
|
background: v("background"),
|
|
@@ -160,7 +120,6 @@ function themeColors(v) {
|
|
|
160
120
|
};
|
|
161
121
|
}
|
|
162
122
|
|
|
163
|
-
/** `nativewind/preset`, or none where NativeWind is not installed (this repository's tests). */
|
|
164
123
|
function nestedPresets() {
|
|
165
124
|
try {
|
|
166
125
|
return [require("nativewind/preset")];
|
|
@@ -169,7 +128,6 @@ function nestedPresets() {
|
|
|
169
128
|
}
|
|
170
129
|
}
|
|
171
130
|
|
|
172
|
-
/** `{ hairline: hairlineWidth() }` from `nativewind/theme`, or none without NativeWind. */
|
|
173
131
|
function hairlineBorder() {
|
|
174
132
|
try {
|
|
175
133
|
const { hairlineWidth } = require("nativewind/theme");
|
|
@@ -179,7 +137,6 @@ function hairlineBorder() {
|
|
|
179
137
|
}
|
|
180
138
|
}
|
|
181
139
|
|
|
182
|
-
/** A Tailwind plugin that writes the colour variables: `:root` (light) and the dark set for `darkMode`. */
|
|
183
140
|
function cssVariablesPlugin(darkMode) {
|
|
184
141
|
return function nativeUiCssVariables({ addBase }) {
|
|
185
142
|
const dark = cssVariables("dark");
|
|
@@ -197,17 +154,6 @@ function cssVariablesPlugin(darkMode) {
|
|
|
197
154
|
};
|
|
198
155
|
}
|
|
199
156
|
|
|
200
|
-
/**
|
|
201
|
-
* The preset. Options:
|
|
202
|
-
* - `darkMode`: `"class"` (default; `ThemeToggle` and `setColorScheme` need it) or `"media"`.
|
|
203
|
-
* - `color`: CSS variable name → colour value. Default `cssVar`, or `rgbAlpha` with `injectCssVariables`.
|
|
204
|
-
* - `injectCssVariables`: write the colour variables and `--radius` from `tokens.ts` and `palette.ts`. Default `false`.
|
|
205
|
-
* - `radiusVariable`: `rounded-lg`, `-md` and `-sm` from `var(--radius)`, as vibot and Velth. Default: on with
|
|
206
|
-
* `injectCssVariables`, else off, so an app without `--radius` keeps the Tailwind radii.
|
|
207
|
-
* - `font`: `{ regular, medium, semibold, bold }` family names for `sans` and the four `font-instrument-sans*`
|
|
208
|
-
* classes. Keys not given keep Instrument Sans. Pass the same names to `configureTheme({ font })`, which sets
|
|
209
|
-
* the JS styles; the app loads the font files.
|
|
210
|
-
*/
|
|
211
157
|
function nativeUiPreset(options = {}) {
|
|
212
158
|
const darkMode = options.darkMode === "media" ? "media" : "class";
|
|
213
159
|
const font = { ...INSTRUMENT_SANS };
|
|
@@ -6,18 +6,10 @@ type CssDeclarations = Record<string, string>;
|
|
|
6
6
|
type AddBase = (base: Record<string, CssDeclarations | Record<string, CssDeclarations>>) => void;
|
|
7
7
|
|
|
8
8
|
export interface NativeUiPresetOptions {
|
|
9
|
-
/** Default `"class"`: `ThemeToggle` and NativeWind `setColorScheme` need it. */
|
|
10
9
|
darkMode?: "class" | "media";
|
|
11
|
-
/** Default `cssVar`, or `rgbAlpha` with `injectCssVariables`. */
|
|
12
10
|
color?: ColorFn;
|
|
13
|
-
/** Write the colour variables (as `r g b` channels) and `--radius` from `tokens.ts` and `palette.ts`. Default `false`. */
|
|
14
11
|
injectCssVariables?: boolean;
|
|
15
|
-
/** `rounded-lg`, `-md` and `-sm` from `var(--radius)`. Default: the value of `injectCssVariables`. */
|
|
16
12
|
radiusVariable?: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Family names for `sans` and the four `font-instrument-sans*` classes. Keys not given keep Instrument Sans.
|
|
19
|
-
* Pass the same names to `configureTheme({ font })`; the app loads the font files.
|
|
20
|
-
*/
|
|
21
13
|
font?: { regular?: string; medium?: string; semibold?: string; bold?: string };
|
|
22
14
|
}
|
|
23
15
|
|
package/src/theme.tsx
CHANGED
|
@@ -5,29 +5,34 @@ import { ThemeVersionContext } from "./useScheme";
|
|
|
5
5
|
|
|
6
6
|
export const DEFAULT_ACCENT = "#db2777";
|
|
7
7
|
|
|
8
|
+
export type NativeUiSurface = "glass" | "flat";
|
|
9
|
+
|
|
8
10
|
export type NativeUiTheme = {
|
|
9
11
|
largerText: boolean;
|
|
10
12
|
accentColor: string;
|
|
13
|
+
surface: NativeUiSurface;
|
|
11
14
|
};
|
|
12
15
|
|
|
13
16
|
const NativeUiContext = createContext<NativeUiTheme>({
|
|
14
17
|
largerText: false,
|
|
15
18
|
accentColor: DEFAULT_ACCENT,
|
|
19
|
+
surface: "glass",
|
|
16
20
|
});
|
|
17
21
|
|
|
18
22
|
export function NativeUiProvider({
|
|
19
23
|
largerText = false,
|
|
20
24
|
accentColor = DEFAULT_ACCENT,
|
|
25
|
+
surface = "glass",
|
|
21
26
|
children,
|
|
22
27
|
}: {
|
|
23
28
|
largerText?: boolean;
|
|
24
29
|
accentColor?: string;
|
|
30
|
+
surface?: NativeUiSurface;
|
|
25
31
|
children: ReactNode;
|
|
26
32
|
}) {
|
|
27
|
-
// Each `configureTheme` call redraws every part below that reads the scheme.
|
|
28
33
|
const themeVersion = useSyncExternalStore(subscribeTheme, getThemeVersion, getThemeVersion);
|
|
29
34
|
return (
|
|
30
|
-
<NativeUiContext.Provider value={{ largerText, accentColor }}>
|
|
35
|
+
<NativeUiContext.Provider value={{ largerText, accentColor, surface }}>
|
|
31
36
|
<ThemeVersionContext.Provider value={themeVersion}>{children}</ThemeVersionContext.Provider>
|
|
32
37
|
</NativeUiContext.Provider>
|
|
33
38
|
);
|
|
@@ -41,6 +46,10 @@ export function useLargerText() {
|
|
|
41
46
|
return useContext(NativeUiContext).largerText;
|
|
42
47
|
}
|
|
43
48
|
|
|
49
|
+
export function useSurface() {
|
|
50
|
+
return useContext(NativeUiContext).surface;
|
|
51
|
+
}
|
|
52
|
+
|
|
44
53
|
export function useAccentColor() {
|
|
45
54
|
return useContext(NativeUiContext).accentColor;
|
|
46
55
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { colorScheme } from "nativewind";
|
|
2
|
+
import { useSyncExternalStore } from "react";
|
|
3
|
+
import { paintDarkFamily } from "./neutralTheme";
|
|
4
|
+
import { parseThemeMode, type ThemeMode } from "./themeModes";
|
|
5
|
+
|
|
6
|
+
/** Where the mode is kept: SecureStore, AsyncStorage or the app's own store. Sync or async. */
|
|
7
|
+
export type ThemeModeStorage = {
|
|
8
|
+
getItem: (key: string) => Promise<string | null> | string | null;
|
|
9
|
+
setItem: (key: string, value: string) => Promise<void> | void;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type ThemeModeStoreOptions = {
|
|
13
|
+
key: string;
|
|
14
|
+
storage: ThemeModeStorage;
|
|
15
|
+
onError?: (error: Error) => void;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type ThemeModeStore = {
|
|
19
|
+
getMode: () => ThemeMode;
|
|
20
|
+
subscribe: (listener: () => void) => () => void;
|
|
21
|
+
restore: () => Promise<void>;
|
|
22
|
+
set: (mode: ThemeMode) => void;
|
|
23
|
+
useMode: () => ThemeMode;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
function toError(error: Error | string | number | boolean | object | null | undefined): Error {
|
|
27
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The appearance mode of this phone: light, neutral, dark or system, starting
|
|
32
|
+
* at "system". Neutral is the NativeWind dark scheme with the Neutral palette
|
|
33
|
+
* in the kit's dark slot (`paintDarkFamily`).
|
|
34
|
+
*/
|
|
35
|
+
export function createThemeModeStore({ key, storage, onError }: ThemeModeStoreOptions): ThemeModeStore {
|
|
36
|
+
let current: ThemeMode = "system";
|
|
37
|
+
let chosen = false;
|
|
38
|
+
const listeners = new Set<() => void>();
|
|
39
|
+
const report = (error: Error | string | number | boolean | object | null | undefined) => onError?.(toError(error));
|
|
40
|
+
|
|
41
|
+
function apply(mode: ThemeMode) {
|
|
42
|
+
current = mode;
|
|
43
|
+
paintDarkFamily(mode === "neutral" ? "neutral" : "dark");
|
|
44
|
+
colorScheme.set(mode === "neutral" ? "dark" : mode);
|
|
45
|
+
for (const listener of listeners) listener();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function subscribe(listener: () => void) {
|
|
49
|
+
listeners.add(listener);
|
|
50
|
+
return () => {
|
|
51
|
+
listeners.delete(listener);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const getMode = () => current;
|
|
56
|
+
|
|
57
|
+
async function restore() {
|
|
58
|
+
let saved: string | null = null;
|
|
59
|
+
try {
|
|
60
|
+
saved = await storage.getItem(key);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
report(error instanceof Error ? error : String(error));
|
|
63
|
+
}
|
|
64
|
+
if (chosen) return;
|
|
65
|
+
apply(parseThemeMode(saved) ?? "system");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function set(mode: ThemeMode) {
|
|
69
|
+
chosen = true;
|
|
70
|
+
if (mode !== current) apply(mode);
|
|
71
|
+
Promise.resolve()
|
|
72
|
+
.then(() => storage.setItem(key, mode))
|
|
73
|
+
.catch(report);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const getServerSnapshot = (): ThemeMode => "system";
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
getMode,
|
|
80
|
+
subscribe,
|
|
81
|
+
restore,
|
|
82
|
+
set,
|
|
83
|
+
useMode: () => useSyncExternalStore(subscribe, getMode, getServerSnapshot),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** A theme the picker can show, as the web `ThemeModePicker`. Neutral is the dark scheme with a grey palette. */
|
|
2
|
+
export type ThemeMode = "light" | "neutral" | "dark" | "system";
|
|
3
|
+
|
|
4
|
+
/** Default order: light to dark, then system. */
|
|
5
|
+
export const THEME_MODES = ["light", "neutral", "dark", "system"] as const satisfies readonly ThemeMode[];
|
|
6
|
+
|
|
7
|
+
/** The mode that `value` names, or `undefined` for anything else (a missing or stale stored value). */
|
|
8
|
+
export function parseThemeMode(value: string | null | undefined): ThemeMode | undefined {
|
|
9
|
+
return THEME_MODES.find((mode) => mode === value);
|
|
10
|
+
}
|
package/src/toastChrome.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The `Toaster` look, from the web `SonnerToaster` at its default density
|
|
3
|
-
* (`createToasterClassNames` in `sonner.tsx`) with `toastIcons="filled24"`
|
|
4
|
-
* (`sonner-icons.tsx`). No React Native import, so the tests can load this
|
|
5
|
-
* file.
|
|
6
|
-
*/
|
|
7
1
|
import { palette, withAlpha } from "./palette";
|
|
8
2
|
import { tokens } from "./tokens";
|
|
9
3
|
|
package/src/toastDrag.ts
CHANGED
|
@@ -1,23 +1,12 @@
|
|
|
1
1
|
import { createContext, type ComponentType, type ReactNode } from "react";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* The rules of a toast's drag to dismiss, as plain numbers, so they stay
|
|
5
|
-
* testable apart from the gesture. A toast enters down from the top edge, so
|
|
6
|
-
* it leaves the same way: up. `dy` is the drag's travel in points (up
|
|
7
|
-
* negative) and `vy` the finger's speed in points per second (the Gesture
|
|
8
|
-
* Handler unit). Each rule is a worklet, so the drag runs it on the UI thread.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
3
|
/** Vertical travel (pt) before a drag takes the toast: a tap still presses it. */
|
|
12
4
|
export const TOAST_DRAG_ACTIVE_OFFSET_Y = 8;
|
|
13
5
|
|
|
14
|
-
/** A flick up at this speed (pt/s) dismisses the toast, however short the drag. */
|
|
15
6
|
const FLICK_VELOCITY = 500;
|
|
16
7
|
|
|
17
|
-
/** How far ahead (s) the release velocity carries the toast when deciding to dismiss it. */
|
|
18
8
|
const PROJECTION_S = 0.2;
|
|
19
9
|
|
|
20
|
-
/** How far a downward pull may move the toast: it is already as low as it goes. */
|
|
21
10
|
const DOWN_REACH = 24;
|
|
22
11
|
|
|
23
12
|
/**
|
|
@@ -43,9 +32,7 @@ export function toastDragDismisses(dy: number, vy: number, height: number): bool
|
|
|
43
32
|
}
|
|
44
33
|
|
|
45
34
|
export type ToastDragProps = {
|
|
46
|
-
/** The drag dismissed the toast: it has left the screen. */
|
|
47
35
|
onDismiss: () => void;
|
|
48
|
-
/** A finger is on the toast (`true`), or has lifted: the toast's timer pauses meanwhile. */
|
|
49
36
|
onHoldChange: (held: boolean) => void;
|
|
50
37
|
children: ReactNode;
|
|
51
38
|
};
|
package/src/toastStore.ts
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
// Module-level toast queue behind `toast()` and `<Toaster />`. No React Native
|
|
2
|
-
// imports, so it runs anywhere (tests, non-component code).
|
|
3
|
-
|
|
4
1
|
export type ToastVariant = "default" | "success" | "error" | "warning" | "info" | "loading";
|
|
5
2
|
|
|
6
3
|
export type ToastOptions = {
|
|
7
|
-
/** Reuse an id to replace a toast in place, for example a `loading` toast with its result. */
|
|
8
4
|
id?: string;
|
|
9
5
|
description?: string;
|
|
10
|
-
/** Milliseconds before it closes. Default 4000; `loading` stays until replaced or dismissed. `Infinity` keeps any toast open. */
|
|
11
6
|
duration?: number;
|
|
12
|
-
/** One text button. A press runs `onPress` and closes the toast. */
|
|
13
7
|
action?: { label: string; onPress: () => void };
|
|
14
8
|
};
|
|
15
9
|
|
|
@@ -77,7 +71,6 @@ export const toast = Object.assign(
|
|
|
77
71
|
warning: (title: string, options?: ToastOptions) => show("warning", title, options),
|
|
78
72
|
info: (title: string, options?: ToastOptions) => show("info", title, options),
|
|
79
73
|
loading: (title: string, options?: ToastOptions) => show("loading", title, options),
|
|
80
|
-
/** Closes one toast, or every toast without an id. */
|
|
81
74
|
dismiss(id?: string) {
|
|
82
75
|
toasts = id === undefined ? [] : toasts.filter((toast) => toast.id !== id);
|
|
83
76
|
emit();
|
package/src/updateCheck.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// The update check behind `UpdateChecker`: for an app that ships its Android
|
|
2
|
-
// APK as GitHub releases tagged `<tagPrefix><version>`, with no store and no
|
|
3
|
-
// over-the-air updates. Plain functions, no React and no native module.
|
|
4
|
-
|
|
5
1
|
/** A newer version to offer. `url` is what Download opens: the APK itself, else its release page. */
|
|
6
2
|
export type AvailableUpdate = { version: string; url: string };
|
|
7
3
|
|
|
@@ -15,21 +11,17 @@ export type GitHubRelease = {
|
|
|
15
11
|
};
|
|
16
12
|
|
|
17
13
|
export type GitHubReleaseSource = {
|
|
18
|
-
/** `"owner/name"` of a public repository. */
|
|
19
14
|
repo: string;
|
|
20
|
-
/** Tag prefix before the version, for example `"myapp-apk-"` for the tag `myapp-apk-1.2.3`. */
|
|
21
15
|
tagPrefix: string;
|
|
22
16
|
};
|
|
23
17
|
|
|
24
18
|
type VersionParts = [number, number, number];
|
|
25
19
|
|
|
26
|
-
/** `[major, minor, patch]` of "1.2.3", or null. */
|
|
27
20
|
function parseVersion(version: string): VersionParts | null {
|
|
28
21
|
const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(version);
|
|
29
22
|
return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : null;
|
|
30
23
|
}
|
|
31
24
|
|
|
32
|
-
/** Positive when `a` is newer than `b`. */
|
|
33
25
|
function compareParts(a: VersionParts, b: VersionParts): number {
|
|
34
26
|
return a[0] - b[0] || a[1] - b[1] || a[2] - b[2];
|
|
35
27
|
}
|
|
@@ -110,15 +102,8 @@ export async function fetchGitHubUpdate(
|
|
|
110
102
|
export const V_STORE_SITE_URL = "https://blessed-porcupine-303.eu-west-1.convex.site";
|
|
111
103
|
|
|
112
104
|
export type VStoreSource = {
|
|
113
|
-
/** The app's Android package, as V Store lists it. */
|
|
114
105
|
packageName: string;
|
|
115
|
-
/**
|
|
116
|
-
* What Download opens for a version: the APK, or its release page. Leave it
|
|
117
|
-
* out when the APK has no public link (a private repository). Download is
|
|
118
|
-
* then hidden, and "Install from V Store" is the one way to update.
|
|
119
|
-
*/
|
|
120
106
|
downloadUrl?: (version: string) => string;
|
|
121
|
-
/** Default `V_STORE_SITE_URL`. */
|
|
122
107
|
siteUrl?: string;
|
|
123
108
|
};
|
|
124
109
|
|
|
@@ -11,13 +11,9 @@ import { useScheme } from "../useScheme";
|
|
|
11
11
|
export const INLINE_VIDEO_ASPECT = 16 / 9;
|
|
12
12
|
|
|
13
13
|
export type InlineVideoProps = {
|
|
14
|
-
/** An http(s) or local video URL. */
|
|
15
14
|
url: string;
|
|
16
|
-
/** Width over height of the box, fixed so nothing moves when the video loads. Default 16:9. */
|
|
17
15
|
aspectRatio?: number;
|
|
18
|
-
/** An image to show before playback. Without it the box is black with the play button. */
|
|
19
16
|
posterUrl?: string;
|
|
20
|
-
/** Names the play button. Default "Play video". */
|
|
21
17
|
accessibilityLabel?: string;
|
|
22
18
|
testID?: string;
|
|
23
19
|
};
|
|
@@ -72,7 +68,6 @@ export function InlineVideo({ url, aspectRatio = INLINE_VIDEO_ASPECT, posterUrl,
|
|
|
72
68
|
);
|
|
73
69
|
}
|
|
74
70
|
|
|
75
|
-
/** Mounted on the first press: one player per pressed video, released when the row unmounts. */
|
|
76
71
|
function Player({ url }: { url: string }) {
|
|
77
72
|
const player = useVideoPlayer(url, (created) => {
|
|
78
73
|
created.loop = false;
|