agentic-mobile-kit 0.5.6 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/bin/cli.js +1 -1
- package/lib/init.js +70 -39
- package/package.json +4 -2
- package/stacks/react-native/expo/.agents/skills/LICENSE-expo +21 -0
- package/stacks/react-native/expo/.agents/skills/THIRD_PARTY.md +11 -0
- package/stacks/react-native/expo/.agents/skills/expo-module/SKILL.md +151 -0
- package/stacks/react-native/expo/.agents/skills/expo-module/agents/openai.yaml +4 -0
- package/stacks/react-native/expo/.agents/skills/expo-module/references/config-plugin.md +90 -0
- package/stacks/react-native/expo/.agents/skills/expo-module/references/create-expo-module.md +206 -0
- package/stacks/react-native/expo/.agents/skills/expo-module/references/lifecycle.md +127 -0
- package/stacks/react-native/expo/.agents/skills/expo-module/references/module-config.md +48 -0
- package/stacks/react-native/expo/.agents/skills/expo-module/references/native-module.md +286 -0
- package/stacks/react-native/expo/.agents/skills/expo-module/references/native-view.md +171 -0
- package/stacks/react-native/expo/.agents/skills/expo-router/SKILL.md +240 -0
- package/stacks/react-native/expo/.agents/skills/expo-router/agents/openai.yaml +4 -0
- package/stacks/react-native/expo/.agents/skills/expo-router/references/form-sheet.md +253 -0
- package/stacks/react-native/expo/.agents/skills/expo-router/references/route-structure.md +229 -0
- package/stacks/react-native/expo/.agents/skills/expo-router/references/search.md +248 -0
- package/stacks/react-native/expo/.agents/skills/expo-router/references/tabs.md +433 -0
- package/stacks/react-native/expo/.agents/skills/expo-router/references/toolbar-and-headers.md +284 -0
- package/stacks/react-native/expo/.agents/skills/expo-router/references/zoom-transitions.md +158 -0
- package/stacks/react-native/expo/.agents/skills/expo-upgrade/SKILL.md +150 -0
- package/stacks/react-native/expo/.agents/skills/expo-upgrade/agents/openai.yaml +4 -0
- package/stacks/react-native/expo/.agents/skills/expo-upgrade/references/expo-av-to-audio.md +132 -0
- package/stacks/react-native/expo/.agents/skills/expo-upgrade/references/expo-av-to-video.md +160 -0
- package/stacks/react-native/expo/.agents/skills/expo-upgrade/references/native-tabs.md +124 -0
- package/stacks/react-native/expo/.agents/skills/expo-upgrade/references/new-architecture.md +79 -0
- package/stacks/react-native/expo/.agents/skills/expo-upgrade/references/react-19.md +79 -0
- package/stacks/react-native/expo/.agents/skills/expo-upgrade/references/react-compiler.md +59 -0
- package/stacks/react-native/expo/.agents/skills/expo-upgrade/references/react-navigation-to-expo-router.md +61 -0
- package/stacks/react-native/expo/.rulesync/permissions.jsonc +40 -0
- package/stacks/react-native/expo/AGENTS.md +52 -0
- package/stacks/react-native/expo/docs/ai/expo.md +35 -0
- package/stacks/react-native/expo/docs/ai/known-issues.md +32 -0
- package/stacks/react-native/template/.agents/skills/m-release/SKILL.md +5 -5
- package/stacks/react-native/template/.github/workflows/e2e.yml +2 -0
- package/stacks/react-native/template/.github/workflows/ios.yml +2 -3
- package/stacks/react-native/template/AGENTS.md +1 -1
- package/stacks/react-native/template/codemagic.yaml +2 -1
- package/stacks/react-native/template/scripts/ai/pm-run.sh +12 -0
- package/stacks/react-native/template/scripts/ai/prebuild.sh +28 -0
- package/stacks/react-native/template/scripts/ai/release-build.sh +6 -2
- package/stacks/react-native/template/scripts/ai/release-check.js +69 -15
- package/stacks/react-native/template/scripts/ai/set-version.sh +19 -1
- package/stacks/react-native/template/scripts/ai/verify.sh +17 -4
- package/stacks/react-native/template/specs/_templates/flow.yaml +7 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# Native View Reference
|
|
2
|
+
|
|
3
|
+
Native views let you render platform UI components (UIView on iOS, Android View on Android) as React components.
|
|
4
|
+
|
|
5
|
+
## Defining a View
|
|
6
|
+
|
|
7
|
+
**Swift:**
|
|
8
|
+
|
|
9
|
+
```swift
|
|
10
|
+
public class MyViewModule: Module {
|
|
11
|
+
public func definition() -> ModuleDefinition {
|
|
12
|
+
Name("MyView")
|
|
13
|
+
|
|
14
|
+
View(MyNativeView.self) {
|
|
15
|
+
Prop("title") { (view: MyNativeView, title: String) in
|
|
16
|
+
view.titleLabel.text = title
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
Events("onPress", "onLoad")
|
|
20
|
+
|
|
21
|
+
AsyncFunction("reset") { (view: MyNativeView) in
|
|
22
|
+
view.reset()
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
class MyNativeView: ExpoView {
|
|
29
|
+
let titleLabel = UILabel()
|
|
30
|
+
|
|
31
|
+
required init(appContext: AppContext) {
|
|
32
|
+
super.init(appContext: appContext)
|
|
33
|
+
clipsToBounds = true
|
|
34
|
+
addSubview(titleLabel)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
override func layoutSubviews() {
|
|
38
|
+
super.layoutSubviews()
|
|
39
|
+
titleLabel.frame = bounds
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Kotlin:**
|
|
45
|
+
|
|
46
|
+
```kotlin
|
|
47
|
+
class MyViewModule : Module() {
|
|
48
|
+
override fun definition() = ModuleDefinition {
|
|
49
|
+
Name("MyView")
|
|
50
|
+
|
|
51
|
+
View(MyNativeView::class) {
|
|
52
|
+
Prop("title") { view: MyNativeView, title: String ->
|
|
53
|
+
view.titleView.text = title
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
Events("onPress", "onLoad")
|
|
57
|
+
|
|
58
|
+
AsyncFunction("reset") { view: MyNativeView ->
|
|
59
|
+
view.reset()
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
class MyNativeView(context: Context, appContext: AppContext) : ExpoView(context, appContext) {
|
|
66
|
+
val titleView = TextView(context).also {
|
|
67
|
+
addView(it, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT))
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**TypeScript:**
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { requireNativeView } from "expo";
|
|
76
|
+
|
|
77
|
+
export type MyViewProps = {
|
|
78
|
+
title?: string;
|
|
79
|
+
onPress?: (event: { nativeEvent: { x: number; y: number } }) => void;
|
|
80
|
+
onLoad?: () => void;
|
|
81
|
+
} & ViewProps;
|
|
82
|
+
|
|
83
|
+
const NativeView = requireNativeView<MyViewProps>("MyView");
|
|
84
|
+
|
|
85
|
+
export function MyView(props: MyViewProps) {
|
|
86
|
+
return <NativeView {...props} />;
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## View Event Dispatching
|
|
91
|
+
|
|
92
|
+
**Swift:**
|
|
93
|
+
|
|
94
|
+
```swift
|
|
95
|
+
class MyNativeView: ExpoView {
|
|
96
|
+
let onPress = EventDispatcher()
|
|
97
|
+
|
|
98
|
+
func handleTap(at point: CGPoint) {
|
|
99
|
+
onPress(["x": point.x, "y": point.y])
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Kotlin:**
|
|
105
|
+
|
|
106
|
+
```kotlin
|
|
107
|
+
class MyNativeView(context: Context, appContext: AppContext) : ExpoView(context, appContext) {
|
|
108
|
+
private val onPress by EventDispatcher()
|
|
109
|
+
|
|
110
|
+
fun handleTap(x: Float, y: Float) {
|
|
111
|
+
onPress(mapOf("x" to x, "y" to y))
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## View Lifecycle
|
|
117
|
+
|
|
118
|
+
```swift
|
|
119
|
+
// Called after all props have been set
|
|
120
|
+
OnViewDidUpdateProps { (view: MyNativeView) in
|
|
121
|
+
view.applyChanges()
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
```kotlin
|
|
126
|
+
// Android only - called when view is no longer used
|
|
127
|
+
OnViewDestroys { view: MyNativeView ->
|
|
128
|
+
view.cleanup()
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## AsyncFunction on Views
|
|
133
|
+
|
|
134
|
+
Functions defined inside `View` are accessible via React ref:
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
const ref = useRef<MyView>(null);
|
|
138
|
+
// Call native function
|
|
139
|
+
await ref.current?.reset();
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## PropGroup (Android)
|
|
143
|
+
|
|
144
|
+
Batch-register multiple props with shared setter logic:
|
|
145
|
+
|
|
146
|
+
```kotlin
|
|
147
|
+
View(MyNativeView::class) {
|
|
148
|
+
PropGroup("border", "width" to Float::class, "color" to Int::class) { view, index, value ->
|
|
149
|
+
when (index) {
|
|
150
|
+
0 -> view.borderWidth = value as Float
|
|
151
|
+
1 -> view.borderColor = value as Int
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## GroupView (Android)
|
|
158
|
+
|
|
159
|
+
Enable view group functionality for managing child views:
|
|
160
|
+
|
|
161
|
+
```kotlin
|
|
162
|
+
View(MyContainerView::class) {
|
|
163
|
+
GroupView {
|
|
164
|
+
AddChildView { parent, child, index -> parent.addView(child, index) }
|
|
165
|
+
GetChildCount { parent -> parent.childCount }
|
|
166
|
+
GetChildViewAt { parent, index -> parent.getChildAt(index) }
|
|
167
|
+
RemoveChildView { parent, child -> parent.removeView(child) }
|
|
168
|
+
RemoveChildViewAt { parent, index -> parent.removeViewAt(index) }
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
```
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: expo-router
|
|
3
|
+
description: Navigation and routing for Expo Router. Covers file-based routes, groups and dynamic routes, folder organization, Link with previews and context menus, native Stack, page titles, modals and form sheets, NativeTabs, headers and toolbars, and header search bars.
|
|
4
|
+
version: 1.0.1
|
|
5
|
+
license: MIT
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Expo Router Navigation
|
|
9
|
+
|
|
10
|
+
Navigation and routing for Expo Router apps. For screen styling, colors, controls, media, and visual effects, use the `expo-native-ui` skill; for motion and gestures, use `expo-animation`.
|
|
11
|
+
|
|
12
|
+
## References
|
|
13
|
+
|
|
14
|
+
Consult these resources as needed:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
references/
|
|
18
|
+
route-structure.md Route conventions, dynamic routes, groups, folder organization
|
|
19
|
+
tabs.md NativeTabs, migration from JS tabs, iOS 26 features
|
|
20
|
+
toolbar-and-headers.md Stack headers and toolbar buttons, menus, search (iOS only)
|
|
21
|
+
form-sheet.md Form sheets in expo-router: configuration, footers and background interaction.
|
|
22
|
+
search.md Search bar with headers, useSearch hook, filtering patterns
|
|
23
|
+
zoom-transitions.md Apple Zoom: fluid zoom transitions with Link.AppleZoom (iOS 18+)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Code Style
|
|
27
|
+
|
|
28
|
+
- Always use kebab-case for file names, e.g. `comment-card.tsx`
|
|
29
|
+
- Always remove old route files when moving or restructuring navigation
|
|
30
|
+
- Never use special characters in file names
|
|
31
|
+
- Configure tsconfig.json with path aliases, and prefer aliases over relative imports for refactors.
|
|
32
|
+
|
|
33
|
+
## Routes
|
|
34
|
+
|
|
35
|
+
See `./references/route-structure.md` for detailed route conventions.
|
|
36
|
+
|
|
37
|
+
- Routes belong in the `app` directory.
|
|
38
|
+
- Never co-locate components, types, or utilities in the app directory. This is an anti-pattern.
|
|
39
|
+
- Ensure the app always has a route that matches "/", it may be inside a group route.
|
|
40
|
+
|
|
41
|
+
## Library Preferences
|
|
42
|
+
|
|
43
|
+
- `Color` from `expo-router` for native semantic colors, not raw `PlatformColor` (type-safe, auto-adapts to light/dark). See `expo-native-ui` for the full color palette pattern.
|
|
44
|
+
- In SDK 56+, never import from `@react-navigation/*` directly — use `expo-router/react-navigation` instead (covers `@react-navigation/native`, `/core`, `/elements`, `/routers`)
|
|
45
|
+
|
|
46
|
+
## Behavior
|
|
47
|
+
|
|
48
|
+
- Prefer `Stack.SearchBar` to add a search bar to a screen
|
|
49
|
+
|
|
50
|
+
# Navigation
|
|
51
|
+
|
|
52
|
+
## Link
|
|
53
|
+
|
|
54
|
+
Use `<Link href="/path" />` from 'expo-router' for navigation between routes.
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
import { Link } from 'expo-router';
|
|
58
|
+
|
|
59
|
+
// Basic link
|
|
60
|
+
<Link href="/path" />
|
|
61
|
+
|
|
62
|
+
// Wrapping custom components
|
|
63
|
+
<Link href="/path" asChild>
|
|
64
|
+
<Pressable>...</Pressable>
|
|
65
|
+
</Link>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Whenever possible, include a `<Link.Preview>` to follow iOS conventions. Add context menus and previews frequently to enhance navigation.
|
|
69
|
+
|
|
70
|
+
## Stack
|
|
71
|
+
|
|
72
|
+
- ALWAYS use `_layout.tsx` files to define stacks
|
|
73
|
+
- Use Stack from 'expo-router/stack' for native navigation stacks
|
|
74
|
+
|
|
75
|
+
### Page Title
|
|
76
|
+
|
|
77
|
+
Set the page title with `Stack.Title`:
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
<Stack.Title>Home</Stack.Title>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Context Menus
|
|
84
|
+
|
|
85
|
+
Add long press context menus to Link components:
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
import { Link } from "expo-router";
|
|
89
|
+
|
|
90
|
+
<Link href="/settings" asChild>
|
|
91
|
+
<Link.Trigger>
|
|
92
|
+
<Pressable>
|
|
93
|
+
<Card />
|
|
94
|
+
</Pressable>
|
|
95
|
+
</Link.Trigger>
|
|
96
|
+
<Link.Menu>
|
|
97
|
+
<Link.MenuAction
|
|
98
|
+
title="Share"
|
|
99
|
+
icon="square.and.arrow.up"
|
|
100
|
+
onPress={handleSharePress}
|
|
101
|
+
/>
|
|
102
|
+
<Link.MenuAction
|
|
103
|
+
title="Block"
|
|
104
|
+
icon="nosign"
|
|
105
|
+
destructive
|
|
106
|
+
onPress={handleBlockPress}
|
|
107
|
+
/>
|
|
108
|
+
<Link.Menu title="More" icon="ellipsis">
|
|
109
|
+
<Link.MenuAction title="Copy" icon="doc.on.doc" onPress={() => {}} />
|
|
110
|
+
<Link.MenuAction
|
|
111
|
+
title="Delete"
|
|
112
|
+
icon="trash"
|
|
113
|
+
destructive
|
|
114
|
+
onPress={() => {}}
|
|
115
|
+
/>
|
|
116
|
+
</Link.Menu>
|
|
117
|
+
</Link.Menu>
|
|
118
|
+
</Link>;
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Link Previews
|
|
122
|
+
|
|
123
|
+
Use link previews frequently to enhance navigation:
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
<Link href="/settings">
|
|
127
|
+
<Link.Trigger>
|
|
128
|
+
<Pressable>
|
|
129
|
+
<Card />
|
|
130
|
+
</Pressable>
|
|
131
|
+
</Link.Trigger>
|
|
132
|
+
<Link.Preview />
|
|
133
|
+
</Link>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Link preview can be used with context menus.
|
|
137
|
+
|
|
138
|
+
## Modal
|
|
139
|
+
|
|
140
|
+
Present a screen as a modal:
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
<Stack.Screen name="modal" options={{ presentation: "modal" }} />
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Prefer this to building a custom modal component.
|
|
147
|
+
|
|
148
|
+
## Sheet
|
|
149
|
+
|
|
150
|
+
Present a screen as a dynamic form sheet:
|
|
151
|
+
|
|
152
|
+
```tsx
|
|
153
|
+
<Stack.Screen
|
|
154
|
+
name="sheet"
|
|
155
|
+
options={{
|
|
156
|
+
presentation: "formSheet",
|
|
157
|
+
sheetGrabberVisible: true,
|
|
158
|
+
sheetAllowedDetents: [0.5, 1.0],
|
|
159
|
+
contentStyle: { backgroundColor: "transparent" },
|
|
160
|
+
}}
|
|
161
|
+
/>
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
- Using `contentStyle: { backgroundColor: "transparent" }` makes the background liquid glass on iOS 26+.
|
|
165
|
+
|
|
166
|
+
## Common route structure
|
|
167
|
+
|
|
168
|
+
A standard app layout with tabs and stacks inside each tab:
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
app/
|
|
172
|
+
_layout.tsx — <NativeTabs />
|
|
173
|
+
(index,search)/
|
|
174
|
+
_layout.tsx — <Stack />
|
|
175
|
+
index.tsx — Main list
|
|
176
|
+
search.tsx — Search view
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
```tsx
|
|
180
|
+
// app/_layout.tsx
|
|
181
|
+
import { NativeTabs } from "expo-router/unstable-native-tabs";
|
|
182
|
+
import { ThemeProvider, DarkTheme, DefaultTheme } from "expo-router/react-navigation";
|
|
183
|
+
import { useColorScheme } from "react-native";
|
|
184
|
+
|
|
185
|
+
export default function Layout() {
|
|
186
|
+
const colorScheme = useColorScheme();
|
|
187
|
+
return (
|
|
188
|
+
<ThemeProvider value={colorScheme === "dark" ? DarkTheme : DefaultTheme}>
|
|
189
|
+
<NativeTabs>
|
|
190
|
+
<NativeTabs.Trigger name="(index)">
|
|
191
|
+
<NativeTabs.Trigger.Icon sf="list.dash" md="list" />
|
|
192
|
+
<NativeTabs.Trigger.Label>Items</NativeTabs.Trigger.Label>
|
|
193
|
+
</NativeTabs.Trigger>
|
|
194
|
+
<NativeTabs.Trigger name="(search)" role="search" />
|
|
195
|
+
</NativeTabs>
|
|
196
|
+
</ThemeProvider>
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Create a shared group route so both tabs can push common screens:
|
|
202
|
+
|
|
203
|
+
```tsx
|
|
204
|
+
// app/(index,search)/_layout.tsx
|
|
205
|
+
import { Stack } from "expo-router/stack";
|
|
206
|
+
import { colors } from "@/theme/colors";
|
|
207
|
+
|
|
208
|
+
export default function Layout({ segment }) {
|
|
209
|
+
const screen = segment.match(/\((.*)\)/)?.[1]!;
|
|
210
|
+
const titles: Record<string, string> = { index: "Items", search: "Search" };
|
|
211
|
+
|
|
212
|
+
return (
|
|
213
|
+
<Stack
|
|
214
|
+
screenOptions={{
|
|
215
|
+
headerTransparent: true,
|
|
216
|
+
headerShadowVisible: false,
|
|
217
|
+
headerLargeTitleShadowVisible: false,
|
|
218
|
+
headerLargeStyle: { backgroundColor: "transparent" },
|
|
219
|
+
headerTitleStyle: { color: colors.label },
|
|
220
|
+
headerLargeTitleEnabled: true,
|
|
221
|
+
headerBlurEffect: "none",
|
|
222
|
+
headerBackButtonDisplayMode: "minimal",
|
|
223
|
+
}}
|
|
224
|
+
>
|
|
225
|
+
<Stack.Screen name={screen} options={{ title: titles[screen] }} />
|
|
226
|
+
<Stack.Screen name="i/[id]" options={{ headerLargeTitleEnabled: false }} />
|
|
227
|
+
</Stack>
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
`headerLargeTitleEnabled` is the SDK 56+ option name; older SDKs use `headerLargeTitle`, which is deprecated upstream.
|
|
233
|
+
|
|
234
|
+
## Submitting Feedback
|
|
235
|
+
If you encounter errors, misleading or outdated information in this skill, report it so Expo can improve:
|
|
236
|
+
```bash
|
|
237
|
+
npx --yes submit-expo-feedback@latest --category skills --subject "expo-router" "<actionable feedback>"
|
|
238
|
+
```
|
|
239
|
+
Only submit when you have something specific and actionable to report. Include as much relevant context as possible.
|
|
240
|
+
If an AI agent repeatedly failed or the user had to take over an Expo task, load the expo-skill-feedback skill and follow its eval-candidate flow instead of reusing the command above.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "Expo Router"
|
|
3
|
+
short_description: "Navigate and structure Expo Router apps: file-based routes, links, native stacks, modals, sheets, native tabs, headers, and search"
|
|
4
|
+
default_prompt: "Use $expo-router to structure file-based routes, wire up navigation with Link previews and context menus, configure native Stack screens, modals, form sheets, NativeTabs, headers, toolbars, and search bars."
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
# Form Sheets in Expo Router
|
|
2
|
+
|
|
3
|
+
This skill covers implementing form sheets with footers using Expo Router's Stack navigator and react-native-screens.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Form sheets are modal presentations that appear as a card sliding up from the bottom of the screen. They're ideal for:
|
|
8
|
+
|
|
9
|
+
- Quick actions and confirmations
|
|
10
|
+
- Settings panels
|
|
11
|
+
- Login/signup flows
|
|
12
|
+
- Action sheets with custom content
|
|
13
|
+
|
|
14
|
+
**Requirements:**
|
|
15
|
+
|
|
16
|
+
- Expo Router Stack navigator
|
|
17
|
+
|
|
18
|
+
## Basic Usage
|
|
19
|
+
|
|
20
|
+
### Form Sheet with Footer
|
|
21
|
+
|
|
22
|
+
Configure the Stack.Screen with transparent backgrounds and sheet presentation:
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
// app/_layout.tsx
|
|
26
|
+
import { Stack } from "expo-router";
|
|
27
|
+
|
|
28
|
+
export default function Layout() {
|
|
29
|
+
return (
|
|
30
|
+
<Stack>
|
|
31
|
+
<Stack.Screen name="index" />
|
|
32
|
+
<Stack.Screen
|
|
33
|
+
name="about"
|
|
34
|
+
options={{
|
|
35
|
+
presentation: "formSheet",
|
|
36
|
+
sheetAllowedDetents: [0.25],
|
|
37
|
+
headerTransparent: true,
|
|
38
|
+
contentStyle: { backgroundColor: "transparent" },
|
|
39
|
+
sheetGrabberVisible: true,
|
|
40
|
+
}}
|
|
41
|
+
>
|
|
42
|
+
<Stack.Header style={{ backgroundColor: "transparent" }}></Stack.Header>
|
|
43
|
+
</Stack.Screen>
|
|
44
|
+
</Stack>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Form Sheet Screen Content
|
|
50
|
+
|
|
51
|
+
> Requires Expo SDK 55 or later.
|
|
52
|
+
|
|
53
|
+
Use `flex: 1` to allow the content to fill available space, enabling footer positioning:
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
// app/about.tsx
|
|
57
|
+
import { View, Text, StyleSheet } from "react-native";
|
|
58
|
+
|
|
59
|
+
export default function AboutSheet() {
|
|
60
|
+
return (
|
|
61
|
+
<View style={styles.container}>
|
|
62
|
+
{/* Main content */}
|
|
63
|
+
<View style={styles.content}>
|
|
64
|
+
<Text>Sheet Content</Text>
|
|
65
|
+
</View>
|
|
66
|
+
|
|
67
|
+
{/* Footer - stays at bottom */}
|
|
68
|
+
<View style={styles.footer}>
|
|
69
|
+
<Text>Footer Content</Text>
|
|
70
|
+
</View>
|
|
71
|
+
</View>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const styles = StyleSheet.create({
|
|
76
|
+
container: {
|
|
77
|
+
flex: 1,
|
|
78
|
+
},
|
|
79
|
+
content: {
|
|
80
|
+
flex: 1,
|
|
81
|
+
padding: 16,
|
|
82
|
+
},
|
|
83
|
+
footer: {
|
|
84
|
+
padding: 16,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Formsheet with interactive content below
|
|
90
|
+
|
|
91
|
+
Use `sheetLargestUndimmedDetentIndex` (zero-indexed) to keep content behind the form sheet interactive — e.g. letting users pan a map beneath it. Setting it to `1` allows interaction at the first two detents but dims on the third.
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
// app/_layout.tsx
|
|
95
|
+
import { Stack } from 'expo-router';
|
|
96
|
+
|
|
97
|
+
export default function Layout() {
|
|
98
|
+
return (
|
|
99
|
+
<Stack screenOptions={{ headerShown: false }}>
|
|
100
|
+
<Stack.Screen name="index" />
|
|
101
|
+
<Stack.Screen
|
|
102
|
+
name="info-sheet"
|
|
103
|
+
options={{
|
|
104
|
+
presentation: "formSheet",
|
|
105
|
+
sheetAllowedDetents: [0.2, 0.5, 1.0],
|
|
106
|
+
sheetLargestUndimmedDetentIndex: 1,
|
|
107
|
+
/* other options */
|
|
108
|
+
}}
|
|
109
|
+
/>
|
|
110
|
+
</Stack>
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Key Options
|
|
116
|
+
|
|
117
|
+
| Option | Type | Description |
|
|
118
|
+
| --------------------- | ---------- | ----------------------------------------------------------- |
|
|
119
|
+
| `presentation` | `string` | Set to `'formSheet'` for sheet presentation |
|
|
120
|
+
| `sheetGrabberVisible` | `boolean` | Shows the drag handle at the top of the sheet |
|
|
121
|
+
| `sheetAllowedDetents` | `number[]` | Array of detent heights (0-1 range, e.g., `[0.25]` for 25%) |
|
|
122
|
+
| `headerTransparent` | `boolean` | Makes header background transparent |
|
|
123
|
+
| `contentStyle` | `object` | Style object for the screen content container |
|
|
124
|
+
| `title` | `string` | Screen title (set to `''` for no title) |
|
|
125
|
+
|
|
126
|
+
## Common Detent Values
|
|
127
|
+
|
|
128
|
+
- `[0.25]` - Quarter sheet (compact actions)
|
|
129
|
+
- `[0.5]` - Half sheet (medium content)
|
|
130
|
+
- `[0.75]` - Three-quarter sheet (detailed forms)
|
|
131
|
+
- `[0.25, 0.5, 1]` - Multiple stops (expandable sheet)
|
|
132
|
+
|
|
133
|
+
## Complete Example
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
// _layout.tsx
|
|
137
|
+
import { Stack } from "expo-router";
|
|
138
|
+
|
|
139
|
+
export default function Layout() {
|
|
140
|
+
return (
|
|
141
|
+
<Stack>
|
|
142
|
+
<Stack.Screen name="index" options={{ title: "Home" }} />
|
|
143
|
+
<Stack.Screen
|
|
144
|
+
name="confirm"
|
|
145
|
+
options={{
|
|
146
|
+
contentStyle: { backgroundColor: "transparent" },
|
|
147
|
+
presentation: "formSheet",
|
|
148
|
+
title: "",
|
|
149
|
+
sheetGrabberVisible: true,
|
|
150
|
+
sheetAllowedDetents: [0.25],
|
|
151
|
+
headerTransparent: true,
|
|
152
|
+
}}
|
|
153
|
+
>
|
|
154
|
+
<Stack.Header style={{ backgroundColor: "transparent" }}>
|
|
155
|
+
<Stack.Header.Right />
|
|
156
|
+
</Stack.Header>
|
|
157
|
+
</Stack.Screen>
|
|
158
|
+
</Stack>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
```tsx
|
|
164
|
+
// app/confirm.tsx
|
|
165
|
+
import { View, Text, Pressable, StyleSheet } from "react-native";
|
|
166
|
+
import { router } from "expo-router";
|
|
167
|
+
|
|
168
|
+
export default function ConfirmSheet() {
|
|
169
|
+
return (
|
|
170
|
+
<View style={styles.container}>
|
|
171
|
+
<View style={styles.content}>
|
|
172
|
+
<Text style={styles.title}>Confirm Action</Text>
|
|
173
|
+
<Text style={styles.description}>
|
|
174
|
+
Are you sure you want to proceed?
|
|
175
|
+
</Text>
|
|
176
|
+
</View>
|
|
177
|
+
|
|
178
|
+
<View style={styles.footer}>
|
|
179
|
+
<Pressable style={styles.cancelButton} onPress={() => router.back()}>
|
|
180
|
+
<Text style={styles.cancelText}>Cancel</Text>
|
|
181
|
+
</Pressable>
|
|
182
|
+
<Pressable style={styles.confirmButton} onPress={() => router.back()}>
|
|
183
|
+
<Text style={styles.confirmText}>Confirm</Text>
|
|
184
|
+
</Pressable>
|
|
185
|
+
</View>
|
|
186
|
+
</View>
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const styles = StyleSheet.create({
|
|
191
|
+
container: {
|
|
192
|
+
flex: 1,
|
|
193
|
+
},
|
|
194
|
+
content: {
|
|
195
|
+
flex: 1,
|
|
196
|
+
padding: 20,
|
|
197
|
+
alignItems: "center",
|
|
198
|
+
justifyContent: "center",
|
|
199
|
+
},
|
|
200
|
+
title: {
|
|
201
|
+
fontSize: 18,
|
|
202
|
+
fontWeight: "600",
|
|
203
|
+
marginBottom: 8,
|
|
204
|
+
},
|
|
205
|
+
description: {
|
|
206
|
+
fontSize: 14,
|
|
207
|
+
color: "#666",
|
|
208
|
+
textAlign: "center",
|
|
209
|
+
},
|
|
210
|
+
footer: {
|
|
211
|
+
flexDirection: "row",
|
|
212
|
+
padding: 16,
|
|
213
|
+
gap: 12,
|
|
214
|
+
},
|
|
215
|
+
cancelButton: {
|
|
216
|
+
flex: 1,
|
|
217
|
+
padding: 14,
|
|
218
|
+
borderRadius: 10,
|
|
219
|
+
backgroundColor: "#f0f0f0",
|
|
220
|
+
alignItems: "center",
|
|
221
|
+
},
|
|
222
|
+
cancelText: {
|
|
223
|
+
fontSize: 16,
|
|
224
|
+
fontWeight: "500",
|
|
225
|
+
},
|
|
226
|
+
confirmButton: {
|
|
227
|
+
flex: 1,
|
|
228
|
+
padding: 14,
|
|
229
|
+
borderRadius: 10,
|
|
230
|
+
backgroundColor: "#007AFF",
|
|
231
|
+
alignItems: "center",
|
|
232
|
+
},
|
|
233
|
+
confirmText: {
|
|
234
|
+
fontSize: 16,
|
|
235
|
+
fontWeight: "500",
|
|
236
|
+
color: "white",
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## Troubleshooting
|
|
242
|
+
|
|
243
|
+
### Content not filling sheet
|
|
244
|
+
|
|
245
|
+
Make sure the root View uses `flex: 1`:
|
|
246
|
+
|
|
247
|
+
```tsx
|
|
248
|
+
<View style={{ flex: 1 }}>{/* content */}</View>
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Sheet background showing through
|
|
252
|
+
|
|
253
|
+
Set `contentStyle: { backgroundColor: 'transparent' }` in options and style your content container with the desired background color instead.
|