lxy 1 year ago
parent
commit
f579060d4a

+ 3 - 0
LenzCameraNativeModuleForRN/Classes/headers/LenzCameraSDK.h

@@ -14,6 +14,9 @@ typedef void(^LenzCameraSDKComplete)(NSDictionary *dict);
 
 @interface LenzCameraSDK : NSObject
 
++ (void)showCameraSDKWithParams:(NSDictionary *)params
+                       complete:(LenzCameraSDKComplete)complete;
+
 + (void)showCameraSDKWithParams:(NSDictionary *)params
                       presentVC:(__kindof UIViewController *)presentVC
                        complete:(LenzCameraSDKComplete)complete;

+ 59 - 6
LenzCameraNativeModuleForRN/Classes/headers/LenzCameraSDK.m

@@ -10,15 +10,68 @@
 
 @implementation LenzCameraSDK
 
+
+
++ (void)showCameraSDKWithParams:(NSDictionary *)params
+                       complete:(LenzCameraSDKComplete)complete {
+
+    dispatch_async(dispatch_get_main_queue(), ^{
+        UIViewController *vc = [LenzCameraSDK topmostViewController];
+        if (vc) {
+            [LenzCameraSDK showCameraSDKWithParams:params presentVC:vc complete:complete];
+        }
+    });
+}
+
 + (void)showCameraSDKWithParams:(NSDictionary *)params
                       presentVC:(__kindof UIViewController *)presentVC
                        complete:(LenzCameraSDKComplete)complete {
-    PCSBaseViewController *vc = [PCSBaseViewController initWithParams:params complete:^(NSDictionary * _Nonnull dict) {
-        if (complete) {
-            complete(dict);
+    if ([NSThread isMainThread]) {
+        PCSBaseViewController *vc = [PCSBaseViewController initWithParams:params complete:^(NSDictionary * _Nonnull dict) {
+            if (complete) {
+                complete(dict);
+            }
+        }];
+        vc.modalPresentationStyle = UIModalPresentationFullScreen;
+        [presentVC presentViewController:vc animated:YES completion:nil];
+    } else {
+        dispatch_async(dispatch_get_main_queue(), ^{
+            PCSBaseViewController *vc = [PCSBaseViewController initWithParams:params complete:^(NSDictionary * _Nonnull dict) {
+                if (complete) {
+                    complete(dict);
+                }
+            }];
+            vc.modalPresentationStyle = UIModalPresentationFullScreen;
+            [presentVC presentViewController:vc animated:YES completion:nil];
+        });
+    }
+
+}
+
+
+
++ (UIViewController * __nullable)topmostViewController {
+    UIViewController *topViewController = [[[UIApplication sharedApplication] keyWindow] rootViewController];
+    
+    if (topViewController == nil) {
+        return nil;
+    }
+    
+    while (true) {
+        if (topViewController.presentedViewController != nil) {
+            topViewController = topViewController.presentedViewController;
+        } else if ([topViewController isKindOfClass:[UINavigationController class]]) {
+            UINavigationController *navi = (UINavigationController *)topViewController;
+            topViewController = navi.topViewController;
+        } else if ([topViewController isKindOfClass:[UITabBarController class]]) {
+            UITabBarController *tab = (UITabBarController *)topViewController;
+            topViewController = tab.selectedViewController;
+        } else {
+            break;
         }
-    }];
-    vc.modalPresentationStyle = UIModalPresentationFullScreen;
-    [presentVC presentViewController:vc animated:YES completion:nil];
+    }
+    
+    return topViewController;
 }
+
 @end

+ 1 - 1
LenzCameraNativeModuleForRN/Classes/inner/PCSBaseViewController/PCSBaseViewController.m

@@ -637,7 +637,7 @@
       @"continuous": @(SDK_CAPTURE_MODE_CONTINUOUS),
       @"single" : @(SDK_CAPTURE_MODE_SINGLE),
       @"video" : @(SDK_CAPTURE_MODE_MOVIE),
-      @"panorama" : @(SDK_CAPTURE_MODE_PANORAMA),
+      @"parnorama" : @(SDK_CAPTURE_MODE_PANORAMA),
       @"panoramaPlus" : @(SDK_CAPTURE_MODE_INTELLEGENCE_PANORAMA)
     };
     NSMutableArray<NSNumber*>* modeIndiciesTable = [NSMutableArray array];

+ 1 - 1
LenzSDK.podspec

@@ -8,7 +8,7 @@
 
 Pod::Spec.new do |s|
   s.name             = 'LenzSDK'
-  s.version          = '1.0.6'
+  s.version          = '1.0.7'
   s.summary          = 'A short description of LenzSDK.'
 
 # This description is used to generate tags and improve search results.