@codyswann/lisa 2.111.0 → 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-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/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/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/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-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-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/src/expo/.mcp.json +3 -3
- package/plugins/src/expo/THIRD-PARTY-NOTICES.md +57 -0
- 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/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/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/scripts/generate-codex-plugin-artifacts.mjs +7 -2
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# Media
|
|
2
|
+
|
|
3
|
+
## Camera
|
|
4
|
+
|
|
5
|
+
- Hide navigation headers when there's a full screen camera
|
|
6
|
+
- Ensure to flip the camera with `mirror` to emulate social apps
|
|
7
|
+
- Use liquid glass buttons on cameras
|
|
8
|
+
- Icons: `arrow.triangle.2.circlepath` (flip), `photo` (gallery), `bolt` (flash)
|
|
9
|
+
- Eagerly request camera permission
|
|
10
|
+
- Lazily request media library permission
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
import React, { useRef, useState } from "react";
|
|
14
|
+
import { View, TouchableOpacity, Text, Alert } from "react-native";
|
|
15
|
+
import { CameraView, CameraType, useCameraPermissions } from "expo-camera";
|
|
16
|
+
import * as MediaLibrary from "expo-media-library";
|
|
17
|
+
import * as ImagePicker from "expo-image-picker";
|
|
18
|
+
import * as Haptics from "expo-haptics";
|
|
19
|
+
import { SymbolView } from "expo-symbols";
|
|
20
|
+
import { PlatformColor } from "react-native";
|
|
21
|
+
import { GlassView } from "expo-glass-effect";
|
|
22
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
23
|
+
|
|
24
|
+
function Camera({ onPicture }: { onPicture: (uri: string) => Promise<void> }) {
|
|
25
|
+
const [permission, requestPermission] = useCameraPermissions();
|
|
26
|
+
const cameraRef = useRef<CameraView>(null);
|
|
27
|
+
const [type, setType] = useState<CameraType>("back");
|
|
28
|
+
const { bottom } = useSafeAreaInsets();
|
|
29
|
+
|
|
30
|
+
if (!permission?.granted) {
|
|
31
|
+
return (
|
|
32
|
+
<View style={{ flex: 1, justifyContent: "center", alignItems: "center", backgroundColor: PlatformColor("systemBackground") }}>
|
|
33
|
+
<Text style={{ color: PlatformColor("label"), padding: 16 }}>Camera access is required</Text>
|
|
34
|
+
<GlassView isInteractive tintColor={PlatformColor("systemBlue")} style={{ borderRadius: 12 }}>
|
|
35
|
+
<TouchableOpacity onPress={requestPermission} style={{ padding: 12, borderRadius: 12 }}>
|
|
36
|
+
<Text style={{ color: "white" }}>Grant Permission</Text>
|
|
37
|
+
</TouchableOpacity>
|
|
38
|
+
</GlassView>
|
|
39
|
+
</View>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const takePhoto = async () => {
|
|
44
|
+
await Haptics.selectionAsync();
|
|
45
|
+
if (!cameraRef.current) return;
|
|
46
|
+
const photo = await cameraRef.current.takePictureAsync({ quality: 0.8 });
|
|
47
|
+
await onPicture(photo.uri);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const selectPhoto = async () => {
|
|
51
|
+
await Haptics.selectionAsync();
|
|
52
|
+
const result = await ImagePicker.launchImageLibraryAsync({
|
|
53
|
+
mediaTypes: "images",
|
|
54
|
+
allowsEditing: false,
|
|
55
|
+
quality: 0.8,
|
|
56
|
+
});
|
|
57
|
+
if (!result.canceled && result.assets?.[0]) {
|
|
58
|
+
await onPicture(result.assets[0].uri);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<View style={{ flex: 1, backgroundColor: "black" }}>
|
|
64
|
+
<CameraView ref={cameraRef} mirror style={{ flex: 1 }} facing={type} />
|
|
65
|
+
<View style={{ position: "absolute", left: 0, right: 0, bottom: bottom, gap: 16, alignItems: "center" }}>
|
|
66
|
+
<GlassView isInteractive style={{ padding: 8, borderRadius: 99 }}>
|
|
67
|
+
<TouchableOpacity onPress={takePhoto} style={{ width: 64, height: 64, borderRadius: 99, backgroundColor: "white" }} />
|
|
68
|
+
</GlassView>
|
|
69
|
+
<View style={{ flexDirection: "row", justifyContent: "space-around", paddingHorizontal: 8 }}>
|
|
70
|
+
<GlassButton onPress={selectPhoto} icon="photo" />
|
|
71
|
+
<GlassButton onPress={() => setType(t => t === "back" ? "front" : "back")} icon="arrow.triangle.2.circlepath" />
|
|
72
|
+
</View>
|
|
73
|
+
</View>
|
|
74
|
+
</View>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Audio Playback
|
|
80
|
+
|
|
81
|
+
Use `expo-audio` not `expo-av`:
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
import { useAudioPlayer } from 'expo-audio';
|
|
85
|
+
|
|
86
|
+
const player = useAudioPlayer({ uri: 'https://stream.nightride.fm/rektory.mp3' });
|
|
87
|
+
|
|
88
|
+
<Button title="Play" onPress={() => player.play()} />
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Audio Recording (Microphone)
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
import {
|
|
95
|
+
useAudioRecorder,
|
|
96
|
+
AudioModule,
|
|
97
|
+
RecordingPresets,
|
|
98
|
+
setAudioModeAsync,
|
|
99
|
+
useAudioRecorderState,
|
|
100
|
+
} from 'expo-audio';
|
|
101
|
+
import { useEffect } from 'react';
|
|
102
|
+
import { Alert, Button } from 'react-native';
|
|
103
|
+
|
|
104
|
+
function App() {
|
|
105
|
+
const audioRecorder = useAudioRecorder(RecordingPresets.HIGH_QUALITY);
|
|
106
|
+
const recorderState = useAudioRecorderState(audioRecorder);
|
|
107
|
+
|
|
108
|
+
const record = async () => {
|
|
109
|
+
await audioRecorder.prepareToRecordAsync();
|
|
110
|
+
audioRecorder.record();
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const stop = () => audioRecorder.stop();
|
|
114
|
+
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
(async () => {
|
|
117
|
+
const status = await AudioModule.requestRecordingPermissionsAsync();
|
|
118
|
+
if (status.granted) {
|
|
119
|
+
setAudioModeAsync({ playsInSilentMode: true, allowsRecording: true });
|
|
120
|
+
} else {
|
|
121
|
+
Alert.alert('Permission to access microphone was denied');
|
|
122
|
+
}
|
|
123
|
+
})();
|
|
124
|
+
}, []);
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<Button
|
|
128
|
+
title={recorderState.isRecording ? 'Stop' : 'Start'}
|
|
129
|
+
onPress={recorderState.isRecording ? stop : record}
|
|
130
|
+
/>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Video Playback
|
|
136
|
+
|
|
137
|
+
Use `expo-video` not `expo-av`:
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
import { useVideoPlayer, VideoView } from 'expo-video';
|
|
141
|
+
import { useEvent } from 'expo';
|
|
142
|
+
|
|
143
|
+
const videoSource = 'https://example.com/video.mp4';
|
|
144
|
+
|
|
145
|
+
const player = useVideoPlayer(videoSource, player => {
|
|
146
|
+
player.loop = true;
|
|
147
|
+
player.play();
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
const { isPlaying } = useEvent(player, 'playingChange', { isPlaying: player.playing });
|
|
151
|
+
|
|
152
|
+
<VideoView player={player} fullscreenOptions={{}} allowsPictureInPicture />
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
VideoView options:
|
|
156
|
+
- `allowsPictureInPicture`: boolean
|
|
157
|
+
- `contentFit`: 'contain' | 'cover' | 'fill'
|
|
158
|
+
- `nativeControls`: boolean
|
|
159
|
+
- `playsInline`: boolean
|
|
160
|
+
- `startsPictureInPictureAutomatically`: boolean
|
|
161
|
+
|
|
162
|
+
## Saving Media
|
|
163
|
+
|
|
164
|
+
```tsx
|
|
165
|
+
import * as MediaLibrary from "expo-media-library";
|
|
166
|
+
|
|
167
|
+
const { granted } = await MediaLibrary.requestPermissionsAsync();
|
|
168
|
+
if (granted) {
|
|
169
|
+
await MediaLibrary.saveToLibraryAsync(uri);
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Saving Base64 Images
|
|
174
|
+
|
|
175
|
+
`MediaLibrary.saveToLibraryAsync` only accepts local file paths. Save base64 strings to disk first:
|
|
176
|
+
|
|
177
|
+
```tsx
|
|
178
|
+
import { File, Paths } from "expo-file-system/next";
|
|
179
|
+
|
|
180
|
+
function base64ToLocalUri(base64: string, filename?: string) {
|
|
181
|
+
if (!filename) {
|
|
182
|
+
const match = base64.match(/^data:(image\/[a-zA-Z]+);base64,/);
|
|
183
|
+
const ext = match ? match[1].split("/")[1] : "jpg";
|
|
184
|
+
filename = `generated-${Date.now()}.${ext}`;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (base64.startsWith("data:")) base64 = base64.split(",")[1];
|
|
188
|
+
const binaryString = atob(base64);
|
|
189
|
+
const len = binaryString.length;
|
|
190
|
+
const bytes = new Uint8Array(new ArrayBuffer(len));
|
|
191
|
+
for (let i = 0; i < len; i++) bytes[i] = binaryString.charCodeAt(i);
|
|
192
|
+
|
|
193
|
+
const f = new File(Paths.cache, filename);
|
|
194
|
+
f.create({ overwrite: true });
|
|
195
|
+
f.write(bytes);
|
|
196
|
+
return f.uri;
|
|
197
|
+
}
|
|
198
|
+
```
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
# Route Structure
|
|
2
|
+
|
|
3
|
+
## File Conventions
|
|
4
|
+
|
|
5
|
+
- Routes belong in the `app` directory
|
|
6
|
+
- Use `[]` for dynamic routes, e.g. `[id].tsx`
|
|
7
|
+
- Routes can never be named `(foo).tsx` - use `(foo)/index.tsx` instead
|
|
8
|
+
- Use `(group)` routes to simplify the public URL structure
|
|
9
|
+
- NEVER co-locate components, types, or utilities in the app directory - these should be in separate directories like `components/`, `utils/`, etc.
|
|
10
|
+
- The app directory should only contain route and `_layout` files; every file should export a default component
|
|
11
|
+
- Ensure the app always has a route that matches "/" so the app is never blank
|
|
12
|
+
- ALWAYS use `_layout.tsx` files to define stacks
|
|
13
|
+
|
|
14
|
+
## Dynamic Routes
|
|
15
|
+
|
|
16
|
+
Use square brackets for dynamic segments:
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
app/
|
|
20
|
+
users/
|
|
21
|
+
[id].tsx # Matches /users/123, /users/abc
|
|
22
|
+
[id]/
|
|
23
|
+
posts.tsx # Matches /users/123/posts
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Catch-All Routes
|
|
27
|
+
|
|
28
|
+
Use `[...slug]` for catch-all routes:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
app/
|
|
32
|
+
docs/
|
|
33
|
+
[...slug].tsx # Matches /docs/a, /docs/a/b, /docs/a/b/c
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Query Parameters
|
|
37
|
+
|
|
38
|
+
Access query parameters with the `useLocalSearchParams` hook:
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
import { useLocalSearchParams } from "expo-router";
|
|
42
|
+
|
|
43
|
+
function Page() {
|
|
44
|
+
const { id } = useLocalSearchParams<{ id: string }>();
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
For dynamic routes, the parameter name matches the file name:
|
|
49
|
+
|
|
50
|
+
- `[id].tsx` → `useLocalSearchParams<{ id: string }>()`
|
|
51
|
+
- `[slug].tsx` → `useLocalSearchParams<{ slug: string }>()`
|
|
52
|
+
|
|
53
|
+
## Pathname
|
|
54
|
+
|
|
55
|
+
Access the current pathname with the `usePathname` hook:
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import { usePathname } from "expo-router";
|
|
59
|
+
|
|
60
|
+
function Component() {
|
|
61
|
+
const pathname = usePathname(); // e.g. "/users/123"
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Group Routes
|
|
66
|
+
|
|
67
|
+
Use parentheses for groups that don't affect the URL:
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
app/
|
|
71
|
+
(auth)/
|
|
72
|
+
login.tsx # URL: /login
|
|
73
|
+
register.tsx # URL: /register
|
|
74
|
+
(main)/
|
|
75
|
+
index.tsx # URL: /
|
|
76
|
+
settings.tsx # URL: /settings
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Groups are useful for:
|
|
80
|
+
|
|
81
|
+
- Organizing related routes
|
|
82
|
+
- Applying different layouts to route groups
|
|
83
|
+
- Keeping URLs clean
|
|
84
|
+
|
|
85
|
+
## Stacks and Tabs Structure
|
|
86
|
+
|
|
87
|
+
When an app has tabs, the header and title should be set in a Stack that is nested INSIDE each tab. This allows tabs to have their own headers and distinct histories. The root layout should often not have a header.
|
|
88
|
+
|
|
89
|
+
- Set the 'headerShown' option to false on the tab layout
|
|
90
|
+
- Use (group) routes to simplify the public URL structure
|
|
91
|
+
- You may need to delete or refactor existing routes to fit this structure
|
|
92
|
+
|
|
93
|
+
Example structure:
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
app/
|
|
97
|
+
_layout.tsx — <Tabs />
|
|
98
|
+
(home)/
|
|
99
|
+
_layout.tsx — <Stack />
|
|
100
|
+
index.tsx — <ScrollView />
|
|
101
|
+
(settings)/
|
|
102
|
+
_layout.tsx — <Stack />
|
|
103
|
+
index.tsx — <ScrollView />
|
|
104
|
+
(home,settings)/
|
|
105
|
+
info.tsx — <ScrollView /> (shared across tabs)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Array Routes for Multiple Stacks
|
|
109
|
+
|
|
110
|
+
Use array routes '(index,settings)' to create multiple stacks. This is useful for tabs that need to share screens across stacks.
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
app/
|
|
114
|
+
_layout.tsx — <Tabs />
|
|
115
|
+
(index,settings)/
|
|
116
|
+
_layout.tsx — <Stack />
|
|
117
|
+
index.tsx — <ScrollView />
|
|
118
|
+
settings.tsx — <ScrollView />
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
This requires a specialized layout with explicit anchor routes:
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
// app/(index,settings)/_layout.tsx
|
|
125
|
+
import { useMemo } from "react";
|
|
126
|
+
import Stack from "expo-router/stack";
|
|
127
|
+
|
|
128
|
+
export const unstable_settings = {
|
|
129
|
+
index: { anchor: "index" },
|
|
130
|
+
settings: { anchor: "settings" },
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export default function Layout({ segment }: { segment: string }) {
|
|
134
|
+
const screen = segment.match(/\((.*)\)/)?.[1]!;
|
|
135
|
+
|
|
136
|
+
const options = useMemo(() => {
|
|
137
|
+
switch (screen) {
|
|
138
|
+
case "index":
|
|
139
|
+
return { headerRight: () => <></> };
|
|
140
|
+
default:
|
|
141
|
+
return {};
|
|
142
|
+
}
|
|
143
|
+
}, [screen]);
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<Stack>
|
|
147
|
+
<Stack.Screen name={screen} options={options} />
|
|
148
|
+
</Stack>
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Complete App Structure Example
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
app/
|
|
157
|
+
_layout.tsx — <NativeTabs />
|
|
158
|
+
(index,search)/
|
|
159
|
+
_layout.tsx — <Stack />
|
|
160
|
+
index.tsx — Main list
|
|
161
|
+
search.tsx — Search view
|
|
162
|
+
i/[id].tsx — Detail page
|
|
163
|
+
components/
|
|
164
|
+
theme.tsx
|
|
165
|
+
list.tsx
|
|
166
|
+
utils/
|
|
167
|
+
storage.ts
|
|
168
|
+
use-search.ts
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Layout Files
|
|
172
|
+
|
|
173
|
+
Every directory can have a `_layout.tsx` file that wraps all routes in that directory:
|
|
174
|
+
|
|
175
|
+
```tsx
|
|
176
|
+
// app/_layout.tsx
|
|
177
|
+
import { Stack } from "expo-router/stack";
|
|
178
|
+
|
|
179
|
+
export default function RootLayout() {
|
|
180
|
+
return <Stack />;
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
```tsx
|
|
185
|
+
// app/(tabs)/_layout.tsx
|
|
186
|
+
import { NativeTabs, Icon, Label } from "expo-router/unstable-native-tabs";
|
|
187
|
+
|
|
188
|
+
export default function TabLayout() {
|
|
189
|
+
return (
|
|
190
|
+
<NativeTabs>
|
|
191
|
+
<NativeTabs.Trigger name="index">
|
|
192
|
+
<Label>Home</Label>
|
|
193
|
+
<Icon sf="house.fill" />
|
|
194
|
+
</NativeTabs.Trigger>
|
|
195
|
+
</NativeTabs>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Route Settings
|
|
201
|
+
|
|
202
|
+
Export `unstable_settings` to configure route behavior:
|
|
203
|
+
|
|
204
|
+
```tsx
|
|
205
|
+
export const unstable_settings = {
|
|
206
|
+
anchor: "index",
|
|
207
|
+
};
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
- `initialRouteName` was renamed to `anchor` in v4
|
|
211
|
+
|
|
212
|
+
## Not Found Routes
|
|
213
|
+
|
|
214
|
+
Create a `+not-found.tsx` file to handle unmatched routes:
|
|
215
|
+
|
|
216
|
+
```tsx
|
|
217
|
+
// app/+not-found.tsx
|
|
218
|
+
import { Link } from "expo-router";
|
|
219
|
+
import { View, Text } from "react-native";
|
|
220
|
+
|
|
221
|
+
export default function NotFound() {
|
|
222
|
+
return (
|
|
223
|
+
<View>
|
|
224
|
+
<Text>Page not found</Text>
|
|
225
|
+
<Link href="/">Go home</Link>
|
|
226
|
+
</View>
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
```
|
|
@@ -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
|
+
```
|