Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,18 @@ index 5e1c1de234e7bdb131769728fc862d389f9995a5..dc21c6503ffe18f3ae1cf99f327e8aa1
void install(jsi::Runtime &rt,
const std::shared_ptr<react::CallInvoker> &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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
}
}
9 changes: 9 additions & 0 deletions android/src/main/java/com/mendixnative/MendixNativeModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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<ReactPackage> = PackageList(this).packages
override fun getJSBundleFile() = null
override fun getAppSessionId() = null
//End - For MendixApplication compatibility only, not part of React Native template
}
59 changes: 31 additions & 28 deletions example/ios/MendixNativeExample/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -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
}
}
10 changes: 4 additions & 6 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,16 +34,14 @@ PODS:
- RNCAsyncStorage
- SSZipArchive
- Yoga
- op-sqlite (12.0.2):
- op-sqlite (15.0.7):
- DoubleConversion
- glog
- hermes-engine
- OpenSSL-Universal
- RCT-Folly (= 2024.11.18.00)
- RCTRequired
- RCTTypeSafety
- React
- React-callinvoker
- React-Core
- React-debug
- React-Fabric
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<View style={styles.container}>
<View style={styles.archContainer}>
Expand Down
9 changes: 9 additions & 0 deletions ios/MendixNative.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export * from './reload-handler';
export * from './encrypted-storage';
export * from './error-handler';
export * from './file-system';
export * from './navigation-mode';
6 changes: 6 additions & 0 deletions src/navigation-mode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Mx from './specs/NativeMendixNative';

export const AndroidNavigationBar = {
height: Mx.navigationModeGetNavigationBarHeight(),
isActive: Mx.navigationModeIsNavigationBarActive(),
};
3 changes: 3 additions & 0 deletions src/specs/NativeMendixNative.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ export interface Spec extends TurboModule {

errorHandlerHandle(message: string, stackTrace: StackFrame[]): void;

navigationModeIsNavigationBarActive(): boolean;
navigationModeGetNavigationBarHeight(): Double;

readonly onReloadWithState: EventEmitter<void>;
readonly onDownloadProgress: EventEmitter<DownloadProgress>;
}
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading