From e10b101d9f6b25a42d9f4ee3491ff54451527036 Mon Sep 17 00:00:00 2001
From: Jim <xujian1030@gmail.com>
Date: Wed, 18 Sep 2019 14:24:18 +0800
Subject: [PATCH] Add files via upload

---
 example/ios/Runner/PlatformRouterImp.h | 25 +++++++++++++
 example/ios/Runner/PlatformRouterImp.m | 52 ++++++++++++++++++++++++++
 2 files changed, 77 insertions(+)
 create mode 100644 example/ios/Runner/PlatformRouterImp.h
 create mode 100644 example/ios/Runner/PlatformRouterImp.m

diff --git a/example/ios/Runner/PlatformRouterImp.h b/example/ios/Runner/PlatformRouterImp.h
new file mode 100644
index 0000000..07157ed
--- /dev/null
+++ b/example/ios/Runner/PlatformRouterImp.h
@@ -0,0 +1,25 @@
+//
+//  DemoRouter.h
+//  Runner
+//
+//  Created by Jidong Chen on 2018/10/22.
+//  Copyright © 2018年 The Chromium Authors. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import <UIKit/UIKit.h>
+#import <flutter_boost/FlutterBoost.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@protocol FLBPlatform;
+
+/**
+ * 实现平台侧的页面打开和关闭,不建议直接使用用于页面打开,建议使用FlutterBoostPlugin中的open和close方法来打开或关闭页面;
+ * FlutterBoostPlugin带有页面返回数据的能力
+ */
+@interface PlatformRouterImp : NSObject<FLBPlatform>
+@property (nonatomic,strong) UINavigationController *navigationController;
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/example/ios/Runner/PlatformRouterImp.m b/example/ios/Runner/PlatformRouterImp.m
new file mode 100644
index 0000000..1491589
--- /dev/null
+++ b/example/ios/Runner/PlatformRouterImp.m
@@ -0,0 +1,52 @@
+//
+//  DemoRouter.m
+//  Runner
+//
+//  Created by Jidong Chen on 2018/10/22.
+//  Copyright © 2018年 The Chromium Authors. All rights reserved.
+//
+
+#import "PlatformRouterImp.h"
+#import <flutter_boost/FlutterBoost.h>
+
+@interface PlatformRouterImp()
+@end
+
+@implementation PlatformRouterImp
+
+#pragma mark - Boost 1.5
+- (void)open:(NSString *)name
+   urlParams:(NSDictionary *)params
+        exts:(NSDictionary *)exts
+  completion:(void (^)(BOOL))completion
+{
+    BOOL animated = [exts[@"animated"] boolValue];
+    if([params[@"present"] boolValue]){
+        FLBFlutterViewContainer *vc = FLBFlutterViewContainer.new;
+        [vc setName:name params:params];
+        [self.navigationController presentViewController:vc animated:animated completion:^{
+            if(completion) completion(YES);
+        }];
+    }else{
+        FLBFlutterViewContainer *vc = FLBFlutterViewContainer.new;
+        [vc setName:name params:params];
+        [self.navigationController pushViewController:vc animated:animated];
+        if(completion) completion(YES);
+    }
+}
+
+- (void)close:(NSString *)uid
+       result:(NSDictionary *)result
+         exts:(NSDictionary *)exts
+   completion:(void (^)(BOOL))completion
+{
+    BOOL animated = [exts[@"animated"] boolValue];
+    animated = YES;
+    FLBFlutterViewContainer *vc = (id)self.navigationController.presentedViewController;
+    if([vc isKindOfClass:FLBFlutterViewContainer.class] && [vc.uniqueIDString isEqual: uid]){
+        [vc dismissViewControllerAnimated:animated completion:^{}];
+    }else{
+        [self.navigationController popViewControllerAnimated:animated];
+    }
+}
+@end
-- 
2.26.2