Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
45 changes: 45 additions & 0 deletions .yarn/patches/expo-updates-npm-29.0.16-1c5c89eb83.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
diff --git a/ios/EXUpdates/UpdatesConfig.swift b/ios/EXUpdates/UpdatesConfig.swift
index 09a1e145a9f5a938e10dd3c59eedfd213ad54346..787c1a8f7ae6a010fff4200ffebe31742e9a25eb 100644
--- a/ios/EXUpdates/UpdatesConfig.swift
+++ b/ios/EXUpdates/UpdatesConfig.swift
@@ -141,7 +141,8 @@ public final class UpdatesConfig: NSObject {
}

private static func configDictionaryWithExpoPlist(mergingOtherDictionary: [String: Any]?) throws -> [String: Any] {
- guard let configPlistPath = Bundle.main.path(forResource: PlistName, ofType: "plist") else {
+ let bundle = Bundle(for: UpdatesConfig.self)
+ guard let configPlistPath = bundle.path(forResource: PlistName, ofType: "plist") else {
throw UpdatesConfigError.ExpoUpdatesConfigPlistError
}

diff --git a/ios/EXUpdates/UpdatesUtils.swift b/ios/EXUpdates/UpdatesUtils.swift
index a1e2c9af4ebaf9e50db2acaabfa876fc46d22454..0b96a7062dbcd021339a9daeb4397b3c7715b96d 100644
--- a/ios/EXUpdates/UpdatesUtils.swift
+++ b/ios/EXUpdates/UpdatesUtils.swift
@@ -108,18 +108,22 @@ public final class UpdatesUtils: NSObject {
return assetFilesMap
}

+ private static func getBundle() -> Bundle {
+ return Bundle(for: UpdatesUtils.self)
+ }
+
internal static func url(forBundledAsset asset: UpdateAsset) -> URL? {
guard let mainBundleDir = asset.mainBundleDir else {
- return Bundle.main.url(forResource: asset.mainBundleFilename, withExtension: asset.type)
+ return getBundle().url(forResource: asset.mainBundleFilename, withExtension: asset.type)
}
- return Bundle.main.url(forResource: asset.mainBundleFilename, withExtension: asset.type, subdirectory: mainBundleDir)
+ return getBundle().url(forResource: asset.mainBundleFilename, withExtension: asset.type, subdirectory: mainBundleDir)
}

internal static func path(forBundledAsset asset: UpdateAsset) -> String? {
guard let mainBundleDir = asset.mainBundleDir else {
- return Bundle.main.path(forResource: asset.mainBundleFilename, ofType: asset.type)
+ return getBundle().path(forResource: asset.mainBundleFilename, ofType: asset.type)
}
- return Bundle.main.path(forResource: asset.mainBundleFilename, ofType: asset.type, inDirectory: mainBundleDir)
+ return getBundle().path(forResource: asset.mainBundleFilename, ofType: asset.type, inDirectory: mainBundleDir)
}

/**
4 changes: 4 additions & 0 deletions apps/AndroidApp/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ android {

dependencies {
implementation("com.google.code.gson:gson:2.13.1")
implementation("androidx.room:room-runtime:2.6.1")
implementation("androidx.room:room-ktx:2.6.1")
implementation("com.squareup.okhttp3:okhttp-brotli:4.9.2")

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
@@ -1,5 +1,6 @@
package com.callstack.brownfield.android.example

//import com.callstack.brownie.registerStoreIfNeeded
import android.content.Intent
import android.content.res.Configuration
import android.os.Bundle
Expand Down Expand Up @@ -27,11 +28,12 @@ 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.nativebrownfieldnavigation.BrownfieldNavigationDelegate
import com.callstack.nativebrownfieldnavigation.BrownfieldNavigationManager
import com.callstack.reactnativebrownfield.ReactNativeBrownfield
import com.callstack.reactnativebrownfield.ReactNativeFragment
import com.callstack.reactnativebrownfield.constants.ReactNativeFragmentArgNames
import expo.modules.updates.procedures.SomeHostManager

class MainActivity : AppCompatActivity(), BrownfieldNavigationDelegate {
override fun onConfigurationChanged(newConfig: Configuration) {
Expand All @@ -52,16 +54,18 @@ class MainActivity : AppCompatActivity(), BrownfieldNavigationDelegate {
"React Native has been loaded",
Toast.LENGTH_LONG
).show()
}

registerStoreIfNeeded(
storeName = BrownfieldStore.STORE_NAME
) {
BrownfieldStore(
counter = 0.0,
user = User(name = "Username")
)
SomeHostManager.setReactHost(ReactNativeBrownfield.shared.reactHost)
}

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

setContent {
Expand Down Expand Up @@ -101,11 +105,13 @@ private fun MainScreen(modifier: Modifier = Modifier) {
verticalArrangement = Arrangement.spacedBy(16.dp),
horizontalAlignment = Alignment.CenterHorizontally // center top bar content
) {
Spacer(modifier = Modifier.height(3.dp))

GreetingCard(
name = ReactNativeConstants.APP_NAME,
)

PostMessageCard()
// PostMessageCard()

Spacer(modifier = Modifier.height(1.dp))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ 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.DisposableEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.remember
Expand All @@ -17,33 +17,33 @@ 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
//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)
}
//private fun brownieStore(): Store<BrownfieldStore>? {
// return StoreManager.shared.store(BrownfieldStore.STORE_NAME)
//}

@Composable
fun GreetingCard(
name: String,
) {
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()
}
}
// DisposableEffect(Unit) {
// val store = brownieStore()
// val unsubscribe = store?.subscribe(
// selector = { state -> state.counter.toInt() },
// onChange = { updatedCounter -> counter = updatedCounter }
// ) ?: {}
//
// onDispose {
// unsubscribe()
// }
// }

MaterialCard {
Column(
Expand All @@ -59,19 +59,19 @@ fun GreetingCard(
textAlign = TextAlign.Center
)

Text(
text = "You clicked the button $counter time${if (counter == 1) "" else "s"}",
textAlign = TextAlign.Center,
style = MaterialTheme.typography.bodyMedium
)

Button(onClick = {
brownieStore()?.set { state ->
state.copy(counter = state.counter + 1)
}
}) {
Text("Increment counter")
}
// Text(
// text = "You clicked the button $counter time${if (counter == 1) "" else "s"}",
// textAlign = TextAlign.Center,
// style = MaterialTheme.typography.bodyMedium
// )
//
// Button(onClick = {
//// brownieStore()?.set { state ->
//// state.copy(counter = state.counter + 1)
//// }
// }) {
// Text("Increment counter")
// }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
buildConfiguration = "Debug Expo"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
Expand Down
4 changes: 4 additions & 0 deletions apps/AppleApp/Brownfield Apple App/BrownfieldAppleApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ class AppDelegate: NSObject, UIApplicationDelegate {
didFinishLaunchingWithOptions: launchOptions
)
}

func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
return ReactNativeBrownfield.shared.application(application, willFinishLaunchingWithOptions: launchOptions)
}
}

public class RNNavigationDelegate: BrownfieldNavigationDelegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ struct SettingsScreen: View {
}
.navigationTitle("Settings")
}
}
}
36 changes: 18 additions & 18 deletions apps/ExpoApp54/BrownfieldStore.brownie.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import type { BrownieStore } from '@callstack/brownie';
// import type { BrownieStore } from '@callstack/brownie';

export interface BrownfieldStore extends BrownieStore {
counter: number;
user: {
name: string;
};
}
// export interface BrownfieldStore extends BrownieStore {
// counter: number;
// user: {
// name: string;
// };
// }

export interface SettingsStore extends BrownieStore {
theme: 'light' | 'dark';
notificationsEnabled: boolean;
privacyMode: boolean;
}
// export interface SettingsStore extends BrownieStore {
// theme: 'light' | 'dark';
// notificationsEnabled: boolean;
// privacyMode: boolean;
// }

declare module '@callstack/brownie' {
interface BrownieStores {
BrownfieldStore: BrownfieldStore;
SettingsStore: SettingsStore;
}
}
// declare module '@callstack/brownie' {
// interface BrownieStores {
// BrownfieldStore: BrownfieldStore;
// SettingsStore: SettingsStore;
// }
// }
5 changes: 2 additions & 3 deletions apps/ExpoApp54/RNApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ import { SafeAreaView } from 'react-native-safe-area-context';
import { Button, StyleSheet, Text, View } from 'react-native';
import BrownfieldNavigation from '@callstack/brownfield-navigation';

import Counter from './components/counter';
import { checkAndFetchUpdate } from './utils/expo-rn-updates';

export default function RNApp() {
return (
<SafeAreaView style={styles.container}>
<Text style={styles.title}>Expo React Native Brownfield</Text>

<View style={styles.content}>
<Counter />

<Button
title="Navigate to Settings"
onPress={() => BrownfieldNavigation.navigateToSettings()}
Expand All @@ -20,6 +18,7 @@ export default function RNApp() {
title="Navigate to Referrals"
onPress={() => BrownfieldNavigation.navigateToReferrals('123')}
/>
<Button title="Fetch Update" onPress={checkAndFetchUpdate} />
</View>
</SafeAreaView>
);
Expand Down
22 changes: 21 additions & 1 deletion apps/ExpoApp54/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,31 @@
}
}
],
"@callstack/react-native-brownfield"
[
"@callstack/react-native-brownfield",
{
"debug": true
}
]
],
"experiments": {
"typedRoutes": true,
"reactCompiler": true
},
"extra": {
"router": {},
"eas": {
"projectId": "5696d23a-8a54-484c-9a7c-c473d0f28c05"
}
},
"runtimeVersion": {
"policy": "appVersion"
},
"updates": {
"url": "https://u.expo.dev/5696d23a-8a54-484c-9a7c-c473d0f28c05",
"requestHeaders": {
"expo-channel-name": "production"
}
}
}
}
4 changes: 3 additions & 1 deletion apps/ExpoApp54/app/(tabs)/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Image } from 'expo-image';
import { Link } from 'expo-router';
import { Platform, StyleSheet, View } from 'react-native';
import { Button, Platform, StyleSheet, View } from 'react-native';

import { HelloWave } from '@/components/hello-wave';
import ParallaxScrollView from '@/components/parallax-scroll-view';
import { ThemedText } from '@/components/themed-text';
import { ThemedView } from '@/components/themed-view';
import { checkAndFetchUpdate } from '@/utils/expo-rn-updates';

export default function HomeScreen() {
return (
Expand All @@ -24,6 +25,7 @@ export default function HomeScreen() {
<HelloWave />
</ThemedView>
<ThemedView style={styles.stepContainer}>
<Button title="Fetch Update" onPress={checkAndFetchUpdate} />
<ThemedText type="subtitle">Step 1: Try it</ThemedText>
<ThemedText>
Edit{' '}
Expand Down
8 changes: 4 additions & 4 deletions apps/ExpoApp54/components/counter/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { StyleSheet, Text, Button } from 'react-native';
import { useStore } from '@callstack/brownie';
// import { useStore } from '@callstack/brownie';

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

return (
<>
<Text style={styles.text}>Count: {counter}</Text>
<Text style={styles.text}>Count: {0}</Text>

<Button
onPress={() => setState((prev) => ({ counter: prev.counter + 1 }))}
// onPress={() => setState((prev) => ({ counter: prev.counter + 1 }))}
title="Increment"
/>
</>
Expand Down
Loading
Loading