Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
bd8a6a0
chore: scaffold android
hurali97 Feb 25, 2026
a25543a
feat: add cpp bindings
hurali97 Feb 25, 2026
b846055
feat: add compiler flags and target linkages
hurali97 Feb 25, 2026
6448067
feat: use brownie on android
hurali97 Feb 25, 2026
9a6b6a8
refactor: use new module registration API
hurali97 Feb 26, 2026
ce074d7
refactor: remove redundancy
hurali97 Feb 26, 2026
ff6cd72
refactor: remove unused methods
hurali97 Feb 26, 2026
5f98c1a
feat: improve Android DX
hurali97 Feb 26, 2026
0567174
refactor: split impl between files
hurali97 Feb 26, 2026
b89111f
docs: add brownie android
hurali97 Feb 26, 2026
4dad9a9
docs: update pre-req
hurali97 Feb 26, 2026
179cbfb
Merge branch 'main' of github.com:callstack/react-native-brownfield i…
hurali97 Feb 26, 2026
6e5433f
fix: add kotlin to platforms
hurali97 Feb 27, 2026
f3c797a
fix: separate imports by flavor
hurali97 Feb 27, 2026
636515e
fix: add brownie config block
hurali97 Feb 27, 2026
7bf3ef9
chore: run changeset
hurali97 Feb 27, 2026
6d08d9d
feat: exclude libc++ at brownie level
hurali97 Feb 27, 2026
dc1bfce
chore: run changeset
hurali97 Feb 27, 2026
b86f3ec
fix: add kotlin to cli choices
hurali97 Feb 27, 2026
c648436
refactor: remove unused style
hurali97 Feb 27, 2026
d8bf7f0
feat: rely on StoreManager instead of custom tracker
hurali97 Feb 27, 2026
aece063
fix: add guard
hurali97 Feb 27, 2026
c43e82d
fix: notify state update only once
hurali97 Feb 27, 2026
1e1e755
chore: add consumer-rules to avoid required function name strip
hurali97 Feb 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/red-llamas-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@callstack/brownie': minor
'@callstack/brownfield-cli': minor
'brownfield': minor
'@callstack/react-native-brownfield': minor
---

add brownie android
7 changes: 4 additions & 3 deletions apps/AndroidApp/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,19 @@ android {
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "11"
jvmTarget = "17"
}
buildFeatures {
compose = true
}
}

dependencies {
implementation("com.google.code.gson:gson:2.13.1")
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.callstack.brownfield.android.example

typealias BrownfieldStore = com.callstack.rnbrownfield.demo.expoapp.BrownfieldStore
typealias User = com.callstack.rnbrownfield.demo.expoapp.User
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import androidx.fragment.compose.AndroidFragment
import com.callstack.brownfield.android.example.components.GreetingCard
import com.callstack.brownfield.android.example.components.PostMessageCard
import com.callstack.brownfield.android.example.ui.theme.AndroidBrownfieldAppTheme
import com.callstack.brownie.registerStoreIfNeeded
import com.callstack.reactnativebrownfield.ReactNativeFragment
import com.callstack.reactnativebrownfield.constants.ReactNativeFragmentArgNames

Expand All @@ -48,6 +49,15 @@ class MainActivity : AppCompatActivity() {
Toast.LENGTH_LONG
).show()
}

registerStoreIfNeeded(
storeName = BrownfieldStore.STORE_NAME
) {
BrownfieldStore(
counter = 0.0,
user = User(name = "Username")
)
}
}

setContent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,42 @@ import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.callstack.brownfield.android.example.BrownfieldStore
import com.callstack.brownie.Store
import com.callstack.brownie.StoreManager
import com.callstack.brownie.store
import com.callstack.brownie.subscribe

private fun brownieStore(): Store<BrownfieldStore>? {
return StoreManager.shared.store(BrownfieldStore.STORE_NAME)
}

@Composable
fun GreetingCard(
name: String,
) {
var counter by rememberSaveable { mutableIntStateOf(0) }
var counter by remember { mutableIntStateOf(0) }

DisposableEffect(Unit) {
val store = brownieStore()
val unsubscribe = store?.subscribe(
selector = { state -> state.counter.toInt() },
onChange = { updatedCounter -> counter = updatedCounter }
) ?: {}

onDispose {
unsubscribe()
}
}

MaterialCard {
Column(
Expand All @@ -43,7 +65,11 @@ fun GreetingCard(
style = MaterialTheme.typography.bodyMedium
)

Button(onClick = { counter++ }) {
Button(onClick = {
brownieStore()?.set { state ->
state.copy(counter = state.counter + 1)
}
}) {
Text("Increment counter")
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.callstack.brownfield.android.example

typealias BrownfieldStore = com.rnapp.brownfieldlib.BrownfieldStore
typealias User = com.rnapp.brownfieldlib.User
33 changes: 0 additions & 33 deletions apps/ExpoApp/components/counter/index.ios.tsx

This file was deleted.

14 changes: 11 additions & 3 deletions apps/ExpoApp/components/counter/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { StyleSheet, Text } from 'react-native';
import { StyleSheet, Text, Button } from 'react-native';
import { useStore } from '@callstack/brownie';

const Counter = () => {
const [counter, setState] = useStore('BrownfieldStore', (s) => s.counter);

return (
<>
<Text style={styles.text}>Brownie: To be implemented</Text>
<Text style={styles.text}>Count: {counter}</Text>

<Button
onPress={() => setState((prev) => ({ counter: prev.counter + 1 }))}
title="Increment"
/>
</>
);
};
Expand All @@ -12,7 +20,7 @@ export default Counter;

const styles = StyleSheet.create({
text: {
fontSize: 18,
fontSize: 30,
fontWeight: 'bold',
margin: 10,
},
Expand Down
4 changes: 4 additions & 0 deletions apps/ExpoApp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,9 @@
"eslint": "^9.25.0",
"eslint-config-expo": "~10.0.0",
"typescript": "~5.9.2"
},
"brownie": {
"kotlin": "./android/brownfieldlib/src/main/java/com/callstack/rnbrownfield/demo/expoapp/Generated/",
"kotlinPackageName": "com.callstack.rnbrownfield.demo.expoapp"
}
}
4 changes: 4 additions & 0 deletions apps/RNApp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
"react-test-renderer": "19.1.1",
"typescript": "^5.9.3"
},
"brownie": {
"kotlin": "./android/BrownfieldLib/src/main/java/com/rnapp/brownfieldlib/Generated/",
"kotlinPackageName": "com.rnapp.brownfieldlib"
},
"engines": {
"node": ">=20"
}
Expand Down
40 changes: 0 additions & 40 deletions apps/RNApp/src/components/counter/index.ios.tsx

This file was deleted.

13 changes: 11 additions & 2 deletions apps/RNApp/src/components/counter/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import { StyleSheet, Text } from 'react-native';
import { Button, StyleSheet, Text } from 'react-native';
import { useStore } from '@callstack/brownie';

type CounterProps = {
colors: { primary: string; secondary: string };
};

const Counter = ({ colors }: CounterProps) => {
const [counter, setState] = useStore('BrownfieldStore', (s) => s.counter);

return (
<>
<Text style={[styles.text, { color: colors.secondary }]}>
Brownie: To be implemented
Count: {counter}
</Text>

<Button
onPress={() => setState((prev) => ({ counter: prev.counter + 1 }))}
color={colors.secondary}
title="Increment"
/>
</>
);
};
Expand Down
5 changes: 5 additions & 0 deletions docs/docs/docs/api-reference/brownie/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
"name": "typescript-usage",
"label": "TypeScript Usage"
},
{
"type": "file",
"name": "android-usage",
"label": "Android Usage"
},
{
"type": "file",
"name": "swift-usage",
Expand Down
Loading