@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
|
@@ -30,29 +30,11 @@ export const MARKDOWN_SCALE = {
|
|
|
30
30
|
} as const;
|
|
31
31
|
|
|
32
32
|
export type MarkdownProps = {
|
|
33
|
-
/** The markdown source. */
|
|
34
33
|
children: string;
|
|
35
|
-
/** With it, fenced code blocks get a copy button (native-ui adds no clipboard package). */
|
|
36
34
|
onCopyCode?: (code: string) => void | Promise<void>;
|
|
37
|
-
/** With it, tables get the web Copy table button: the table as Markdown, CSV or TSV. */
|
|
38
35
|
onCopyTable?: (text: string) => void | Promise<void>;
|
|
39
|
-
/**
|
|
40
|
-
* Body line height. Default `relaxed`, the web `.markdown` 1.625 (14 / 22.75).
|
|
41
|
-
* `normal` is the text size's own (14 / 20), as a web `Markdown` with
|
|
42
|
-
* `text-sm` on it: Eva's user bubbles.
|
|
43
|
-
*/
|
|
44
36
|
leading?: "relaxed" | "normal";
|
|
45
|
-
/**
|
|
46
|
-
* Draws a link your way (an app's mention chip): called with the link's
|
|
47
|
-
* href and plain text; return undefined to keep the default link.
|
|
48
|
-
*/
|
|
49
37
|
renderLink?: (href: string, text: string) => ReactNode | undefined;
|
|
50
|
-
/**
|
|
51
|
-
* Heading look. Default `default`, the web `.markdown` scale. `label`
|
|
52
|
-
* demotes every heading to a quiet section label (`text-xs` medium,
|
|
53
|
-
* uppercase, `tracking-wide`, muted, 16 above and 8 below), as a digest
|
|
54
|
-
* of short themed lists (Eva's standup cards) styles its `###` headings.
|
|
55
|
-
*/
|
|
56
38
|
headings?: MarkdownHeadings;
|
|
57
39
|
};
|
|
58
40
|
|
|
@@ -88,9 +70,6 @@ export function Markdown({ children, onCopyCode, onCopyTable, leading = "relaxed
|
|
|
88
70
|
},
|
|
89
71
|
styles: markdownStyles(scheme, body, color, headings),
|
|
90
72
|
});
|
|
91
|
-
// Every block has half the gap above and below (React Native margins do not
|
|
92
|
-
// collapse), so 16 between blocks; this takes the outer halves off, as the
|
|
93
|
-
// web `first-child:mt-0` and `last-child:mb-0`.
|
|
94
73
|
return <View style={{ marginVertical: -MARKDOWN_SCALE.blockGap / 2 }}>{elements}</View>;
|
|
95
74
|
}
|
|
96
75
|
|
|
@@ -108,8 +87,6 @@ export function markdownStyles(
|
|
|
108
87
|
...trackingStyle(12, "wide"),
|
|
109
88
|
textTransform: "uppercase",
|
|
110
89
|
color: tokens.color.muted[scheme],
|
|
111
|
-
// With the half gap each block keeps (margins do not collapse): 16 above,
|
|
112
|
-
// the next block's 8 below (the web `mt-4 mb-1.5`, collapsed).
|
|
113
90
|
marginTop: MARKDOWN_SCALE.blockGap / 2,
|
|
114
91
|
marginBottom: 0,
|
|
115
92
|
paddingBottom: 0,
|
|
@@ -123,14 +100,11 @@ export function markdownStyles(
|
|
|
123
100
|
letterSpacing: -0.01 * body.fontSize * scale,
|
|
124
101
|
color,
|
|
125
102
|
marginVertical: MARKDOWN_SCALE.blockGap / 2,
|
|
126
|
-
// `react-native-marked` rules h1 and h2 off; the web has no rule.
|
|
127
103
|
paddingBottom: 0,
|
|
128
104
|
borderBottomWidth: 0,
|
|
129
105
|
});
|
|
130
106
|
const heading = (scale: number): TextStyle => (headings === "label" ? label : scaled(scale));
|
|
131
107
|
const gap = { marginVertical: MARKDOWN_SCALE.blockGap / 2 };
|
|
132
|
-
// The library's inline styles start from its own 16 / 24 text, so each one
|
|
133
|
-
// restates the body size, or a bold or linked word grows the line.
|
|
134
108
|
const inline = { fontSize: body.fontSize, lineHeight: body.lineHeight };
|
|
135
109
|
return {
|
|
136
110
|
text: { fontFamily: fontFamily.regular, ...inline, color },
|
|
@@ -180,21 +154,12 @@ export function inlineCodeStyle(scheme: "light" | "dark", fontSize: number, colo
|
|
|
180
154
|
};
|
|
181
155
|
}
|
|
182
156
|
|
|
183
|
-
/**
|
|
184
|
-
* A paragraph block. A component of its own so `listItem` can find it in a
|
|
185
|
-
* loose list (the parser's own paragraph is a plain `View`).
|
|
186
|
-
*/
|
|
187
157
|
function Paragraph({ style, children }: { style?: StyleProp<ViewStyle>; children?: ReactNode }) {
|
|
188
158
|
return <View style={style}>{children}</View>;
|
|
189
159
|
}
|
|
190
160
|
|
|
191
161
|
type StyledNodeProps ={ children?: ReactNode; style?: StyleProp<TextStyle>; accessibilityRole?: string };
|
|
192
162
|
|
|
193
|
-
/**
|
|
194
|
-
* An inline-code chip (see `codespan`). A component of its own so
|
|
195
|
-
* `restyleText` can find it: NativeWind's JSX swaps a `Text` made in this
|
|
196
|
-
* file for its own wrapper, so the type no longer equals `Text`.
|
|
197
|
-
*/
|
|
198
163
|
function InlineCode({ style, children }: { style?: StyleProp<TextStyle>; children: string }) {
|
|
199
164
|
return (
|
|
200
165
|
<Text selectable style={style}>
|
|
@@ -203,12 +168,6 @@ function InlineCode({ style, children }: { style?: StyleProp<TextStyle>; childre
|
|
|
203
168
|
);
|
|
204
169
|
}
|
|
205
170
|
|
|
206
|
-
/**
|
|
207
|
-
* `node` with `map` applied to the style of every `Text` in it. The parser
|
|
208
|
-
* bakes the text style into each `Text`, and React Native text takes no
|
|
209
|
-
* style from a parent view, so a block that restyles its text (a quote, a
|
|
210
|
-
* table) rewrites it here. Links keep their own style.
|
|
211
|
-
*/
|
|
212
171
|
function restyleText(node: ReactNode, map: (style: TextStyle) => TextStyle): ReactNode {
|
|
213
172
|
return Children.map(node, (child) => {
|
|
214
173
|
if (!isValidElement<StyledNodeProps>(child)) return child;
|
|
@@ -221,7 +180,6 @@ function restyleText(node: ReactNode, map: (style: TextStyle) => TextStyle): Rea
|
|
|
221
180
|
});
|
|
222
181
|
}
|
|
223
182
|
|
|
224
|
-
/** A link's text with its styling stripped: the strings in it, in order. */
|
|
225
183
|
function plainText(node: ReactNode): string {
|
|
226
184
|
let out = "";
|
|
227
185
|
Children.forEach(node, (child) => {
|
|
@@ -231,10 +189,6 @@ function plainText(node: ReactNode): string {
|
|
|
231
189
|
return out;
|
|
232
190
|
}
|
|
233
191
|
|
|
234
|
-
/**
|
|
235
|
-
* A cell's plain text, as the web reads a cell's `textContent` for Copy
|
|
236
|
-
* table: inline code without the no-break spaces that pad its chip.
|
|
237
|
-
*/
|
|
238
192
|
function cellText(cell: ReactNode): string {
|
|
239
193
|
return nodeText(cell).trim();
|
|
240
194
|
}
|
|
@@ -253,12 +207,6 @@ function nodeText(node: ReactNode): string {
|
|
|
253
207
|
/** Web `.markdown` lists: 1.25rem (20) indent, 0.25rem (4) between items, muted markers (a 5-wide disc). */
|
|
254
208
|
export const MARKDOWN_LIST = { indent: 20, itemGap: 4, disc: 5 } as const;
|
|
255
209
|
|
|
256
|
-
/**
|
|
257
|
-
* `react-native-marked`'s renderer with native-ui code and lists: `CodeBlock`
|
|
258
|
-
* panels, inline-code chips, and lists drawn as the web `.markdown` lists
|
|
259
|
-
* (the library's own markers apply its marker style to every item). Links,
|
|
260
|
-
* quotes and tables are drawn here too.
|
|
261
|
-
*/
|
|
262
210
|
class NativeUiMarkdownRenderer extends Renderer {
|
|
263
211
|
constructor(
|
|
264
212
|
private readonly scheme: "light" | "dark",
|
|
@@ -271,11 +219,6 @@ class NativeUiMarkdownRenderer extends Renderer {
|
|
|
271
219
|
super();
|
|
272
220
|
}
|
|
273
221
|
|
|
274
|
-
/**
|
|
275
|
-
* Web `.markdown-link`, medium weight. The parser gives a link the
|
|
276
|
-
* paragraph's regular face, so the face is set here, on the link and the
|
|
277
|
-
* text in it.
|
|
278
|
-
*/
|
|
279
222
|
override link(children: string | ReactNode[], href: string, styles?: TextStyle, title?: string): ReactNode {
|
|
280
223
|
const custom = this.renderLink?.(href, plainText(children));
|
|
281
224
|
if (custom !== undefined) return <Fragment key={this.getKey()}>{custom}</Fragment>;
|
|
@@ -284,10 +227,8 @@ class NativeUiMarkdownRenderer extends Renderer {
|
|
|
284
227
|
return super.link(content, href, medium(styles ?? {}), title);
|
|
285
228
|
}
|
|
286
229
|
|
|
287
|
-
/** Web `.markdown blockquote`: the left rule, and the text in the muted colour. */
|
|
288
230
|
override blockquote(children: ReactNode[], styles?: ViewStyle): ReactNode {
|
|
289
231
|
const muted = tokens.color.muted[this.scheme];
|
|
290
|
-
// The inner blocks' outer margins come off, as web margins collapse into the quote's.
|
|
291
232
|
return (
|
|
292
233
|
<View key={this.getKey()} style={styles}>
|
|
293
234
|
<View style={{ marginVertical: -MARKDOWN_SCALE.blockGap / 2 }}>
|
|
@@ -297,15 +238,10 @@ class NativeUiMarkdownRenderer extends Renderer {
|
|
|
297
238
|
);
|
|
298
239
|
}
|
|
299
240
|
|
|
300
|
-
/**
|
|
301
|
-
* The web table on its panel (`MarkdownTable`): header cells semibold,
|
|
302
|
-
* rows split by a 70% border, and the table actions above it.
|
|
303
|
-
*/
|
|
304
241
|
override table(header: ReactNode[][], rows: ReactNode[][][]): ReactNode {
|
|
305
242
|
const { fontScale, lineHeight } = MARKDOWN_TABLE;
|
|
306
243
|
const small = (style: TextStyle): TextStyle => {
|
|
307
244
|
const size = typeof style.fontSize === "number" ? style.fontSize * fontScale : this.fontSize * fontScale;
|
|
308
|
-
// Body text takes the table line height; inline code keeps its own.
|
|
309
245
|
return style.fontFamily === MONO_FONT
|
|
310
246
|
? { ...style, fontSize: size }
|
|
311
247
|
: { ...style, fontSize: size, lineHeight: size * lineHeight };
|
|
@@ -332,11 +268,6 @@ class NativeUiMarkdownRenderer extends Renderer {
|
|
|
332
268
|
);
|
|
333
269
|
}
|
|
334
270
|
|
|
335
|
-
/**
|
|
336
|
-
* A loose list (items a blank line apart, as Eva's doc editor writes them)
|
|
337
|
-
* puts each item's text in a paragraph. Its outer margins come off, as in
|
|
338
|
-
* a quote, so the text sits on the marker's line, as the tight list.
|
|
339
|
-
*/
|
|
340
271
|
override listItem(children: ReactNode[], styles?: ViewStyle): ReactNode {
|
|
341
272
|
const loose = children.some((child) => isValidElement(child) && child.type === Paragraph);
|
|
342
273
|
if (!loose) return super.listItem(children, styles);
|
|
@@ -352,7 +283,6 @@ class NativeUiMarkdownRenderer extends Renderer {
|
|
|
352
283
|
}
|
|
353
284
|
|
|
354
285
|
override codespan(text: string): ReactNode {
|
|
355
|
-
// Text in Text takes no padding: no-break spaces pad the chip and keep it on one line.
|
|
356
286
|
return (
|
|
357
287
|
<InlineCode key={this.getKey()} style={inlineCodeStyle(this.scheme, this.fontSize, this.color)}>
|
|
358
288
|
{`\u00A0${text}\u00A0`}
|
|
@@ -369,7 +299,6 @@ class NativeUiMarkdownRenderer extends Renderer {
|
|
|
369
299
|
): ReactNode {
|
|
370
300
|
const muted = tokens.color.muted[this.scheme];
|
|
371
301
|
const lineHeight = typeof textStyle?.lineHeight === "number" ? textStyle.lineHeight : 24;
|
|
372
|
-
// A drawn disc: the font's bullet glyph is far smaller than the web `disc` marker.
|
|
373
302
|
const disc = MARKDOWN_LIST.disc;
|
|
374
303
|
return (
|
|
375
304
|
<View key={this.getKey()} style={{ marginVertical: MARKDOWN_SCALE.blockGap / 2, gap: MARKDOWN_LIST.itemGap }}>
|
|
@@ -30,23 +30,12 @@ export const MARKDOWN_TABLE = {
|
|
|
30
30
|
cellPaddingY: 7,
|
|
31
31
|
panelPadding: { top: 4, x: 5, bottom: 6 },
|
|
32
32
|
tableMargin: 10,
|
|
33
|
-
/** The web action row: 24 buttons in a 27 row. */
|
|
34
33
|
actionsHeight: 27,
|
|
35
|
-
/**
|
|
36
|
-
* The web buttons sit 4 apart; here 16, so each slops to 44 without
|
|
37
|
-
* taking its neighbour's taps.
|
|
38
|
-
*/
|
|
39
34
|
actionsGap: 16,
|
|
40
35
|
} as const;
|
|
41
36
|
|
|
42
|
-
/**
|
|
43
|
-
* The full-screen table sizes each column to its text, as the web table does
|
|
44
|
-
* (`markdownTableColumnWidths`). 8.5 a character fits the 12 mono of inline
|
|
45
|
-
* code with its chip padding, so a code cell does not wrap; body text is narrower.
|
|
46
|
-
*/
|
|
47
37
|
const FULL_SCREEN_COLUMN = { charWidth: 8.5, min: 72, max: 320 } as const;
|
|
48
38
|
|
|
49
|
-
/** The web Copy table menu, in its order. */
|
|
50
39
|
const COPY_FORMATS: ReadonlyArray<{ format: MarkdownTableFormat; title: string }> = [
|
|
51
40
|
{ format: "markdown", title: "Markdown" },
|
|
52
41
|
{ format: "csv", title: "CSV" },
|
|
@@ -54,27 +43,16 @@ const COPY_FORMATS: ReadonlyArray<{ format: MarkdownTableFormat; title: string }
|
|
|
54
43
|
];
|
|
55
44
|
|
|
56
45
|
export type MarkdownTableProps = {
|
|
57
|
-
/** Header cells, already styled. */
|
|
58
46
|
header: ReactNode[];
|
|
59
|
-
/** Body rows of cells, already styled. */
|
|
60
47
|
rows: ReactNode[][];
|
|
61
|
-
/** The same cells as plain text, for copying and for the full-screen column widths. */
|
|
62
48
|
data: MarkdownTableData;
|
|
63
|
-
/** The cell text colour. */
|
|
64
49
|
color: string;
|
|
65
|
-
/** With it, a Copy table button: a sheet of the web formats (Markdown, CSV, TSV). */
|
|
66
50
|
onCopy?: (text: string) => void | Promise<void>;
|
|
67
51
|
};
|
|
68
52
|
|
|
69
|
-
/**
|
|
70
|
-
* The cells as rows. `widths` gives every column its own width (the
|
|
71
|
-
* full-screen view, which scrolls sideways); without it the columns share the
|
|
72
|
-
* width equally and the cells wrap, so they line up in a chat column.
|
|
73
|
-
*/
|
|
74
53
|
function TableRows({ header, rows, color, widths }: Pick<MarkdownTableProps, "header" | "rows" | "color"> & { widths?: number[] }) {
|
|
75
54
|
const scheme = useScheme();
|
|
76
55
|
const { cellPaddingX, cellPaddingY } = MARKDOWN_TABLE;
|
|
77
|
-
// The header row is ruled off in the border colour, body rows at 70%.
|
|
78
56
|
const rule = (index: number) => (index === 1 ? tokens.color.border[scheme] : withAlpha(tokens.color.border[scheme], 0.7));
|
|
79
57
|
const row = (cells: ReactNode[], index: number) => (
|
|
80
58
|
<View key={index} style={{ flexDirection: "row", borderTopWidth: index > 0 ? 1 : 0, borderTopColor: rule(index) }}>
|
|
@@ -167,7 +145,6 @@ export function MarkdownTable({ header, rows, data, color, onCopy }: MarkdownTab
|
|
|
167
145
|
paddingRight: insets.right,
|
|
168
146
|
}}
|
|
169
147
|
>
|
|
170
|
-
{/* Web: the actions top right, Exit fullscreen last. */}
|
|
171
148
|
<View className="flex-row items-center justify-end px-2 py-1.5" style={{ gap: actionsGap }}>
|
|
172
149
|
{copyButton}
|
|
173
150
|
<ChatIconButton icon={IconX} label="Exit fullscreen" iconColor={muted} onPress={() => setFullScreen(false)} />
|
|
@@ -7,13 +7,11 @@ export type MarkdownTableData = { headers: string[]; rows: string[][] };
|
|
|
7
7
|
|
|
8
8
|
export type MarkdownTableFormat = "markdown" | "csv" | "tsv";
|
|
9
9
|
|
|
10
|
-
/** CSV: a cell with a comma, quote or line break is quoted, its quotes doubled. Lines join with `\n`. */
|
|
11
10
|
function toCsv({ headers, rows }: MarkdownTableData): string {
|
|
12
11
|
const cell = (text: string) => (/[",\n\r]/.test(text) ? `"${text.replace(/"/g, '""')}"` : text);
|
|
13
12
|
return [...(headers.length > 0 ? [headers] : []), ...rows].map((row) => row.map(cell).join(",")).join("\n");
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
/** TSV: tabs and line breaks in a cell are written as `\t`, `\n` and `\r`. */
|
|
17
15
|
function toTsv({ headers, rows }: MarkdownTableData): string {
|
|
18
16
|
const cell = (text: string) => text.replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r");
|
|
19
17
|
return [...(headers.length > 0 ? [headers] : []), ...rows].map((row) => row.map(cell).join("\t")).join("\n");
|
|
@@ -21,7 +19,6 @@ function toTsv({ headers, rows }: MarkdownTableData): string {
|
|
|
21
19
|
|
|
22
20
|
const MARKDOWN_ESCAPES: Record<string, string> = { "\\": "\\\\", "|": "\\|", "\n": "<br>", "&": "&", "<": "<", ">": ">" };
|
|
23
21
|
|
|
24
|
-
/** GitHub markdown: pipes and backslashes escaped, line breaks as `<br>`, short rows padded to the header. */
|
|
25
22
|
function toMarkdown({ headers, rows }: MarkdownTableData): string {
|
|
26
23
|
if (headers.length === 0) return "";
|
|
27
24
|
const cell = (text: string) => text.replace(/[\\|\n&<>]/g, (char) => MARKDOWN_ESCAPES[char] ?? char);
|
|
@@ -33,35 +33,23 @@ import {
|
|
|
33
33
|
|
|
34
34
|
export type PricingModalProps = {
|
|
35
35
|
open: boolean;
|
|
36
|
-
/** Called by the close button and Android back (and an iOS swipe-down). */
|
|
37
36
|
onClose: () => void;
|
|
38
|
-
/** Accessible title, read first. Not visible. */
|
|
39
37
|
title: string;
|
|
40
|
-
/** Accessible description. Not visible. */
|
|
41
38
|
description?: string;
|
|
42
|
-
/** Cards, top to bottom. */
|
|
43
39
|
plans: readonly PricingPlan[];
|
|
44
|
-
/** App marks at the top left. Family apps only: each links to its `FAMILY_APPS` site. */
|
|
45
40
|
apps?: readonly FamilyAppName[];
|
|
46
|
-
/** App the modal is shown in. Its `appBenefits` group comes first. */
|
|
47
41
|
currentApp?: ProductAppName;
|
|
48
|
-
/** Centred headline, for example "One plan. Every V app." */
|
|
49
42
|
headline?: ReactNode;
|
|
50
|
-
/** Small print under the cards. */
|
|
51
43
|
finePrint?: ReactNode;
|
|
52
44
|
billingPeriod?: PricingModalPeriod;
|
|
53
45
|
onBillingPeriodChange?: (period: PricingModalPeriod) => void;
|
|
54
|
-
/** Default `"month"`. */
|
|
55
46
|
defaultBillingPeriod?: PricingModalPeriod;
|
|
56
|
-
/** Called by a plan's button. Not called for the `current` plan. Route it to the store's purchase flow. */
|
|
57
47
|
onCheckout?: (plan: PricingPlan, period: PricingModalPeriod) => void;
|
|
58
|
-
/** Wraps each plan's button (the web `renderCheckout`). The button already calls `onCheckout`. Not called for the `current` plan. */
|
|
59
48
|
renderCheckout?: (
|
|
60
49
|
button: ReactElement,
|
|
61
50
|
plan: PricingPlan,
|
|
62
51
|
period: PricingModalPeriod,
|
|
63
52
|
) => ReactNode;
|
|
64
|
-
/** Called when an app mark is pressed. Without it the marks are not pressable. */
|
|
65
53
|
onAppPress?: (app: AppName, url: string) => void;
|
|
66
54
|
testID?: string;
|
|
67
55
|
};
|
|
@@ -117,7 +105,6 @@ export function PricingModal({
|
|
|
117
105
|
paddingBottom: insets.bottom,
|
|
118
106
|
}}
|
|
119
107
|
>
|
|
120
|
-
{/* The web `sr-only` DialogTitle: a visually hidden header. */}
|
|
121
108
|
<View
|
|
122
109
|
accessible
|
|
123
110
|
accessibilityRole="header"
|
|
@@ -5,25 +5,14 @@ import { tokens } from "../tokens";
|
|
|
5
5
|
import { useLargerText } from "../theme";
|
|
6
6
|
import { useScheme } from "../useScheme";
|
|
7
7
|
|
|
8
|
-
/** Web `rounded-2xl` (16) on the card. */
|
|
9
8
|
const RADIUS = tokens.radius.lg;
|
|
10
9
|
|
|
11
|
-
// The web `Button` `sm` (`h-8 px-3 text-xs`) uses `max-sm:hit-target`, 8 on
|
|
12
|
-
// each side: 32 + 16 = 48, as the native `Button` `small`.
|
|
13
10
|
const HIT_SLOP = 8;
|
|
14
11
|
|
|
15
12
|
export type UpgradeToProCardProps = {
|
|
16
|
-
/** Opens the app's `PricingModal`. */
|
|
17
13
|
onUpgrade: () => void;
|
|
18
|
-
/**
|
|
19
|
-
* A "Pro" pill (labelled with `title`) instead of the full card. Like the
|
|
20
|
-
* web `Button` it stretches across a column and fits its label in a row.
|
|
21
|
-
* Default `false`.
|
|
22
|
-
*/
|
|
23
14
|
collapsed?: boolean;
|
|
24
|
-
/** Default "Upgrade to Pro". */
|
|
25
15
|
title?: string;
|
|
26
|
-
/** Default "Upgrade". */
|
|
27
16
|
ctaLabel?: string;
|
|
28
17
|
className?: string;
|
|
29
18
|
testID?: string;
|
|
@@ -44,11 +33,8 @@ export function UpgradeToProCard({
|
|
|
44
33
|
}: UpgradeToProCardProps) {
|
|
45
34
|
const scheme = useScheme();
|
|
46
35
|
const largerText = useLargerText();
|
|
47
|
-
// Each class is also set as a style (`sizeStyle`): web `text-sm` is 14 / 20.
|
|
48
36
|
const titleSize = largerText ? "text-lg" : "text-sm";
|
|
49
37
|
const ctaSize = largerText ? "text-base" : "text-sm";
|
|
50
|
-
// The web pill is a `Button` `sm` (`font-medium`) in `bg-foreground text-background`,
|
|
51
|
-
// at the phone `Button` `sm` size: 36 high with a 14 label (the web h-8 `text-xs`).
|
|
52
38
|
const pill = (label: string, accessibilityLabel?: string) => (
|
|
53
39
|
<Pressable
|
|
54
40
|
testID={testID ? `${testID}-cta` : undefined}
|
package/src/marketing/pricing.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// Plan types and pure helpers for `PricingModal`, the same shapes and rules as
|
|
2
|
-
// the web `PricingModal` multi-plan layout. No React Native imports.
|
|
3
1
|
import type { ReactNode } from "react";
|
|
4
2
|
import type { AppName } from "../brand/svg";
|
|
5
3
|
import { V_PRO_APP_BENEFITS, type PricingPlanAppBenefit } from "../brand/vProAppBenefits";
|
|
@@ -8,32 +6,22 @@ export type PricingModalPeriod = "month" | "year";
|
|
|
8
6
|
|
|
9
7
|
export type PricingPlanBenefit = {
|
|
10
8
|
label: ReactNode;
|
|
11
|
-
/** `"check"` (default) or an app mark. */
|
|
12
9
|
icon?: "check" | AppName;
|
|
13
|
-
/** Dimmed row. */
|
|
14
10
|
muted?: boolean;
|
|
15
11
|
};
|
|
16
12
|
|
|
17
13
|
export type PricingPlan = {
|
|
18
14
|
id: string;
|
|
19
15
|
name: string;
|
|
20
|
-
/** Display strings per month, for example `{ month: "$10", year: "$8" }`. The yearly price is still per month. */
|
|
21
16
|
price: { month: string; year: string };
|
|
22
|
-
/** Default "Get started". */
|
|
23
17
|
ctaLabel?: string;
|
|
24
|
-
/** Line above the highlight, for example "Everything in Free, and:". */
|
|
25
18
|
intro?: ReactNode;
|
|
26
|
-
/** Large title with small text under it. */
|
|
27
19
|
highlight?: { title: string; description: string };
|
|
28
20
|
benefits?: readonly PricingPlanBenefit[];
|
|
29
|
-
/** Grouped per app, after `benefits`. The featured plan defaults to `V_PRO_APP_BENEFITS`. */
|
|
30
21
|
appBenefits?: readonly PricingPlanAppBenefit[];
|
|
31
|
-
/** The plan the user is on: the button reads "Current plan" and is disabled. */
|
|
32
22
|
current?: boolean;
|
|
33
|
-
/** Subtle ring on the card. `highlighted` is an alias. */
|
|
34
23
|
featured?: boolean;
|
|
35
24
|
highlighted?: boolean;
|
|
36
|
-
/** Text after the price. Default "/month". */
|
|
37
25
|
periodSuffix?: string;
|
|
38
26
|
};
|
|
39
27
|
|
|
@@ -13,7 +13,6 @@ import { imageAspect, imageGridTiles, imageViewerPage, MEDIA, type GalleryImage,
|
|
|
13
13
|
|
|
14
14
|
export type ImageGalleryProps = {
|
|
15
15
|
images: GalleryImage[];
|
|
16
|
-
/** With it, the viewer has an "Open in browser" button that hands it the image's URL. */
|
|
17
16
|
onOpenImage?: (url: string) => void;
|
|
18
17
|
testID?: string;
|
|
19
18
|
};
|
|
@@ -46,7 +45,6 @@ export function ImageGallery({ images, onOpenImage, testID }: ImageGalleryProps)
|
|
|
46
45
|
);
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
/** The hairline-ringed, rounded frame of a gallery image or grid. */
|
|
50
48
|
function useMediaFrame() {
|
|
51
49
|
const scheme = useScheme();
|
|
52
50
|
return {
|
|
@@ -58,11 +56,6 @@ function useMediaFrame() {
|
|
|
58
56
|
};
|
|
59
57
|
}
|
|
60
58
|
|
|
61
|
-
/**
|
|
62
|
-
* A lone image, sized from the column and the image's own shape and capped
|
|
63
|
-
* at 384 high, so a tall capture keeps its shape instead of being cropped.
|
|
64
|
-
* Until both are known it holds a full-width 4:3 box.
|
|
65
|
-
*/
|
|
66
59
|
function SingleImage({ image, onOpen }: { image: GalleryImage; onOpen: () => void }) {
|
|
67
60
|
const frame = useMediaFrame();
|
|
68
61
|
const [columnWidth, setColumnWidth] = useState(0);
|
|
@@ -90,11 +83,6 @@ function SingleImage({ image, onOpen }: { image: GalleryImage; onOpen: () => voi
|
|
|
90
83
|
);
|
|
91
84
|
}
|
|
92
85
|
|
|
93
|
-
/**
|
|
94
|
-
* Two columns of 4:3 tiles, filled as the web grid's rows are: tiles 0 and 2
|
|
95
|
-
* on the left, 1 and 3 on the right. With three, the first fills the left
|
|
96
|
-
* column, as tall as the two on the right.
|
|
97
|
-
*/
|
|
98
86
|
function ImageGrid({ images, onOpen }: { images: GalleryImage[]; onOpen: (index: number) => void }) {
|
|
99
87
|
const frame = useMediaFrame();
|
|
100
88
|
const tiles = imageGridTiles(images.length);
|
|
@@ -137,11 +125,9 @@ function ImageGrid({ images, onOpen }: { images: GalleryImage[]; onOpen: (index:
|
|
|
137
125
|
|
|
138
126
|
export type ImageViewerProps = {
|
|
139
127
|
images: GalleryImage[];
|
|
140
|
-
/** The image on screen; `null` while closed. */
|
|
141
128
|
index: number | null;
|
|
142
129
|
onIndexChange: (index: number) => void;
|
|
143
130
|
onClose: () => void;
|
|
144
|
-
/** With it, an "Open in browser" button hands it the image's URL. */
|
|
145
131
|
onOpenImage?: (url: string) => void;
|
|
146
132
|
};
|
|
147
133
|
|
|
@@ -158,8 +144,6 @@ export type ImageViewerProps = {
|
|
|
158
144
|
export function ImageViewer({ images, index, onIndexChange, onClose, onOpenImage }: ImageViewerProps) {
|
|
159
145
|
if (index === null) return null;
|
|
160
146
|
return (
|
|
161
|
-
// In the app's window (`WindowLayer`): a Modal's own window moved the focus on Android, and a chat
|
|
162
|
-
// list under the viewer scrolled to its newest message as it opened and closed.
|
|
163
147
|
<WindowLayer onRequestClose={onClose}>
|
|
164
148
|
<ViewerRoot>
|
|
165
149
|
<ViewerPages images={images} index={index} onIndexChange={onIndexChange} onClose={onClose} onOpenImage={onOpenImage} />
|
|
@@ -168,7 +152,6 @@ export function ImageViewer({ images, index, onIndexChange, onClose, onOpenImage
|
|
|
168
152
|
);
|
|
169
153
|
}
|
|
170
154
|
|
|
171
|
-
/** The zoom parts' gesture root, when there are zoom parts. */
|
|
172
155
|
function ViewerRoot({ children }: { children: ReactNode }) {
|
|
173
156
|
const zoom = useContext(ZoomImageContext);
|
|
174
157
|
return zoom ? <zoom.Root>{children}</zoom.Root> : children;
|
|
@@ -177,7 +160,6 @@ function ViewerRoot({ children }: { children: ReactNode }) {
|
|
|
177
160
|
function ViewerPages({ images, index, onIndexChange, onClose, onOpenImage }: Omit<ImageViewerProps, "index"> & { index: number }) {
|
|
178
161
|
const { width, height } = useWindowDimensions();
|
|
179
162
|
const zoom = useContext(ZoomImageContext);
|
|
180
|
-
// While the image on screen is zoomed, a drag pans it: the pages hold still.
|
|
181
163
|
const [zoomed, setZoomed] = useState(false);
|
|
182
164
|
const insets = useSafeAreaInsets();
|
|
183
165
|
const count = images.length;
|
package/src/media/MediaCard.tsx
CHANGED
|
@@ -8,21 +8,13 @@ import { useScheme } from "../useScheme";
|
|
|
8
8
|
export type MediaCardProps = {
|
|
9
9
|
icon: ComponentType<IconProps>;
|
|
10
10
|
title: string;
|
|
11
|
-
/** One muted line under the title. */
|
|
12
11
|
description?: string;
|
|
13
|
-
/** Makes the whole card one button. Then leave `action` out: a button cannot hold another. */
|
|
14
12
|
onPress?: () => void;
|
|
15
|
-
/** A control at the end, such as a delete button, for a card that is not itself a button. */
|
|
16
13
|
action?: ReactNode;
|
|
17
|
-
/** A glyph at the end of a pressable card, such as an open-in-browser arrow. Decorative. */
|
|
18
14
|
trailingIcon?: ComponentType<IconProps>;
|
|
19
|
-
/** Fill. Default `tokens.color.surface` (the web `bg-card`). */
|
|
20
15
|
backgroundColor?: string;
|
|
21
|
-
/** Title colour. Default the theme foreground. */
|
|
22
16
|
color?: string;
|
|
23
|
-
/** Icon and description colour. Default the theme muted. */
|
|
24
17
|
mutedColor?: string;
|
|
25
|
-
/** Names the pressable card. Default `title`. */
|
|
26
18
|
accessibilityLabel?: string;
|
|
27
19
|
accessibilityHint?: string;
|
|
28
20
|
testID?: string;
|
package/src/media/imageZoom.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// The zoom rules of `ImageViewer`, as plain worklets: the gesture part
|
|
2
|
-
// (`zoom-image-gesture`) runs them on the UI thread, and tests call them.
|
|
3
|
-
|
|
4
1
|
/** Fitted size is 1; a pinch goes up to 5 and rubber-bands a little past both ends. */
|
|
5
2
|
export const ZOOM = { min: 1, max: 5, doubleTap: 2.5 } as const;
|
|
6
3
|
|
|
@@ -47,7 +44,6 @@ export function doubleTapZoom(
|
|
|
47
44
|
"worklet";
|
|
48
45
|
if (scale > ZOOM.min) return { scale: ZOOM.min, x: 0, y: 0 };
|
|
49
46
|
const next = ZOOM.doubleTap;
|
|
50
|
-
// The tapped point, from centre, moves out by `next`; shift back by that much.
|
|
51
47
|
const x = -(point.x - size.width / 2) * (next - 1);
|
|
52
48
|
const y = -(point.y - size.height / 2) * (next - 1);
|
|
53
49
|
return { scale: next, x: clampPan(x, next, size.width), y: clampPan(y, next, size.height) };
|
|
@@ -5,24 +5,17 @@ import Animated, { ReduceMotion, runOnJS, useAnimatedStyle, useSharedValue, with
|
|
|
5
5
|
import type { ZoomImageParts, ZoomImageProps } from "./zoomImage";
|
|
6
6
|
import { clampPan, doubleTapZoom, isZoomed, settleScale, zoomScale, ZOOM } from "./imageZoom";
|
|
7
7
|
|
|
8
|
-
// Pinch, pan and double tap for an `ImageViewer` page, on Gesture Handler: the
|
|
9
|
-
// track phase runs as worklets on the UI thread, so the image never lags the
|
|
10
|
-
// fingers. The rules are plain worklets in `imageZoom`.
|
|
11
|
-
|
|
12
|
-
/** The settle after a release or a double tap: quick, no bounce past the edges. */
|
|
13
8
|
const ZOOM_SPRING = { duration: 300, dampingRatio: 1, reduceMotion: ReduceMotion.System } as const;
|
|
14
9
|
|
|
15
10
|
function ZoomImage({ image, width, height, onZoomChange }: ZoomImageProps) {
|
|
16
11
|
const scale = useSharedValue<number>(ZOOM.min);
|
|
17
12
|
const x = useSharedValue(0);
|
|
18
13
|
const y = useSharedValue(0);
|
|
19
|
-
// Where the gesture started: the scale and translation, and the pinch's focal point from centre.
|
|
20
14
|
const startScale = useSharedValue<number>(ZOOM.min);
|
|
21
15
|
const startX = useSharedValue(0);
|
|
22
16
|
const startY = useSharedValue(0);
|
|
23
17
|
const focalX = useSharedValue(0);
|
|
24
18
|
const focalY = useSharedValue(0);
|
|
25
|
-
// Pan only while zoomed: at fitted size a drag turns the page.
|
|
26
19
|
const [zoomed, setZoomed] = useState(false);
|
|
27
20
|
const report = (next: boolean) => {
|
|
28
21
|
setZoomed(next);
|
|
@@ -49,7 +42,6 @@ function ZoomImage({ image, width, height, onZoomChange }: ZoomImageProps) {
|
|
|
49
42
|
.onUpdate((event) => {
|
|
50
43
|
const next = zoomScale(startScale.get() * event.scale);
|
|
51
44
|
const ratio = next / startScale.get();
|
|
52
|
-
// The point under the fingers stays under them.
|
|
53
45
|
x.set(focalX.get() - (focalX.get() - startX.get()) * ratio);
|
|
54
46
|
y.set(focalY.get() - (focalY.get() - startY.get()) * ratio);
|
|
55
47
|
scale.set(next);
|
|
@@ -96,7 +88,6 @@ function ZoomImage({ image, width, height, onZoomChange }: ZoomImageProps) {
|
|
|
96
88
|
);
|
|
97
89
|
}
|
|
98
90
|
|
|
99
|
-
/** Gestures inside a `Modal` need a root view of their own. */
|
|
100
91
|
function ZoomRoot({ children }: { children: ReactNode }) {
|
|
101
92
|
return <GestureHandlerRootView style={styles.fill}>{children}</GestureHandlerRootView>;
|
|
102
93
|
}
|
package/src/media/zoomImage.ts
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { createContext, type ComponentType, type ReactNode } from "react";
|
|
2
2
|
import type { GalleryImage } from "./imageGrid";
|
|
3
3
|
|
|
4
|
-
// The seam between `ImageViewer` and its optional zoom (`zoom-image-gesture`),
|
|
5
|
-
// kept apart from both so the gesture provider does not load the viewer.
|
|
6
|
-
|
|
7
4
|
export type ZoomImageProps = {
|
|
8
5
|
image: GalleryImage;
|
|
9
|
-
/** The page's size: the image fits it at zoom 1. */
|
|
10
6
|
width: number;
|
|
11
7
|
height: number;
|
|
12
|
-
/** Called as the image zooms in past fitted size, and back: while zoomed, a drag pans it instead of turning the page. */
|
|
13
8
|
onZoomChange: (zoomed: boolean) => void;
|
|
14
9
|
};
|
|
15
10
|
|
package/src/motion.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { Easing, ReduceMotion } from "react-native-reanimated";
|
|
2
2
|
import { useReduceMotion } from "./useReduceMotion";
|
|
3
3
|
|
|
4
|
-
// The kit's motion values, from the `animate-expo` tables, so every part
|
|
5
|
-
// eases and springs in one family.
|
|
6
|
-
|
|
7
4
|
/** Strong ease-out: things entering or leaving the screen. */
|
|
8
5
|
export const EASE_OUT = Easing.bezier(0.23, 1, 0.32, 1);
|
|
9
6
|
|