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
46 changes: 30 additions & 16 deletions apps/AppleApp/Brownfield Apple App.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
objects = {

/* Begin PBXBuildFile section */
798B42862F3E9A8B00DAD195 /* BrownfieldLib.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 79A7F5CA2F3E93D90099076A /* BrownfieldLib.xcframework */; };
798B42872F3E9A8B00DAD195 /* BrownfieldLib.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 79A7F5CA2F3E93D90099076A /* BrownfieldLib.xcframework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
798B42882F3E9A8D00DAD195 /* Brownie.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 79A7F5CB2F3E93D90099076A /* Brownie.xcframework */; };
798B42892F3E9A8D00DAD195 /* Brownie.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 79A7F5CB2F3E93D90099076A /* Brownie.xcframework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
798B428A2F3E9A8E00DAD195 /* hermesvm.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 79A7F5CC2F3E93D90099076A /* hermesvm.xcframework */; };
798B428B2F3E9A8E00DAD195 /* hermesvm.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 79A7F5CC2F3E93D90099076A /* hermesvm.xcframework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
798B428C2F3E9A8F00DAD195 /* ReactBrownfield.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 79A7F5CD2F3E93D90099076A /* ReactBrownfield.xcframework */; };
798B428D2F3E9A8F00DAD195 /* ReactBrownfield.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 79A7F5CD2F3E93D90099076A /* ReactBrownfield.xcframework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
6162B59C2F4DB20800EE908E /* BrownfieldLib.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 79A7F5CA2F3E93D90099076A /* BrownfieldLib.xcframework */; };
6162B59D2F4DB20800EE908E /* BrownfieldLib.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 79A7F5CA2F3E93D90099076A /* BrownfieldLib.xcframework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
6162B59E2F4DB20800EE908E /* Brownie.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 79A7F5CB2F3E93D90099076A /* Brownie.xcframework */; };
6162B59F2F4DB20800EE908E /* Brownie.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 79A7F5CB2F3E93D90099076A /* Brownie.xcframework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
6162B5A02F4DB20800EE908E /* hermesvm.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 79A7F5CC2F3E93D90099076A /* hermesvm.xcframework */; };
6162B5A12F4DB20800EE908E /* hermesvm.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 79A7F5CC2F3E93D90099076A /* hermesvm.xcframework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
6162B5A22F4DB20800EE908E /* ReactBrownfield.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 79A7F5CD2F3E93D90099076A /* ReactBrownfield.xcframework */; };
6162B5A32F4DB20800EE908E /* ReactBrownfield.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 79A7F5CD2F3E93D90099076A /* ReactBrownfield.xcframework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
6162B5A42F4DB20F00EE908E /* BrownfieldNavigation.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6162B5882F4DB17600EE908E /* BrownfieldNavigation.xcframework */; };
6162B5A52F4DB20F00EE908E /* BrownfieldNavigation.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 6162B5882F4DB17600EE908E /* BrownfieldNavigation.xcframework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand All @@ -24,17 +26,19 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
798B428B2F3E9A8E00DAD195 /* hermesvm.xcframework in Embed Frameworks */,
798B428D2F3E9A8F00DAD195 /* ReactBrownfield.xcframework in Embed Frameworks */,
798B42892F3E9A8D00DAD195 /* Brownie.xcframework in Embed Frameworks */,
798B42872F3E9A8B00DAD195 /* BrownfieldLib.xcframework in Embed Frameworks */,
6162B5A52F4DB20F00EE908E /* BrownfieldNavigation.xcframework in Embed Frameworks */,
6162B5A12F4DB20800EE908E /* hermesvm.xcframework in Embed Frameworks */,
6162B5A32F4DB20800EE908E /* ReactBrownfield.xcframework in Embed Frameworks */,
6162B59F2F4DB20800EE908E /* Brownie.xcframework in Embed Frameworks */,
6162B59D2F4DB20800EE908E /* BrownfieldLib.xcframework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
6162B5882F4DB17600EE908E /* BrownfieldNavigation.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = BrownfieldNavigation.xcframework; path = package/BrownfieldNavigation.xcframework; sourceTree = "<group>"; };
793C76A72EEBF938008A2A34 /* Brownfield Apple App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Brownfield Apple App.app"; sourceTree = BUILT_PRODUCTS_DIR; };
79A7F5CA2F3E93D90099076A /* BrownfieldLib.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = BrownfieldLib.xcframework; path = package/BrownfieldLib.xcframework; sourceTree = "<group>"; };
79A7F5CB2F3E93D90099076A /* Brownie.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = Brownie.xcframework; path = package/Brownie.xcframework; sourceTree = "<group>"; };
Expand All @@ -55,22 +59,32 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
798B42882F3E9A8D00DAD195 /* Brownie.xcframework in Frameworks */,
798B428C2F3E9A8F00DAD195 /* ReactBrownfield.xcframework in Frameworks */,
798B42862F3E9A8B00DAD195 /* BrownfieldLib.xcframework in Frameworks */,
798B428A2F3E9A8E00DAD195 /* hermesvm.xcframework in Frameworks */,
6162B5A42F4DB20F00EE908E /* BrownfieldNavigation.xcframework in Frameworks */,
6162B59E2F4DB20800EE908E /* Brownie.xcframework in Frameworks */,
6162B5A22F4DB20800EE908E /* ReactBrownfield.xcframework in Frameworks */,
6162B5A02F4DB20800EE908E /* hermesvm.xcframework in Frameworks */,
6162B59C2F4DB20800EE908E /* BrownfieldLib.xcframework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
6108E5322F40A26800EA8FA1 /* Frameworks */ = {
isa = PBXGroup;
children = (
);
name = Frameworks;
sourceTree = "<group>";
};
793C769E2EEBF938008A2A34 = {
isa = PBXGroup;
children = (
793C76A92EEBF938008A2A34 /* Brownfield Apple App */,
6108E5322F40A26800EA8FA1 /* Frameworks */,
793C76A82EEBF938008A2A34 /* Products */,
79A7F5CA2F3E93D90099076A /* BrownfieldLib.xcframework */,
6162B5882F4DB17600EE908E /* BrownfieldNavigation.xcframework */,
79A7F5CB2F3E93D90099076A /* Brownie.xcframework */,
79A7F5CC2F3E93D90099076A /* hermesvm.xcframework */,
79A7F5CD2F3E93D90099076A /* ReactBrownfield.xcframework */,
Expand Down
66 changes: 66 additions & 0 deletions apps/AppleApp/Brownfield Apple App/BrownfieldAppleApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import BrownfieldLib
import Brownie
import SwiftUI
import ReactBrownfield
import UIKit
import BrownfieldNavigation

class AppDelegate: NSObject, UIApplicationDelegate {
var window: UIWindow?
Expand All @@ -14,6 +16,55 @@ class AppDelegate: NSObject, UIApplicationDelegate {
}
}

public class RNNavigationDelegate: BrownfieldNavigationDelegate {
public func navigateToSettings() {
present(SettingsScreen())
}

public func navigateToReferrals(userId: String) {
present(ReferralsScreen(userId: userId))
}

private func present<Content: View>(_ view: Content) {
DispatchQueue.main.async {
let hostingController = UIHostingController(rootView: view)

guard let topController = UIApplication.shared.topMostViewController() else {
return
}

if let navigationController = topController.navigationController {
navigationController.pushViewController(hostingController, animated: true)
return
}

let navigationController = UINavigationController(rootViewController: hostingController)
topController.present(navigationController, animated: true)
}
}
}

private extension UIApplication {
func topMostViewController(
base: UIViewController? = UIApplication.shared.connectedScenes
.compactMap { $0 as? UIWindowScene }
.flatMap { $0.windows }
.first(where: { $0.isKeyWindow })?.rootViewController
) -> UIViewController? {
if let navigationController = base as? UINavigationController {
return topMostViewController(base: navigationController.visibleViewController)
}
if let tabBarController = base as? UITabBarController,
let selected = tabBarController.selectedViewController {
return topMostViewController(base: selected)
}
if let presented = base?.presentedViewController {
return topMostViewController(base: presented)
}
return base
}
}

@main
struct BrownfieldAppleApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
Expand All @@ -23,6 +74,21 @@ struct BrownfieldAppleApp: App {
ReactNativeBrownfield.shared.startReactNative {
print("React Native has been loaded")
}

// let mgr = ReactBrownfield.BrownfieldNavigationManager.shared
// print("SWIFT mgr:", Unmanaged.passUnretained(mgr).toOpaque())
// print("SWIFT class:", NSStringFromClass(type(of: mgr)))
// print("SWIFT bundle:", Bundle(for: ReactBrownfield.BrownfieldNavigationManager.self).bundlePath)
// ReactBrownfield.BrownfieldNavigationManager.shared.setDelegate(navigationDelegate: RNNavigationDelegate())

let mgr = BrownfieldNavigationManager.shared
print("11 SWIFT mgr:", Unmanaged.passUnretained(mgr).toOpaque())
print("11 SWIFT class:", NSStringFromClass(type(of: mgr)))
print("11 SWIFT bundle:", Bundle(for: BrownfieldNavigationManager.self).bundlePath)

mgr.setDelegate(
navigationDelegate: RNNavigationDelegate()
)

#if USE_EXPO_HOST
ReactNativeBrownfield.shared.ensureExpoModulesProvider()
Expand Down
47 changes: 47 additions & 0 deletions apps/AppleApp/Brownfield Apple App/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,53 @@ struct MainScreen: View {
}
}

struct SettingsScreen: View {
var body: some View {
Form {
Section("Preferences") {
Toggle("Enable notifications", isOn: .constant(true))
Toggle("Dark mode", isOn: .constant(false))
}

Section("About") {
HStack {
Text("Version")
Spacer()
Text("1.0.0")
.foregroundStyle(.secondary)
}
}
}
.navigationTitle("Settings")
}
}

struct ReferralsScreen: View {
let userId: String

var body: some View {
VStack(spacing: 16) {
Text("Referrals")
.font(.title2)
.fontWeight(.semibold)

Text("User ID")
.foregroundStyle(.secondary)
Text(userId)
.font(.body.monospaced())
.textSelection(.enabled)

Button("Share referral link") {
// Placeholder action for the sample app.
}
.buttonStyle(.borderedProminent)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.padding()
.navigationTitle("Referrals")
}
}

struct GreetingCard: View {
let name: String
@UseStore(\BrownfieldStore.counter) var counter
Expand Down
1 change: 1 addition & 0 deletions apps/AppleApp/prepareXCFrameworks.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const validNames = [
'Brownie.xcframework',
'hermesvm.xcframework',
'ReactBrownfield.xcframework',
'BrownfieldNavigation.xcframework',
];

for (const file of fs.readdirSync(targetPackagePath)) {
Expand Down
12 changes: 12 additions & 0 deletions apps/RNApp/brownfield.navigation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export interface BrownfieldNavigationSpec {
/**
* Navigate to the native settings screen
*/
navigateToSettings(): void;

/**
* Navigate to the native referrals screen
* @param userId - The user's unique identifier
*/
navigateToReferrals(userId: string): void;
}
40 changes: 36 additions & 4 deletions apps/RNApp/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
PODS:
- boost (1.84.0)
- Brownie (0.0.5):
- BrownfieldNavigation (1.0.0):
- boost
- DoubleConversion
- fast_float
- fmt
- glog
- hermes-engine
- RCT-Folly
- RCT-Folly/Fabric
- RCTRequired
- RCTTypeSafety
- React-Core
- React-debug
- React-Fabric
- React-featureflags
- React-graphics
- React-ImageManager
- React-jsi
- React-NativeModulesApple
- React-RCTFabric
- React-renderercss
- React-rendererdebug
- React-utils
- ReactCodegen
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- SocketRocket
- Yoga
- Brownie (3.0.0-rc.2):
- boost
- DoubleConversion
- fast_float
Expand Down Expand Up @@ -2350,7 +2378,7 @@ PODS:
- SocketRocket
- ReactAppDependencyProvider (0.82.1):
- ReactCodegen
- ReactBrownfield (3.0.0-rc.1):
- ReactBrownfield (3.0.0-rc.2):
- boost
- DoubleConversion
- fast_float
Expand Down Expand Up @@ -2530,6 +2558,7 @@ PODS:

DEPENDENCIES:
- boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`)
- "BrownfieldNavigation (from `../node_modules/@callstack/brownfield-navigation`)"
- "Brownie (from `../node_modules/@callstack/brownie`)"
- DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)
- fast_float (from `../node_modules/react-native/third-party-podspecs/fast_float.podspec`)
Expand Down Expand Up @@ -2616,6 +2645,8 @@ SPEC REPOS:
EXTERNAL SOURCES:
boost:
:podspec: "../node_modules/react-native/third-party-podspecs/boost.podspec"
BrownfieldNavigation:
:path: "../node_modules/@callstack/brownfield-navigation"
Brownie:
:path: "../node_modules/@callstack/brownie"
DoubleConversion:
Expand Down Expand Up @@ -2772,7 +2803,8 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
boost: 7e761d76ca2ce687f7cc98e698152abd03a18f90
Brownie: e4291b884a7157a2dbe6d60dd72e962078223791
BrownfieldNavigation: 3141ebc18a1dbeb374fff7ae12b2f5d9d1272f2f
Brownie: 062c63b8aff0eedae128008f2375478fd86fd928
DoubleConversion: cb417026b2400c8f53ae97020b2be961b59470cb
fast_float: b32c788ed9c6a8c584d114d0047beda9664e7cc6
FBLazyVector: 0aa6183b9afe3c31fc65b5d1eeef1f3c19b63bfa
Expand Down Expand Up @@ -2843,7 +2875,7 @@ SPEC CHECKSUMS:
React-utils: f06ff240e06e2bd4b34e48f1b34cac00866e8979
React-webperformancenativemodule: b3398f8175fa96d992c071b1fa59bd6f9646b840
ReactAppDependencyProvider: a45ef34bb22dc1c9b2ac1f74167d9a28af961176
ReactBrownfield: ce231a9060b34e1fe8f91ec8416f21dc6da8b4b5
ReactBrownfield: 91f5dde821a05d473b97fba634a7d401a697b9d1
ReactCodegen: 0bce2d209e2e802589f4c5ff76d21618200e74cb
ReactCommon: 801eff8cb9c940c04d3a89ce399c343ee3eff654
RNScreens: d6413aeb1878cdafd3c721e2c5218faf5d5d3b13
Expand Down
Loading
Loading