agentic-mobile-kit 0.5.4 → 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 +6 -1
- package/bin/cli.js +1 -1
- package/lib/doctor.js +26 -5
- package/lib/init.js +235 -49
- 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 -4
- package/stacks/react-native/template/.githooks/pre-commit +7 -2
- package/stacks/react-native/template/.github/workflows/e2e.yml +2 -0
- package/stacks/react-native/template/.github/workflows/ios.yml +3 -5
- package/stacks/react-native/template/AGENTS.md +4 -4
- package/stacks/react-native/template/codemagic.yaml +2 -1
- package/stacks/react-native/template/docs/ai/known-issues.md +12 -2
- package/stacks/react-native/template/docs/ai/react-native.md +5 -4
- package/stacks/react-native/template/scripts/ai/android-flavors.js +41 -0
- package/stacks/react-native/template/scripts/ai/case-check.js +35 -0
- package/stacks/react-native/template/scripts/ai/install-deps.sh +4 -1
- package/stacks/react-native/template/scripts/ai/ios-build.sh +10 -3
- package/stacks/react-native/template/scripts/ai/pm-run.sh +12 -0
- package/stacks/react-native/template/scripts/ai/pod-install.sh +12 -0
- package/stacks/react-native/template/scripts/ai/prebuild.sh +28 -0
- package/stacks/react-native/template/scripts/ai/release-build.sh +32 -8
- package/stacks/react-native/template/scripts/ai/release-check.js +98 -18
- package/stacks/react-native/template/scripts/ai/set-version.sh +19 -1
- package/stacks/react-native/template/scripts/ai/verify.sh +69 -16
- package/stacks/react-native/template/specs/_templates/flow.yaml +9 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
# Native Module DSL Reference
|
|
2
|
+
|
|
3
|
+
Swift is shown as the primary language. Kotlin follows the same DSL structure (see SKILL.md for both). Kotlin-specific syntax is noted where it meaningfully differs.
|
|
4
|
+
|
|
5
|
+
## Name
|
|
6
|
+
|
|
7
|
+
Sets the module identifier used in JavaScript.
|
|
8
|
+
|
|
9
|
+
```swift
|
|
10
|
+
Name("MyModule")
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Constant
|
|
14
|
+
|
|
15
|
+
Computed once on first access, then cached.
|
|
16
|
+
|
|
17
|
+
```swift
|
|
18
|
+
Constant("PI") { 3.14159 }
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Function (Synchronous)
|
|
22
|
+
|
|
23
|
+
Blocks the JS thread until completion. Supports up to 8 arguments.
|
|
24
|
+
|
|
25
|
+
```swift
|
|
26
|
+
Function("add") { (a: Int, b: Int) -> Int in
|
|
27
|
+
return a + b
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## AsyncFunction
|
|
32
|
+
|
|
33
|
+
Returns a Promise. Runs on a background thread by default.
|
|
34
|
+
|
|
35
|
+
```swift
|
|
36
|
+
AsyncFunction("fetchData") { (url: URL) -> String in
|
|
37
|
+
let data = try Data(contentsOf: url)
|
|
38
|
+
return String(data: data, encoding: .utf8) ?? ""
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Force main queue execution
|
|
42
|
+
AsyncFunction("updateUI") { () -> Void in
|
|
43
|
+
// UI work
|
|
44
|
+
}.runOnQueue(.main)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Kotlin differences:**
|
|
48
|
+
|
|
49
|
+
```kotlin
|
|
50
|
+
// Supports Kotlin coroutines
|
|
51
|
+
AsyncFunction("fetchData") Coroutine { url: java.net.URL ->
|
|
52
|
+
withContext(Dispatchers.IO) {
|
|
53
|
+
url.readText()
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Property
|
|
59
|
+
|
|
60
|
+
Getter/setter for JS object properties.
|
|
61
|
+
|
|
62
|
+
```swift
|
|
63
|
+
// Read-only
|
|
64
|
+
Property("version") { "1.0.0" }
|
|
65
|
+
|
|
66
|
+
// Read-write
|
|
67
|
+
Property("volume")
|
|
68
|
+
.get { () -> Float in self.volume }
|
|
69
|
+
.set { (newValue: Float) in self.volume = newValue }
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Events
|
|
73
|
+
|
|
74
|
+
Declares events the module can send to JS. Must be declared before using `sendEvent`.
|
|
75
|
+
|
|
76
|
+
```swift
|
|
77
|
+
// Declaration
|
|
78
|
+
Events("onChange", "onError")
|
|
79
|
+
|
|
80
|
+
// Sending from native (Swift)
|
|
81
|
+
sendEvent("onChange", ["value": newValue])
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Kotlin difference** — uses `bundleOf`:
|
|
85
|
+
|
|
86
|
+
```kotlin
|
|
87
|
+
sendEvent("onChange", bundleOf("value" to newValue))
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**JS subscription:**
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { useEvent } from "expo";
|
|
94
|
+
import MyModule from "./MyModule";
|
|
95
|
+
|
|
96
|
+
// Hook-based (recommended)
|
|
97
|
+
const event = useEvent(MyModule, "onChange");
|
|
98
|
+
|
|
99
|
+
// Manual subscription
|
|
100
|
+
const subscription = MyModule.addListener("onChange", (event) => {
|
|
101
|
+
console.log(event.value);
|
|
102
|
+
});
|
|
103
|
+
// Clean up: subscription.remove()
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### OnStartObserving / OnStopObserving
|
|
107
|
+
|
|
108
|
+
Called when the first listener attaches / last listener detaches. Can be scoped to specific events.
|
|
109
|
+
|
|
110
|
+
```swift
|
|
111
|
+
OnStartObserving("onChange") {
|
|
112
|
+
// Start producing events
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
OnStopObserving("onChange") {
|
|
116
|
+
// Stop producing events
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Type System
|
|
123
|
+
|
|
124
|
+
### Primitives
|
|
125
|
+
|
|
126
|
+
| Swift | Kotlin | JS |
|
|
127
|
+
|-------|--------|----|
|
|
128
|
+
| `Bool` | `Boolean` | `boolean` |
|
|
129
|
+
| `Int`, `Int32` | `Int` | `number` |
|
|
130
|
+
| `Int64` | `Long` | `number` |
|
|
131
|
+
| `Float`, `Float32` | `Float` | `number` |
|
|
132
|
+
| `Double` | `Double` | `number` |
|
|
133
|
+
| `String` | `String` | `string` |
|
|
134
|
+
| `URL` | `java.net.URL` / `android.net.Uri` | `string` |
|
|
135
|
+
| `CGPoint` | - | `{ x, y }` |
|
|
136
|
+
| `CGSize` | - | `{ width, height }` |
|
|
137
|
+
| `CGRect` | - | `{ x, y, width, height }` |
|
|
138
|
+
| `UIColor` / `CGColor` | `android.graphics.Color` | `string` (ProcessedColorValue) |
|
|
139
|
+
| `Data` | `kotlin.ByteArray` | `Uint8Array` |
|
|
140
|
+
|
|
141
|
+
### Records (Struct-like types)
|
|
142
|
+
|
|
143
|
+
```swift
|
|
144
|
+
struct UserRecord: Record {
|
|
145
|
+
@Field var name: String = ""
|
|
146
|
+
@Field var age: Int = 0
|
|
147
|
+
@Field var email: String?
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
Function("createUser") { (user: UserRecord) -> Bool in
|
|
151
|
+
return true
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**Kotlin difference** — uses `class` instead of `struct`, optional fields need explicit `= null`:
|
|
156
|
+
|
|
157
|
+
```kotlin
|
|
158
|
+
class UserRecord : Record {
|
|
159
|
+
@Field var name: String = ""
|
|
160
|
+
@Field var age: Int = 0
|
|
161
|
+
@Field var email: String? = null
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Enums (Enumerable)
|
|
166
|
+
|
|
167
|
+
```swift
|
|
168
|
+
enum Theme: String, Enumerable {
|
|
169
|
+
case light
|
|
170
|
+
case dark
|
|
171
|
+
case system
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
Function("setTheme") { (theme: Theme) in
|
|
175
|
+
// type-safe enum value
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Kotlin difference** — uses `enum class` with explicit `value` property:
|
|
180
|
+
|
|
181
|
+
```kotlin
|
|
182
|
+
enum class Theme(val value: String) : Enumerable {
|
|
183
|
+
LIGHT("light"),
|
|
184
|
+
DARK("dark"),
|
|
185
|
+
SYSTEM("system")
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Either Types (Union types)
|
|
190
|
+
|
|
191
|
+
```swift
|
|
192
|
+
Function("process") { (input: Either<String, Int>) in
|
|
193
|
+
if let str = input.get(String.self) {
|
|
194
|
+
// handle string
|
|
195
|
+
} else if let num = input.get(Int.self) {
|
|
196
|
+
// handle number
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Also available: `EitherOfThree<A, B, C>`, `EitherOfFour<A, B, C, D>`.
|
|
202
|
+
|
|
203
|
+
### JavaScript Values (Direct JS manipulation)
|
|
204
|
+
|
|
205
|
+
For advanced use in synchronous functions running on JS thread:
|
|
206
|
+
|
|
207
|
+
```swift
|
|
208
|
+
Function("callback") { (fn: JavaScriptFunction<String>) in
|
|
209
|
+
let result = fn("arg1", "arg2")
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## Shared Objects
|
|
216
|
+
|
|
217
|
+
Bridge native class instances to JS with automatic lifecycle management. Instances are deallocated when neither JS nor native code holds a reference.
|
|
218
|
+
|
|
219
|
+
### Defining a Shared Object
|
|
220
|
+
|
|
221
|
+
```swift
|
|
222
|
+
class ImageContext: SharedObject {
|
|
223
|
+
private var image: UIImage
|
|
224
|
+
|
|
225
|
+
init(image: UIImage) {
|
|
226
|
+
self.image = image
|
|
227
|
+
super.init()
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
func rotate(degrees: Double) {
|
|
231
|
+
image = image.rotated(degrees: degrees)
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
**Kotlin difference** — takes `RuntimeContext` in constructor, override `sharedObjectDidRelease()` for cleanup:
|
|
237
|
+
|
|
238
|
+
```kotlin
|
|
239
|
+
class ImageContext(
|
|
240
|
+
runtimeContext: RuntimeContext,
|
|
241
|
+
private var bitmap: Bitmap
|
|
242
|
+
) : SharedObject(runtimeContext) {
|
|
243
|
+
|
|
244
|
+
fun rotate(degrees: Float) { /* ... */ }
|
|
245
|
+
|
|
246
|
+
override fun sharedObjectDidRelease() {
|
|
247
|
+
if (!bitmap.isRecycled) bitmap.recycle()
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Exposing via Class DSL
|
|
253
|
+
|
|
254
|
+
```swift
|
|
255
|
+
Class("Context", ImageContext.self) {
|
|
256
|
+
Constructor { (path: String) -> ImageContext in
|
|
257
|
+
return ImageContext(image: UIImage(contentsOfFile: path)!)
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
Function("rotate") { (ctx: ImageContext, degrees: Double) -> ImageContext in
|
|
261
|
+
ctx.rotate(degrees: degrees)
|
|
262
|
+
return ctx
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
Property("width")
|
|
266
|
+
.get { (ctx: ImageContext) -> Int in ctx.width }
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Other Class DSL components: `StaticFunction`, `StaticAsyncFunction`, `AsyncFunction`.
|
|
271
|
+
|
|
272
|
+
### SharedRef
|
|
273
|
+
|
|
274
|
+
Specialized shared reference for passing typed objects between modules:
|
|
275
|
+
|
|
276
|
+
```swift
|
|
277
|
+
final class ImageRef: SharedRef<UIImage> {}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### JS Usage
|
|
281
|
+
|
|
282
|
+
```typescript
|
|
283
|
+
const ctx = await ImageModule.create("/path/to/image.png");
|
|
284
|
+
ctx.rotate(90);
|
|
285
|
+
console.log(ctx.width);
|
|
286
|
+
```
|
|
@@ -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."
|