@vvedantb/native-ui 0.38.0 → 0.40.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/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 +2 -3
- 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 +10 -18
- 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 +2 -29
- 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/auth/AuthScreen.jsx +0 -5
- package/dist/auth/GoogleSignInButton.jsx +0 -3
- package/dist/auth/SecondFactorScreen.jsx +0 -2
- package/dist/auth/SignInScreen.jsx +0 -17
- 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/lastCrash.js +3 -24
- package/dist/entries/ai.js +0 -3
- package/dist/entries/ambient.js +0 -2
- package/dist/entries/app-root.js +0 -5
- 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 +0 -3
- 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 +1 -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 +1 -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 +0 -5
- package/dist/pagerSwipe.js +0 -16
- package/dist/palette.js +0 -10
- package/dist/primitives/button.jsx +0 -5
- 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 -8
- 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 +0 -4
- 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 +0 -5
- 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 +3 -3
- 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 +2 -3
- 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 +5 -22
- 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 +1 -98
- 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 +0 -8
- package/src/app-root/SsoCallbackScreen.tsx +0 -10
- package/src/app-root/fonts.ts +0 -2
- package/src/auth/AccountScreens.tsx +0 -16
- package/src/auth/AuthProviders.tsx +0 -13
- package/src/auth/AuthScreen.tsx +0 -12
- package/src/auth/GoogleSignInButton.tsx +0 -12
- package/src/auth/SecondFactorScreen.tsx +0 -16
- package/src/auth/SignInScreen.tsx +0 -68
- 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 +0 -6
- package/src/crash/lastCrash.ts +0 -21
- package/src/entries/ai.ts +0 -3
- package/src/entries/ambient.ts +0 -2
- package/src/entries/app-root.ts +0 -5
- 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 +0 -3
- 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 +2 -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 +0 -20
- package/src/index.ts +2 -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 +0 -3
- 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/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 -16
- 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 +0 -11
- 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 +0 -9
- 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
|
@@ -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
|
|
package/src/neutralTheme.ts
CHANGED
|
@@ -24,7 +24,6 @@ export const NEUTRAL_CHANNELS = {
|
|
|
24
24
|
foreground: "250 250 250",
|
|
25
25
|
} as const;
|
|
26
26
|
|
|
27
|
-
/** The kit dark-slot values that Neutral changes. */
|
|
28
27
|
type DarkFamily = {
|
|
29
28
|
color: Record<
|
|
30
29
|
| "background"
|
|
@@ -41,7 +40,6 @@ type DarkFamily = {
|
|
|
41
40
|
palette: Record<"default" | "overlay" | "segment" | "surfaceTertiary" | "fieldPlaceholder" | "tabBarPill", string>;
|
|
42
41
|
};
|
|
43
42
|
|
|
44
|
-
/** The package dark values, copied at import so a Neutral pick can be undone. */
|
|
45
43
|
const DARK: DarkFamily = {
|
|
46
44
|
color: {
|
|
47
45
|
background: tokens.color.background.dark,
|
|
@@ -74,7 +72,6 @@ const NEUTRAL: DarkFamily = {
|
|
|
74
72
|
surface: NEUTRAL_PALETTE.surface,
|
|
75
73
|
surfaceSecondary: NEUTRAL_PALETTE.surfaceSecondary,
|
|
76
74
|
surfaceCard: NEUTRAL_PALETTE.surface,
|
|
77
|
-
// The package glass is its dark surface at 88%; Neutral's surface the same.
|
|
78
75
|
fill: withAlpha(NEUTRAL_PALETTE.surface, 0.88),
|
|
79
76
|
},
|
|
80
77
|
palette: {
|
package/src/pagerSwipe.ts
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The rules of a swiped `Pager`, as plain numbers, so they stay testable
|
|
3
|
-
* apart from the gesture. The pager's position is in pages: 0 is the first
|
|
4
|
-
* page, 1.5 is halfway between the second and the third. Distances are in
|
|
5
|
-
* points and velocities in points per second (the Gesture Handler units),
|
|
6
|
-
* positive to the right. Each rule is a worklet, so the drag runs it on the
|
|
7
|
-
* UI thread.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
1
|
/**
|
|
11
2
|
* Sideways travel (pt) before a drag takes the pager: twice a row swipe's
|
|
12
3
|
* (`SWIPE_ACTIVE_OFFSET_X`), so a swipeable row under the finger takes its
|
|
@@ -17,13 +8,10 @@ export const PAGER_ACTIVE_OFFSET_X = 24;
|
|
|
17
8
|
/** Vertical travel (pt) that leaves the touch to the page's own scroll. */
|
|
18
9
|
export const PAGER_FAIL_OFFSET_Y = 14;
|
|
19
10
|
|
|
20
|
-
/** A sideways flick at this speed (pt/s) turns the page, however short the drag. */
|
|
21
11
|
const FLICK_VELOCITY = 500;
|
|
22
12
|
|
|
23
|
-
/** How far ahead (s) the release velocity carries the pages when deciding where they settle. */
|
|
24
13
|
const PROJECTION_S = 0.2;
|
|
25
14
|
|
|
26
|
-
/** How far the pages move past the first or last page: less and less the further the finger goes. */
|
|
27
15
|
function rubberband(overshoot: number, dimension: number): number {
|
|
28
16
|
"worklet";
|
|
29
17
|
const constant = 0.55;
|
|
@@ -55,7 +43,6 @@ export function pagerPosition(start: number, dx: number, width: number, count: n
|
|
|
55
43
|
export function pagerSettle(position: number, vx: number, width: number, from: number, count: number): number {
|
|
56
44
|
"worklet";
|
|
57
45
|
const moved = position - from;
|
|
58
|
-
// A drag left (negative `vx`) moves toward the next page (a larger position).
|
|
59
46
|
const toward = -Math.sign(vx);
|
|
60
47
|
let target: number;
|
|
61
48
|
if (Math.abs(vx) >= FLICK_VELOCITY && moved !== 0 && toward === Math.sign(moved)) {
|
package/src/palette.ts
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
* drifts, so change `tokens.css` first and then this file.
|
|
10
10
|
*/
|
|
11
11
|
export const palette = {
|
|
12
|
-
/** `--accent` (web `primary`): near-black in light, near-white in dark. */
|
|
13
12
|
primary: { light: "#181818", dark: "#fcfcfc" },
|
|
14
13
|
primaryForeground: { light: "#fcfcfc", dark: "#181818" },
|
|
15
14
|
danger: { light: "#ff373c", dark: "#db3b3e" },
|
|
@@ -18,26 +17,17 @@ export const palette = {
|
|
|
18
17
|
successForeground: { light: "#161917", dark: "#161917" },
|
|
19
18
|
warning: { light: "#f5a523", dark: "#f7b750" },
|
|
20
19
|
warningForeground: { light: "#1a1815", dark: "#1a1815" },
|
|
21
|
-
/** `--default` (web `secondary`): neutral control fill. */
|
|
22
20
|
default: { light: "#ebebeb", dark: "#272727" },
|
|
23
21
|
defaultForeground: { light: "#181818", dark: "#fcfcfc" },
|
|
24
22
|
overlay: { light: "#ffffff", dark: "#181818" },
|
|
25
23
|
overlayForeground: { light: "#181818", dark: "#fcfcfc" },
|
|
26
24
|
segment: { light: "#ffffff", dark: "#474747" },
|
|
27
25
|
segmentForeground: { light: "#181818", dark: "#fcfcfc" },
|
|
28
|
-
/**
|
|
29
|
-
* The `FloatingTabBar` active pill: `--default` in light (it shows on the
|
|
30
|
-
* near-white glass bar) and `--segment` in dark. Its own key, so an app that
|
|
31
|
-
* themes `segment` for the segmented `Tabs` thumb keeps a pill that shows on
|
|
32
|
-
* the dark glass bar.
|
|
33
|
-
*/
|
|
34
26
|
tabBarPill: { light: "#ebebeb", dark: "#474747" },
|
|
35
27
|
surfaceTertiary: { light: "#eaeaea", dark: "#282627" },
|
|
36
28
|
fieldPlaceholder: { light: "#727272", dark: "#a0a0a0" },
|
|
37
29
|
backdrop: { light: "rgba(0, 0, 0, 0.5)", dark: "rgba(0, 0, 0, 0.6)" },
|
|
38
|
-
/** Web `DialogDescription` text: `--overlay-foreground` mixed 72% into `--overlay` (oklch), for 4.5:1 on the overlay. */
|
|
39
30
|
overlayMuted: { light: "#505050", dark: "#b5b5b5" },
|
|
40
|
-
/** Fill of the web destructive `Button` (`oklch(47.2% 0.195 25.7)`), the same in both schemes. */
|
|
41
31
|
destructive: "#af0015",
|
|
42
32
|
} as const;
|
|
43
33
|
|
package/src/pressScale.ts
CHANGED
|
@@ -14,19 +14,12 @@ export const AnimatedPressable = Animated.createAnimatedComponent(Pressable);
|
|
|
14
14
|
cssInterop(AnimatedPressable, { className: "style" });
|
|
15
15
|
|
|
16
16
|
export type PressScaleOptions = {
|
|
17
|
-
/** Scale while pressed. Default 0.97. */
|
|
18
17
|
scale?: number;
|
|
19
|
-
/** Opacity while pressed, a light dim. Default 0.7, the dim these controls had before the scale. */
|
|
20
18
|
dim?: number;
|
|
21
|
-
/** Dim used instead under Reduce Motion. Default `dim`. */
|
|
22
19
|
reducedDim?: number;
|
|
23
|
-
/** Opacity at rest, such as 0.5 when disabled. The press dims from here. Default 1. */
|
|
24
20
|
restOpacity?: number;
|
|
25
|
-
/** Press-in duration in ms. Default 120. */
|
|
26
21
|
pressInMs?: number;
|
|
27
|
-
/** Release duration in ms. Default 160. */
|
|
28
22
|
pressOutMs?: number;
|
|
29
|
-
/** A disabled control lets go at once, so it cannot stay pressed. */
|
|
30
23
|
disabled?: boolean;
|
|
31
24
|
};
|
|
32
25
|
|
|
@@ -40,8 +40,6 @@ const buttonVariants = cva(
|
|
|
40
40
|
lg: "h-11 px-6",
|
|
41
41
|
icon: "h-10 w-10",
|
|
42
42
|
},
|
|
43
|
-
// The web `shape`: `pill` (default) is fully round, `rounded` the radius
|
|
44
|
-
// before 0.6.0. `Button` also sets the radius as a style, which wins.
|
|
45
43
|
shape: {
|
|
46
44
|
pill: "rounded-full",
|
|
47
45
|
rounded: "rounded-lg",
|
|
@@ -55,8 +53,6 @@ const buttonVariants = cva(
|
|
|
55
53
|
},
|
|
56
54
|
);
|
|
57
55
|
|
|
58
|
-
// No weight: a class context cannot carry the `typeStyle` that a face class
|
|
59
|
-
// needs, so `Button` sets the medium face and its weight on its label.
|
|
60
56
|
const buttonTextVariants = cva("text-sm text-foreground", {
|
|
61
57
|
variants: {
|
|
62
58
|
variant: {
|
package/src/primitives/card.tsx
CHANGED
|
@@ -42,7 +42,6 @@ const CardTitle = React.forwardRef<
|
|
|
42
42
|
React.ElementRef<typeof Text>,
|
|
43
43
|
React.ComponentPropsWithoutRef<typeof Text> & { className?: string }
|
|
44
44
|
>(({ className, style, ...props }, ref) => {
|
|
45
|
-
// The web `font-medium`: the semibold face, with its weight as a style.
|
|
46
45
|
return (
|
|
47
46
|
<Text
|
|
48
47
|
ref={ref}
|
package/src/primitives/input.tsx
CHANGED
|
@@ -14,10 +14,6 @@ const Input = React.forwardRef<React.ElementRef<typeof TextInput>, InputProps>(
|
|
|
14
14
|
return (
|
|
15
15
|
<TextInput
|
|
16
16
|
ref={ref}
|
|
17
|
-
// A prop, not a `placeholder:` class: on native NativeWind turns that
|
|
18
|
-
// class into `placeholderTextColor`, which beats the prop. The old
|
|
19
|
-
// `placeholder:text-muted-foreground/50` was the light grey at half
|
|
20
|
-
// opacity in apps that nest `dark` under `muted-foreground`.
|
|
21
17
|
placeholderTextColor={placeholderTextColor ?? palette.fieldPlaceholder[scheme]}
|
|
22
18
|
className={cn(
|
|
23
19
|
"flex w-full flex-row items-center rounded-lg border-0 bg-secondary px-3 py-2 text-base text-foreground",
|
|
@@ -10,17 +10,6 @@ import {
|
|
|
10
10
|
import { runOnJS } from "react-native-reanimated";
|
|
11
11
|
import { COMPOSER_INPUT_ID, KeyboardPartsContext, type KeyboardParts } from "./keyboard-parts";
|
|
12
12
|
|
|
13
|
-
// The keyboard parts on `react-native-keyboard-controller`: the keyboard's
|
|
14
|
-
// real position, frame by frame, on the UI thread. No timing of our own, so
|
|
15
|
-
// the composer can neither lag nor lead the keyboard; with Reduce Motion the
|
|
16
|
-
// system shortens the keyboard's own motion and the parts follow it.
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* A drag moves the keyboard on iOS (`keyboardDismissMode="interactive"`) and
|
|
20
|
-
* on Android 11+ (API 30, `WindowInsetsAnimation`). Android 10 and below has
|
|
21
|
-
* no interactive keyboard: `KeyboardGestureArea` then only renders its
|
|
22
|
-
* children, and the transcript keeps `on-drag`.
|
|
23
|
-
*/
|
|
24
13
|
const INTERACTIVE = Platform.OS === "ios" || (Platform.OS === "android" && Number(Platform.Version) >= 30);
|
|
25
14
|
|
|
26
15
|
function AvoidingView(props: ComponentProps<KeyboardParts["AvoidingView"]>) {
|
|
@@ -31,15 +20,6 @@ function StickyView({ bottomOffset, ...props }: ComponentProps<KeyboardParts["St
|
|
|
31
20
|
return <KeyboardStickyView {...props} offset={{ opened: bottomOffset }} />;
|
|
32
21
|
}
|
|
33
22
|
|
|
34
|
-
/**
|
|
35
|
-
* `always`: the content rises with the keyboard wherever the reader is, so
|
|
36
|
-
* what sat on the composer stays there (the newest message, at the end).
|
|
37
|
-
* Inverted, the keyboard's space is the content's top inset, the visual
|
|
38
|
-
* bottom: iOS scrolls below offset 0 into it, so the end moves there; Android
|
|
39
|
-
* moves the content down by it instead, so offset 0 stays the end. While the
|
|
40
|
-
* keyboard moves, the list scrolls with it, through offsets that are not the
|
|
41
|
-
* end on either platform.
|
|
42
|
-
*/
|
|
43
23
|
function ChatScrollView({
|
|
44
24
|
bottomOffset,
|
|
45
25
|
inverted = false,
|
|
@@ -65,7 +45,6 @@ function ChatScrollView({
|
|
|
65
45
|
<KeyboardChatScrollView
|
|
66
46
|
{...props}
|
|
67
47
|
inverted={inverted}
|
|
68
|
-
// An overlay window (a hold menu) takes the focus on Android: its keyboard events must not scroll the list.
|
|
69
48
|
freeze={freeze}
|
|
70
49
|
offset={bottomOffset}
|
|
71
50
|
keyboardLiftBehavior="always"
|
|
@@ -76,10 +55,6 @@ function ChatScrollView({
|
|
|
76
55
|
);
|
|
77
56
|
}
|
|
78
57
|
|
|
79
|
-
/**
|
|
80
|
-
* `ios`: the keyboard follows once the finger reaches the composer, then 1:1,
|
|
81
|
-
* and a release carries the finger's velocity, on both platforms.
|
|
82
|
-
*/
|
|
83
58
|
function GestureArea({ offset, style, children }: ComponentProps<KeyboardParts["GestureArea"]>) {
|
|
84
59
|
return (
|
|
85
60
|
<KeyboardGestureArea interpolator="ios" offset={offset} textInputNativeID={COMPOSER_INPUT_ID} style={style}>
|
|
@@ -16,24 +16,8 @@ import {
|
|
|
16
16
|
* the peer and an app without it bundles as before.
|
|
17
17
|
*/
|
|
18
18
|
export type KeyboardParts = {
|
|
19
|
-
/** A `KeyboardAvoidingView` that pads frame by frame with the keyboard. */
|
|
20
19
|
AvoidingView: ComponentType<KeyboardAvoidingViewProps>;
|
|
21
|
-
/**
|
|
22
|
-
* Moves with the keyboard (`translateY`), less `bottomOffset` while it is
|
|
23
|
-
* open: the bottom inset the content pads, which the keyboard covers.
|
|
24
|
-
*/
|
|
25
20
|
StickyView: ComponentType<ViewProps & { bottomOffset: number }>;
|
|
26
|
-
/**
|
|
27
|
-
* The chat transcript's scroll view (a `FlatList` `renderScrollComponent`).
|
|
28
|
-
* Its content gains the keyboard height less `bottomOffset` at the end (at
|
|
29
|
-
* its start when `inverted`, the visual bottom either way), and moves up
|
|
30
|
-
* with the keyboard, so the newest message stays in view. `onInsetChange`
|
|
31
|
-
* gets that extra space as the scroll offset sees it, which `onScroll` does
|
|
32
|
-
* not report: past the content's end, or when `inverted` before offset 0.
|
|
33
|
-
* `onKeyboardMove` is true from the start to the end of each keyboard
|
|
34
|
-
* move, while the keyboard, not the reader, scrolls the list. With
|
|
35
|
-
* `freeze`, keyboard events change nothing (an overlay window is open).
|
|
36
|
-
*/
|
|
37
21
|
ChatScrollView: ComponentType<
|
|
38
22
|
ScrollViewProps & {
|
|
39
23
|
bottomOffset: number;
|
|
@@ -43,15 +27,7 @@ export type KeyboardParts = {
|
|
|
43
27
|
onKeyboardMove: (moving: boolean) => void;
|
|
44
28
|
}
|
|
45
29
|
>;
|
|
46
|
-
/**
|
|
47
|
-
* Around the transcript: a drag that reaches `offset` above the keyboard
|
|
48
|
-
* (the composer's top) moves the keyboard with the finger.
|
|
49
|
-
*/
|
|
50
30
|
GestureArea: ComponentType<{ offset: number; style?: StyleProp<ViewStyle>; children: ReactNode }>;
|
|
51
|
-
/**
|
|
52
|
-
* Whether a drag on the transcript moves the keyboard (iOS, Android 11+).
|
|
53
|
-
* False on Android 10 and below: there a drag lowers it at once.
|
|
54
|
-
*/
|
|
55
31
|
interactive: boolean;
|
|
56
32
|
};
|
|
57
33
|
|
|
@@ -83,12 +59,9 @@ export function useKeyboardParts(): KeyboardParts | null {
|
|
|
83
59
|
export const COMPOSER_INPUT_ID = "native-ui-composer";
|
|
84
60
|
|
|
85
61
|
export type KeyboardAvoidingViewProps = {
|
|
86
|
-
/** Default `padding`, on iOS and Android: Android `height` does nothing edge-to-edge. */
|
|
87
62
|
behavior?: "padding" | "height" | "position";
|
|
88
|
-
/** Height of anything above the view's top, such as a navigation header. Default 0. */
|
|
89
63
|
keyboardVerticalOffset?: number;
|
|
90
64
|
enabled?: boolean;
|
|
91
|
-
/** A style, not a class: the keyboard-controller view takes no NativeWind `className`. */
|
|
92
65
|
style?: StyleProp<ViewStyle>;
|
|
93
66
|
testID?: string;
|
|
94
67
|
children?: ReactNode;
|
|
@@ -8,11 +8,6 @@ type NativeOnlyAnimatedViewProps = ViewProps & {
|
|
|
8
8
|
layout?: AnimatedProps<ViewProps>["layout"];
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
/**
|
|
12
|
-
* `Animated.View` with layout animations on iOS and Android, a plain `View`
|
|
13
|
-
* on web. With Reduce Motion on, it drops the animations: sheets, toasts and
|
|
14
|
-
* the `Select` popover appear and leave in place.
|
|
15
|
-
*/
|
|
16
11
|
function NativeOnlyAnimatedView({
|
|
17
12
|
children,
|
|
18
13
|
entering,
|
|
@@ -53,11 +53,8 @@ export function useOverlay(part: string): OverlayContextValue {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
export type OverlayRootProps = {
|
|
56
|
-
/** Open state when the parent controls it. */
|
|
57
56
|
open?: boolean;
|
|
58
|
-
/** Initial open state when `open` is not set. Default `false`. */
|
|
59
57
|
defaultOpen?: boolean;
|
|
60
|
-
/** Called with the next open state (trigger, close, backdrop, Android back). */
|
|
61
58
|
onOpenChange?: (open: boolean) => void;
|
|
62
59
|
children?: ReactNode;
|
|
63
60
|
};
|
|
@@ -82,7 +79,6 @@ export function OverlayRoot({
|
|
|
82
79
|
}
|
|
83
80
|
|
|
84
81
|
export type OverlayPressableProps = ComponentPropsWithoutRef<typeof Pressable> & {
|
|
85
|
-
/** Merge the press handler into the single child (for example a `Button`) instead of wrapping it. */
|
|
86
82
|
asChild?: boolean;
|
|
87
83
|
};
|
|
88
84
|
|
|
@@ -144,7 +140,6 @@ export function OverlayModal({
|
|
|
144
140
|
part: string;
|
|
145
141
|
placement: "center" | "bottom";
|
|
146
142
|
dismissible: boolean;
|
|
147
|
-
/** Once the overlay is on screen: where to focus a field (see `DialogContent`'s `onShow`). */
|
|
148
143
|
onShow?: () => void;
|
|
149
144
|
children: ReactNode;
|
|
150
145
|
}) {
|
|
@@ -153,7 +148,6 @@ export function OverlayModal({
|
|
|
153
148
|
const reduceMotion = useReduceMotion();
|
|
154
149
|
const slides = placement === "bottom" && !reduceMotion;
|
|
155
150
|
const scales = placement === "center" && !reduceMotion;
|
|
156
|
-
// Up while open, and after a close until a sliding sheet or a scaling dialog is out of sight.
|
|
157
151
|
const [shown, setShown] = useState(open);
|
|
158
152
|
if (open && !shown) setShown(true);
|
|
159
153
|
if (!open && shown && !slides && !scales) setShown(false);
|
|
@@ -162,8 +156,6 @@ export function OverlayModal({
|
|
|
162
156
|
|
|
163
157
|
if (!shown) return null;
|
|
164
158
|
return (
|
|
165
|
-
// The layer runs its own motion, so no fade; a layer loses the context
|
|
166
|
-
// between it and the host, so the open state is provided again.
|
|
167
159
|
<WindowLayer onRequestClose={close} onShow={onShow} fade={false}>
|
|
168
160
|
<OverlayContext.Provider value={overlay}>
|
|
169
161
|
<ModalRoot>
|
|
@@ -185,7 +177,6 @@ export function OverlayModal({
|
|
|
185
177
|
);
|
|
186
178
|
}
|
|
187
179
|
|
|
188
|
-
/** The layer's content: mounted with each opening, so a sheet starts below the screen (or at rest). */
|
|
189
180
|
function OverlayModalBody({
|
|
190
181
|
part,
|
|
191
182
|
placement,
|
|
@@ -211,9 +202,6 @@ function OverlayModalBody({
|
|
|
211
202
|
const insets = useSafeAreaInsets();
|
|
212
203
|
const drag = useSheetDragState(close, slides);
|
|
213
204
|
const sheetBackdropStyle = useSheetBackdropStyle(drag);
|
|
214
|
-
// A centred dialog: one 0 to 1 `progress` drives the backdrop fade and the
|
|
215
|
-
// panel's scale and opacity. It mounts at 0 with each opening, and at 1
|
|
216
|
-
// under Reduce Motion, so there the dialog simply appears.
|
|
217
205
|
const progress = useSharedValue(scales ? 0 : 1);
|
|
218
206
|
const centreBackdropStyle = useAnimatedStyle(() => ({ opacity: progress.get() }));
|
|
219
207
|
const centrePanelStyle = useAnimatedStyle(() => ({
|
|
@@ -221,18 +209,11 @@ function OverlayModalBody({
|
|
|
221
209
|
transform: [{ scale: PANEL_SCALE_FROM + (1 - PANEL_SCALE_FROM) * progress.get() }],
|
|
222
210
|
}));
|
|
223
211
|
const backdropStyle = placement === "center" ? centreBackdropStyle : sheetBackdropStyle;
|
|
224
|
-
// The open state lives in React, the sheet's position on the UI thread:
|
|
225
|
-
// each change of `open` starts the slide that matches it. The slide in on
|
|
226
|
-
// opening starts from the sheet's first layout (`SheetDragView`).
|
|
227
212
|
useEffect(() => {
|
|
228
213
|
if (!slides) return;
|
|
229
214
|
if (open) slideSheetIn(drag);
|
|
230
215
|
else slideSheetOut(drag, onHidden);
|
|
231
|
-
// Only a change of `open` starts a slide; `drag` and `onHidden` keep their meaning.
|
|
232
216
|
}, [open, slides]);
|
|
233
|
-
// The same for a centred dialog, from wherever `progress` is. Opened again
|
|
234
|
-
// while it leaves, it turns back at once, and the exit callback reports
|
|
235
|
-
// `finished` false, so the layer stays up.
|
|
236
217
|
useEffect(() => {
|
|
237
218
|
if (!scales) return;
|
|
238
219
|
if (open) {
|
|
@@ -245,16 +226,10 @@ function OverlayModalBody({
|
|
|
245
226
|
}),
|
|
246
227
|
);
|
|
247
228
|
}
|
|
248
|
-
// As the slide: only a change of `open` starts it.
|
|
249
229
|
}, [open, scales]);
|
|
250
230
|
return (
|
|
251
231
|
<SheetDragProvider value={drag}>
|
|
252
|
-
{/* Android too: a modal window with `statusBarTranslucent` may not
|
|
253
|
-
resize for the keyboard, which then covers the fields. The padding
|
|
254
|
-
is the measured overlap, so it drops to 0 where the window does
|
|
255
|
-
resize. Frame by frame with `KeyboardControllerProvider`. */}
|
|
256
232
|
<KeyboardAvoidingView style={styles.fill}>
|
|
257
|
-
{/* Over the app, not in the dock it opened from: the dock's lift is not for it. */}
|
|
258
233
|
<KeyboardLiftContext.Provider value={false}>
|
|
259
234
|
<Animated.View
|
|
260
235
|
pointerEvents="box-none"
|
|
@@ -15,33 +15,21 @@ import { InsidePagerContext, type PagerProps } from "../Pager";
|
|
|
15
15
|
import { PAGER_ACTIVE_OFFSET_X, PAGER_FAIL_OFFSET_Y, pagerPosition, pagerSettle, pagesBetween } from "../pagerSwipe";
|
|
16
16
|
import { useWebClickGuard } from "./web-click-guard";
|
|
17
17
|
|
|
18
|
-
// The pager on Gesture Handler: the track phase and the release run as
|
|
19
|
-
// worklets on the UI thread, so the pages never lag the finger. The rules are
|
|
20
|
-
// plain worklets in `pagerSwipe`.
|
|
21
|
-
|
|
22
|
-
/** The release: springs on at the finger's speed, no bounce (an overshoot would flash the next page's edge). */
|
|
23
18
|
const PAGER_SPRING = { duration: 250, dampingRatio: 1, reduceMotion: ReduceMotion.System } as const;
|
|
24
19
|
|
|
25
|
-
/** A page set from outside (a tab press) slides there; at once with Reduce Motion. */
|
|
26
20
|
const PAGER_SLIDE = { duration: 220, reduceMotion: ReduceMotion.System } as const;
|
|
27
21
|
|
|
28
22
|
export function GesturePager({ index, count, onIndexChange, progress, renderPage }: PagerProps) {
|
|
29
23
|
const width = useSharedValue(0);
|
|
30
|
-
// Where the pages were when the finger caught them, and the finger's travel then.
|
|
31
24
|
const start = useSharedValue(0);
|
|
32
25
|
const startX = useSharedValue(0);
|
|
33
26
|
const [mounted, setMounted] = useState<ReadonlySet<number>>(() => new Set([index]));
|
|
34
27
|
const [shown, setShown] = useState(index);
|
|
35
|
-
// A page reached from outside is drawn from then on, with every page the
|
|
36
|
-
// slide there passes, so it never crosses a blank page.
|
|
37
28
|
if (shown !== index) {
|
|
38
29
|
setShown(index);
|
|
39
30
|
setMounted(new Set([...mounted, ...pagesBetween(shown, index)]));
|
|
40
31
|
}
|
|
41
|
-
// The page a swipe settled on, until the new `index` comes back: that one must not stop the spring.
|
|
42
32
|
const settling = useRef<number | null>(null);
|
|
43
|
-
// A page set from outside slides there. An effect: a shared value is never
|
|
44
|
-
// written in render.
|
|
45
33
|
useEffect(() => {
|
|
46
34
|
const fromSwipe = settling.current === index;
|
|
47
35
|
settling.current = null;
|
|
@@ -52,7 +40,6 @@ export function GesturePager({ index, count, onIndexChange, progress, renderPage
|
|
|
52
40
|
const webClicks = useWebClickGuard();
|
|
53
41
|
const dragStarted = () => {
|
|
54
42
|
webClicks.swallowNext();
|
|
55
|
-
// Both neighbours, so the finger finds a page there.
|
|
56
43
|
setMounted((current) => new Set([...current, index - 1, index + 1].filter((page) => page >= 0 && page < count)));
|
|
57
44
|
};
|
|
58
45
|
const settled = (page: number) => {
|
|
@@ -61,28 +48,22 @@ export function GesturePager({ index, count, onIndexChange, progress, renderPage
|
|
|
61
48
|
onIndexChange(page);
|
|
62
49
|
};
|
|
63
50
|
|
|
64
|
-
// Built on each render (for `index` and `count`): the detector keeps the
|
|
65
|
-
// same handler, and a drag in flight, and only takes the new config.
|
|
66
51
|
const pan = Gesture.Pan()
|
|
67
52
|
.enabled(count > 1)
|
|
68
|
-
// Clearly sideways only: a vertical drag is the page's scroll, and a row swipe starts sooner.
|
|
69
53
|
.activeOffsetX([-PAGER_ACTIVE_OFFSET_X, PAGER_ACTIVE_OFFSET_X])
|
|
70
54
|
.failOffsetY([-PAGER_FAIL_OFFSET_Y, PAGER_FAIL_OFFSET_Y])
|
|
71
55
|
.onStart((event) => {
|
|
72
56
|
cancelAnimation(progress);
|
|
73
57
|
start.set(progress.get());
|
|
74
|
-
// Count from here, so the pages do not jump by the slop the drag needed to start.
|
|
75
58
|
startX.set(event.translationX);
|
|
76
59
|
runOnJS(dragStarted)();
|
|
77
60
|
})
|
|
78
|
-
// Track phase: one shared value write per frame, on the UI thread.
|
|
79
61
|
.onUpdate((event) => {
|
|
80
62
|
progress.set(pagerPosition(start.get(), event.translationX - startX.get(), width.get(), count));
|
|
81
63
|
})
|
|
82
64
|
.onEnd((event) => {
|
|
83
65
|
const pageWidth = width.get();
|
|
84
66
|
const target = pagerSettle(progress.get(), event.velocityX, pageWidth, Math.round(start.get()), count);
|
|
85
|
-
// The finger's speed in pages per second, the unit of `progress`.
|
|
86
67
|
const velocity = pageWidth > 0 ? -event.velocityX / pageWidth : 0;
|
|
87
68
|
progress.set(withSpring(target, { ...PAGER_SPRING, velocity }));
|
|
88
69
|
if (target !== index) runOnJS(settled)(target);
|
|
@@ -100,7 +81,6 @@ export function GesturePager({ index, count, onIndexChange, progress, renderPage
|
|
|
100
81
|
{Array.from({ length: count }, (_, page) => (
|
|
101
82
|
<View
|
|
102
83
|
key={page}
|
|
103
|
-
// Off-screen pages are hidden from screen readers; the tabs above switch pages for them.
|
|
104
84
|
accessibilityElementsHidden={page !== index}
|
|
105
85
|
importantForAccessibility={page === index ? "auto" : "no-hide-descendants"}
|
|
106
86
|
style={{ width: `${100 / count}%` }}
|
|
@@ -2,10 +2,6 @@ import { TextInputWrapper, type PasteEventPayload } from "expo-paste-input";
|
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
3
|
import { PastePartsContext, type PasteParts } from "./paste-parts";
|
|
4
4
|
|
|
5
|
-
// The image paste on `expo-paste-input`: on Android an `OnReceiveContentListener`
|
|
6
|
-
// on the wrapped field (Paste, and the keyboard's image insert), on iOS the
|
|
7
|
-
// field's `paste(_:)` and keyboard stickers. Text paste stays the field's own.
|
|
8
|
-
|
|
9
5
|
const Target: PasteParts["Target"] = ({ onPasteImages, style, children }) => (
|
|
10
6
|
<TextInputWrapper
|
|
11
7
|
style={style}
|
|
@@ -12,7 +12,6 @@ import type { StyleProp, ViewStyle } from "react-native";
|
|
|
12
12
|
*/
|
|
13
13
|
export type PasteParts = {
|
|
14
14
|
Target: ComponentType<{
|
|
15
|
-
/** The pasted images, as `file://` URIs in the app's cache. */
|
|
16
15
|
onPasteImages: (uris: string[]) => void;
|
|
17
16
|
style?: StyleProp<ViewStyle>;
|
|
18
17
|
children: ReactNode;
|