Commit b5e7077a authored by Wei Han's avatar Wei Han

ui progress

parent de578d80
...@@ -8,32 +8,32 @@ ...@@ -8,32 +8,32 @@
<key>BinaryPath</key> <key>BinaryPath</key>
<string>QmsPluginFramework.framework/QmsPluginFramework</string> <string>QmsPluginFramework.framework/QmsPluginFramework</string>
<key>LibraryIdentifier</key> <key>LibraryIdentifier</key>
<string>ios-arm64</string> <string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key> <key>LibraryPath</key>
<string>QmsPluginFramework.framework</string> <string>QmsPluginFramework.framework</string>
<key>SupportedArchitectures</key> <key>SupportedArchitectures</key>
<array> <array>
<string>arm64</string> <string>arm64</string>
<string>x86_64</string>
</array> </array>
<key>SupportedPlatform</key> <key>SupportedPlatform</key>
<string>ios</string> <string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict> </dict>
<dict> <dict>
<key>BinaryPath</key> <key>BinaryPath</key>
<string>QmsPluginFramework.framework/QmsPluginFramework</string> <string>QmsPluginFramework.framework/QmsPluginFramework</string>
<key>LibraryIdentifier</key> <key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string> <string>ios-arm64</string>
<key>LibraryPath</key> <key>LibraryPath</key>
<string>QmsPluginFramework.framework</string> <string>QmsPluginFramework.framework</string>
<key>SupportedArchitectures</key> <key>SupportedArchitectures</key>
<array> <array>
<string>arm64</string> <string>arm64</string>
<string>x86_64</string>
</array> </array>
<key>SupportedPlatform</key> <key>SupportedPlatform</key>
<string>ios</string> <string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict> </dict>
</array> </array>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
......
//QmsPlugin.h //QmsPlugin.h
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
FOUNDATION_EXPORT NSNumber* QmsPluginMultiply(double a, double b); FOUNDATION_EXPORT NSNumber* QmsPluginMultiply(double a, double b);
FOUNDATION_EXPORT UIViewController* QmsPluginMakeViewController(void);
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
<dict> <dict>
<key>Headers/QmsPlugin.h</key> <key>Headers/QmsPlugin.h</key>
<data> <data>
T0w73SfaKmay5cfzE/KHplzhWis= 5nKoARTfB27hIPyN1aDnt2M2AlM=
</data> </data>
<key>Info.plist</key> <key>Info.plist</key>
<data> <data>
QvWHhX2X4hW9mXAFtK1rMMulanM= ScoY0XAgmZ3U9Q0BvlfgQfJm2bo=
</data> </data>
</dict> </dict>
<key>files2</key> <key>files2</key>
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<dict> <dict>
<key>hash2</key> <key>hash2</key>
<data> <data>
U05V7l0WqfmXhNjNLDaPBAUgwRfBgPpUE5n7pvQshgg= YSvzim+1uTbTL+VKFNabNPhqRNP3ftgBHgFyhbD5cCM=
</data> </data>
</dict> </dict>
</dict> </dict>
......
//QmsPlugin.h //QmsPlugin.h
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
FOUNDATION_EXPORT NSNumber* QmsPluginMultiply(double a, double b); FOUNDATION_EXPORT NSNumber* QmsPluginMultiply(double a, double b);
FOUNDATION_EXPORT UIViewController* QmsPluginMakeViewController(void);
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
<dict> <dict>
<key>Headers/QmsPlugin.h</key> <key>Headers/QmsPlugin.h</key>
<data> <data>
T0w73SfaKmay5cfzE/KHplzhWis= 5nKoARTfB27hIPyN1aDnt2M2AlM=
</data> </data>
<key>Info.plist</key> <key>Info.plist</key>
<data> <data>
mHHohDKLbelgffJEne6sKFR+cnQ= JGviPenfphujtQEGyJZCIZTsd2c=
</data> </data>
</dict> </dict>
<key>files2</key> <key>files2</key>
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<dict> <dict>
<key>hash2</key> <key>hash2</key>
<data> <data>
U05V7l0WqfmXhNjNLDaPBAUgwRfBgPpUE5n7pvQshgg= YSvzim+1uTbTL+VKFNabNPhqRNP3ftgBHgFyhbD5cCM=
</data> </data>
</dict> </dict>
</dict> </dict>
......
...@@ -6,8 +6,15 @@ ...@@ -6,8 +6,15 @@
objectVersion = 77; objectVersion = 77;
objects = { objects = {
/* Begin PBXBuildFile section */
2FAEF09A2E8B7BC80086EDA3 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2FAEF0992E8B7BC80086EDA3 /* UIKit.framework */; };
2FAEF09C2E8B7BD40086EDA3 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2FAEF09B2E8B7BD40086EDA3 /* Foundation.framework */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
2F9647652E86307D002CC7CB /* QmsPluginFramework.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = QmsPluginFramework.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 2F9647652E86307D002CC7CB /* QmsPluginFramework.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = QmsPluginFramework.framework; sourceTree = BUILT_PRODUCTS_DIR; };
2FAEF0992E8B7BC80086EDA3 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.0.sdk/System/iOSSupport/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; };
2FAEF09B2E8B7BD40086EDA3 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */ /* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
...@@ -36,6 +43,8 @@ ...@@ -36,6 +43,8 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
2FAEF09C2E8B7BD40086EDA3 /* Foundation.framework in Frameworks */,
2FAEF09A2E8B7BC80086EDA3 /* UIKit.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -46,6 +55,7 @@ ...@@ -46,6 +55,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
2F9647672E86307D002CC7CB /* QmsPluginFramework */, 2F9647672E86307D002CC7CB /* QmsPluginFramework */,
2FAEF0982E8B7BC80086EDA3 /* Frameworks */,
2F9647662E86307D002CC7CB /* Products */, 2F9647662E86307D002CC7CB /* Products */,
); );
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -58,6 +68,15 @@ ...@@ -58,6 +68,15 @@
name = Products; name = Products;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
2FAEF0982E8B7BC80086EDA3 /* Frameworks */ = {
isa = PBXGroup;
children = (
2FAEF09B2E8B7BD40086EDA3 /* Foundation.framework */,
2FAEF0992E8B7BC80086EDA3 /* UIKit.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */ /* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */ /* Begin PBXHeadersBuildPhase section */
......
//QmsPlugin.h //QmsPlugin.h
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
FOUNDATION_EXPORT NSNumber* QmsPluginMultiply(double a, double b); FOUNDATION_EXPORT NSNumber* QmsPluginMultiply(double a, double b);
FOUNDATION_EXPORT UIViewController* QmsPluginMakeViewController(void);
...@@ -4,3 +4,15 @@ ...@@ -4,3 +4,15 @@
NSNumber* QmsPluginMultiply(double a, double b) { NSNumber* QmsPluginMultiply(double a, double b) {
return @(a * b); return @(a * b);
} }
UIViewController* QmsPluginMakeViewController(void) {
UIViewController *vc = [UIViewController new];
vc.view.backgroundColor = [UIColor whiteColor];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(40, 100, 300, 40)];
label.text = @"UI from xcframework (no subclass)";
label.font = [UIFont boldSystemFontOfSize:22];
[vc.view addSubview:label];
return vc;
}
#import <React/RCTBridgeModule.h> #import <React/RCTBridgeModule.h>
#import <QmsPluginSpec/QmsPluginSpec.h> #import <QmsPluginSpec/QmsPluginSpec.h>
#import <QmsPluginFramework/QmsPlugin.h> #import <QmsPluginFramework/QmsPlugin.h> // this is your xcframework header
@interface QmsPlugin : NSObject <NativeQmsPluginSpec> @interface QmsPlugin : NSObject <NativeQmsPluginSpec>
@end @end
...@@ -9,7 +9,14 @@ ...@@ -9,7 +9,14 @@
RCT_EXPORT_MODULE() RCT_EXPORT_MODULE()
// Implement multiply using the xcframework - (instancetype)init {
if (self = [super init]) {
NSLog(@"[QmsPlugin] Native module initialized");
}
return self;
}
// Wraps the C function QmsPluginMultiply
- (NSNumber *)multiply:(double)a b:(double)b { - (NSNumber *)multiply:(double)a b:(double)b {
NSLog(@"[QmsPlugin] multiply called with a=%f, b=%f", a, b); NSLog(@"[QmsPlugin] multiply called with a=%f, b=%f", a, b);
NSNumber *result = QmsPluginMultiply(a, b); NSNumber *result = QmsPluginMultiply(a, b);
...@@ -17,13 +24,54 @@ RCT_EXPORT_MODULE() ...@@ -17,13 +24,54 @@ RCT_EXPORT_MODULE()
return result; return result;
} }
// Wraps the C function QmsPluginMakeViewController
- (void)showPluginUI {
NSLog(@"[QmsPlugin] showPluginUI CALLED from JS");
dispatch_async(dispatch_get_main_queue(), ^{
UIViewController *vc = QmsPluginMakeViewController();
NSLog(@"[QmsPlugin] created QmsPluginViewController: %@", vc);
// Find topmost view controller
UIWindow *keyWindow = nil;
for (UIWindowScene *scene in UIApplication.sharedApplication.connectedScenes) {
if (scene.activationState == UISceneActivationStateForegroundActive) {
keyWindow = scene.windows.firstObject;
if (keyWindow) break;
}
}
if (keyWindow == nil) {
NSLog(@"[QmsPlugin] ERROR: keyWindow is nil");
return;
} else {
NSLog(@"[QmsPlugin] Found keyWindow: %@", keyWindow);
}
UIViewController *presentingVC = keyWindow.rootViewController;
NSLog(@"[QmsPlugin] rootViewController = %@", presentingVC);
while (presentingVC.presentedViewController) {
presentingVC = presentingVC.presentedViewController;
}
if (presentingVC) {
NSLog(@"[QmsPlugin] Presenting VC = %@", presentingVC);
[presentingVC presentViewController:vc animated:YES completion:^{
NSLog(@"[QmsPlugin] UI presented successfully");
}];
} else {
NSLog(@"[QmsPlugin] ERROR: No presenting view controller");
}
});
}
// TurboModule boilerplate // TurboModule boilerplate
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule: - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
(const facebook::react::ObjCTurboModule::InitParams &)params (const facebook::react::ObjCTurboModule::InitParams &)params
{ {
NSLog(@"[QmsPlugin] getTurboModule called");
return std::make_shared<facebook::react::NativeQmsPluginSpecJSI>(params); return std::make_shared<facebook::react::NativeQmsPluginSpecJSI>(params);
} }
@end @end
...@@ -8,32 +8,32 @@ ...@@ -8,32 +8,32 @@
<key>BinaryPath</key> <key>BinaryPath</key>
<string>QmsPluginFramework.framework/QmsPluginFramework</string> <string>QmsPluginFramework.framework/QmsPluginFramework</string>
<key>LibraryIdentifier</key> <key>LibraryIdentifier</key>
<string>ios-arm64</string> <string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key> <key>LibraryPath</key>
<string>QmsPluginFramework.framework</string> <string>QmsPluginFramework.framework</string>
<key>SupportedArchitectures</key> <key>SupportedArchitectures</key>
<array> <array>
<string>arm64</string> <string>arm64</string>
<string>x86_64</string>
</array> </array>
<key>SupportedPlatform</key> <key>SupportedPlatform</key>
<string>ios</string> <string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict> </dict>
<dict> <dict>
<key>BinaryPath</key> <key>BinaryPath</key>
<string>QmsPluginFramework.framework/QmsPluginFramework</string> <string>QmsPluginFramework.framework/QmsPluginFramework</string>
<key>LibraryIdentifier</key> <key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string> <string>ios-arm64</string>
<key>LibraryPath</key> <key>LibraryPath</key>
<string>QmsPluginFramework.framework</string> <string>QmsPluginFramework.framework</string>
<key>SupportedArchitectures</key> <key>SupportedArchitectures</key>
<array> <array>
<string>arm64</string> <string>arm64</string>
<string>x86_64</string>
</array> </array>
<key>SupportedPlatform</key> <key>SupportedPlatform</key>
<string>ios</string> <string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict> </dict>
</array> </array>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
......
//QmsPlugin.h //QmsPlugin.h
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
FOUNDATION_EXPORT NSNumber* QmsPluginMultiply(double a, double b); FOUNDATION_EXPORT NSNumber* QmsPluginMultiply(double a, double b);
FOUNDATION_EXPORT UIViewController* QmsPluginMakeViewController(void);
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
<dict> <dict>
<key>Headers/QmsPlugin.h</key> <key>Headers/QmsPlugin.h</key>
<data> <data>
T0w73SfaKmay5cfzE/KHplzhWis= 5nKoARTfB27hIPyN1aDnt2M2AlM=
</data> </data>
<key>Info.plist</key> <key>Info.plist</key>
<data> <data>
QvWHhX2X4hW9mXAFtK1rMMulanM= ScoY0XAgmZ3U9Q0BvlfgQfJm2bo=
</data> </data>
</dict> </dict>
<key>files2</key> <key>files2</key>
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<dict> <dict>
<key>hash2</key> <key>hash2</key>
<data> <data>
U05V7l0WqfmXhNjNLDaPBAUgwRfBgPpUE5n7pvQshgg= YSvzim+1uTbTL+VKFNabNPhqRNP3ftgBHgFyhbD5cCM=
</data> </data>
</dict> </dict>
</dict> </dict>
......
//QmsPlugin.h //QmsPlugin.h
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
FOUNDATION_EXPORT NSNumber* QmsPluginMultiply(double a, double b); FOUNDATION_EXPORT NSNumber* QmsPluginMultiply(double a, double b);
FOUNDATION_EXPORT UIViewController* QmsPluginMakeViewController(void);
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
<dict> <dict>
<key>Headers/QmsPlugin.h</key> <key>Headers/QmsPlugin.h</key>
<data> <data>
T0w73SfaKmay5cfzE/KHplzhWis= 5nKoARTfB27hIPyN1aDnt2M2AlM=
</data> </data>
<key>Info.plist</key> <key>Info.plist</key>
<data> <data>
mHHohDKLbelgffJEne6sKFR+cnQ= JGviPenfphujtQEGyJZCIZTsd2c=
</data> </data>
</dict> </dict>
<key>files2</key> <key>files2</key>
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<dict> <dict>
<key>hash2</key> <key>hash2</key>
<data> <data>
U05V7l0WqfmXhNjNLDaPBAUgwRfBgPpUE5n7pvQshgg= YSvzim+1uTbTL+VKFNabNPhqRNP3ftgBHgFyhbD5cCM=
</data> </data>
</dict> </dict>
</dict> </dict>
......
...@@ -2,6 +2,7 @@ import { TurboModuleRegistry, type TurboModule } from 'react-native'; ...@@ -2,6 +2,7 @@ import { TurboModuleRegistry, type TurboModule } from 'react-native';
export interface Spec extends TurboModule { export interface Spec extends TurboModule {
multiply(a: number, b: number): number; multiply(a: number, b: number): number;
showPluginUI(): void;
} }
export default TurboModuleRegistry.getEnforcing<Spec>('QmsPlugin'); export default TurboModuleRegistry.getEnforcing<Spec>('QmsPlugin');
...@@ -3,3 +3,12 @@ import QmsPlugin from './NativeQmsPlugin'; ...@@ -3,3 +3,12 @@ import QmsPlugin from './NativeQmsPlugin';
export function multiply(a: number, b: number): number { export function multiply(a: number, b: number): number {
return QmsPlugin.multiply(a, b); return QmsPlugin.multiply(a, b);
} }
export function showPluginUI(): void {
QmsPlugin.showPluginUI();
}
export default {
multiply,
showPluginUI,
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment