expo-module-template 56.0.10 → 56.0.11
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 +7 -1
- package/android/build.gradle +32 -0
- package/android/src/main/java/{%= project.package %}/{%- project.moduleName %}.kt +7 -0
- package/ios/{%- project.moduleName %}.swift +3 -0
- package/ios/{%- project.name %}.podspec +3 -0
- package/package.json +2 -2
- package/snippets/ComposeModifier/app.external-imports.tsx.ejs +6 -0
- package/snippets/ComposeModifier/app.jsx.tsx.ejs +13 -0
- package/snippets/ComposeModifier/modifier.kt.ejs +23 -0
- package/snippets/ComposeModifier/modifiers.ts.ejs +7 -0
- package/snippets/ComposeModifier/module.kt.ejs +5 -0
- package/snippets/ComposeView/app.external-imports.tsx.ejs +2 -0
- package/snippets/ComposeView/app.jsx.tsx.ejs +11 -0
- package/snippets/ComposeView/module.kt.ejs +5 -0
- package/snippets/ComposeView/view.kt.ejs +30 -0
- package/snippets/ComposeView/view.tsx.ejs +27 -0
- package/snippets/SwiftUIModifier/app.external-imports.tsx.ejs +6 -0
- package/snippets/SwiftUIModifier/app.jsx.tsx.ejs +13 -0
- package/snippets/SwiftUIModifier/modifier.swift.ejs +17 -0
- package/snippets/SwiftUIModifier/modifiers.ts.ejs +7 -0
- package/snippets/SwiftUIModifier/module.swift.ejs +9 -0
- package/snippets/SwiftUIView/app.external-imports.tsx.ejs +2 -0
- package/snippets/SwiftUIView/app.jsx.tsx.ejs +11 -0
- package/snippets/SwiftUIView/module.swift.ejs +1 -0
- package/snippets/SwiftUIView/view.swift.ejs +19 -0
- package/snippets/SwiftUIView/view.tsx.ejs +27 -0
- package/src/index.ts +12 -0
package/$package.json
CHANGED
|
@@ -28,13 +28,16 @@
|
|
|
28
28
|
"homepage": "<%- repo %>#readme",
|
|
29
29
|
"dependencies": {},
|
|
30
30
|
"devDependencies": {
|
|
31
|
+
<% if (usesExpoUI) { -%>
|
|
32
|
+
"@expo/ui": "^56.0.10",
|
|
33
|
+
<% } -%>
|
|
31
34
|
"@babel/core": "^7.26.0",
|
|
32
35
|
"@types/jest": "^29.2.1",
|
|
33
36
|
"@types/react": "~19.1.1",
|
|
34
37
|
"babel-preset-expo": "~55.0.8",
|
|
35
38
|
"eslint": "~9.39.4",
|
|
36
39
|
"eslint-config-universe": "^15.0.3",
|
|
37
|
-
"expo": "^56.0.
|
|
40
|
+
"expo": "^56.0.5",
|
|
38
41
|
"jest": "^29.7.0",
|
|
39
42
|
"jest-expo": "~55.0.9",
|
|
40
43
|
"prettier": "^3.0.0",
|
|
@@ -48,6 +51,9 @@
|
|
|
48
51
|
]
|
|
49
52
|
},
|
|
50
53
|
"peerDependencies": {
|
|
54
|
+
<% if (usesExpoUI) { -%>
|
|
55
|
+
"@expo/ui": "*",
|
|
56
|
+
<% } -%>
|
|
51
57
|
"expo": "*",
|
|
52
58
|
"react": "*",
|
|
53
59
|
"react-native": "*"
|
package/android/build.gradle
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
|
+
<% if (usesCompose) { -%>
|
|
2
|
+
buildscript {
|
|
3
|
+
repositories {
|
|
4
|
+
mavenCentral()
|
|
5
|
+
}
|
|
6
|
+
dependencies {
|
|
7
|
+
classpath("org.jetbrains.kotlin.plugin.compose:org.jetbrains.kotlin.plugin.compose.gradle.plugin:${kotlinVersion}")
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
<% } -%>
|
|
1
12
|
plugins {
|
|
2
13
|
id 'com.android.library'
|
|
3
14
|
id 'expo-module-gradle-plugin'
|
|
4
15
|
}
|
|
16
|
+
<% if (usesCompose) { -%>
|
|
17
|
+
apply plugin: 'org.jetbrains.kotlin.plugin.compose'
|
|
18
|
+
<% } -%>
|
|
5
19
|
|
|
6
20
|
group = '<%- project.package %>'
|
|
7
21
|
version = '<% if (type === 'remote') { %><%- project.version %><% } else { %>0.1.0<% } %>'
|
|
@@ -12,7 +26,25 @@ android {
|
|
|
12
26
|
versionCode 1
|
|
13
27
|
versionName "<% if (type === 'remote') { %><%- project.version %><% } else { %>0.1.0<% } %>"
|
|
14
28
|
}
|
|
29
|
+
<% if (usesCompose) { -%>
|
|
30
|
+
buildFeatures {
|
|
31
|
+
compose true
|
|
32
|
+
}
|
|
33
|
+
<% } -%>
|
|
15
34
|
lintOptions {
|
|
16
35
|
abortOnError false
|
|
17
36
|
}
|
|
18
37
|
}
|
|
38
|
+
<% if (usesCompose) { -%>
|
|
39
|
+
|
|
40
|
+
dependencies {
|
|
41
|
+
implementation 'androidx.compose.foundation:foundation-android:1.10.6'
|
|
42
|
+
implementation 'androidx.compose.ui:ui-android:1.10.6'
|
|
43
|
+
implementation 'androidx.compose.material3:material3-android:1.5.0-alpha17'
|
|
44
|
+
if (findProject(':expo-ui') != null) {
|
|
45
|
+
implementation project(':expo-ui')
|
|
46
|
+
} else {
|
|
47
|
+
implementation 'expo.modules.ui:expo.modules.ui:+'
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
<% } -%>
|
|
@@ -2,6 +2,13 @@ package <%- project.package %>
|
|
|
2
2
|
|
|
3
3
|
import expo.modules.kotlin.modules.Module
|
|
4
4
|
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
|
+
<% if (project.features.includes('ComposeView')) { -%>
|
|
6
|
+
import expo.modules.ui.ExpoUIView
|
|
7
|
+
<% } -%>
|
|
8
|
+
<% if (project.features.includes('ComposeModifier')) { -%>
|
|
9
|
+
import expo.modules.kotlin.records.recordFromMap
|
|
10
|
+
import expo.modules.ui.ModifierRegistry
|
|
11
|
+
<% } -%>
|
|
5
12
|
|
|
6
13
|
class <%- project.moduleName %> : Module() {
|
|
7
14
|
override fun definition() = ModuleDefinition {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-module-template",
|
|
3
|
-
"version": "56.0.
|
|
3
|
+
"version": "56.0.11",
|
|
4
4
|
"description": "ExpoModuleTemplate standalone module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -23,6 +23,6 @@
|
|
|
23
23
|
"typescript": "^6.0.3"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "f67a101bcbe56114e982184834b93da7bbed00af",
|
|
27
27
|
"scripts": {}
|
|
28
28
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<% if (project.features.includes('ComposeView')) { -%>
|
|
2
|
+
import { Column } from '@expo/ui/jetpack-compose';
|
|
3
|
+
<% } else { -%>
|
|
4
|
+
import { Host as ComposeHost, Column, Text as ComposeText } from '@expo/ui/jetpack-compose';
|
|
5
|
+
import { paddingAll } from '@expo/ui/jetpack-compose/modifiers';
|
|
6
|
+
<% } -%>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{process.env.EXPO_OS === 'android' && (
|
|
2
|
+
<Group name="Compose Modifier">
|
|
3
|
+
<ComposeHost style={styles.view}>
|
|
4
|
+
<Column
|
|
5
|
+
modifiers={[
|
|
6
|
+
paddingAll(20),
|
|
7
|
+
<%= project.composeModifierName.charAt(0).toLowerCase() + project.composeModifierName.slice(1) %>({ color: 0xFFFF6B35, width: 3, cornerRadius: 8 }),
|
|
8
|
+
]}>
|
|
9
|
+
<ComposeText>Custom modifier example</ComposeText>
|
|
10
|
+
</Column>
|
|
11
|
+
</ComposeHost>
|
|
12
|
+
</Group>
|
|
13
|
+
)}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
package <%- project.package %>
|
|
2
|
+
|
|
3
|
+
import androidx.compose.foundation.border
|
|
4
|
+
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
5
|
+
import androidx.compose.ui.Modifier
|
|
6
|
+
import androidx.compose.ui.graphics.Color
|
|
7
|
+
import androidx.compose.ui.unit.dp
|
|
8
|
+
import expo.modules.kotlin.records.Field
|
|
9
|
+
import expo.modules.kotlin.records.Record
|
|
10
|
+
|
|
11
|
+
data class <%- project.composeModifierName %>Params(
|
|
12
|
+
@Field val color: Long = 0xFFFF0000,
|
|
13
|
+
@Field val width: Int = 2,
|
|
14
|
+
@Field val cornerRadius: Int = 0
|
|
15
|
+
) : Record {
|
|
16
|
+
fun toModifier(): Modifier {
|
|
17
|
+
return Modifier.border(
|
|
18
|
+
width = width.dp,
|
|
19
|
+
color = Color(color),
|
|
20
|
+
shape = RoundedCornerShape(cornerRadius.dp)
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createModifier, type ModifierConfig } from '@expo/ui/jetpack-compose/modifiers';
|
|
2
|
+
|
|
3
|
+
export const <%= project.composeModifierName.charAt(0).toLowerCase() + project.composeModifierName.slice(1) %> = (params: {
|
|
4
|
+
color?: number;
|
|
5
|
+
width?: number;
|
|
6
|
+
cornerRadius?: number;
|
|
7
|
+
}): ModifierConfig => createModifier('<%= project.composeModifierName.charAt(0).toLowerCase() + project.composeModifierName.slice(1) %>', params);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{process.env.EXPO_OS === 'android' && (
|
|
2
|
+
<Group name="Compose View">
|
|
3
|
+
<ComposeHost style={styles.view}>
|
|
4
|
+
<<%- project.composeViewName %>
|
|
5
|
+
title="Hello from <%- project.name %>"
|
|
6
|
+
modifiers={[paddingAll(16), composeBackground('#f0f0f0')]}>
|
|
7
|
+
<ComposeText>Child content</ComposeText>
|
|
8
|
+
</<%- project.composeViewName %>>
|
|
9
|
+
</ComposeHost>
|
|
10
|
+
</Group>
|
|
11
|
+
)}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
package <%- project.package %>
|
|
2
|
+
|
|
3
|
+
import androidx.compose.foundation.layout.Column
|
|
4
|
+
import androidx.compose.material3.Text
|
|
5
|
+
import androidx.compose.runtime.Composable
|
|
6
|
+
import expo.modules.kotlin.records.Field
|
|
7
|
+
import expo.modules.kotlin.views.ComposeProps
|
|
8
|
+
import expo.modules.kotlin.views.FunctionalComposableScope
|
|
9
|
+
import expo.modules.ui.ModifierList
|
|
10
|
+
import expo.modules.ui.ModifierRegistry
|
|
11
|
+
|
|
12
|
+
data class <%- project.composeViewName %>Props(
|
|
13
|
+
@Field val title: String = "",
|
|
14
|
+
@Field val modifiers: ModifierList = emptyList()
|
|
15
|
+
) : ComposeProps
|
|
16
|
+
|
|
17
|
+
@Composable
|
|
18
|
+
fun FunctionalComposableScope.<%- project.composeViewName %>Content(props: <%- project.composeViewName %>Props) {
|
|
19
|
+
Column(
|
|
20
|
+
modifier = ModifierRegistry.applyModifiers(
|
|
21
|
+
props.modifiers,
|
|
22
|
+
appContext,
|
|
23
|
+
composableScope,
|
|
24
|
+
globalEventDispatcher
|
|
25
|
+
)
|
|
26
|
+
) {
|
|
27
|
+
Text(props.title)
|
|
28
|
+
Children(composableScope)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { requireNativeView } from 'expo';
|
|
2
|
+
import { type PrimitiveBaseProps } from '@expo/ui/jetpack-compose';
|
|
3
|
+
import { createViewModifierEventListener } from '@expo/ui/jetpack-compose/modifiers';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
|
|
6
|
+
export interface <%- project.composeViewName %>Props extends PrimitiveBaseProps {
|
|
7
|
+
title: string;
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const Native<%- project.composeViewName %> = requireNativeView<<%- project.composeViewName %>Props>(
|
|
12
|
+
'<%- project.name %>',
|
|
13
|
+
'<%- project.composeViewName %>'
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export default function <%- project.composeViewName %>({
|
|
17
|
+
modifiers,
|
|
18
|
+
...rest
|
|
19
|
+
}: <%- project.composeViewName %>Props) {
|
|
20
|
+
return (
|
|
21
|
+
<Native<%- project.composeViewName %>
|
|
22
|
+
modifiers={modifiers}
|
|
23
|
+
{...(modifiers ? createViewModifierEventListener(modifiers) : undefined)}
|
|
24
|
+
{...rest}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<% if (project.features.includes('SwiftUIView')) { -%>
|
|
2
|
+
import { VStack } from '@expo/ui/swift-ui';
|
|
3
|
+
<% } else { -%>
|
|
4
|
+
import { Host as SwiftUIHost, VStack, Text as SwiftUIText } from '@expo/ui/swift-ui';
|
|
5
|
+
import { padding } from '@expo/ui/swift-ui/modifiers';
|
|
6
|
+
<% } -%>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{process.env.EXPO_OS === 'ios' && (
|
|
2
|
+
<Group name="SwiftUI Modifier">
|
|
3
|
+
<SwiftUIHost style={styles.view}>
|
|
4
|
+
<VStack
|
|
5
|
+
modifiers={[
|
|
6
|
+
padding({ all: 20 }),
|
|
7
|
+
<%= project.swiftUIModifierName.charAt(0).toLowerCase() + project.swiftUIModifierName.slice(1) %>({ color: '#FF6B35', width: 3, cornerRadius: 8 }),
|
|
8
|
+
]}>
|
|
9
|
+
<SwiftUIText>Custom modifier example</SwiftUIText>
|
|
10
|
+
</VStack>
|
|
11
|
+
</SwiftUIHost>
|
|
12
|
+
</Group>
|
|
13
|
+
)}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import SwiftUI
|
|
2
|
+
import ExpoModulesCore
|
|
3
|
+
import ExpoUI
|
|
4
|
+
|
|
5
|
+
struct <%- project.swiftUIModifierName %>: ViewModifier, Record {
|
|
6
|
+
@Field var color: Color = .red
|
|
7
|
+
@Field var width: CGFloat = 2
|
|
8
|
+
@Field var cornerRadius: CGFloat = 0
|
|
9
|
+
|
|
10
|
+
func body(content: Content) -> some View {
|
|
11
|
+
content
|
|
12
|
+
.overlay(
|
|
13
|
+
RoundedRectangle(cornerRadius: cornerRadius)
|
|
14
|
+
.stroke(color, lineWidth: width)
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createModifier, type ModifierConfig } from '@expo/ui/swift-ui/modifiers';
|
|
2
|
+
|
|
3
|
+
export const <%= project.swiftUIModifierName.charAt(0).toLowerCase() + project.swiftUIModifierName.slice(1) %> = (params: {
|
|
4
|
+
color?: string;
|
|
5
|
+
width?: number;
|
|
6
|
+
cornerRadius?: number;
|
|
7
|
+
}): ModifierConfig => createModifier('<%= project.swiftUIModifierName.charAt(0).toLowerCase() + project.swiftUIModifierName.slice(1) %>', params);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
OnCreate {
|
|
2
|
+
ViewModifierRegistry.register("<%= project.swiftUIModifierName.charAt(0).toLowerCase() + project.swiftUIModifierName.slice(1) %>") { params, appContext, _ in
|
|
3
|
+
return try <%- project.swiftUIModifierName %>(from: params, appContext: appContext)
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
OnDestroy {
|
|
8
|
+
ViewModifierRegistry.unregister("<%= project.swiftUIModifierName.charAt(0).toLowerCase() + project.swiftUIModifierName.slice(1) %>")
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{process.env.EXPO_OS === 'ios' && (
|
|
2
|
+
<Group name="SwiftUI View">
|
|
3
|
+
<SwiftUIHost style={styles.view}>
|
|
4
|
+
<<%- project.swiftUIViewName %>
|
|
5
|
+
title="Hello from <%- project.name %>"
|
|
6
|
+
modifiers={[padding({ all: 16 }), cornerRadius(12), background('#f0f0f0')]}>
|
|
7
|
+
<SwiftUIText>Child content</SwiftUIText>
|
|
8
|
+
</<%- project.swiftUIViewName %>>
|
|
9
|
+
</SwiftUIHost>
|
|
10
|
+
</Group>
|
|
11
|
+
)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ExpoUIView(<%- project.swiftUIViewName %>.self)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import SwiftUI
|
|
2
|
+
import ExpoModulesCore
|
|
3
|
+
import ExpoUI
|
|
4
|
+
|
|
5
|
+
final class <%- project.swiftUIViewName %>Props: UIBaseViewProps {
|
|
6
|
+
@Field var title: String = ""
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
struct <%- project.swiftUIViewName %>: ExpoSwiftUI.View {
|
|
10
|
+
@ObservedObject public var props: <%- project.swiftUIViewName %>Props
|
|
11
|
+
|
|
12
|
+
var body: some View {
|
|
13
|
+
VStack {
|
|
14
|
+
Text(props.title)
|
|
15
|
+
.font(.headline)
|
|
16
|
+
Children()
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { requireNativeView } from 'expo';
|
|
2
|
+
import { type CommonViewModifierProps } from '@expo/ui/swift-ui';
|
|
3
|
+
import { createViewModifierEventListener } from '@expo/ui/swift-ui/modifiers';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
|
|
6
|
+
export interface <%- project.swiftUIViewName %>Props extends CommonViewModifierProps {
|
|
7
|
+
title: string;
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const Native<%- project.swiftUIViewName %> = requireNativeView<<%- project.swiftUIViewName %>Props>(
|
|
12
|
+
'<%- project.name %>',
|
|
13
|
+
'<%- project.swiftUIViewName %>'
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export default function <%- project.swiftUIViewName %>({
|
|
17
|
+
modifiers,
|
|
18
|
+
...rest
|
|
19
|
+
}: <%- project.swiftUIViewName %>Props) {
|
|
20
|
+
return (
|
|
21
|
+
<Native<%- project.swiftUIViewName %>
|
|
22
|
+
modifiers={modifiers}
|
|
23
|
+
{...(modifiers ? createViewModifierEventListener(modifiers) : undefined)}
|
|
24
|
+
{...rest}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -4,6 +4,18 @@ export { default } from './<%- project.moduleName %>';
|
|
|
4
4
|
<% if (project.features.includes('View')) { -%>
|
|
5
5
|
export { default as <%- project.viewName %> } from './<%- project.viewName %>';
|
|
6
6
|
<% } -%>
|
|
7
|
+
<% if (project.features.includes('SwiftUIView')) { -%>
|
|
8
|
+
export { default as <%- project.swiftUIViewName %> } from './<%- project.swiftUIViewName %>';
|
|
9
|
+
<% } -%>
|
|
10
|
+
<% if (project.features.includes('ComposeView')) { -%>
|
|
11
|
+
export { default as <%- project.composeViewName %> } from './<%- project.composeViewName %>';
|
|
12
|
+
<% } -%>
|
|
13
|
+
<% if (project.features.includes('SwiftUIModifier')) { -%>
|
|
14
|
+
export * from './<%- project.swiftUIModifierName %>';
|
|
15
|
+
<% } -%>
|
|
16
|
+
<% if (project.features.includes('ComposeModifier')) { -%>
|
|
17
|
+
export * from './<%- project.composeModifierName %>';
|
|
18
|
+
<% } -%>
|
|
7
19
|
export * from './<%- project.name %>.types';
|
|
8
20
|
<% if (project.features.includes('SharedObject')) { -%>
|
|
9
21
|
export * from './<%- project.sharedObjectName %>';
|