nwui-cli 0.3.6 → 0.4.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/build/index.js +15 -3
- package/build/install-component.js +117 -32
- package/build/utils/env.js +3 -0
- package/my-expo-app-2/app/+html.tsx +46 -0
- package/my-expo-app-2/app/+not-found.tsx +33 -0
- package/my-expo-app-2/app/_layout.tsx +22 -0
- package/my-expo-app-2/app/details.tsx +17 -0
- package/my-expo-app-2/app/index.tsx +23 -0
- package/my-expo-app-2/app-env.d.ts +2 -0
- package/my-expo-app-2/app.json +48 -0
- package/my-expo-app-2/assets/adaptive-icon.png +0 -0
- package/my-expo-app-2/assets/favicon.png +0 -0
- package/my-expo-app-2/assets/icon.png +0 -0
- package/my-expo-app-2/assets/splash.png +0 -0
- package/my-expo-app-2/babel.config.js +18 -0
- package/my-expo-app-2/cesconfig.json +35 -0
- package/my-expo-app-2/components/Button.tsx +19 -0
- package/my-expo-app-2/components/Container.tsx +9 -0
- package/my-expo-app-2/components/EditScreenInfo.tsx +34 -0
- package/my-expo-app-2/components/ScreenContent.tsx +25 -0
- package/my-expo-app-2/components/nativewindui/ActivityIndicator.tsx +13 -0
- package/my-expo-app-2/components/nativewindui/AdaptiveSearchHeader/AdaptiveSearchHeader.ios.tsx +97 -0
- package/my-expo-app-2/components/nativewindui/AdaptiveSearchHeader/AdaptiveSearchHeader.tsx +264 -0
- package/my-expo-app-2/components/nativewindui/AdaptiveSearchHeader/index.ts +1 -0
- package/my-expo-app-2/components/nativewindui/AdaptiveSearchHeader/types.ts +95 -0
- package/my-expo-app-2/components/nativewindui/Alert/Alert.ios.tsx +65 -0
- package/my-expo-app-2/components/nativewindui/Alert/Alert.tsx +291 -0
- package/my-expo-app-2/components/nativewindui/Alert/index.ts +1 -0
- package/my-expo-app-2/components/nativewindui/Alert/types.ts +27 -0
- package/my-expo-app-2/components/nativewindui/Badge.tsx +84 -0
- package/my-expo-app-2/components/nativewindui/Button.tsx +156 -0
- package/my-expo-app-2/components/nativewindui/Checkbox.tsx +61 -0
- package/my-expo-app-2/components/nativewindui/ContextMenu/ContextMenu.ios.tsx +221 -0
- package/my-expo-app-2/components/nativewindui/ContextMenu/ContextMenu.tsx +420 -0
- package/my-expo-app-2/components/nativewindui/ContextMenu/index.ts +1 -0
- package/my-expo-app-2/components/nativewindui/ContextMenu/types.ts +91 -0
- package/my-expo-app-2/components/nativewindui/ContextMenu/utils.ts +14 -0
- package/my-expo-app-2/components/nativewindui/DrawerContent.tsx +145 -0
- package/my-expo-app-2/components/nativewindui/DropdownMenu/DropdownMenu.ios.tsx +168 -0
- package/my-expo-app-2/components/nativewindui/DropdownMenu/DropdownMenu.tsx +330 -0
- package/my-expo-app-2/components/nativewindui/DropdownMenu/index.ts +1 -0
- package/my-expo-app-2/components/nativewindui/DropdownMenu/types.ts +93 -0
- package/my-expo-app-2/components/nativewindui/DropdownMenu/utils.ts +14 -0
- package/my-expo-app-2/components/nativewindui/Form.tsx +125 -0
- package/my-expo-app-2/components/nativewindui/LargeTitleHeader/LargeTitleHeader.ios.tsx +99 -0
- package/my-expo-app-2/components/nativewindui/LargeTitleHeader/LargeTitleHeader.tsx +288 -0
- package/my-expo-app-2/components/nativewindui/LargeTitleHeader/index.ts +1 -0
- package/my-expo-app-2/components/nativewindui/LargeTitleHeader/types.ts +89 -0
- package/my-expo-app-2/components/nativewindui/List.tsx +433 -0
- package/my-expo-app-2/components/nativewindui/SearchInput/SearchInput.ios.tsx +177 -0
- package/my-expo-app-2/components/nativewindui/SearchInput/SearchInput.tsx +86 -0
- package/my-expo-app-2/components/nativewindui/SearchInput/index.tsx +1 -0
- package/my-expo-app-2/components/nativewindui/SearchInput/types.ts +12 -0
- package/my-expo-app-2/components/nativewindui/SegmentedControl/SegmentedControl.ios.tsx +31 -0
- package/my-expo-app-2/components/nativewindui/SegmentedControl/SegmentedControl.tsx +55 -0
- package/my-expo-app-2/components/nativewindui/SegmentedControl/index.ts +1 -0
- package/my-expo-app-2/components/nativewindui/SegmentedControl/types.ts +15 -0
- package/my-expo-app-2/components/nativewindui/Stepper.tsx +62 -0
- package/my-expo-app-2/components/nativewindui/Text.tsx +55 -0
- package/my-expo-app-2/components/nativewindui/TextField/TextField.ios.tsx +85 -0
- package/my-expo-app-2/components/nativewindui/TextField/TextField.tsx +326 -0
- package/my-expo-app-2/components/nativewindui/TextField/index.tsx +1 -0
- package/my-expo-app-2/components/nativewindui/TextField/types.ts +26 -0
- package/my-expo-app-2/components/nativewindui/Toolbar.tsx +116 -0
- package/my-expo-app-2/global.css +3 -0
- package/my-expo-app-2/metro.config.js +12 -0
- package/my-expo-app-2/package-lock.json +19162 -0
- package/my-expo-app-2/package.json +74 -0
- package/my-expo-app-2/prettier.config.js +11 -0
- package/my-expo-app-2/tailwind.config.js +11 -0
- package/my-expo-app-3/app/+html.tsx +46 -0
- package/my-expo-app-3/app/+not-found.tsx +33 -0
- package/my-expo-app-3/app/_layout.tsx +22 -0
- package/my-expo-app-3/app/details.tsx +17 -0
- package/my-expo-app-3/app/index.tsx +23 -0
- package/my-expo-app-3/app-env.d.ts +2 -0
- package/my-expo-app-3/app.json +48 -0
- package/my-expo-app-3/assets/adaptive-icon.png +0 -0
- package/my-expo-app-3/assets/favicon.png +0 -0
- package/my-expo-app-3/assets/icon.png +0 -0
- package/my-expo-app-3/assets/splash.png +0 -0
- package/my-expo-app-3/babel.config.js +18 -0
- package/my-expo-app-3/cesconfig.json +35 -0
- package/my-expo-app-3/components/Button.tsx +19 -0
- package/my-expo-app-3/components/Container.tsx +9 -0
- package/my-expo-app-3/components/EditScreenInfo.tsx +34 -0
- package/my-expo-app-3/components/ScreenContent.tsx +25 -0
- package/my-expo-app-3/components/nativewindui/ActivityIndicator.tsx +13 -0
- package/my-expo-app-3/components/nativewindui/AdaptiveSearchHeader/AdaptiveSearchHeader.ios.tsx +97 -0
- package/my-expo-app-3/components/nativewindui/AdaptiveSearchHeader/AdaptiveSearchHeader.tsx +264 -0
- package/my-expo-app-3/components/nativewindui/AdaptiveSearchHeader/index.ts +1 -0
- package/my-expo-app-3/components/nativewindui/AdaptiveSearchHeader/types.ts +95 -0
- package/my-expo-app-3/components/nativewindui/Alert/Alert.ios.tsx +65 -0
- package/my-expo-app-3/components/nativewindui/Alert/Alert.tsx +291 -0
- package/my-expo-app-3/components/nativewindui/Alert/index.ts +1 -0
- package/my-expo-app-3/components/nativewindui/Alert/types.ts +27 -0
- package/my-expo-app-3/components/nativewindui/Badge.tsx +84 -0
- package/my-expo-app-3/components/nativewindui/Button.tsx +156 -0
- package/my-expo-app-3/components/nativewindui/Checkbox.tsx +61 -0
- package/my-expo-app-3/components/nativewindui/ContextMenu/ContextMenu.ios.tsx +221 -0
- package/my-expo-app-3/components/nativewindui/ContextMenu/ContextMenu.tsx +420 -0
- package/my-expo-app-3/components/nativewindui/ContextMenu/index.ts +1 -0
- package/my-expo-app-3/components/nativewindui/ContextMenu/types.ts +91 -0
- package/my-expo-app-3/components/nativewindui/ContextMenu/utils.ts +14 -0
- package/my-expo-app-3/components/nativewindui/DrawerContent.tsx +145 -0
- package/my-expo-app-3/components/nativewindui/DropdownMenu/DropdownMenu.ios.tsx +168 -0
- package/my-expo-app-3/components/nativewindui/DropdownMenu/DropdownMenu.tsx +330 -0
- package/my-expo-app-3/components/nativewindui/DropdownMenu/index.ts +1 -0
- package/my-expo-app-3/components/nativewindui/DropdownMenu/types.ts +93 -0
- package/my-expo-app-3/components/nativewindui/DropdownMenu/utils.ts +14 -0
- package/my-expo-app-3/components/nativewindui/Form.tsx +125 -0
- package/my-expo-app-3/components/nativewindui/LargeTitleHeader/LargeTitleHeader.ios.tsx +99 -0
- package/my-expo-app-3/components/nativewindui/LargeTitleHeader/LargeTitleHeader.tsx +288 -0
- package/my-expo-app-3/components/nativewindui/LargeTitleHeader/index.ts +1 -0
- package/my-expo-app-3/components/nativewindui/LargeTitleHeader/types.ts +89 -0
- package/my-expo-app-3/components/nativewindui/List.tsx +433 -0
- package/my-expo-app-3/components/nativewindui/SearchInput/SearchInput.ios.tsx +177 -0
- package/my-expo-app-3/components/nativewindui/SearchInput/SearchInput.tsx +86 -0
- package/my-expo-app-3/components/nativewindui/SearchInput/index.tsx +1 -0
- package/my-expo-app-3/components/nativewindui/SearchInput/types.ts +12 -0
- package/my-expo-app-3/components/nativewindui/SegmentedControl/SegmentedControl.ios.tsx +31 -0
- package/my-expo-app-3/components/nativewindui/SegmentedControl/SegmentedControl.tsx +55 -0
- package/my-expo-app-3/components/nativewindui/SegmentedControl/index.ts +1 -0
- package/my-expo-app-3/components/nativewindui/SegmentedControl/types.ts +15 -0
- package/my-expo-app-3/components/nativewindui/Stepper.tsx +62 -0
- package/my-expo-app-3/components/nativewindui/Text.tsx +55 -0
- package/my-expo-app-3/components/nativewindui/TextField/TextField.ios.tsx +85 -0
- package/my-expo-app-3/components/nativewindui/TextField/TextField.tsx +326 -0
- package/my-expo-app-3/components/nativewindui/TextField/index.tsx +1 -0
- package/my-expo-app-3/components/nativewindui/TextField/types.ts +26 -0
- package/my-expo-app-3/components/nativewindui/Toolbar.tsx +116 -0
- package/my-expo-app-3/components/nativewindui/examples/selectable-text.tsx +43 -0
- package/my-expo-app-3/components/nativewindui/examples/text.tsx +43 -0
- package/my-expo-app-3/global.css +3 -0
- package/my-expo-app-3/metro.config.js +12 -0
- package/my-expo-app-3/package-lock.json +19141 -0
- package/my-expo-app-3/package.json +73 -0
- package/my-expo-app-3/prettier.config.js +11 -0
- package/my-expo-app-3/tailwind.config.js +11 -0
- package/my-expo-app-test-case/app/+html.tsx +46 -0
- package/my-expo-app-test-case/app/+not-found.tsx +33 -0
- package/my-expo-app-test-case/app/_layout.tsx +22 -0
- package/my-expo-app-test-case/app/details.tsx +17 -0
- package/my-expo-app-test-case/app/index.tsx +23 -0
- package/my-expo-app-test-case/app-env.d.ts +2 -0
- package/my-expo-app-test-case/app.json +48 -0
- package/my-expo-app-test-case/assets/adaptive-icon.png +0 -0
- package/my-expo-app-test-case/assets/favicon.png +0 -0
- package/my-expo-app-test-case/assets/icon.png +0 -0
- package/my-expo-app-test-case/assets/splash.png +0 -0
- package/my-expo-app-test-case/babel.config.js +18 -0
- package/my-expo-app-test-case/cesconfig.json +35 -0
- package/my-expo-app-test-case/components/Button.tsx +19 -0
- package/my-expo-app-test-case/components/Container.tsx +9 -0
- package/my-expo-app-test-case/components/EditScreenInfo.tsx +34 -0
- package/my-expo-app-test-case/components/ScreenContent.tsx +25 -0
- package/my-expo-app-test-case/components/nativewindui/ActivityIndicator.tsx +13 -0
- package/my-expo-app-test-case/components/nativewindui/AdaptiveSearchHeader/AdaptiveSearchHeader.ios.tsx +97 -0
- package/my-expo-app-test-case/components/nativewindui/AdaptiveSearchHeader/AdaptiveSearchHeader.tsx +264 -0
- package/my-expo-app-test-case/components/nativewindui/AdaptiveSearchHeader/index.ts +1 -0
- package/my-expo-app-test-case/components/nativewindui/AdaptiveSearchHeader/types.ts +95 -0
- package/my-expo-app-test-case/components/nativewindui/Alert/Alert.ios.tsx +65 -0
- package/my-expo-app-test-case/components/nativewindui/Alert/Alert.tsx +291 -0
- package/my-expo-app-test-case/components/nativewindui/Alert/index.ts +1 -0
- package/my-expo-app-test-case/components/nativewindui/Alert/types.ts +27 -0
- package/my-expo-app-test-case/components/nativewindui/Badge.tsx +84 -0
- package/my-expo-app-test-case/components/nativewindui/Button.tsx +156 -0
- package/my-expo-app-test-case/components/nativewindui/Checkbox.tsx +61 -0
- package/my-expo-app-test-case/components/nativewindui/ContextMenu/ContextMenu.ios.tsx +221 -0
- package/my-expo-app-test-case/components/nativewindui/ContextMenu/ContextMenu.tsx +420 -0
- package/my-expo-app-test-case/components/nativewindui/ContextMenu/index.ts +1 -0
- package/my-expo-app-test-case/components/nativewindui/ContextMenu/types.ts +91 -0
- package/my-expo-app-test-case/components/nativewindui/ContextMenu/utils.ts +14 -0
- package/my-expo-app-test-case/components/nativewindui/DrawerContent.tsx +145 -0
- package/my-expo-app-test-case/components/nativewindui/DropdownMenu/DropdownMenu.ios.tsx +168 -0
- package/my-expo-app-test-case/components/nativewindui/DropdownMenu/DropdownMenu.tsx +330 -0
- package/my-expo-app-test-case/components/nativewindui/DropdownMenu/index.ts +1 -0
- package/my-expo-app-test-case/components/nativewindui/DropdownMenu/types.ts +93 -0
- package/my-expo-app-test-case/components/nativewindui/DropdownMenu/utils.ts +14 -0
- package/my-expo-app-test-case/components/nativewindui/Form.tsx +125 -0
- package/my-expo-app-test-case/components/nativewindui/LargeTitleHeader/LargeTitleHeader.ios.tsx +99 -0
- package/my-expo-app-test-case/components/nativewindui/LargeTitleHeader/LargeTitleHeader.tsx +288 -0
- package/my-expo-app-test-case/components/nativewindui/LargeTitleHeader/index.ts +1 -0
- package/my-expo-app-test-case/components/nativewindui/LargeTitleHeader/types.ts +89 -0
- package/my-expo-app-test-case/components/nativewindui/List.tsx +433 -0
- package/my-expo-app-test-case/components/nativewindui/SearchInput/SearchInput.ios.tsx +177 -0
- package/my-expo-app-test-case/components/nativewindui/SearchInput/SearchInput.tsx +86 -0
- package/my-expo-app-test-case/components/nativewindui/SearchInput/index.tsx +1 -0
- package/my-expo-app-test-case/components/nativewindui/SearchInput/types.ts +12 -0
- package/my-expo-app-test-case/components/nativewindui/SegmentedControl/SegmentedControl.ios.tsx +31 -0
- package/my-expo-app-test-case/components/nativewindui/SegmentedControl/SegmentedControl.tsx +55 -0
- package/my-expo-app-test-case/components/nativewindui/SegmentedControl/index.ts +1 -0
- package/my-expo-app-test-case/components/nativewindui/SegmentedControl/types.ts +15 -0
- package/my-expo-app-test-case/components/nativewindui/Stepper.tsx +62 -0
- package/my-expo-app-test-case/components/nativewindui/Text.tsx +55 -0
- package/my-expo-app-test-case/components/nativewindui/TextField/TextField.ios.tsx +85 -0
- package/my-expo-app-test-case/components/nativewindui/TextField/TextField.tsx +326 -0
- package/my-expo-app-test-case/components/nativewindui/TextField/index.tsx +1 -0
- package/my-expo-app-test-case/components/nativewindui/TextField/types.ts +26 -0
- package/my-expo-app-test-case/components/nativewindui/Toolbar.tsx +116 -0
- package/my-expo-app-test-case/components/nativewindui/examples/a-user-created-file.tsx +0 -0
- package/my-expo-app-test-case/components/nativewindui/examples/selectable-text.tsx +43 -0
- package/my-expo-app-test-case/components/nativewindui/examples/text.tsx +43 -0
- package/my-expo-app-test-case/global.css +3 -0
- package/my-expo-app-test-case/metro.config.js +12 -0
- package/my-expo-app-test-case/package-lock.json +19141 -0
- package/my-expo-app-test-case/package.json +73 -0
- package/my-expo-app-test-case/prettier.config.js +11 -0
- package/my-expo-app-test-case/tailwind.config.js +11 -0
- package/package.json +2 -2
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { useAugmentedRef } from '@rn-primitives/hooks';
|
|
2
|
+
import { Portal } from '@rn-primitives/portal';
|
|
3
|
+
import { Icon } from '@roninoss/icons';
|
|
4
|
+
import { Stack, useNavigation } from 'expo-router';
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import { BackHandler, TextInput, View } from 'react-native';
|
|
7
|
+
import Animated, {
|
|
8
|
+
FadeIn,
|
|
9
|
+
FadeInRight,
|
|
10
|
+
FadeInUp,
|
|
11
|
+
FadeOut,
|
|
12
|
+
FadeOutRight,
|
|
13
|
+
ZoomIn,
|
|
14
|
+
withTiming,
|
|
15
|
+
} from 'react-native-reanimated';
|
|
16
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
17
|
+
|
|
18
|
+
import type {
|
|
19
|
+
AdaptiveSearchBarRef,
|
|
20
|
+
AdaptiveSearchHeaderProps,
|
|
21
|
+
NativeStackNavigationSearchBarOptions,
|
|
22
|
+
} from './types';
|
|
23
|
+
|
|
24
|
+
import { Button } from '~/components/nativewindui/Button';
|
|
25
|
+
import { Text } from '~/components/nativewindui/Text';
|
|
26
|
+
import { cn } from '~/lib/cn';
|
|
27
|
+
import { useColorScheme } from '~/lib/useColorScheme';
|
|
28
|
+
|
|
29
|
+
const SCREEN_OPTIONS = {
|
|
30
|
+
headerShown: false,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export function AdaptiveSearchHeader(props: AdaptiveSearchHeaderProps) {
|
|
34
|
+
const insets = useSafeAreaInsets();
|
|
35
|
+
const { colors } = useColorScheme();
|
|
36
|
+
const navigation = useNavigation();
|
|
37
|
+
const id = React.useId();
|
|
38
|
+
const fallbackSearchBarRef = React.useRef<AdaptiveSearchBarRef>(null);
|
|
39
|
+
|
|
40
|
+
const [searchValue, setSearchValue] = React.useState('');
|
|
41
|
+
const [showSearchBar, setShowSearchBar] = React.useState(false);
|
|
42
|
+
|
|
43
|
+
const augmentedRef = useAugmentedRef({
|
|
44
|
+
ref: props.searchBar?.ref ?? fallbackSearchBarRef,
|
|
45
|
+
methods: {
|
|
46
|
+
focus: () => {
|
|
47
|
+
setShowSearchBar(true);
|
|
48
|
+
},
|
|
49
|
+
blur: () => {
|
|
50
|
+
setShowSearchBar(false);
|
|
51
|
+
},
|
|
52
|
+
setText: (text) => {
|
|
53
|
+
setSearchValue(text);
|
|
54
|
+
props.searchBar?.onChangeText?.(text);
|
|
55
|
+
},
|
|
56
|
+
clearText: () => {
|
|
57
|
+
setSearchValue('');
|
|
58
|
+
props.searchBar?.onChangeText?.('');
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
React.useEffect(() => {
|
|
64
|
+
const backHandler = BackHandler.addEventListener('hardwareBackPress', () => {
|
|
65
|
+
if (showSearchBar) {
|
|
66
|
+
setShowSearchBar(false);
|
|
67
|
+
setSearchValue('');
|
|
68
|
+
props.searchBar?.onChangeText?.('');
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
return false;
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
return () => {
|
|
75
|
+
backHandler.remove();
|
|
76
|
+
};
|
|
77
|
+
}, [showSearchBar]);
|
|
78
|
+
|
|
79
|
+
function onSearchButtonPress() {
|
|
80
|
+
setShowSearchBar(true);
|
|
81
|
+
props.searchBar?.onSearchButtonPress?.();
|
|
82
|
+
}
|
|
83
|
+
function onBlur() {
|
|
84
|
+
setShowSearchBar(false);
|
|
85
|
+
props.searchBar?.onBlur?.();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function onChangeText(text: string) {
|
|
89
|
+
setSearchValue(text);
|
|
90
|
+
props.searchBar?.onChangeText?.(text);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function onSearchBackPress() {
|
|
94
|
+
setShowSearchBar(false);
|
|
95
|
+
setSearchValue('');
|
|
96
|
+
props.searchBar?.onChangeText?.('');
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function onClearText() {
|
|
100
|
+
setSearchValue('');
|
|
101
|
+
props.searchBar?.onChangeText?.('');
|
|
102
|
+
props.searchBar?.onCancelButtonPress?.();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const canGoBack = navigation.canGoBack();
|
|
106
|
+
|
|
107
|
+
if (props.shown === false) return null;
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<>
|
|
111
|
+
<Stack.Screen options={Object.assign(props.screen ?? {}, SCREEN_OPTIONS)} />
|
|
112
|
+
{/* Ref is set in View so we can call its methods before the input is mounted */}
|
|
113
|
+
<View ref={augmentedRef as unknown as React.RefObject<View>} />
|
|
114
|
+
<View
|
|
115
|
+
style={{
|
|
116
|
+
paddingTop: (props.materialUseSafeAreaTop === false ? 0 : insets.top) + 6,
|
|
117
|
+
backgroundColor: props.backgroundColor ?? colors.background,
|
|
118
|
+
}}
|
|
119
|
+
className={cn('px-4 pb-3 shadow-none', props.shadowVisible && 'shadow-xl')}>
|
|
120
|
+
<Button
|
|
121
|
+
variant="plain"
|
|
122
|
+
className="bg-muted/25 android:gap-0 dark:bg-card h-14 flex-row items-center rounded-full px-2.5"
|
|
123
|
+
onPress={onSearchButtonPress}>
|
|
124
|
+
{!!props.leftView ? (
|
|
125
|
+
<View className="flex-row justify-center gap-4 pl-0.5">
|
|
126
|
+
{props.leftView({ canGoBack, tintColor: colors.foreground })}
|
|
127
|
+
</View>
|
|
128
|
+
) : (
|
|
129
|
+
<Button variant="plain" size="sm" className="p-2" pointerEvents="none">
|
|
130
|
+
<Icon color={colors.grey2} name="magnifyingglass" namingScheme="sfSymbol" size={24} />
|
|
131
|
+
</Button>
|
|
132
|
+
)}
|
|
133
|
+
|
|
134
|
+
<View className="flex-1 px-2">
|
|
135
|
+
<Text
|
|
136
|
+
numberOfLines={1}
|
|
137
|
+
variant="callout"
|
|
138
|
+
className="android:text-muted-foreground font-normal">
|
|
139
|
+
{props.searchBar?.placeholder ?? 'Search...'}
|
|
140
|
+
</Text>
|
|
141
|
+
</View>
|
|
142
|
+
<View className="flex-row items-center gap-2">
|
|
143
|
+
{!!props.rightView && (
|
|
144
|
+
<>{props.rightView({ canGoBack, tintColor: colors.foreground })}</>
|
|
145
|
+
)}
|
|
146
|
+
</View>
|
|
147
|
+
</Button>
|
|
148
|
+
</View>
|
|
149
|
+
{showSearchBar && (
|
|
150
|
+
<Portal name={`large-title:${id}`}>
|
|
151
|
+
<Animated.View exiting={FadeOut} className="absolute bottom-0 left-0 right-0 top-0">
|
|
152
|
+
<View
|
|
153
|
+
style={{ paddingTop: insets.top + 6 }}
|
|
154
|
+
className="bg-background relative z-50 overflow-hidden">
|
|
155
|
+
<Animated.View
|
|
156
|
+
entering={customEntering}
|
|
157
|
+
exiting={customExiting}
|
|
158
|
+
className="bg-muted/25 dark:bg-card absolute bottom-2.5 left-4 right-4 h-14 rounded-full"
|
|
159
|
+
/>
|
|
160
|
+
<View className="pb-2.5">
|
|
161
|
+
<Animated.View
|
|
162
|
+
entering={FadeIn}
|
|
163
|
+
exiting={FadeOut}
|
|
164
|
+
className="h-14 flex-row items-center pl-3.5 pr-5">
|
|
165
|
+
<Animated.View entering={FadeInRight} exiting={FadeOutRight}>
|
|
166
|
+
<Animated.View entering={FadeIn} exiting={FadeOut}>
|
|
167
|
+
<Button variant="plain" size="icon" onPress={onSearchBackPress}>
|
|
168
|
+
<Icon color={colors.grey} name="arrow-left" size={24} />
|
|
169
|
+
</Button>
|
|
170
|
+
</Animated.View>
|
|
171
|
+
</Animated.View>
|
|
172
|
+
<Animated.View entering={FadeInRight} exiting={FadeOutRight} className="flex-1">
|
|
173
|
+
<TextInput
|
|
174
|
+
autoFocus
|
|
175
|
+
placeholder={props.searchBar?.placeholder ?? 'Search...'}
|
|
176
|
+
className="flex-1 rounded-r-full p-2 text-[17px]"
|
|
177
|
+
style={{ color: props.searchBar?.textColor ?? colors.foreground }}
|
|
178
|
+
placeholderTextColor={colors.grey2}
|
|
179
|
+
onBlur={onBlur}
|
|
180
|
+
onFocus={props.searchBar?.onFocus}
|
|
181
|
+
value={searchValue}
|
|
182
|
+
onChangeText={onChangeText}
|
|
183
|
+
autoCapitalize={props.searchBar?.autoCapitalize}
|
|
184
|
+
keyboardType={searchBarInputTypeToKeyboardType(props.searchBar?.inputType)}
|
|
185
|
+
returnKeyType="search"
|
|
186
|
+
blurOnSubmit={props.searchBar?.materialBlurOnSubmit}
|
|
187
|
+
onSubmitEditing={props.searchBar?.materialOnSubmitEditing}
|
|
188
|
+
/>
|
|
189
|
+
</Animated.View>
|
|
190
|
+
|
|
191
|
+
<View className="flex-row items-center gap-3 pr-1.5">
|
|
192
|
+
{!!searchValue && (
|
|
193
|
+
<Animated.View entering={FadeIn} exiting={FadeOut}>
|
|
194
|
+
<Button size="icon" variant="plain" onPress={onClearText}>
|
|
195
|
+
<Icon color={colors.grey2} name="close" size={24} />
|
|
196
|
+
</Button>
|
|
197
|
+
</Animated.View>
|
|
198
|
+
)}
|
|
199
|
+
{!!props.searchBar?.materialRightView && (
|
|
200
|
+
<>
|
|
201
|
+
{props.searchBar?.materialRightView({
|
|
202
|
+
canGoBack,
|
|
203
|
+
tintColor: colors.foreground,
|
|
204
|
+
})}
|
|
205
|
+
</>
|
|
206
|
+
)}
|
|
207
|
+
</View>
|
|
208
|
+
</Animated.View>
|
|
209
|
+
</View>
|
|
210
|
+
<Animated.View entering={ZoomIn} className="bg-border h-px" />
|
|
211
|
+
</View>
|
|
212
|
+
<Animated.View entering={FadeInUp} className="bg-background flex-1 ">
|
|
213
|
+
<View className="bg-muted/25 dark:bg-card flex-1">{props.searchBar?.content}</View>
|
|
214
|
+
</Animated.View>
|
|
215
|
+
</Animated.View>
|
|
216
|
+
</Portal>
|
|
217
|
+
)}
|
|
218
|
+
</>
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function searchBarInputTypeToKeyboardType(
|
|
223
|
+
inputType: NativeStackNavigationSearchBarOptions['inputType']
|
|
224
|
+
) {
|
|
225
|
+
switch (inputType) {
|
|
226
|
+
case 'email':
|
|
227
|
+
return 'email-address';
|
|
228
|
+
case 'number':
|
|
229
|
+
return 'numeric';
|
|
230
|
+
case 'phone':
|
|
231
|
+
return 'phone-pad';
|
|
232
|
+
default:
|
|
233
|
+
return 'default';
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const customEntering = () => {
|
|
238
|
+
'worklet';
|
|
239
|
+
const animations = {
|
|
240
|
+
transform: [{ scale: withTiming(3, { duration: 400 }) }],
|
|
241
|
+
};
|
|
242
|
+
const initialValues = {
|
|
243
|
+
transform: [{ scale: 1 }],
|
|
244
|
+
};
|
|
245
|
+
return {
|
|
246
|
+
initialValues,
|
|
247
|
+
animations,
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
const customExiting = () => {
|
|
251
|
+
'worklet';
|
|
252
|
+
const animations = {
|
|
253
|
+
transform: [{ scale: withTiming(1) }],
|
|
254
|
+
opacity: withTiming(0),
|
|
255
|
+
};
|
|
256
|
+
const initialValues = {
|
|
257
|
+
transform: [{ scale: 3 }],
|
|
258
|
+
opacity: 1,
|
|
259
|
+
};
|
|
260
|
+
return {
|
|
261
|
+
initialValues,
|
|
262
|
+
animations,
|
|
263
|
+
};
|
|
264
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AdaptiveSearchHeader';
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { Stack } from 'expo-router';
|
|
2
|
+
import type { NativeSyntheticEvent, TextInputSubmitEditingEventData } from 'react-native';
|
|
3
|
+
import type { SearchBarCommands } from 'react-native-screens';
|
|
4
|
+
|
|
5
|
+
type NativeStackNavigationOptions = NonNullable<
|
|
6
|
+
React.ComponentPropsWithoutRef<typeof Stack.Screen>['options']
|
|
7
|
+
>;
|
|
8
|
+
|
|
9
|
+
type ScreenOptions = Pick<
|
|
10
|
+
NativeStackNavigationOptions,
|
|
11
|
+
| 'animation'
|
|
12
|
+
| 'animationDuration'
|
|
13
|
+
| 'contentStyle'
|
|
14
|
+
| 'navigationBarColor'
|
|
15
|
+
| 'animationTypeForReplace'
|
|
16
|
+
| 'autoHideHomeIndicator'
|
|
17
|
+
| 'customAnimationOnGesture'
|
|
18
|
+
| 'gestureEnabled'
|
|
19
|
+
| 'freezeOnBlur'
|
|
20
|
+
| 'fullScreenGestureEnabled'
|
|
21
|
+
| 'gestureDirection'
|
|
22
|
+
| 'navigationBarHidden'
|
|
23
|
+
| 'orientation'
|
|
24
|
+
| 'presentation'
|
|
25
|
+
| 'statusBarTranslucent'
|
|
26
|
+
| 'statusBarStyle'
|
|
27
|
+
| 'statusBarHidden'
|
|
28
|
+
| 'statusBarColor'
|
|
29
|
+
| 'statusBarAnimation'
|
|
30
|
+
| 'title'
|
|
31
|
+
>;
|
|
32
|
+
|
|
33
|
+
type HeaderOptions = Omit<NativeStackNavigationOptions, keyof ScreenOptions>;
|
|
34
|
+
|
|
35
|
+
type NativeStackNavigationSearchBarOptions = NonNullable<HeaderOptions['headerSearchBarOptions']>;
|
|
36
|
+
|
|
37
|
+
type AdaptiveSearchBarRef = Omit<SearchBarCommands, 'blur' | 'toggleCancelButton'>;
|
|
38
|
+
|
|
39
|
+
type AdaptiveSearchHeaderProps = {
|
|
40
|
+
/**
|
|
41
|
+
* Default is false
|
|
42
|
+
*/
|
|
43
|
+
iosIsLargeTitle?: boolean;
|
|
44
|
+
iosBackButtonMenuEnabled?: boolean;
|
|
45
|
+
iosBackButtonTitle?: string;
|
|
46
|
+
iosBackButtonTitleVisible?: boolean;
|
|
47
|
+
iosBackVisible?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Default is 'systemMaterial'
|
|
50
|
+
*/
|
|
51
|
+
iosBlurEffect?: HeaderOptions['headerBlurEffect'] | 'none';
|
|
52
|
+
iosTitle?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Default is true
|
|
55
|
+
*/
|
|
56
|
+
materialUseSafeAreaTop?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* iOS - iosBlurEffect must be set to 'none' for this to work
|
|
59
|
+
* @default iOS: true | Material: false
|
|
60
|
+
*/
|
|
61
|
+
shadowVisible?: boolean;
|
|
62
|
+
leftView?: HeaderOptions['headerLeft'];
|
|
63
|
+
rightView?: HeaderOptions['headerRight'];
|
|
64
|
+
shown?: boolean;
|
|
65
|
+
backgroundColor?: string;
|
|
66
|
+
screen?: ScreenOptions;
|
|
67
|
+
searchBar?: {
|
|
68
|
+
iosCancelButtonText?: string;
|
|
69
|
+
iosHideWhenScrolling?: boolean;
|
|
70
|
+
iosTintColor?: string;
|
|
71
|
+
materialRightView?: HeaderOptions['headerRight'];
|
|
72
|
+
materialBlurOnSubmit?: boolean;
|
|
73
|
+
materialOnSubmitEditing?:
|
|
74
|
+
| ((e: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => void)
|
|
75
|
+
| undefined;
|
|
76
|
+
autoCapitalize?: NativeStackNavigationSearchBarOptions['autoCapitalize'];
|
|
77
|
+
inputType?: NativeStackNavigationSearchBarOptions['inputType'];
|
|
78
|
+
onBlur?: () => void;
|
|
79
|
+
onCancelButtonPress?: () => void;
|
|
80
|
+
onChangeText?: (text: string) => void;
|
|
81
|
+
onFocus?: () => void;
|
|
82
|
+
onSearchButtonPress?: () => void;
|
|
83
|
+
placeholder?: string;
|
|
84
|
+
ref?: React.RefObject<AdaptiveSearchBarRef>;
|
|
85
|
+
textColor?: string;
|
|
86
|
+
content?: React.ReactNode;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export type {
|
|
91
|
+
NativeStackNavigationOptions,
|
|
92
|
+
AdaptiveSearchBarRef,
|
|
93
|
+
AdaptiveSearchHeaderProps,
|
|
94
|
+
NativeStackNavigationSearchBarOptions,
|
|
95
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useAugmentedRef } from '@rn-primitives/hooks';
|
|
2
|
+
import * as Slot from '@rn-primitives/slot';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { AlertButton, Pressable, Alert as RNAlert } from 'react-native';
|
|
5
|
+
|
|
6
|
+
import { AlertProps, AlertRef } from './types';
|
|
7
|
+
|
|
8
|
+
const Alert = React.forwardRef<AlertRef, AlertProps>(
|
|
9
|
+
({ children, title, buttons, message, prompt }, ref) => {
|
|
10
|
+
const augmentedRef = useAugmentedRef({
|
|
11
|
+
ref,
|
|
12
|
+
methods: {
|
|
13
|
+
show: () => {
|
|
14
|
+
onPress();
|
|
15
|
+
},
|
|
16
|
+
alert,
|
|
17
|
+
prompt: promptAlert,
|
|
18
|
+
},
|
|
19
|
+
deps: [prompt],
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
function promptAlert(args: AlertProps & { prompt: Required<AlertProps['prompt']> }) {
|
|
23
|
+
RNAlert.prompt(
|
|
24
|
+
args.title,
|
|
25
|
+
args.message,
|
|
26
|
+
args.buttons as AlertButton[],
|
|
27
|
+
args.prompt?.type,
|
|
28
|
+
args.prompt?.defaultValue,
|
|
29
|
+
args.prompt?.keyboardType
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function alert(args: AlertProps) {
|
|
34
|
+
RNAlert.alert(args.title, args.message, args.buttons as AlertButton[]);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function onPress() {
|
|
38
|
+
if (prompt) {
|
|
39
|
+
promptAlert({
|
|
40
|
+
title,
|
|
41
|
+
message,
|
|
42
|
+
buttons,
|
|
43
|
+
prompt: prompt as Required<AlertProps['prompt']>,
|
|
44
|
+
});
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
alert({ title, message, buttons });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const Component = !children ? Pressable : Slot.Pressable;
|
|
51
|
+
return (
|
|
52
|
+
<Component ref={augmentedRef} onPress={onPress}>
|
|
53
|
+
{children}
|
|
54
|
+
</Component>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
Alert.displayName = 'Alert';
|
|
60
|
+
|
|
61
|
+
const AlertAnchor = React.forwardRef<AlertRef>((_, ref) => {
|
|
62
|
+
return <Alert ref={ref} title="" buttons={[]} />;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
export { Alert, AlertAnchor };
|