diff --git a/.yarn/patches/@op-engineering-op-sqlite-npm-15.0.7-39fbf4933a.patch b/.yarn/patches/@op-engineering-op-sqlite-npm-15.0.7-39fbf4933a.patch index d8c4e7e..71e4eac 100644 --- a/.yarn/patches/@op-engineering-op-sqlite-npm-15.0.7-39fbf4933a.patch +++ b/.yarn/patches/@op-engineering-op-sqlite-npm-15.0.7-39fbf4933a.patch @@ -193,6 +193,18 @@ index 5e1c1de234e7bdb131769728fc862d389f9995a5..dc21c6503ffe18f3ae1cf99f327e8aa1 void install(jsi::Runtime &rt, const std::shared_ptr &invoker, const char *base_path, const char *crsqlite_path, +diff --git a/cpp/bindings.h b/cpp/bindings.h +index 91511ab8dff0cbd34c6b8b844c1783c39d4317cb..cc73dfe4405d568cbfbbfa5a9c879a1d88f260bf 100644 +--- a/cpp/bindings.h ++++ b/cpp/bindings.h +@@ -14,6 +14,7 @@ void install(jsi::Runtime &rt, + const char *base_path, const char *crsqlite_path, + const char *sqlite_vec_path); + void invalidate(); ++bool deleteAllDbs(); + void expoUpdatesWorkaround(const char *base_path); + + } // namespace opsqlite diff --git a/op-sqlite.podspec b/op-sqlite.podspec index 375cc3ef0838a3cffb87ec970f636880a8676bb3..e6fce21630ed00aa863f2baae7b3d04de783dcb0 100644 --- a/op-sqlite.podspec diff --git a/android/src/main/java/com/mendix/mendixnative/react/NavigationModeModule.kt b/android/src/main/java/com/mendix/mendixnative/react/NavigationModeModule.kt new file mode 100644 index 0000000..d4e243b --- /dev/null +++ b/android/src/main/java/com/mendix/mendixnative/react/NavigationModeModule.kt @@ -0,0 +1,81 @@ +package com.mendix.mendixnative.react + +import android.util.Log +import com.facebook.react.bridge.ReactApplicationContext + +class NavigationModeModule(val context: ReactApplicationContext) { + + companion object { + const val TAG = "NavigationModeModule" + const val NAVIGATION_BAR_INTERACTION_MODE_THREE_BUTTON = 0 + const val NAVIGATION_BAR_INTERACTION_MODE_TWO_BUTTON = 1 + const val NAVIGATION_BAR_INTERACTION_MODE_GESTURE = 2 + } + + fun isNavigationBarActive(): Boolean { + Log.d(TAG, "=== isNavigationBarActive called (sync) ===") + return try { + Log.d(TAG, "Context: $context") + + val resources = context.resources + Log.d(TAG, "Resources: $resources") + + val resourceId = resources.getIdentifier( + "config_navBarInteractionMode", + "integer", + "android" + ) + Log.d(TAG, "Resource ID: $resourceId") + + val mode = if (resourceId > 0) { + val retrievedMode = resources.getInteger(resourceId) + Log.d(TAG, "Retrieved mode from resources: $retrievedMode") + retrievedMode + } else { + Log.w(TAG, "Resource not found, defaulting to THREE_BUTTON (0)") + NAVIGATION_BAR_INTERACTION_MODE_THREE_BUTTON + } + + Log.d(TAG, "Final mode value: $mode") + + // Navigation bar is active for three-button and two-button modes + val isActive = mode == NAVIGATION_BAR_INTERACTION_MODE_THREE_BUTTON || + mode == NAVIGATION_BAR_INTERACTION_MODE_TWO_BUTTON + + Log.d(TAG, "Is navigation bar active: $isActive") + Log.d(TAG, "Returning: $isActive") + + isActive + + } catch (e: Exception) { + Log.e(TAG, "Error in isNavigationBarActive", e) + false + } + } + + fun getNavigationBarHeight(): Double { + Log.d(TAG, "=== getNavigationBarHeight called (sync) ===") + return try { + val resources = context.resources + + val resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android") + val height = if (resourceId > 0) { + val heightPx = resources.getDimensionPixelSize(resourceId) + // Convert to dp for React Native + val density = resources.displayMetrics.density + val heightDp = heightPx / density + Log.d(TAG, "Navigation bar height: ${heightPx}px = ${heightDp}dp") + heightDp.toDouble() + } else { + Log.w(TAG, "Navigation bar height resource not found, returning 0") + 0.0 + } + + height + + } catch (e: Exception) { + Log.e(TAG, "Error in getNavigationBarHeight", e) + 0.0 + } + } +} diff --git a/android/src/main/java/com/mendixnative/MendixNativeModule.kt b/android/src/main/java/com/mendixnative/MendixNativeModule.kt index 1c2410e..c050cd5 100644 --- a/android/src/main/java/com/mendixnative/MendixNativeModule.kt +++ b/android/src/main/java/com/mendixnative/MendixNativeModule.kt @@ -10,6 +10,7 @@ import com.mendix.mendixnative.encryption.MendixEncryptedStorageModule import com.mendix.mendixnative.react.MxConfiguration import com.mendix.mendixnative.react.NativeErrorHandler import com.mendix.mendixnative.react.NativeReloadHandler +import com.mendix.mendixnative.react.NavigationModeModule import com.mendix.mendixnative.react.cookie.NativeCookieModule import com.mendix.mendixnative.react.download.NativeDownloadModule import com.mendix.mendixnative.react.fs.NativeFsModule @@ -168,6 +169,14 @@ class MendixNativeModule(reactContext: ReactApplicationContext) : NativeMendixNa NativeErrorHandler(reactApplicationContext).handle(message, stackTrace) } + override fun navigationModeIsNavigationBarActive(): Boolean { + return NavigationModeModule(reactApplicationContext).isNavigationBarActive() + } + + override fun navigationModeGetNavigationBarHeight(): Double { + return NavigationModeModule(reactApplicationContext).getNavigationBarHeight() + } + companion object { const val NAME = "MendixNative" } diff --git a/example/android/app/src/main/java/mendixnative/example/MainApplication.kt b/example/android/app/src/main/java/mendixnative/example/MainApplication.kt index c0a332e..e41702a 100644 --- a/example/android/app/src/main/java/mendixnative/example/MainApplication.kt +++ b/example/android/app/src/main/java/mendixnative/example/MainApplication.kt @@ -12,7 +12,18 @@ import com.facebook.react.defaults.DefaultReactNativeHost import com.facebook.react.soloader.OpenSourceMergedSoMapping import com.facebook.soloader.SoLoader -class MainApplication : Application(), ReactApplication { +//Start - For MendixApplication compatibility only, not part of React Native template +import com.mendix.mendixnative.MendixApplication +import com.mendix.mendixnative.react.splash.MendixSplashScreenPresenter +import com.mendix.mendixnative.react.MxConfiguration + +class SplashScreenPresenter: MendixSplashScreenPresenter { + override fun show(activity: android.app.Activity) {} + override fun hide(activity: android.app.Activity) {} +} +//End - For MendixApplication compatibility only, not part of React Native template + +class MainApplication : Application(), MendixApplication { override val reactNativeHost: ReactNativeHost = object : DefaultReactNativeHost(this) { @@ -35,10 +46,19 @@ class MainApplication : Application(), ReactApplication { override fun onCreate() { super.onCreate() + MxConfiguration.runtimeUrl = "http://10.0.2.2:8081" //For MendixApplication compatibility only, not part of React Native template SoLoader.init(this, OpenSourceMergedSoMapping) if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { // If you opted-in for the New Architecture, we load the native entry point for this app. load() } } + + //Start - For MendixApplication compatibility only, not part of React Native template + override fun getUseDeveloperSupport() = false + override fun createSplashScreenPresenter() = SplashScreenPresenter() + override fun getPackages(): List = PackageList(this).packages + override fun getJSBundleFile() = null + override fun getAppSessionId() = null + //End - For MendixApplication compatibility only, not part of React Native template } diff --git a/example/ios/MendixNativeExample/AppDelegate.swift b/example/ios/MendixNativeExample/AppDelegate.swift index 99daee7..b6d5e16 100644 --- a/example/ios/MendixNativeExample/AppDelegate.swift +++ b/example/ios/MendixNativeExample/AppDelegate.swift @@ -1,43 +1,46 @@ import UIKit import React +import React_RCTAppDelegate +import ReactAppDependencyProvider import MendixNative @main -class AppDelegate: ReactAppProvider { +class AppDelegate: RCTAppDelegate { override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { - super.setUpProvider() + + self.moduleName = "App" + self.dependencyProvider = RCTAppDependencyProvider() + self.initialProps = [:] super.application(application, didFinishLaunchingWithOptions: launchOptions) - changeRoot(to: Home()) + + //Start - For MendixApplication compatibility only, not part of React Native template + MxConfiguration.update(from: + MendixApp.init( + identifier: nil, + bundleUrl: bundleURL()!, + runtimeUrl: URL(string: "http://localhost:8081")!, + warningsFilter: .none, + isDeveloperApp: false, + clearDataAtLaunch: false, + splashScreenPresenter: nil, + reactLoading: nil, + enableThreeFingerGestures: false + ) + ) + //End - For MendixApplication compatibility only, not part of React Native template return true } - open override func bundleURL() -> URL? { - return RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index") + override func sourceURL(for bridge: RCTBridge) -> URL? { + self.bundleURL() } -} -class Home: UIViewController { - - lazy var button: UIButton = { - let button = UIButton(type: .system) - button.setTitle("Open React App", for: .normal) - button.translatesAutoresizingMaskIntoConstraints = false - button.addTarget(self, action: #selector(openApp), for: .touchUpInside) - return button - }() - - override func viewDidLoad() { - super.viewDidLoad() - view.backgroundColor = .white - view.addSubview(button) - NSLayoutConstraint.activate([ - button.centerXAnchor.constraint(equalTo: view.centerXAnchor), - button.centerYAnchor.constraint(equalTo: view.centerYAnchor) - ]) - } - - @objc func openApp() { - ReactAppProvider.shared()?.setReactViewController(UIViewController()) + override func bundleURL() -> URL? { + #if DEBUG + RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index") + #else + Bundle.main.url(forResource: "main", withExtension: "jsbundle") + #endif } } diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index bd2783a..304422c 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -8,7 +8,7 @@ PODS: - hermes-engine (0.77.3): - hermes-engine/Pre-built (= 0.77.3) - hermes-engine/Pre-built (0.77.3) - - MendixNative (0.0.1): + - MendixNative (0.1.2): - DoubleConversion - glog - hermes-engine @@ -34,7 +34,7 @@ PODS: - RNCAsyncStorage - SSZipArchive - Yoga - - op-sqlite (12.0.2): + - op-sqlite (15.0.7): - DoubleConversion - glog - hermes-engine @@ -42,8 +42,6 @@ PODS: - RCT-Folly (= 2024.11.18.00) - RCTRequired - RCTTypeSafety - - React - - React-callinvoker - React-Core - React-debug - React-Fabric @@ -1827,8 +1825,8 @@ SPEC CHECKSUMS: fmt: a40bb5bd0294ea969aaaba240a927bd33d878cdd glog: eb93e2f488219332457c3c4eafd2738ddc7e80b8 hermes-engine: b2187dbe13edb0db8fcb2a93a69c1987a30d98a4 - MendixNative: d76c461cfe93066190b9f1c21d01a4960e1f7ce2 - op-sqlite: f364fb409143a1194b76909630c050c6e91245e9 + MendixNative: 0405210432ee514e2d7906fe5714f719eb6d7c75 + op-sqlite: 12554de3e1a0cb86cbad3cf1f0c50450f57d3855 OpenSSL-Universal: 6082b0bf950e5636fe0d78def171184e2b3899c2 RCT-Folly: e78785aa9ba2ed998ea4151e314036f6c49e6d82 RCTDeprecation: 6ee92578d332db1d4e03267d3ae98bcf8b780863 diff --git a/example/src/App.tsx b/example/src/App.tsx index 5546efd..b9ba3bb 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -1,10 +1,14 @@ import { Text, View, StyleSheet } from 'react-native'; +import { AndroidNavigationBar } from 'mendix-native'; export default function App() { const runtime = (global as any).nativeFabricUIManager ? 'New Architecture' : 'Legacy Architecture'; + console.log('Navigation Bar Height:', AndroidNavigationBar.height); + console.log('Is Navigation Bar Active:', AndroidNavigationBar.isActive); + return ( diff --git a/ios/MendixNative.mm b/ios/MendixNative.mm index be00204..7907018 100644 --- a/ios/MendixNative.mm +++ b/ios/MendixNative.mm @@ -140,5 +140,14 @@ - (void)fsReadAsText:(nonnull NSString *)filePath resolve:(nonnull RCTPromiseRes reject(@"NOT_SPPORTED", @"Read as text is not supported on iOS", nil); } +- (nonnull NSNumber *)navigationModeGetNavigationBarHeight { + return [NSNumber numberWithBool:NO]; +} + + +- (nonnull NSNumber *)navigationModeIsNavigationBarActive { + return [NSNumber numberWithDouble:0.0]; +} + @end diff --git a/src/index.ts b/src/index.ts index 24403af..77b7b17 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,3 +8,4 @@ export * from './reload-handler'; export * from './encrypted-storage'; export * from './error-handler'; export * from './file-system'; +export * from './navigation-mode'; diff --git a/src/navigation-mode.ts b/src/navigation-mode.ts new file mode 100644 index 0000000..5788ff4 --- /dev/null +++ b/src/navigation-mode.ts @@ -0,0 +1,6 @@ +import Mx from './specs/NativeMendixNative'; + +export const AndroidNavigationBar = { + height: Mx.navigationModeGetNavigationBarHeight(), + isActive: Mx.navigationModeIsNavigationBarActive(), +}; diff --git a/src/specs/NativeMendixNative.ts b/src/specs/NativeMendixNative.ts index 731d39e..91dd3bf 100644 --- a/src/specs/NativeMendixNative.ts +++ b/src/specs/NativeMendixNative.ts @@ -48,6 +48,9 @@ export interface Spec extends TurboModule { errorHandlerHandle(message: string, stackTrace: StackFrame[]): void; + navigationModeIsNavigationBarActive(): boolean; + navigationModeGetNavigationBarHeight(): Double; + readonly onReloadWithState: EventEmitter; readonly onDownloadProgress: EventEmitter; } diff --git a/yarn.lock b/yarn.lock index 349922a..f4741c6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2496,11 +2496,11 @@ __metadata: "@op-engineering/op-sqlite@patch:@op-engineering/op-sqlite@npm%3A15.0.7#./.yarn/patches/@op-engineering-op-sqlite-npm-15.0.7-39fbf4933a.patch::locator=mendix-native%40workspace%3A.": version: 15.0.7 - resolution: "@op-engineering/op-sqlite@patch:@op-engineering/op-sqlite@npm%3A15.0.7#./.yarn/patches/@op-engineering-op-sqlite-npm-15.0.7-39fbf4933a.patch::version=15.0.7&hash=2e90b0&locator=mendix-native%40workspace%3A." + resolution: "@op-engineering/op-sqlite@patch:@op-engineering/op-sqlite@npm%3A15.0.7#./.yarn/patches/@op-engineering-op-sqlite-npm-15.0.7-39fbf4933a.patch::version=15.0.7&hash=686531&locator=mendix-native%40workspace%3A." peerDependencies: react: "*" react-native: "*" - checksum: 9c9d3148f4ad7d5025a5d6df9c2c82996b10270936f788a5486ab1df26307ab9b88130f00472f32bd6e7a13793312be04f3e60a0ccbd1bd88ec90b3fb4a8163e + checksum: 4f77818b144fe18bfdcc5f02c2e3249b7b7686b378fd8d72db69c27a13af3e45c679ef66a2d34f4da6eca732882b696e7e1a2d54eee158edeb95c9391f3433b6 languageName: node linkType: hard