Skip to content

Commit 23f3cb9

Browse files
committed
Merge branch 'main' into feat/cli
2 parents c7733f3 + 0e0059a commit 23f3cb9

67 files changed

Lines changed: 3844 additions & 186 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/actions/setup/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ runs:
55
using: composite
66
steps:
77
- name: Setup Node.js
8-
uses: actions/setup-node@v4
8+
uses: actions/setup-node@65d868f8d4d85d7d4abb7de0875cde3fcc8798f5 # v6
99
with:
1010
node-version: 'lts/*'
1111
cache: 'yarn'
1212

1313
- name: Restore turbo cache
14-
uses: actions/cache@v5
14+
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5
1515
with:
1616
path: |
1717
.turbo

.github/workflows/ci.yml

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@ on:
66
pull_request:
77
branches: [main]
88

9-
env:
10-
USE_CCACHE: 1
9+
concurrency:
10+
group: pr-${{ github.event.pull_request.number }}
11+
cancel-in-progress: true
1112

1213
jobs:
1314
build-lint:
1415
name: Build & static code analysis
1516
runs-on: ubuntu-latest
1617
steps:
1718
- name: Checkout
18-
uses: actions/checkout@v4
19+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
1920

2021
- name: Setup
2122
uses: ./.github/actions/setup
@@ -40,16 +41,19 @@ jobs:
4041

4142
steps:
4243
- name: Checkout
43-
uses: actions/checkout@v4
44+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
45+
46+
- name: Validate Gradle Wrapper
47+
uses: gradle/actions/wrapper-validation@6f229686ee4375cc4a86b2514c89bac4930e82c4 # v5
4448

4549
- name: Setup Java
46-
uses: actions/setup-java@v4
50+
uses: actions/setup-java@5d7b2146334bacf88728daaa70414a99f5164e0f # v5
4751
with:
4852
distribution: 'zulu'
4953
java-version: '17'
5054

5155
- name: Setup Node.js
52-
uses: actions/setup-node@v4
56+
uses: actions/setup-node@65d868f8d4d85d7d4abb7de0875cde3fcc8798f5 # v6
5357
with:
5458
node-version: 'lts/*'
5559
cache: 'yarn'
@@ -61,7 +65,7 @@ jobs:
6165
run: yarn build
6266

6367
- name: Restore android build cache
64-
uses: actions/cache@v5
68+
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5
6569
with:
6670
path: |
6771
apps/TesterIntegrated/kotlin/build
@@ -71,8 +75,8 @@ jobs:
7175
restore-keys: |
7276
${{ runner.os }}-tester-android-build-
7377
74-
- name: Restore Gradle cache
75-
uses: actions/cache@v5
78+
- name: Resture Gradle cache
79+
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5
7680
with:
7781
path: |
7882
~/.gradle/caches
@@ -117,24 +121,21 @@ jobs:
117121

118122
steps:
119123
- name: Checkout
120-
uses: actions/checkout@v4
124+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
121125

122126
- name: Use appropriate Xcode version
123127
uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0
124128
with:
125129
xcode-version: '16'
126130

127131
- name: Setup Node.js
128-
uses: actions/setup-node@v4
132+
uses: actions/setup-node@65d868f8d4d85d7d4abb7de0875cde3fcc8798f5 # v6
129133
with:
130134
node-version: 'lts/*'
131135
cache: 'yarn'
132136

133-
- name: Restore ccache
134-
uses: hendrikmuhs/ccache-action@v1.2
135-
136137
- name: Setup Ruby
137-
uses: ruby/setup-ruby@v1
138+
uses: ruby/setup-ruby@5dd816ae0186f20dfa905997a64104db9a8221c7 # v1.280.0
138139
with:
139140
ruby-version: '3.2'
140141
bundler-cache: true
@@ -146,28 +147,19 @@ jobs:
146147
run: yarn build
147148

148149
- name: Restore Pods cache
149-
uses: actions/cache@v5
150+
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5
150151
with:
151152
path: |
152153
apps/TesterIntegrated/swift/Pods
153154
key: ${{ runner.os }}-tester-ios-pods-${{ hashFiles('apps/TesterIntegrated/swift/Podfile.lock') }}
154155
restore-keys: |
155156
${{ runner.os }}-tester-ios-pods-
156157
157-
- name: Install pods (TesterIntegrated)
158+
- name: Install pods
158159
run: |
159160
cd apps/TesterIntegrated/swift
160161
pod install
161162
162-
- name: Restore iOS build cache
163-
uses: actions/cache@v5
164-
with:
165-
path: |
166-
apps/TesterIntegrated/swift/build
167-
key: ${{ runner.os }}-tester-ios-build-${{ github.sha }}
168-
restore-keys: |
169-
${{ runner.os }}-tester-ios-build-
170-
171163
# == IntegratedTester ==
172164

173165
- name: Build integrated iOS tester app

.github/workflows/deploy-docs.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ jobs:
2121
runs-on: ubuntu-latest
2222
steps:
2323
- name: Checkout
24-
uses: actions/checkout@v4
24+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
2525
with:
2626
fetch-depth: 0 # Not needed if lastUpdated is not enabled
2727
- name: Setup
2828
uses: ./.github/actions/setup
2929

3030
- name: Setup Pages
31-
uses: actions/configure-pages@v5
31+
uses: actions/configure-pages@d5606572c479bee637007364c6b4800ac4fc8573 # v5
3232

3333
- name: Install dependencies
3434
working-directory: docs
@@ -40,7 +40,7 @@ jobs:
4040
yarn run build
4141
4242
- name: Upload artifact
43-
uses: actions/upload-pages-artifact@v3
43+
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4
4444
with:
4545
path: docs/doc_build
4646

@@ -55,4 +55,4 @@ jobs:
5555
steps:
5656
- name: Deploy to GitHub Pages
5757
id: deployment
58-
uses: actions/deploy-pages@v4
58+
uses: actions/deploy-pages@854d7aa1b99e4509c4d1b53d69b7ba4eaf39215a # v4.0.5

.github/workflows/gradle-plugin-lint.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ jobs:
1313

1414
steps:
1515
- name: Checkout repository
16-
uses: actions/checkout@v4
16+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
1717

1818
- name: Validate Gradle Wrapper
19-
uses: gradle/wrapper-validation-action@v2
19+
uses: gradle/actions/wrapper-validation@6f229686ee4375cc4a86b2514c89bac4930e82c4 # v5
2020

2121
- name: Set up JDK
22-
uses: actions/setup-java@v4
22+
uses: actions/setup-java@5d7b2146334bacf88728daaa70414a99f5164e0f # v5
2323
with:
2424
distribution: temurin
2525
java-version: 17
2626

2727
- name: Restore Gradle cache
28-
uses: actions/cache@v5
28+
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5
2929
with:
3030
path: |
3131
~/.gradle/caches

apps/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ This directory contains demo projects showcasing the usage of the `react-native-
55
- `RNApp` - the React Native application that is packaged to AAR and XCFramework archives and integrated into native projects
66
- `AndroidApp` - the native Android application that integrates the RNApp AAR package (a "consumer" of the RNApp library)
77
- `iOSApp` - the native iOS application that integrates the RNApp XCFramework package (a "consumer" of the RNApp library)
8-
- TesterIntegrated` - a native tester application that integrates the native projects with and React Native project inside a single application, consuming the brownfield module directly, without packaging to an artifact; this is mostly useful for internal development purposes and is not as meaningful for end users of React Native Brownfield
8+
- `TesterIntegrated` - a native tester application that integrates the native projects with and React Native project inside a single application, consuming the brownfield module directly, without packaging to an artifact; this is mostly useful for internal development purposes and is not as meaningful for end users of React Native Brownfield

apps/TesterIntegrated/App.tsx

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import React, { useEffect } from 'react';
2-
import { StyleSheet, Text, View, Button } from 'react-native';
1+
import { useEffect } from 'react';
2+
import { StyleSheet, Text, View, Button, TextInput } from 'react-native';
3+
import { useStore } from '@callstack/brownie';
34
import {
45
createNativeStackNavigator,
56
type NativeStackScreenProps,
67
} from '@react-navigation/native-stack';
78
import ReactNativeBrownfield from '@callstack/react-native-brownfield';
89
import { NavigationContainer } from '@react-navigation/native';
10+
import './BrownfieldStore.brownie';
911

1012
const getRandomValue = () => Math.round(Math.random() * 255);
1113
const getRandomTheme = () => {
@@ -22,10 +24,18 @@ const getRandomTheme = () => {
2224
};
2325
};
2426

25-
type Props = NativeStackScreenProps<RootStackParamList, 'Home'>;
27+
type RootStackParamList = {
28+
Home: { theme: { primary: string; secondary: string } };
29+
};
2630

27-
function HomeScreen({ navigation, route }: Props) {
28-
const colors = route.params?.theme || getRandomTheme();
31+
type HomeScreenProps = NativeStackScreenProps<RootStackParamList, 'Home'>;
32+
33+
const theme = getRandomTheme();
34+
35+
function HomeScreen({ navigation, route }: HomeScreenProps) {
36+
const colors = route.params?.theme || theme;
37+
const [counter, setState] = useStore('BrownfieldStore', (s) => s.counter);
38+
const [user] = useStore('BrownfieldStore', (s) => s.user);
2939

3040
useEffect(() => {
3141
const unsubscribe = navigation.addListener('focus', () => {
@@ -37,10 +47,29 @@ function HomeScreen({ navigation, route }: Props) {
3747

3848
return (
3949
<View style={[styles.container, { backgroundColor: colors.primary }]}>
40-
<Text style={[styles.text, { color: colors.secondary }]}>
50+
<Text style={[styles.title, { color: colors.secondary }]}>
4151
React Native Screen
4252
</Text>
4353

54+
<Text style={[styles.text, { color: colors.secondary }]}>
55+
Count: {counter}
56+
</Text>
57+
58+
<TextInput
59+
style={styles.input}
60+
value={user.name}
61+
onChangeText={(text) =>
62+
setState((prev) => ({ user: { ...prev.user, name: text } }))
63+
}
64+
placeholder="User name"
65+
/>
66+
67+
<Button
68+
onPress={() => setState((prev) => ({ counter: prev.counter + 1 }))}
69+
color={colors.secondary}
70+
title="Increment"
71+
/>
72+
4473
<Button
4574
onPress={() => {
4675
navigation.push('Home', {
@@ -65,9 +94,6 @@ function HomeScreen({ navigation, route }: Props) {
6594
</View>
6695
);
6796
}
68-
type RootStackParamList = {
69-
Home: { theme: { primary: string; secondary: string } };
70-
};
7197

7298
const Stack = createNativeStackNavigator<RootStackParamList>();
7399

@@ -87,9 +113,22 @@ const styles = StyleSheet.create({
87113
justifyContent: 'center',
88114
alignItems: 'center',
89115
},
90-
text: {
116+
title: {
91117
fontSize: 30,
92118
fontWeight: 'bold',
93119
margin: 10,
94120
},
121+
text: {
122+
fontSize: 16,
123+
margin: 5,
124+
},
125+
input: {
126+
borderWidth: 1,
127+
borderColor: '#ccc',
128+
borderRadius: 8,
129+
padding: 10,
130+
width: 200,
131+
marginVertical: 10,
132+
backgroundColor: '#fff',
133+
},
95134
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import type { BrownieStore } from '@callstack/brownie';
2+
3+
interface BrownfieldStore extends BrownieStore {
4+
counter: number;
5+
user: {
6+
name: string;
7+
};
8+
}
9+
10+
interface SettingsStore extends BrownieStore {
11+
theme: 'light' | 'dark';
12+
notificationsEnabled: boolean;
13+
privacyMode: boolean;
14+
}
15+
16+
declare module '@callstack/brownie' {
17+
interface BrownieStores {
18+
BrownfieldStore: BrownfieldStore;
19+
SettingsStore: SettingsStore;
20+
}
21+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.callstack.kotlinexample
2+
3+
data class BrownfieldStore (
4+
val counter: Double,
5+
val user: User
6+
) {
7+
companion object {
8+
const val STORE_NAME = "BrownfieldStore"
9+
}
10+
}
11+
12+
data class User (
13+
val name: String
14+
)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.callstack.kotlinexample
2+
3+
data class SettingsStore (
4+
val notificationsEnabled: Boolean,
5+
val privacyMode: Boolean,
6+
val theme: Theme
7+
) {
8+
companion object {
9+
const val STORE_NAME = "SettingsStore"
10+
}
11+
}
12+
13+
enum class Theme {
14+
Dark,
15+
Light
16+
}
Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
21
const path = require('path');
2+
const { getDefaultConfig } = require('@react-native/metro-config'); // Import from `@expo/metro-config` if using Expo CLI
3+
const { withMetroConfig } = require('react-native-monorepo-config');
34

4-
const root = path.resolve(__dirname, '../..');
5-
6-
/**
7-
* Metro configuration
8-
* https://reactnative.dev/docs/metro
9-
*
10-
* @type {import('@react-native/metro-config').MetroConfig}
11-
*/
12-
const config = {
13-
watchFolders: [root],
14-
};
15-
16-
module.exports = mergeConfig(getDefaultConfig(__dirname), config);
5+
module.exports = withMetroConfig(
6+
getDefaultConfig(__dirname), // Metro config to extend
7+
{
8+
root: path.resolve(__dirname, '../..'), // Path to the monorepo root
9+
dirname: __dirname, // Path to the current directory
10+
}
11+
);

0 commit comments

Comments
 (0)