Skip to content

Commit a7d5727

Browse files
committed
feat: wip rewrite to shared cxx layer
1 parent 8cb5397 commit a7d5727

18 files changed

Lines changed: 751 additions & 359 deletions

apps/example/App.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ function HomeScreen() {
1515

1616
<TextInput
1717
style={styles.input}
18-
value={state.user}
19-
onChangeText={(text) => setState({ user: text })}
18+
value={state.user.name}
19+
onChangeText={(text) =>
20+
setState((prev) => ({ user: { ...prev.user, name: text } }))
21+
}
2022
placeholder="User name"
2123
/>
2224

apps/example/BrownfieldStore.brownie.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import type { BrownieStore } from '@callstack/brownie';
22

33
interface BrownfieldStore extends BrownieStore {
44
counter: number;
5-
user: string;
5+
user: {
6+
name: string;
7+
settings: {
8+
theme: 'light' | 'dark';
9+
};
10+
};
611
isLoading: boolean;
712
hasError: boolean;
813
}

apps/example/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"@react-native/metro-config": "0.82.1",
2828
"@react-native/typescript-config": "0.82.1",
2929
"@types/react": "^19.1.1",
30-
"babel-plugin-module-resolver": "^5.0.2",
3130
"react-native-monorepo-config": "^0.3.1"
3231
},
3332
"engines": {

apps/example/swift/App.swift

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import Brownie
22
import ReactBrownfield
33
import SwiftUI
44

5-
let initialState = BrownfieldStore(counter: 0, hasError: false, isLoading: false, user: "okwasniewski")
5+
let initialState = BrownfieldStore(
6+
counter: 0,
7+
hasError: false,
8+
isLoading: false,
9+
user: User(name: "okwasniewski", settings: Settings(theme: .light))
10+
)
611

712
@main
813
struct MyApp: App {
@@ -12,11 +17,7 @@ struct MyApp: App {
1217
print("loaded")
1318
}
1419

15-
let state = Store(initialState)
16-
StoreManager.shared.register(
17-
store: state,
18-
key: BrownfieldStore.storeName
19-
)
20+
_ = Store(initialState, key: BrownfieldStore.storeName)
2021
}
2122

2223
var body: some Scene {
@@ -40,7 +41,7 @@ struct MyApp: App {
4041
}
4142

4243
struct NativeView: View {
43-
@UseStore<BrownfieldStore, String>(\.user, key: BrownfieldStore.storeName) var user
44+
@UseStore<BrownfieldStore, User>(\.user, key: BrownfieldStore.storeName) var user
4445
@UseStore<BrownfieldStore, Double>(\.counter, key: BrownfieldStore.storeName) var counter
4546

4647
var body: some View {
@@ -49,11 +50,13 @@ struct MyApp: App {
4950
.font(.headline)
5051
.padding(.top)
5152

52-
Text("User: \(user)")
53+
Text("User: \(user.name)")
5354
Text("Count: \(Int(counter))")
5455

55-
TextField("Name", text: Binding(get: { user }, set: { data in
56-
$user.set { state in state.user = data }
56+
TextField("Name", text: Binding(get: { user.name }, set: { data in
57+
$user.set { state in
58+
state.user.name = data
59+
}
5760
}))
5861
.textFieldStyle(.roundedBorder)
5962
.padding(.horizontal)

apps/example/swift/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2772,7 +2772,7 @@ EXTERNAL SOURCES:
27722772

27732773
SPEC CHECKSUMS:
27742774
boost: 7e761d76ca2ce687f7cc98e698152abd03a18f90
2775-
Brownie: d1a36299ae5b669a71da298023b7eb970ef7bd2c
2775+
Brownie: ac51b21f5e34bba2ad62cafcd0c56ceabe6ff866
27762776
DoubleConversion: cb417026b2400c8f53ae97020b2be961b59470cb
27772777
fast_float: b32c788ed9c6a8c584d114d0047beda9664e7cc6
27782778
FBLazyVector: 0aa6183b9afe3c31fc65b5d1eeef1f3c19b63bfa

0 commit comments

Comments
 (0)