@codyswann/lisa 2.110.1 → 2.112.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/package.json +1 -1
- package/plugins/lisa/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa/commands/repair-intake.md +2 -2
- package/plugins/lisa/rules/config-resolution.md +2 -2
- package/plugins/lisa/skills/repair-intake/SKILL.md +86 -9
- package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.mcp.json +3 -3
- package/plugins/lisa-expo/THIRD-PARTY-NOTICES.md +57 -0
- package/plugins/lisa-expo/commands/e2e-coverage-gaps.md +7 -0
- package/plugins/lisa-expo/commands/exploratory-qa.md +2 -2
- package/plugins/lisa-expo/skills/add-app-clip/SKILL.md +280 -0
- package/plugins/lisa-expo/skills/add-app-clip/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/add-app-clip/references/native-module.md +96 -0
- package/plugins/lisa-expo/skills/building-native-ui/SKILL.md +321 -0
- package/plugins/lisa-expo/skills/building-native-ui/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/animations.md +220 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/controls.md +272 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/form-sheet.md +253 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/gradients.md +106 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/icons.md +213 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/media.md +198 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/route-structure.md +229 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/search.md +248 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/storage.md +121 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/tabs.md +433 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/toolbar-and-headers.md +284 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/visual-effects.md +197 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/webgpu-three.md +605 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/zoom-transitions.md +158 -0
- package/plugins/lisa-expo/skills/e2e-coverage-gaps/SKILL.md +105 -0
- package/plugins/lisa-expo/skills/e2e-coverage-gaps/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/eas-update-insights/SKILL.md +228 -0
- package/plugins/lisa-expo/skills/eas-update-insights/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/eas-update-insights/references/channel-insights-schema.md +47 -0
- package/plugins/lisa-expo/skills/eas-update-insights/references/update-insights-schema.md +69 -0
- package/plugins/lisa-expo/skills/exploratory-qa/SKILL.md +100 -93
- package/plugins/lisa-expo/skills/exploratory-qa/agents/openai.yaml +2 -2
- package/plugins/lisa-expo/skills/expo-api-routes/SKILL.md +369 -0
- package/plugins/lisa-expo/skills/expo-api-routes/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/expo-brownfield/SKILL.md +54 -0
- package/plugins/lisa-expo/skills/expo-brownfield/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/expo-brownfield/references/brownfield-integrated.md +526 -0
- package/plugins/lisa-expo/skills/expo-brownfield/references/brownfield-isolated.md +402 -0
- package/plugins/lisa-expo/skills/expo-brownfield/references/comparison.md +63 -0
- package/plugins/lisa-expo/skills/expo-brownfield/references/troubleshooting.md +88 -0
- package/plugins/lisa-expo/skills/expo-cicd-workflows/SKILL.md +92 -0
- package/plugins/lisa-expo/skills/expo-cicd-workflows/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/expo-cicd-workflows/scripts/fetch.js +113 -0
- package/plugins/lisa-expo/skills/expo-cicd-workflows/scripts/package.json +11 -0
- package/plugins/lisa-expo/skills/expo-cicd-workflows/scripts/validate.js +85 -0
- package/plugins/lisa-expo/skills/expo-deployment/SKILL.md +190 -0
- package/plugins/lisa-expo/skills/expo-deployment/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/expo-deployment/references/app-store-metadata.md +479 -0
- package/plugins/lisa-expo/skills/expo-deployment/references/ios-app-store.md +355 -0
- package/plugins/lisa-expo/skills/expo-deployment/references/play-store.md +246 -0
- package/plugins/lisa-expo/skills/expo-deployment/references/testflight.md +58 -0
- package/plugins/lisa-expo/skills/expo-deployment/references/workflows.md +200 -0
- package/plugins/lisa-expo/skills/expo-dev-client/SKILL.md +164 -0
- package/plugins/lisa-expo/skills/expo-dev-client/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/expo-module/SKILL.md +141 -0
- package/plugins/lisa-expo/skills/expo-module/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/expo-module/references/config-plugin.md +90 -0
- package/plugins/lisa-expo/skills/expo-module/references/create-expo-module.md +206 -0
- package/plugins/lisa-expo/skills/expo-module/references/lifecycle.md +127 -0
- package/plugins/lisa-expo/skills/expo-module/references/module-config.md +48 -0
- package/plugins/lisa-expo/skills/expo-module/references/native-module.md +286 -0
- package/plugins/lisa-expo/skills/expo-module/references/native-view.md +171 -0
- package/plugins/lisa-expo/skills/expo-tailwind-setup/SKILL.md +480 -0
- package/plugins/lisa-expo/skills/expo-tailwind-setup/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/expo-ui-jetpack-compose/SKILL.md +40 -0
- package/plugins/lisa-expo/skills/expo-ui-jetpack-compose/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/expo-ui-swift-ui/SKILL.md +39 -0
- package/plugins/lisa-expo/skills/expo-ui-swift-ui/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/native-data-fetching/SKILL.md +507 -0
- package/plugins/lisa-expo/skills/native-data-fetching/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/native-data-fetching/references/expo-router-loaders.md +344 -0
- package/plugins/lisa-expo/skills/upgrading-expo/SKILL.md +134 -0
- package/plugins/lisa-expo/skills/upgrading-expo/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/upgrading-expo/references/expo-av-to-audio.md +132 -0
- package/plugins/lisa-expo/skills/upgrading-expo/references/expo-av-to-video.md +160 -0
- package/plugins/lisa-expo/skills/upgrading-expo/references/native-tabs.md +124 -0
- package/plugins/lisa-expo/skills/upgrading-expo/references/new-architecture.md +79 -0
- package/plugins/lisa-expo/skills/upgrading-expo/references/react-19.md +79 -0
- package/plugins/lisa-expo/skills/upgrading-expo/references/react-compiler.md +59 -0
- package/plugins/lisa-expo/skills/upgrading-expo/references/react-navigation-to-expo-router.md +61 -0
- package/plugins/lisa-expo/skills/use-dom/SKILL.md +417 -0
- package/plugins/lisa-expo/skills/use-dom/agents/openai.yaml +4 -0
- package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/commands/e2e-coverage-gaps.md +7 -0
- package/plugins/lisa-harper-fabric/commands/exploratory-qa.md +2 -2
- package/plugins/lisa-harper-fabric/skills/e2e-coverage-gaps/SKILL.md +105 -0
- package/plugins/lisa-harper-fabric/skills/e2e-coverage-gaps/agents/openai.yaml +4 -0
- package/plugins/lisa-harper-fabric/skills/exploratory-qa/SKILL.md +100 -93
- package/plugins/lisa-harper-fabric/skills/exploratory-qa/agents/openai.yaml +2 -2
- package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/commands/e2e-coverage-gaps.md +7 -0
- package/plugins/lisa-rails/commands/exploratory-qa.md +2 -2
- package/plugins/lisa-rails/skills/e2e-coverage-gaps/SKILL.md +105 -0
- package/plugins/lisa-rails/skills/e2e-coverage-gaps/agents/openai.yaml +4 -0
- package/plugins/lisa-rails/skills/exploratory-qa/SKILL.md +100 -93
- package/plugins/lisa-rails/skills/exploratory-qa/agents/openai.yaml +2 -2
- package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/templates/llm-wiki-contract.md +12 -0
- package/plugins/src/base/commands/repair-intake.md +2 -2
- package/plugins/src/base/rules/config-resolution.md +2 -2
- package/plugins/src/base/skills/repair-intake/SKILL.md +86 -9
- package/plugins/src/expo/.mcp.json +3 -3
- package/plugins/src/expo/THIRD-PARTY-NOTICES.md +57 -0
- package/plugins/src/expo/commands/e2e-coverage-gaps.md +7 -0
- package/plugins/src/expo/commands/exploratory-qa.md +2 -2
- package/plugins/src/expo/skills/add-app-clip/SKILL.md +280 -0
- package/plugins/src/expo/skills/add-app-clip/references/native-module.md +96 -0
- package/plugins/src/expo/skills/building-native-ui/SKILL.md +321 -0
- package/plugins/src/expo/skills/building-native-ui/references/animations.md +220 -0
- package/plugins/src/expo/skills/building-native-ui/references/controls.md +272 -0
- package/plugins/src/expo/skills/building-native-ui/references/form-sheet.md +253 -0
- package/plugins/src/expo/skills/building-native-ui/references/gradients.md +106 -0
- package/plugins/src/expo/skills/building-native-ui/references/icons.md +213 -0
- package/plugins/src/expo/skills/building-native-ui/references/media.md +198 -0
- package/plugins/src/expo/skills/building-native-ui/references/route-structure.md +229 -0
- package/plugins/src/expo/skills/building-native-ui/references/search.md +248 -0
- package/plugins/src/expo/skills/building-native-ui/references/storage.md +121 -0
- package/plugins/src/expo/skills/building-native-ui/references/tabs.md +433 -0
- package/plugins/src/expo/skills/building-native-ui/references/toolbar-and-headers.md +284 -0
- package/plugins/src/expo/skills/building-native-ui/references/visual-effects.md +197 -0
- package/plugins/src/expo/skills/building-native-ui/references/webgpu-three.md +605 -0
- package/plugins/src/expo/skills/building-native-ui/references/zoom-transitions.md +158 -0
- package/plugins/src/expo/skills/e2e-coverage-gaps/SKILL.md +105 -0
- package/plugins/src/expo/skills/eas-update-insights/SKILL.md +228 -0
- package/plugins/src/expo/skills/eas-update-insights/references/channel-insights-schema.md +47 -0
- package/plugins/src/expo/skills/eas-update-insights/references/update-insights-schema.md +69 -0
- package/plugins/src/expo/skills/exploratory-qa/SKILL.md +100 -93
- package/plugins/src/expo/skills/expo-api-routes/SKILL.md +369 -0
- package/plugins/src/expo/skills/expo-brownfield/SKILL.md +54 -0
- package/plugins/src/expo/skills/expo-brownfield/references/brownfield-integrated.md +526 -0
- package/plugins/src/expo/skills/expo-brownfield/references/brownfield-isolated.md +402 -0
- package/plugins/src/expo/skills/expo-brownfield/references/comparison.md +63 -0
- package/plugins/src/expo/skills/expo-brownfield/references/troubleshooting.md +88 -0
- package/plugins/src/expo/skills/expo-cicd-workflows/SKILL.md +92 -0
- package/plugins/src/expo/skills/expo-cicd-workflows/scripts/fetch.js +113 -0
- package/plugins/src/expo/skills/expo-cicd-workflows/scripts/package.json +11 -0
- package/plugins/src/expo/skills/expo-cicd-workflows/scripts/validate.js +85 -0
- package/plugins/src/expo/skills/expo-deployment/SKILL.md +190 -0
- package/plugins/src/expo/skills/expo-deployment/references/app-store-metadata.md +479 -0
- package/plugins/src/expo/skills/expo-deployment/references/ios-app-store.md +355 -0
- package/plugins/src/expo/skills/expo-deployment/references/play-store.md +246 -0
- package/plugins/src/expo/skills/expo-deployment/references/testflight.md +58 -0
- package/plugins/src/expo/skills/expo-deployment/references/workflows.md +200 -0
- package/plugins/src/expo/skills/expo-dev-client/SKILL.md +164 -0
- package/plugins/src/expo/skills/expo-module/SKILL.md +141 -0
- package/plugins/src/expo/skills/expo-module/references/config-plugin.md +90 -0
- package/plugins/src/expo/skills/expo-module/references/create-expo-module.md +206 -0
- package/plugins/src/expo/skills/expo-module/references/lifecycle.md +127 -0
- package/plugins/src/expo/skills/expo-module/references/module-config.md +48 -0
- package/plugins/src/expo/skills/expo-module/references/native-module.md +286 -0
- package/plugins/src/expo/skills/expo-module/references/native-view.md +171 -0
- package/plugins/src/expo/skills/expo-tailwind-setup/SKILL.md +480 -0
- package/plugins/src/expo/skills/expo-ui-jetpack-compose/SKILL.md +40 -0
- package/plugins/src/expo/skills/expo-ui-swift-ui/SKILL.md +39 -0
- package/plugins/src/expo/skills/native-data-fetching/SKILL.md +507 -0
- package/plugins/src/expo/skills/native-data-fetching/references/expo-router-loaders.md +344 -0
- package/plugins/src/expo/skills/upgrading-expo/SKILL.md +134 -0
- package/plugins/src/expo/skills/upgrading-expo/references/expo-av-to-audio.md +132 -0
- package/plugins/src/expo/skills/upgrading-expo/references/expo-av-to-video.md +160 -0
- package/plugins/src/expo/skills/upgrading-expo/references/native-tabs.md +124 -0
- package/plugins/src/expo/skills/upgrading-expo/references/new-architecture.md +79 -0
- package/plugins/src/expo/skills/upgrading-expo/references/react-19.md +79 -0
- package/plugins/src/expo/skills/upgrading-expo/references/react-compiler.md +59 -0
- package/plugins/src/expo/skills/upgrading-expo/references/react-navigation-to-expo-router.md +61 -0
- package/plugins/src/expo/skills/use-dom/SKILL.md +417 -0
- package/plugins/src/harper-fabric/commands/e2e-coverage-gaps.md +7 -0
- package/plugins/src/harper-fabric/commands/exploratory-qa.md +2 -2
- package/plugins/src/harper-fabric/skills/e2e-coverage-gaps/SKILL.md +105 -0
- package/plugins/src/harper-fabric/skills/exploratory-qa/SKILL.md +100 -93
- package/plugins/src/rails/commands/e2e-coverage-gaps.md +7 -0
- package/plugins/src/rails/commands/exploratory-qa.md +2 -2
- package/plugins/src/rails/skills/e2e-coverage-gaps/SKILL.md +105 -0
- package/plugins/src/rails/skills/exploratory-qa/SKILL.md +100 -93
- package/plugins/src/wiki/templates/llm-wiki-contract.md +12 -0
- package/scripts/generate-codex-plugin-artifacts.mjs +7 -2
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# Search
|
|
2
|
+
|
|
3
|
+
## Header Search Bar
|
|
4
|
+
|
|
5
|
+
Add a search bar to the stack header with `headerSearchBarOptions`:
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
<Stack.Screen
|
|
9
|
+
name="index"
|
|
10
|
+
options={{
|
|
11
|
+
headerSearchBarOptions: {
|
|
12
|
+
placeholder: "Search",
|
|
13
|
+
onChangeText: (event) => console.log(event.nativeEvent.text),
|
|
14
|
+
},
|
|
15
|
+
}}
|
|
16
|
+
/>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Options
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
headerSearchBarOptions: {
|
|
23
|
+
// Placeholder text
|
|
24
|
+
placeholder: "Search items...",
|
|
25
|
+
|
|
26
|
+
// Auto-capitalize behavior
|
|
27
|
+
autoCapitalize: "none",
|
|
28
|
+
|
|
29
|
+
// Input type
|
|
30
|
+
inputType: "text", // "text" | "phone" | "number" | "email"
|
|
31
|
+
|
|
32
|
+
// Cancel button text (iOS)
|
|
33
|
+
cancelButtonText: "Cancel",
|
|
34
|
+
|
|
35
|
+
// Hide when scrolling (iOS)
|
|
36
|
+
hideWhenScrolling: true,
|
|
37
|
+
|
|
38
|
+
// Hide navigation bar during search (iOS)
|
|
39
|
+
hideNavigationBar: true,
|
|
40
|
+
|
|
41
|
+
// Obscure background during search (iOS)
|
|
42
|
+
obscureBackground: true,
|
|
43
|
+
|
|
44
|
+
// Placement
|
|
45
|
+
placement: "automatic", // "automatic" | "inline" | "stacked"
|
|
46
|
+
|
|
47
|
+
// Callbacks
|
|
48
|
+
onChangeText: (event) => {},
|
|
49
|
+
onSearchButtonPress: (event) => {},
|
|
50
|
+
onCancelButtonPress: (event) => {},
|
|
51
|
+
onFocus: () => {},
|
|
52
|
+
onBlur: () => {},
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## useSearch Hook
|
|
57
|
+
|
|
58
|
+
Reusable hook for search state management:
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
import { useEffect, useState } from "react";
|
|
62
|
+
import { useNavigation } from "expo-router";
|
|
63
|
+
|
|
64
|
+
export function useSearch(options: any = {}) {
|
|
65
|
+
const [search, setSearch] = useState("");
|
|
66
|
+
const navigation = useNavigation();
|
|
67
|
+
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
navigation.setOptions({
|
|
70
|
+
headerShown: true,
|
|
71
|
+
headerSearchBarOptions: {
|
|
72
|
+
...options,
|
|
73
|
+
onChangeText(e: any) {
|
|
74
|
+
setSearch(e.nativeEvent.text);
|
|
75
|
+
options.onChangeText?.(e);
|
|
76
|
+
},
|
|
77
|
+
onSearchButtonPress(e: any) {
|
|
78
|
+
setSearch(e.nativeEvent.text);
|
|
79
|
+
options.onSearchButtonPress?.(e);
|
|
80
|
+
},
|
|
81
|
+
onCancelButtonPress(e: any) {
|
|
82
|
+
setSearch("");
|
|
83
|
+
options.onCancelButtonPress?.(e);
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
}, [options, navigation]);
|
|
88
|
+
|
|
89
|
+
return search;
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Usage
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
function SearchScreen() {
|
|
97
|
+
const search = useSearch({ placeholder: "Search items..." });
|
|
98
|
+
|
|
99
|
+
const filteredItems = items.filter(item =>
|
|
100
|
+
item.name.toLowerCase().includes(search.toLowerCase())
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<FlatList
|
|
105
|
+
data={filteredItems}
|
|
106
|
+
renderItem={({ item }) => <ItemRow item={item} />}
|
|
107
|
+
/>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Filtering Patterns
|
|
113
|
+
|
|
114
|
+
### Simple Text Filter
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
const filtered = items.filter(item =>
|
|
118
|
+
item.name.toLowerCase().includes(search.toLowerCase())
|
|
119
|
+
);
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Multiple Fields
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
const filtered = items.filter(item => {
|
|
126
|
+
const query = search.toLowerCase();
|
|
127
|
+
return (
|
|
128
|
+
item.name.toLowerCase().includes(query) ||
|
|
129
|
+
item.description.toLowerCase().includes(query) ||
|
|
130
|
+
item.tags.some(tag => tag.toLowerCase().includes(query))
|
|
131
|
+
);
|
|
132
|
+
});
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Debounced Search
|
|
136
|
+
|
|
137
|
+
For expensive filtering or API calls:
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
import { useState, useEffect, useMemo } from "react";
|
|
141
|
+
|
|
142
|
+
function useDebounce<T>(value: T, delay: number): T {
|
|
143
|
+
const [debounced, setDebounced] = useState(value);
|
|
144
|
+
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
const timer = setTimeout(() => setDebounced(value), delay);
|
|
147
|
+
return () => clearTimeout(timer);
|
|
148
|
+
}, [value, delay]);
|
|
149
|
+
|
|
150
|
+
return debounced;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function SearchScreen() {
|
|
154
|
+
const search = useSearch();
|
|
155
|
+
const debouncedSearch = useDebounce(search, 300);
|
|
156
|
+
|
|
157
|
+
const filteredItems = useMemo(() =>
|
|
158
|
+
items.filter(item =>
|
|
159
|
+
item.name.toLowerCase().includes(debouncedSearch.toLowerCase())
|
|
160
|
+
),
|
|
161
|
+
[debouncedSearch]
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
return <FlatList data={filteredItems} />;
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Search with Native Tabs
|
|
169
|
+
|
|
170
|
+
When using NativeTabs with a search role, the search bar integrates with the tab bar:
|
|
171
|
+
|
|
172
|
+
```tsx
|
|
173
|
+
// app/_layout.tsx
|
|
174
|
+
<NativeTabs>
|
|
175
|
+
<NativeTabs.Trigger name="(home)">
|
|
176
|
+
<Label>Home</Label>
|
|
177
|
+
<Icon sf="house.fill" />
|
|
178
|
+
</NativeTabs.Trigger>
|
|
179
|
+
<NativeTabs.Trigger name="(search)" role="search">
|
|
180
|
+
<Label>Search</Label>
|
|
181
|
+
</NativeTabs.Trigger>
|
|
182
|
+
</NativeTabs>
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
```tsx
|
|
186
|
+
// app/(search)/_layout.tsx
|
|
187
|
+
<Stack>
|
|
188
|
+
<Stack.Screen
|
|
189
|
+
name="index"
|
|
190
|
+
options={{
|
|
191
|
+
headerSearchBarOptions: {
|
|
192
|
+
placeholder: "Search...",
|
|
193
|
+
onChangeText: (e) => setSearch(e.nativeEvent.text),
|
|
194
|
+
},
|
|
195
|
+
}}
|
|
196
|
+
/>
|
|
197
|
+
</Stack>
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Empty States
|
|
201
|
+
|
|
202
|
+
Show appropriate UI when search returns no results:
|
|
203
|
+
|
|
204
|
+
```tsx
|
|
205
|
+
function SearchResults({ search, items }) {
|
|
206
|
+
const filtered = items.filter(/* ... */);
|
|
207
|
+
|
|
208
|
+
if (search && filtered.length === 0) {
|
|
209
|
+
return (
|
|
210
|
+
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
|
|
211
|
+
<Text style={{ color: PlatformColor("secondaryLabel") }}>
|
|
212
|
+
No results for "{search}"
|
|
213
|
+
</Text>
|
|
214
|
+
</View>
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return <FlatList data={filtered} />;
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Search Suggestions
|
|
223
|
+
|
|
224
|
+
Show recent searches or suggestions:
|
|
225
|
+
|
|
226
|
+
```tsx
|
|
227
|
+
function SearchScreen() {
|
|
228
|
+
const search = useSearch();
|
|
229
|
+
const [recentSearches, setRecentSearches] = useState<string[]>([]);
|
|
230
|
+
|
|
231
|
+
if (!search && recentSearches.length > 0) {
|
|
232
|
+
return (
|
|
233
|
+
<View>
|
|
234
|
+
<Text style={{ color: PlatformColor("secondaryLabel") }}>
|
|
235
|
+
Recent Searches
|
|
236
|
+
</Text>
|
|
237
|
+
{recentSearches.map((term) => (
|
|
238
|
+
<Pressable key={term} onPress={() => /* apply search */}>
|
|
239
|
+
<Text>{term}</Text>
|
|
240
|
+
</Pressable>
|
|
241
|
+
))}
|
|
242
|
+
</View>
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return <SearchResults search={search} />;
|
|
247
|
+
}
|
|
248
|
+
```
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Storage
|
|
2
|
+
|
|
3
|
+
## Key-Value Storage
|
|
4
|
+
|
|
5
|
+
Use the localStorage polyfill for key-value storage. **Never use AsyncStorage**
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import "expo-sqlite/localStorage/install";
|
|
9
|
+
|
|
10
|
+
// Simple get/set
|
|
11
|
+
localStorage.setItem("key", "value");
|
|
12
|
+
localStorage.getItem("key");
|
|
13
|
+
|
|
14
|
+
// Store objects as JSON
|
|
15
|
+
localStorage.setItem("user", JSON.stringify({ name: "John", id: 1 }));
|
|
16
|
+
const user = JSON.parse(localStorage.getItem("user") ?? "{}");
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## When to Use What
|
|
20
|
+
|
|
21
|
+
| Use Case | Solution |
|
|
22
|
+
| ---------------------------------------------------- | ----------------------- |
|
|
23
|
+
| Simple key-value (settings, preferences, small data) | `localStorage` polyfill |
|
|
24
|
+
| Large datasets, complex queries, relational data | Full `expo-sqlite` |
|
|
25
|
+
| Sensitive data (tokens, passwords) | `expo-secure-store` |
|
|
26
|
+
|
|
27
|
+
## Storage with React State
|
|
28
|
+
|
|
29
|
+
Create a storage utility with subscriptions for reactive updates:
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
// utils/storage.ts
|
|
33
|
+
import "expo-sqlite/localStorage/install";
|
|
34
|
+
|
|
35
|
+
type Listener = () => void;
|
|
36
|
+
const listeners = new Map<string, Set<Listener>>();
|
|
37
|
+
|
|
38
|
+
export const storage = {
|
|
39
|
+
get<T>(key: string, defaultValue: T): T {
|
|
40
|
+
const value = localStorage.getItem(key);
|
|
41
|
+
return value ? JSON.parse(value) : defaultValue;
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
set<T>(key: string, value: T): void {
|
|
45
|
+
localStorage.setItem(key, JSON.stringify(value));
|
|
46
|
+
listeners.get(key)?.forEach((fn) => fn());
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
subscribe(key: string, listener: Listener): () => void {
|
|
50
|
+
if (!listeners.has(key)) listeners.set(key, new Set());
|
|
51
|
+
listeners.get(key)!.add(listener);
|
|
52
|
+
return () => listeners.get(key)?.delete(listener);
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## React Hook for Storage
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
// hooks/use-storage.ts
|
|
61
|
+
import { useSyncExternalStore } from "react";
|
|
62
|
+
import { storage } from "@/utils/storage";
|
|
63
|
+
|
|
64
|
+
export function useStorage<T>(
|
|
65
|
+
key: string,
|
|
66
|
+
defaultValue: T
|
|
67
|
+
): [T, (value: T) => void] {
|
|
68
|
+
const value = useSyncExternalStore(
|
|
69
|
+
(cb) => storage.subscribe(key, cb),
|
|
70
|
+
() => storage.get(key, defaultValue)
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
return [value, (newValue: T) => storage.set(key, newValue)];
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Usage:
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
function Settings() {
|
|
81
|
+
const [theme, setTheme] = useStorage("theme", "light");
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<Switch
|
|
85
|
+
value={theme === "dark"}
|
|
86
|
+
onValueChange={(dark) => setTheme(dark ? "dark" : "light")}
|
|
87
|
+
/>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Full SQLite for Complex Data
|
|
93
|
+
|
|
94
|
+
For larger datasets or complex queries, use expo-sqlite directly:
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
import * as SQLite from "expo-sqlite";
|
|
98
|
+
|
|
99
|
+
const db = await SQLite.openDatabaseAsync("app.db");
|
|
100
|
+
|
|
101
|
+
// Create table
|
|
102
|
+
await db.execAsync(`
|
|
103
|
+
CREATE TABLE IF NOT EXISTS events (
|
|
104
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
105
|
+
title TEXT NOT NULL,
|
|
106
|
+
date TEXT NOT NULL,
|
|
107
|
+
location TEXT
|
|
108
|
+
)
|
|
109
|
+
`);
|
|
110
|
+
|
|
111
|
+
// Insert
|
|
112
|
+
await db.runAsync("INSERT INTO events (title, date) VALUES (?, ?)", [
|
|
113
|
+
"Meeting",
|
|
114
|
+
"2024-01-15",
|
|
115
|
+
]);
|
|
116
|
+
|
|
117
|
+
// Query
|
|
118
|
+
const events = await db.getAllAsync("SELECT * FROM events WHERE date > ?", [
|
|
119
|
+
"2024-01-01",
|
|
120
|
+
]);
|
|
121
|
+
```
|