From 50e7acc70bff8481c9e28c7835dbc36793420f68 Mon Sep 17 00:00:00 2001 From: Jidong Chen <jidongchen93@gmail.com> Date: Fri, 28 Jun 2019 16:34:47 +0800 Subject: [PATCH] refactory to support co-existing of flutter_boost and flutter_boost2 --- ios/Classes/1.0/FLBFlutterApplication.h | 36 -- ios/Classes/1.0/FLBFlutterApplication.m | 180 -------- ios/Classes/1.0/FLBFlutterEngineOld.h | 37 -- ios/Classes/1.0/FLBFlutterEngineOld.m | 99 ----- ios/Classes/1.0/FLBFlutterProvider.h | 44 -- ios/Classes/1.0/FLBFlutterViewContainer.h | 35 -- ios/Classes/1.0/FLBFlutterViewContainer.m | 394 ------------------ .../1.0/FLBFlutterViewControllerAdaptor.h | 38 -- .../1.0/FLBFlutterViewControllerAdaptor.m | 99 ----- ios/Classes/1.0/FLBFlutterViewProvider.h | 43 -- ios/Classes/1.0/FLBViewProviderFactory.h | 39 -- ios/Classes/1.0/FLBViewProviderFactory.m | 42 -- ios/Classes/1.0/FlutterBoostConfig.h | 40 -- ios/Classes/1.0/FlutterBoostConfig.m | 59 --- ios/Classes/1.0/Support/Cache/FLBStackCache.h | 72 ---- ios/Classes/1.0/Support/Cache/FLBStackCache.m | 210 ---------- .../Support/Cache/FLBStackCacheObjectImg.h | 37 -- .../Support/Cache/FLBStackCacheObjectImg.m | 116 ------ .../1.0/Support/Memory/FLBMemoryInspector.h | 47 --- .../1.0/Support/Memory/FLBMemoryInspector.mm | 157 ------- ios/Classes/1.5/FLB2FlutterApplication.h | 1 - ios/Classes/1.5/FLB2FlutterApplication.m | 11 +- ios/Classes/1.5/FLB2FlutterViewContainer.m | 14 +- .../FLBFactory.h => Boost/BoostChannel.h} | 7 +- .../FLBFactory.m => Boost/BoostChannel.m} | 23 +- ...AppDelegate.h => FLB2FlutterAppDelegate.h} | 2 +- ...AppDelegate.m => FLB2FlutterAppDelegate.m} | 8 +- ...anager.h => FLB2FlutterContainerManager.h} | 2 +- ...anager.m => FLB2FlutterContainerManager.m} | 6 +- ios/Classes/Boost/FLB2FlutterProvider.h | 6 +- ios/Classes/Boost/FLB2Platform.h | 6 +- .../Boost/FLBFlutterApplicationInterface.h | 2 +- ios/Classes/Boost/FLBFlutterContainer.h | 2 - ios/Classes/Boost/FLBPlatform.h | 41 -- ios/Classes/Boost/FLBTypes.h | 2 +- .../Boost/{FlutterBoost.h => FlutterBoost2.h} | 8 +- ...terBoostPlugin.h => FlutterBoostPlugin2.h} | 2 +- ...terBoostPlugin.m => FlutterBoostPlugin2.m} | 28 +- ...rivate.h => FlutterBoostPlugin2_private.h} | 4 +- ios/Classes/Messaging/BoostMessageChannel.mm | 8 +- ios/flutter_boost2.podspec | 32 ++ 41 files changed, 90 insertions(+), 1949 deletions(-) delete mode 100755 ios/Classes/1.0/FLBFlutterApplication.h delete mode 100755 ios/Classes/1.0/FLBFlutterApplication.m delete mode 100755 ios/Classes/1.0/FLBFlutterEngineOld.h delete mode 100755 ios/Classes/1.0/FLBFlutterEngineOld.m delete mode 100755 ios/Classes/1.0/FLBFlutterProvider.h delete mode 100755 ios/Classes/1.0/FLBFlutterViewContainer.h delete mode 100755 ios/Classes/1.0/FLBFlutterViewContainer.m delete mode 100755 ios/Classes/1.0/FLBFlutterViewControllerAdaptor.h delete mode 100755 ios/Classes/1.0/FLBFlutterViewControllerAdaptor.m delete mode 100755 ios/Classes/1.0/FLBFlutterViewProvider.h delete mode 100755 ios/Classes/1.0/FLBViewProviderFactory.h delete mode 100755 ios/Classes/1.0/FLBViewProviderFactory.m delete mode 100755 ios/Classes/1.0/FlutterBoostConfig.h delete mode 100755 ios/Classes/1.0/FlutterBoostConfig.m delete mode 100755 ios/Classes/1.0/Support/Cache/FLBStackCache.h delete mode 100755 ios/Classes/1.0/Support/Cache/FLBStackCache.m delete mode 100755 ios/Classes/1.0/Support/Cache/FLBStackCacheObjectImg.h delete mode 100755 ios/Classes/1.0/Support/Cache/FLBStackCacheObjectImg.m delete mode 100755 ios/Classes/1.0/Support/Memory/FLBMemoryInspector.h delete mode 100755 ios/Classes/1.0/Support/Memory/FLBMemoryInspector.mm rename ios/Classes/{1.0/FLBFactory.h => Boost/BoostChannel.h} (93%) rename ios/Classes/{1.0/FLBFactory.m => Boost/BoostChannel.m} (75%) rename ios/Classes/Boost/{FLBFlutterAppDelegate.h => FLB2FlutterAppDelegate.h} (96%) rename ios/Classes/Boost/{FLBFlutterAppDelegate.m => FLB2FlutterAppDelegate.m} (87%) rename ios/Classes/Boost/{FLBFlutterContainerManager.h => FLB2FlutterContainerManager.h} (96%) rename ios/Classes/Boost/{FLBFlutterContainerManager.m => FLB2FlutterContainerManager.m} (94%) delete mode 100755 ios/Classes/Boost/FLBPlatform.h rename ios/Classes/Boost/{FlutterBoost.h => FlutterBoost2.h} (89%) rename ios/Classes/Boost/{FlutterBoostPlugin.h => FlutterBoostPlugin2.h} (97%) rename ios/Classes/Boost/{FlutterBoostPlugin.m => FlutterBoostPlugin2.m} (86%) rename ios/Classes/Boost/{FlutterBoostPlugin_private.h => FlutterBoostPlugin2_private.h} (96%) create mode 100755 ios/flutter_boost2.podspec diff --git a/ios/Classes/1.0/FLBFlutterApplication.h b/ios/Classes/1.0/FLBFlutterApplication.h deleted file mode 100755 index 0c42552..0000000 --- a/ios/Classes/1.0/FLBFlutterApplication.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import <Foundation/Foundation.h> - - -#import "FLBFlutterApplicationInterface.h" - -NS_ASSUME_NONNULL_BEGIN -@interface FLBFlutterApplication : NSObject<FLBFlutterApplicationInterface> -@property (nonatomic,strong) id<FLB2Platform> platform; - -@end - -NS_ASSUME_NONNULL_END diff --git a/ios/Classes/1.0/FLBFlutterApplication.m b/ios/Classes/1.0/FLBFlutterApplication.m deleted file mode 100755 index 0d309f1..0000000 --- a/ios/Classes/1.0/FLBFlutterApplication.m +++ /dev/null @@ -1,180 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import "FLBFlutterApplication.h" -#import "FlutterBoost.h" -#import "FLBFlutterContainerManager.h" -#import "FLBViewProviderFactory.h" - -@interface FLBFlutterApplication() -@property (nonatomic,strong) FLBFlutterContainerManager *manager; -@property (nonatomic,strong) id<FLBFlutterViewProvider> viewProvider; - -@property (nonatomic,assign) BOOL isRendering; -@property (nonatomic,assign) BOOL isRunning; -@end - - -@implementation FLBFlutterApplication - -- (BOOL)isRunning -{ - return _isRunning; -} - -- (void)startFlutterWithPlatform:(id<FLB2Platform>)platform onStart:(void (^)(id<FlutterBinaryMessenger,FlutterTextureRegistry,FlutterPluginRegistry> _Nonnull))callback -{ - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - self.platform = platform; - self.viewProvider = [[FLBViewProviderFactory new] createViewProviderWithPlatform:platform]; - [self.viewProvider resume]; - self.isRendering = YES; - self.isRunning = YES; - if(callback) callback(self.viewProvider.viewController); - }); -} - -- (instancetype)init -{ - if (self = [super init]) { - _manager = [FLBFlutterContainerManager new]; - } - return self; -} - -- (void)dealloc -{ - [[NSNotificationCenter defaultCenter] removeObserver:self]; -} - -- (UIView *)flutterView -{ - return [self flutterViewController].view; -} - -- (FlutterViewController *)flutterViewController -{ - return self.viewProvider.viewController; -} - - -- (BOOL)contains:(id<FLBFlutterContainer>)vc -{ - return [_manager contains:vc]; -} - -- (void)addUniqueViewController:(id<FLBFlutterContainer>)vc -{ - return [_manager addUnique:vc]; -} - -- (void)removeViewController:(id<FLBFlutterContainer>)vc -{ - return [_manager remove:vc]; -} - - -- (BOOL)isTop:(NSString *)pageId -{ - return [_manager.peak isEqual:pageId]; -} - -- (void)pause -{ - if(!_isRendering) return; - - [self.viewProvider pause]; - - _isRendering = NO; - -} - -- (void)resume -{ - if(_isRendering) return; - - [self.viewProvider resume]; - - _isRendering = YES; - -} - -- (void)inactive -{ - [self.viewProvider inactive]; -} - -- (id<FLB2FlutterProvider>)flutterProvider -{ - return (id)_viewProvider; -} - -- (void)close:(NSString *)uid - result:(NSDictionary *)result - exts:(NSDictionary *)exts - completion:(void (^)(BOOL))completion -{ - BOOL animated = YES; - if([exts[@"animated"] boolValue]){ - animated = [exts[@"animated"] boolValue]; - } - [self.platform closePage:uid - animated:animated - params:exts[@"params"] - completion:completion]; -} - -- (void)open:(NSString *)url - urlParams:(NSDictionary *)urlParams - exts:(NSDictionary *)exts - reult:(void (^)(NSDictionary *))resultCallback - completion:(void (^)(BOOL))completion -{ - - BOOL animated = YES; - if([exts[@"animated"] boolValue]){ - animated = [exts[@"animated"] boolValue]; - } - [self.platform openPage:url - params:urlParams - animated:animated - completion:completion]; -} - -- (void)didInitPageContainer:(NSString *)url - params:(NSDictionary *)urlParams - uniqueId:(NSString *)uniqueId -{ - -} - -- (void)willDeallocPageContainer:(NSString *)url - params:(NSDictionary *)params - uniqueId:(NSString *)uniqueId -{ - -} - -@end diff --git a/ios/Classes/1.0/FLBFlutterEngineOld.h b/ios/Classes/1.0/FLBFlutterEngineOld.h deleted file mode 100755 index b2e8315..0000000 --- a/ios/Classes/1.0/FLBFlutterEngineOld.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import <Foundation/Foundation.h> -#import "FLBFlutterViewProvider.h" -#import "FLBPlatform.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface FLBFlutterEngineOld : NSObject<FLBFlutterViewProvider> - -- (instancetype)initWithPlatform:(id<FLBPlatform>)platform; - -@end - -NS_ASSUME_NONNULL_END diff --git a/ios/Classes/1.0/FLBFlutterEngineOld.m b/ios/Classes/1.0/FLBFlutterEngineOld.m deleted file mode 100755 index 48fc6a7..0000000 --- a/ios/Classes/1.0/FLBFlutterEngineOld.m +++ /dev/null @@ -1,99 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import "FLBFlutterEngineOld.h" -#import "FLBFlutterViewControllerAdaptor.h" -#import <objc/runtime.h> - -@interface FLBFlutterEngineOld() -@property (nonatomic,strong) FLBFlutterViewControllerAdaptor *viewController; -@end - -@implementation FLBFlutterEngineOld - -- (instancetype)initWithPlatform:(id<FLBPlatform>)platform -{ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Warc-performSelector-leaks" - - if (self = [super init]) { - - Class class = [FLBFlutterViewControllerAdaptor class]; - SEL originalSelector = @selector(onAccessibilityStatusChanged:); - SEL swizzledSelector = @selector(fixed_onAccessibilityStatusChanged:); - Method originalMethod = class_getInstanceMethod(class, originalSelector); - Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); - method_exchangeImplementations(originalMethod, swizzledMethod); - - _viewController = [FLBFlutterViewControllerAdaptor new]; - - [_viewController view]; - Class clazz = NSClassFromString(@"GeneratedPluginRegistrant"); - if (clazz) { - if ([clazz respondsToSelector:NSSelectorFromString(@"registerWithRegistry:")]) { - [clazz performSelector:NSSelectorFromString(@"registerWithRegistry:") - withObject:_viewController]; - } - } - } - - return self; -#pragma clang diagnostic pop -} - -- (FlutterViewController *)viewController -{ - return _viewController; -} - -- (void)pause -{ - [self.viewController boost_viewWillDisappear:NO]; - [self.viewController boost_viewDidDisappear:NO]; -} - -- (void)resume -{ - [self.viewController boost_viewWillAppear:NO]; - [self.viewController boost_viewDidAppear:NO]; -} - -- (void)inactive -{ - NSString *channel = @"flutter/lifecycle"; - NSString *message = @"AppLifecycleState.inactive"; - NSData *data = [[FlutterStringCodec sharedInstance] encode:message]; - [self.viewController sendOnChannel:channel message:data]; -} - -- (void)resumeFlutterOnly -{ - NSString *channel = @"flutter/lifecycle"; - NSString *message = @"AppLifecycleState.resumed"; - NSData *data = [[FlutterStringCodec sharedInstance] encode:message]; - [self.viewController sendOnChannel:channel message:data]; -} - - -@end diff --git a/ios/Classes/1.0/FLBFlutterProvider.h b/ios/Classes/1.0/FLBFlutterProvider.h deleted file mode 100755 index cc96e78..0000000 --- a/ios/Classes/1.0/FLBFlutterProvider.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import <Foundation/Foundation.h> - -@class FlutterViewController; - -NS_ASSUME_NONNULL_BEGIN - -#define RELEASE_1_0 0 - -@protocol FLBFlutterViewProvider <NSObject> - -@required - -- (FlutterViewController *)viewController; -- (void)pause; -- (void)resume; -- (void)inactive; - -@end - -NS_ASSUME_NONNULL_END diff --git a/ios/Classes/1.0/FLBFlutterViewContainer.h b/ios/Classes/1.0/FLBFlutterViewContainer.h deleted file mode 100755 index 2791f2c..0000000 --- a/ios/Classes/1.0/FLBFlutterViewContainer.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import <UIKit/UIKit.h> - -#import "FLBFlutterContainer.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface FLBFlutterViewContainer : UIViewController<FLBFlutterContainer> - -@end - -NS_ASSUME_NONNULL_END diff --git a/ios/Classes/1.0/FLBFlutterViewContainer.m b/ios/Classes/1.0/FLBFlutterViewContainer.m deleted file mode 100755 index b05379f..0000000 --- a/ios/Classes/1.0/FLBFlutterViewContainer.m +++ /dev/null @@ -1,394 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import "FLBFlutterViewContainer.h" -#import "FLBFlutterApplication.h" -#import "FLBStackCache.h" -#import "FLBStackCacheObjectImg.h" -#import "FLBMemoryInspector.h" -#import "BoostMessageChannel.h" -#import "FlutterBoostConfig.h" -#import "FlutterBoostPlugin_private.h" - -#define FLUTTER_APP [FlutterBoostPlugin sharedInstance].application -#define FLUTTER_VIEW FLUTTER_APP.flutterViewController.view -#define FLUTTER_VC FLUTTER_APP.flutterViewController - -@interface FLBFlutterViewContainer () -@property (nonatomic,copy,readwrite) NSString *name; -@property (nonatomic,strong,readwrite) NSDictionary *params; -@property (nonatomic,strong) UIImageView *screenShotView; -@property (nonatomic,assign) long long identifier; -@property (nonatomic,assign) BOOL interactiveGestureActive; -@end - -@implementation FLBFlutterViewContainer - -- (void)setName:(NSString *)name params:(NSDictionary *)params -{ - if(!_name && name){ - _name = name; - _params = params; - [BoostMessageChannel didInitPageContainer:^(NSNumber *r) {} - pageName:name - params:params - uniqueId:[self uniqueIDString]]; - } -} - - -static NSUInteger kInstanceCounter = 0; - -+ (NSUInteger)instanceCounter -{ - return kInstanceCounter; -} - -+ (void)instanceCounterIncrease -{ - kInstanceCounter++; - if(kInstanceCounter == 1){ - [FLUTTER_APP resume]; - } -} - -+ (void)instanceCounterDecrease -{ - kInstanceCounter--; - if([self.class instanceCounter] == 0){ - [[FLBStackCache sharedInstance] clear]; - [FLUTTER_APP pause]; - } -} - -- (NSString *)uniqueIDString -{ - return @(_identifier).stringValue; -} - -- (void)_setup -{ - static long long sCounter = 0; - _identifier = sCounter++; - [self.class instanceCounterIncrease]; - - SEL sel = @selector(flutterViewDidShow:); - NSString *notiName = @"flutter_boost_container_showed"; - [NSNotificationCenter.defaultCenter addObserver:self - selector:sel - name:notiName - object:nil]; -} - -- (instancetype)init -{ - if(self = [super init]){ - [self _setup]; - } - return self; -} - -- (instancetype)initWithCoder:(NSCoder *)aDecoder{ - if (self = [super initWithCoder: aDecoder]) { - [self _setup]; - } - return self; -} - -- (void)flutterViewDidAppear:(NSDictionary *)params -{ - //Notify flutter view appeared. -} - -- (void)flutterViewDidShow:(NSNotification *)notification -{ - __weak typeof(self) weakSelf = self; - if([notification.object isEqual: self.uniqueIDString]){ - dispatch_async(dispatch_get_main_queue(), ^{ - [weakSelf showFlutterView]; - }); - } -} - -- (void)dealloc -{ - [self notifyWillDealloc]; - [NSNotificationCenter.defaultCenter removeObserver:self]; -} - -- (void)notifyWillDealloc -{ - [BoostMessageChannel willDeallocPageContainer:^(NSNumber *r) {} - pageName:_name params:_params - uniqueId:[self uniqueIDString]]; - - [[FLBStackCache sharedInstance] remove:self.uniqueIDString]; - [FLUTTER_APP removeViewController:self]; - - [self.class instanceCounterDecrease]; -} - -- (void)viewDidLoad { - [super viewDidLoad]; - - self.view.backgroundColor = UIColor.whiteColor; - - self.screenShotView = [[UIImageView alloc] initWithFrame:self.view.bounds]; - self.screenShotView.backgroundColor = [UIColor whiteColor]; - - [self.view addSubview:self.screenShotView]; -} - -#pragma mark - ScreenShots -- (UIImage *)takeScreenShot -{ - CGFloat scale = 1; - switch ([FLBMemoryInspector.sharedInstance currentCondition]) { - case FLBMemoryConditionNormal: - scale = 2; - break; - case FLBMemoryConditionLowMemory: - scale = 1; - break; - case FLBMemoryConditionExtremelyLow: - scale = 0.75; - break; - case FLBMemoryConditionAboutToDie: - return [UIImage new]; - break; - case FLBMemoryConditionUnknown: - if([[FLBMemoryInspector sharedInstance] smallMemoryDevice]){ - scale = 1; - }else{ - scale = 2; - } - break; - } - - self.screenShotView.opaque = YES; - - CGRect flutterBounds = self.view.bounds; - CGSize snapshotSize = CGSizeMake(flutterBounds.size.width , - flutterBounds.size.height); - UIGraphicsBeginImageContextWithOptions(snapshotSize, NO, scale); - - [self.view drawViewHierarchyInRect:flutterBounds - afterScreenUpdates:NO]; - - UIImage *snapImage = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - - return snapImage; -} - -- (void)saveScreenShot -{ - UIImage *snapImage = [self takeScreenShot]; - if(snapImage){ - FLBStackCacheObjectImg *cImg = [[FLBStackCacheObjectImg alloc] initWithImage:snapImage]; - [[FLBStackCache sharedInstance] pushObject:cImg key:self.uniqueIDString]; - } -} - -- (void)clearCurrentScreenShotImage -{ - self.screenShotView.image = nil; -} - -- (UIImage *)getSavedScreenShot -{ - FLBStackCacheObjectImg *cImg = [[FLBStackCache sharedInstance] objectForKey:self.uniqueIDString]; - return [cImg image]; -} - -- (BOOL)isFlutterViewAttatched -{ - return FLUTTER_VIEW.superview == self.view; -} - -- (void)attatchFlutterView -{ - if([self isFlutterViewAttatched]) return; - - [FLUTTER_VC willMoveToParentViewController:nil]; - [FLUTTER_VC removeFromParentViewController]; - [FLUTTER_VC didMoveToParentViewController:nil]; - - [FLUTTER_VC willMoveToParentViewController:self]; - FLUTTER_VIEW.frame = self.view.bounds; - - if(!self.screenShotView.image){ - [self.view addSubview: FLUTTER_VIEW]; - }else{ - [self.view insertSubview:FLUTTER_VIEW belowSubview:self.screenShotView]; - } - - [self addChildViewController:FLUTTER_VC]; - [FLUTTER_VC didMoveToParentViewController:self]; -} - -- (BOOL)showSnapShotVew -{ - self.screenShotView.image = [self getSavedScreenShot]; - - if([self isFlutterViewAttatched]){ - NSUInteger fIdx = [self.view.subviews indexOfObject:FLUTTER_VIEW]; - NSUInteger sIdx = [self.view.subviews indexOfObject:self.screenShotView]; - if(fIdx > sIdx){ - [self.view insertSubview:FLUTTER_VIEW - atIndex:0]; - } - }else{ - - } - - return self.screenShotView.image != nil; -} - -- (void)showFlutterView -{ - if(FLUTTER_VIEW.superview != self.view) return; - - if([self isFlutterViewAttatched] ){ - NSUInteger fIdx = [self.view.subviews indexOfObject:FLUTTER_VIEW]; - NSUInteger sIdx = [self.view.subviews indexOfObject:self.screenShotView]; - self.screenShotView.backgroundColor = UIColor.clearColor; - if(sIdx > fIdx){ - [self.view insertSubview:self.screenShotView belowSubview:FLUTTER_VIEW]; - [self flutterViewDidAppear:@{@"uid":self.uniqueIDString?:@""}]; - } - } - - [self clearCurrentScreenShotImage]; - - //Invalidate obsolete screenshot. - [FLBStackCache.sharedInstance invalidate:self.uniqueIDString]; -} - -#pragma mark - Life circle methods - -- (void)viewDidLayoutSubviews -{ - [super viewDidLayoutSubviews]; - [FLUTTER_APP resume]; -} - -- (void)viewWillAppear:(BOOL)animated -{ - if(self.navigationController.interactivePopGestureRecognizer.state == UIGestureRecognizerStateBegan){ - self.interactiveGestureActive = true; - } - - [FLUTTER_APP resume]; - //For new page we should attach flutter view in view will appear - //for better performance. - if(![FLUTTER_APP contains:self]){ - [self attatchFlutterView]; - } - - [self showSnapShotVew]; - - [BoostMessageChannel willShowPageContainer:^(NSNumber *result) {} - pageName:_name - params:_params - uniqueId:self.uniqueIDString]; - //Save some first time page info. - if(![FlutterBoostPlugin sharedInstance].fPagename){ - [FlutterBoostPlugin sharedInstance].fPagename = _name; - [FlutterBoostPlugin sharedInstance].fPageId = self.uniqueIDString; - [FlutterBoostPlugin sharedInstance].fParams = _params; - } - - [super viewWillAppear:animated]; -} - -- (void)viewDidAppear:(BOOL)animated -{ - [FLUTTER_APP resume]; - - //Ensure flutter view is attached. - [self attatchFlutterView]; - - [BoostMessageChannel didShowPageContainer:^(NSNumber *result) {} - pageName:_name - params:_params - uniqueId:self.uniqueIDString]; - - [FLUTTER_APP addUniqueViewController:self]; - - [super viewDidAppear:animated]; - - __weak typeof(self) weakSelf = self; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, - (int64_t)(2 * NSEC_PER_SEC)), - dispatch_get_main_queue(),^{ - if (weakSelf.isViewLoaded && weakSelf.view.window) { - // viewController is visible - [weakSelf showFlutterView]; - } - }); - - self.interactiveGestureActive = NO; -} - -- (void)viewWillDisappear:(BOOL)animated -{ - //is top. - if([FLUTTER_APP isTop:self.uniqueIDString] - && self.navigationController.interactivePopGestureRecognizer.state != UIGestureRecognizerStateBegan - && !self.interactiveGestureActive){ - [self saveScreenShot]; - } - - self.interactiveGestureActive = NO; - - self.screenShotView.image = [self getSavedScreenShot]; - if(self.screenShotView.image){ - [self.view bringSubviewToFront:self.screenShotView]; - } - - [BoostMessageChannel willDisappearPageContainer:^(NSNumber *result) {} - pageName:_name - params:_params - uniqueId:self.uniqueIDString]; - [super viewWillDisappear:animated]; -} - - -- (void)viewDidDisappear:(BOOL)animated -{ - [BoostMessageChannel didDisappearPageContainer:^(NSNumber *result) {} - pageName:_name - params:_params - uniqueId:self.uniqueIDString]; - - [self clearCurrentScreenShotImage]; - [super viewDidDisappear:animated]; - - [FLUTTER_APP inactive]; - self.interactiveGestureActive = NO; -} - - -@end diff --git a/ios/Classes/1.0/FLBFlutterViewControllerAdaptor.h b/ios/Classes/1.0/FLBFlutterViewControllerAdaptor.h deleted file mode 100755 index c1eb515..0000000 --- a/ios/Classes/1.0/FLBFlutterViewControllerAdaptor.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import <Flutter/Flutter.h> - -NS_ASSUME_NONNULL_BEGIN - -@interface FLBFlutterViewControllerAdaptor : FlutterViewController -- (void)boost_viewWillAppear:(BOOL)animated; -- (void)boost_viewDidAppear:(BOOL)animated; -- (void)boost_viewWillDisappear:(BOOL)animated; -- (void)boost_viewDidDisappear:(BOOL)animated; - - -@end - -NS_ASSUME_NONNULL_END diff --git a/ios/Classes/1.0/FLBFlutterViewControllerAdaptor.m b/ios/Classes/1.0/FLBFlutterViewControllerAdaptor.m deleted file mode 100755 index 6faa1ab..0000000 --- a/ios/Classes/1.0/FLBFlutterViewControllerAdaptor.m +++ /dev/null @@ -1,99 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import "FLBFlutterViewControllerAdaptor.h" -#import <objc/runtime.h> - -@interface FLBFlutterViewControllerAdaptor () -@end - -@implementation FLBFlutterViewControllerAdaptor - -- (void)viewDidLoad { - [super viewDidLoad]; - self.view.backgroundColor = [UIColor whiteColor]; - // Do any additional setup after loading the view. -} - - -- (void)viewWillAppear:(BOOL)animated -{ - //Left blank intentionally. -} - -- (void)viewDidAppear:(BOOL)animated -{ - //Left blank intentionally. -} - -- (void)viewWillDisappear:(BOOL)animated -{ - [[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil]; - //Avoid super call intentionally. -} - -- (void)viewDidDisappear:(BOOL)animated -{ - //Avoid super call intentionally. - [[[UIApplication sharedApplication] keyWindow] endEditing:YES]; -} - - -- (void)boost_viewWillAppear:(BOOL)animated -{ - [super viewWillAppear:animated]; -} - -- (void)boost_viewDidAppear:(BOOL)animated -{ - [super viewDidAppear:animated]; -} - -- (void)boost_viewWillDisappear:(BOOL)animated -{ - [super viewWillDisappear:animated]; -} - -- (void)boost_viewDidDisappear:(BOOL)animated -{ - [super viewDidDisappear:animated]; -} - - -- (UIEdgeInsets)paddingEdgeInsets{ - UIEdgeInsets edgeInsets = UIEdgeInsetsZero; - if (@available(iOS 11, *)) { - edgeInsets = UIEdgeInsetsMake(0, self.view.safeAreaInsets.left, self.view.safeAreaInsets.bottom, self.view.safeAreaInsets.right); - } else { - edgeInsets = UIEdgeInsetsZero; - } - return edgeInsets; -} - -- (void)installSplashScreenViewIfNecessary { - //Override this to avoid unnecessary splash Screen. -} - - -@end diff --git a/ios/Classes/1.0/FLBFlutterViewProvider.h b/ios/Classes/1.0/FLBFlutterViewProvider.h deleted file mode 100755 index 4b7fca3..0000000 --- a/ios/Classes/1.0/FLBFlutterViewProvider.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import <Foundation/Foundation.h> - -@class FlutterViewController; - -NS_ASSUME_NONNULL_BEGIN - -#define RELEASE_1_0 0 - -@protocol FLBFlutterViewProvider <NSObject> - -@required -- (FlutterViewController *)viewController; -- (void)pause; -- (void)resume; -- (void)inactive; - -@end - -NS_ASSUME_NONNULL_END diff --git a/ios/Classes/1.0/FLBViewProviderFactory.h b/ios/Classes/1.0/FLBViewProviderFactory.h deleted file mode 100755 index b09c6c2..0000000 --- a/ios/Classes/1.0/FLBViewProviderFactory.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import <Foundation/Foundation.h> - -#import "FLBFlutterViewProvider.h" -#import "FLBPlatform.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface FLBViewProviderFactory : NSObject - -- (id<FLBFlutterViewProvider>)createViewProvider; -- (id<FLBFlutterViewProvider>)createViewProviderWithPlatform:(id<FLBPlatform>)platform; - -@end - -NS_ASSUME_NONNULL_END diff --git a/ios/Classes/1.0/FLBViewProviderFactory.m b/ios/Classes/1.0/FLBViewProviderFactory.m deleted file mode 100755 index 4da15eb..0000000 --- a/ios/Classes/1.0/FLBViewProviderFactory.m +++ /dev/null @@ -1,42 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import "FLBViewProviderFactory.h" -#import "FLBFlutterEngineOld.h" -#import "FLBPlatform.h" - - -@implementation FLBViewProviderFactory - -- (id<FLBFlutterViewProvider>)createViewProviderWithPlatform:(id<FLBPlatform>)platform -{ - return [[FLBFlutterEngineOld alloc] initWithPlatform:platform]; -} - -- (id<FLBFlutterViewProvider>)createViewProvider -{ - return [FLBFlutterEngineOld new]; -} - -@end diff --git a/ios/Classes/1.0/FlutterBoostConfig.h b/ios/Classes/1.0/FlutterBoostConfig.h deleted file mode 100755 index 565308a..0000000 --- a/ios/Classes/1.0/FlutterBoostConfig.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -NS_ASSUME_NONNULL_BEGIN - -@interface FlutterBoostConfig : NSObject -#pragma mark - Store first open page -//There are some cases first page messages could be lost. -//So we store the first page info for later usage. -+ (instancetype)sharedInstance; -@property (nonatomic,copy) NSString *fPagename; -@property (nonatomic,copy) NSString *fPageId; -@property (nonatomic,strong) NSDictionary *fParams; -- (BOOL)firstView; -@end - - - -NS_ASSUME_NONNULL_END diff --git a/ios/Classes/1.0/FlutterBoostConfig.m b/ios/Classes/1.0/FlutterBoostConfig.m deleted file mode 100755 index 00b853b..0000000 --- a/ios/Classes/1.0/FlutterBoostConfig.m +++ /dev/null @@ -1,59 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import "FlutterBoostConfig.h" - -@interface FlutterBoostConfig() -@property (nonatomic,assign) BOOL firstView; - -@end - -@implementation FlutterBoostConfig - -+ (instancetype)sharedInstance -{ - static FlutterBoostConfig *instance = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - instance = [self new]; - instance.firstView = YES; - }); - - return instance; -} - -- (void)setFPageId:(NSString *)fPageId -{ - _fPageId = fPageId; - _firstView = NO; -} - -- (BOOL)firstView -{ - return _firstView; -} - -@end - - diff --git a/ios/Classes/1.0/Support/Cache/FLBStackCache.h b/ios/Classes/1.0/Support/Cache/FLBStackCache.h deleted file mode 100755 index 75c067c..0000000 --- a/ios/Classes/1.0/Support/Cache/FLBStackCache.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import <Foundation/Foundation.h> - -@class FLBStackCache; - -@protocol FLBStackCacheObject<NSObject> - -@required -@property (nonatomic,copy) NSString *key; - -- (BOOL)writeToFileWithKey:(NSString *)key - queue:(dispatch_queue_t)queue - cache:(FLBStackCache *)cache - completion:(void (^)(NSError *err,NSString *path))completion; - -+ (BOOL)loadFromFileWithKey:(NSString *)key - queue:(dispatch_queue_t)queue - cache:(FLBStackCache *)cache - completion:(void (^)(NSError *err ,id<FLBStackCacheObject>))completion; - -- (BOOL)removeCachedFileWithKey:(NSString *)key - queue:(dispatch_queue_t)queue - cache:(FLBStackCache *)cache - completion:(void (^)(NSError *, NSString *))completion; - - -@end - - -@interface FLBStackCache : NSObject -+ (instancetype)sharedInstance; - -/** - * Num of objects allowed in memory. - * Default value is set to 2. - */ -@property (nonatomic,assign) NSUInteger inMemoryCount; - -#pragma mark - basic operations. -- (void)pushObject:(id<FLBStackCacheObject>)obj key:(NSString *)key; -- (id<FLBStackCacheObject>)remove:(NSString *)key; -- (void)invalidate:(NSString *)key; -- (BOOL)empty; -- (void)clear; -- (id<FLBStackCacheObject>)objectForKey:(NSString *)key; - -#pragma mark - Disk thing. -- (NSString *)cacheDir; -@end diff --git a/ios/Classes/1.0/Support/Cache/FLBStackCache.m b/ios/Classes/1.0/Support/Cache/FLBStackCache.m deleted file mode 100755 index 3a153d5..0000000 --- a/ios/Classes/1.0/Support/Cache/FLBStackCache.m +++ /dev/null @@ -1,210 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import "FLBStackCache.h" - -@interface FLBStackCache() - -@property (nonatomic,strong) NSMutableArray *keyStack; -@property (nonatomic,strong) NSMutableDictionary *typesMap; -@property (nonatomic,strong) NSMutableDictionary *inMemoryObjectsMap; -@property (nonatomic,strong) NSMutableDictionary *loadinMap; -@property (nonatomic,strong) dispatch_queue_t queueIO; -@end - -@implementation FLBStackCache - -+ (instancetype)sharedInstance -{ - static id sInstance = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - sInstance = [self.class new]; - }); - - return sInstance; -} - -- (BOOL)empty -{ - return _keyStack.count<=0; -} - -- (void)clear -{ - [self.keyStack removeAllObjects]; - [self.inMemoryObjectsMap removeAllObjects]; - [self.typesMap removeAllObjects]; - NSError *err = nil; - [[NSFileManager defaultManager] removeItemAtPath:self.cacheDir error:&err]; - if (err) { - NSLog(@"fail to remove cache dir %@",err); - } -} - - -- (instancetype)init -{ - if (self = [super init]) { - _keyStack = [NSMutableArray new]; - _inMemoryObjectsMap = [NSMutableDictionary new]; - _loadinMap = [NSMutableDictionary new]; - _typesMap = [NSMutableDictionary new]; - _queueIO = dispatch_queue_create("Stack cache working queue", NULL); - } - _inMemoryCount = 2; - return self; -} - - - (void)pushObject:(id<FLBStackCacheObject>)obj - key:(NSString *)key -{ - if (!obj || key.length <= 0) { - return; - } - - if(![_keyStack containsObject:key]){ - [_keyStack addObject:key]; - }else{ - //return; - } - - obj.key = key; - _typesMap[key] = obj.class; - _inMemoryObjectsMap[key] = obj; - - for(NSUInteger i = _keyStack.count - _inMemoryObjectsMap.count ; - i < _keyStack.count && _inMemoryObjectsMap.count > _inMemoryCount; - i++){ - - NSString *keyToSave = _keyStack[i]; - if(_inMemoryObjectsMap[keyToSave]){ - id<FLBStackCacheObject> ob = _inMemoryObjectsMap[keyToSave]; - [_inMemoryObjectsMap removeObjectForKey:keyToSave]; - [ob writeToFileWithKey:keyToSave - queue:_queueIO - cache:self - completion:^(NSError *err, NSString *path) { - if (err) { - NSLog(@"Caching object to file failed!"); - } - }]; - } - } -} - -- (id<FLBStackCacheObject>)objectForKey:(NSString *)key -{ - return _inMemoryObjectsMap[key]; -} - -- (id<FLBStackCacheObject>)remove:(NSString *)key -{ - if([self empty]) return nil; - - if(![_keyStack containsObject:key]) return nil; - - id ob = _inMemoryObjectsMap[key]; - - [_keyStack removeObject:key]; - [_inMemoryObjectsMap removeObjectForKey:key]; - [_typesMap removeObjectForKey:key]; - - [self preloadIfNeeded]; - - return ob; -} - -- (void)invalidate:(NSString *)key -{ - if(!key || [self empty]) return; - - if(![_keyStack containsObject:key]) return; - - id<FLBStackCacheObject> ob = _inMemoryObjectsMap[key]; - [ob removeCachedFileWithKey:key - queue:_queueIO - cache:self - completion:^(NSError *err, NSString *k) { - }]; - [_inMemoryObjectsMap removeObjectForKey:key]; - - [self preloadIfNeeded]; -} - -- (void)preloadIfNeeded -{ - for(NSString *key in self.keyStack.reverseObjectEnumerator){ - Class typeClass = _typesMap[key]; - id cache = _inMemoryObjectsMap[key]; - if(typeClass && !cache && [typeClass conformsToProtocol: @protocol(FLBStackCacheObject)]){ - _loadinMap[key] = @(YES); - [typeClass loadFromFileWithKey:key - queue:_queueIO - cache:self - completion:^(NSError *err ,id<FLBStackCacheObject> ob){ - [self.loadinMap removeObjectForKey:key]; - if (ob && !err) { - if(self.typesMap[key]){ - self.inMemoryObjectsMap[key] = ob; - } - }else{ - NSLog(@"preload object from file failed!"); - } - }]; - } - - if(_inMemoryObjectsMap.count + _loadinMap.count >= _inMemoryCount){ - break; - } - } -} - - - -- (NSString *)cacheDir -{ - static NSString *cachePath = nil; - if (!cachePath) { - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); - NSString *cacheDirectory = [paths objectAtIndex:0]; - cachePath = [cacheDirectory stringByAppendingPathComponent:@"FlutterScreenshots"]; - } - - BOOL dir = NO; - if(![[NSFileManager defaultManager] fileExistsAtPath:cachePath isDirectory:&dir]){ - NSError *eror = nil; - [[NSFileManager defaultManager] createDirectoryAtPath:cachePath - withIntermediateDirectories:YES - attributes:nil - error:&eror]; - if (eror) { - NSLog(@"%@",eror); - } - } - - return cachePath; -} - -@end diff --git a/ios/Classes/1.0/Support/Cache/FLBStackCacheObjectImg.h b/ios/Classes/1.0/Support/Cache/FLBStackCacheObjectImg.h deleted file mode 100755 index 9ce0dc5..0000000 --- a/ios/Classes/1.0/Support/Cache/FLBStackCacheObjectImg.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import <Foundation/Foundation.h> - -#import "FLBStackCache.h" - -@interface FLBStackCacheObjectImg : NSObject<FLBStackCacheObject> - -@property (nonatomic,copy) NSString *key; - -- (instancetype)initWithImage:(UIImage *)image; - -- (UIImage *)image; - -@end diff --git a/ios/Classes/1.0/Support/Cache/FLBStackCacheObjectImg.m b/ios/Classes/1.0/Support/Cache/FLBStackCacheObjectImg.m deleted file mode 100755 index b95eef1..0000000 --- a/ios/Classes/1.0/Support/Cache/FLBStackCacheObjectImg.m +++ /dev/null @@ -1,116 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import "FLBStackCacheObjectImg.h" - -@interface FLBStackCacheObjectImg() -@property (nonatomic,strong) UIImage *image; -@end - -@implementation FLBStackCacheObjectImg - -- (instancetype)initWithImage:(UIImage *)image -{ - if (self = [super init]) { - _image = image; - } - - return self; -} - - - -+ (BOOL)loadFromFileWithKey:(NSString *)key - queue:(dispatch_queue_t)queue - cache:(FLBStackCache *)cache - completion:(void (^)(NSError *, id<FLBStackCacheObject>))completion -{ - dispatch_async(queue, ^{ - UIImage *image = [[UIImage alloc] initWithContentsOfFile:[self filePathByKey:key dirPath:cache.cacheDir]]; - if (completion) { - if (image) { - FLBStackCacheObjectImg *ob = [[FLBStackCacheObjectImg alloc] initWithImage:image]; - ob.key = key; - completion(nil,ob); - }else{ - completion([NSError new],nil); - } - } - }); - - return YES; -} - -+ (NSString *)filePathByKey:(NSString *)key dirPath:(NSString *)cacheDir -{ - key = [key stringByReplacingOccurrencesOfString:@"/" withString:@""]; - key = [key stringByReplacingOccurrencesOfString:@":" withString:@""]; - NSString *path = [cacheDir stringByAppendingPathComponent:key]; - return path; -} - -- (BOOL)writeToFileWithKey:(NSString *)key - queue:(dispatch_queue_t)queue - cache:(FLBStackCache *)cache - completion:(void (^)(NSError *, NSString *))completion -{ - if(!_image){ - return NO; - } - - dispatch_async(queue, ^{ - NSData *imgData = UIImagePNGRepresentation(self.image); - NSString *filePath = [FLBStackCacheObjectImg filePathByKey:key dirPath:cache.cacheDir]; - [imgData writeToFile:filePath atomically:YES]; - if (completion) { - completion(nil,key); - } - }); - - return YES; -} - -- (BOOL)removeCachedFileWithKey:(NSString *)key - queue:(dispatch_queue_t)queue - cache:(FLBStackCache *)cache - completion:(void (^)(NSError *, NSString *))completion -{ - if(!key){ - return NO; - } - - dispatch_async(queue, ^{ - NSString *filePath = [FLBStackCacheObjectImg filePathByKey:key dirPath:cache.cacheDir]; - NSError *err = nil; - [NSFileManager.defaultManager removeItemAtPath:filePath error:&err]; - if (completion) { - completion(err,key); - } - }); - - return YES; -} - - -@end diff --git a/ios/Classes/1.0/Support/Memory/FLBMemoryInspector.h b/ios/Classes/1.0/Support/Memory/FLBMemoryInspector.h deleted file mode 100755 index f04b3f4..0000000 --- a/ios/Classes/1.0/Support/Memory/FLBMemoryInspector.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import <Foundation/Foundation.h> - -#define kFLBMemoryInspectorChangedNotification @"__FlutterMemoryInspectorChangedNotification__" -#define kFLBMemoryInspectorKeyCondition @"condition" - -typedef NS_ENUM(NSUInteger,FLBMemoryCondition) { - FLBMemoryConditionUnknown, - FLBMemoryConditionNormal, - FLBMemoryConditionLowMemory, - FLBMemoryConditionExtremelyLow, - FLBMemoryConditionAboutToDie -}; - -@interface FLBMemoryInspector : NSObject - -+ (instancetype)sharedInstance; - -- (FLBMemoryCondition)currentCondition; -- (int64_t)currentFootPrint; -- (int64_t)deviceMemory; -- (BOOL)smallMemoryDevice; - -@end diff --git a/ios/Classes/1.0/Support/Memory/FLBMemoryInspector.mm b/ios/Classes/1.0/Support/Memory/FLBMemoryInspector.mm deleted file mode 100755 index 2854b76..0000000 --- a/ios/Classes/1.0/Support/Memory/FLBMemoryInspector.mm +++ /dev/null @@ -1,157 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import "FLBMemoryInspector.h" - -#include <mach/mach.h> -#include <stdlib.h> -#include <sys/sysctl.h> - -#define MB(_v_) (_v_*1024*1024) -#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame) -#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending) -#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) -#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) -#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending) - -@interface FLBMemoryInspector() -@property(nonatomic,assign) FLBMemoryCondition condition; -@end - -@implementation FLBMemoryInspector - -+ (instancetype)sharedInstance -{ - static id sInstance = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - sInstance = [[self.class alloc] init]; - }); - - return sInstance; -} - -static bool isHighterThanIos9(){ - bool ret = SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.0.0"); - return ret; -} - -static int64_t memoryFootprint() -{ - task_vm_info_data_t vmInfo; - mach_msg_type_number_t count = TASK_VM_INFO_COUNT; - kern_return_t result = task_info(mach_task_self(), TASK_VM_INFO, (task_info_t) &vmInfo, &count); - if (result != KERN_SUCCESS) - return -1; - return vmInfo.phys_footprint; -} - - -static int64_t _memoryWarningLimit() -{ - size_t size; - sysctlbyname("hw.machine", NULL, &size, NULL, 0); - char *machine =(char *) malloc(size); - sysctlbyname("hw.machine", machine, &size, NULL, 0); - NSString *platform = [NSString stringWithUTF8String:machine]; - free(machine); - - if ([platform isEqualToString:@"iPhone5,1"]) return MB(600); - if ([platform isEqualToString:@"iPhone5,2"]) return MB(600); - if ([platform isEqualToString:@"iPhone5,3"]) return MB(600); - if ([platform isEqualToString:@"iPhone5,4"]) return MB(600); - if ([platform isEqualToString:@"iPhone6,1"]) return MB(600); - if ([platform isEqualToString:@"iPhone6,2"]) return MB(600); - if ([platform isEqualToString:@"iPhone7,1"]) return MB(600); - if ([platform isEqualToString:@"iPhone7,2"]) return MB(600); - if ([platform isEqualToString:@"iPhone8,1"]) return MB(1280); - if ([platform isEqualToString:@"iPhone8,2"]) return MB(1280); - if ([platform isEqualToString:@"iPhone8,4"]) return MB(1280); - if ([platform isEqualToString:@"iPhone9,1"]) return MB(1280); - if ([platform isEqualToString:@"iPhone9,2"]) return MB(1950); - if ([platform isEqualToString:@"iPhone9,3"]) return MB(1280); - if ([platform isEqualToString:@"iPhone9,4"]) return MB(1950); - if ([platform isEqualToString:@"iPhone10,1"]) return MB(1280); - if ([platform isEqualToString:@"iPhone10,2"]) return MB(1950); - if ([platform isEqualToString:@"iPhone10,3"]) return MB(1950); - if ([platform isEqualToString:@"iPhone10,4"]) return MB(1280); - if ([platform isEqualToString:@"iPhone10,5"]) return MB(1950); - if ([platform isEqualToString:@"iPhone10,6"]) return MB(1950); - - return 0; -} - -static int64_t getLimit(){ - const static size_t l = _memoryWarningLimit(); - return l; -} - -- (int64_t)deviceMemory -{ - int64_t size = [NSProcessInfo processInfo].physicalMemory; - return size; -} - -- (BOOL)smallMemoryDevice -{ - if([self deviceMemory] <= MB(1024)){ - return YES; - }else{ - return NO; - } -} - -- (FLBMemoryCondition)currentCondition -{ - FLBMemoryCondition newCondition = FLBMemoryConditionUnknown; - - - if(!isHighterThanIos9() || getLimit() <= 0){ - newCondition = FLBMemoryConditionUnknown; - }else if(memoryFootprint() < getLimit() * 0.40){ - newCondition = FLBMemoryConditionNormal; - }else if(memoryFootprint() < getLimit() * 0.60){ - newCondition = FLBMemoryConditionLowMemory; - }else if(memoryFootprint() < getLimit() * 0.80){ - newCondition = FLBMemoryConditionExtremelyLow; - }else{ - newCondition = FLBMemoryConditionAboutToDie; - } - - if (newCondition != self.condition) { - [[NSNotificationCenter defaultCenter] postNotificationName:kFLBMemoryInspectorChangedNotification - object:@{kFLBMemoryInspectorKeyCondition:@(newCondition)}]; - } - - self.condition = newCondition; - - return newCondition; -} - -- (int64_t)currentFootPrint -{ - return memoryFootprint(); -} - -@end diff --git a/ios/Classes/1.5/FLB2FlutterApplication.h b/ios/Classes/1.5/FLB2FlutterApplication.h index f688235..8ba59bf 100755 --- a/ios/Classes/1.5/FLB2FlutterApplication.h +++ b/ios/Classes/1.5/FLB2FlutterApplication.h @@ -25,7 +25,6 @@ #import <Foundation/Foundation.h> #import <Flutter/Flutter.h> #import "FLB2Platform.h" -#import "FlutterBoost.h" #import "FLB2FlutterProvider.h" #import "FLBFlutterApplicationInterface.h" diff --git a/ios/Classes/1.5/FLB2FlutterApplication.m b/ios/Classes/1.5/FLB2FlutterApplication.m index edfd323..6dfaca2 100755 --- a/ios/Classes/1.5/FLB2FlutterApplication.m +++ b/ios/Classes/1.5/FLB2FlutterApplication.m @@ -23,17 +23,14 @@ */ #import "FLB2FlutterApplication.h" -#import "FlutterBoost.h" -#import "FLBFlutterContainerManager.h" +#import "FlutterBoost2.h" +#import "FLB2FlutterContainerManager.h" #import "FLB2FlutterEngine.h" @interface FLB2FlutterApplication() -@property (nonatomic,strong) FLBFlutterContainerManager *manager; +@property (nonatomic,strong) FLB2FlutterContainerManager *manager; @property (nonatomic,strong) id<FLB2FlutterProvider> viewProvider; - @property (nonatomic,assign) BOOL isRunning; - - @property (nonatomic,strong) NSMutableDictionary *pageResultCallbacks; @property (nonatomic,strong) NSMutableDictionary *callbackCache; @end @@ -76,7 +73,7 @@ - (instancetype)init { if (self = [super init]) { - _manager = [FLBFlutterContainerManager new]; + _manager = [FLB2FlutterContainerManager new]; _pageResultCallbacks = NSMutableDictionary.new; _callbackCache = NSMutableDictionary.new; } diff --git a/ios/Classes/1.5/FLB2FlutterViewContainer.m b/ios/Classes/1.5/FLB2FlutterViewContainer.m index 082c0dd..2b0ea87 100755 --- a/ios/Classes/1.5/FLB2FlutterViewContainer.m +++ b/ios/Classes/1.5/FLB2FlutterViewContainer.m @@ -25,10 +25,10 @@ #import "FLB2FlutterViewContainer.h" #import "FLB2FlutterApplication.h" #import "BoostMessageChannel.h" -#import "FLBFlutterContainerManager.h" -#import "FlutterBoostPlugin_private.h" +#import "FLB2FlutterContainerManager.h" +#import "FlutterBoostPlugin2_private.h" -#define FLUTTER_APP [FlutterBoostPlugin sharedInstance].application +#define FLUTTER_APP [FlutterBoostPlugin2 sharedInstance].application #define FLUTTER_VIEW FLUTTER_APP.flutterViewController.view #define FLUTTER_VC FLUTTER_APP.flutterViewController @@ -174,10 +174,10 @@ static NSUInteger kInstanceCounter = 0; params:_params uniqueId:self.uniqueIDString]; //Save some first time page info. - if(![FlutterBoostPlugin sharedInstance].fPagename){ - [FlutterBoostPlugin sharedInstance].fPagename = _name; - [FlutterBoostPlugin sharedInstance].fPageId = self.uniqueIDString; - [FlutterBoostPlugin sharedInstance].fParams = _params; + if(![FlutterBoostPlugin2 sharedInstance].fPagename){ + [FlutterBoostPlugin2 sharedInstance].fPagename = _name; + [FlutterBoostPlugin2 sharedInstance].fPageId = self.uniqueIDString; + [FlutterBoostPlugin2 sharedInstance].fParams = _params; } [super viewWillAppear:animated]; diff --git a/ios/Classes/1.0/FLBFactory.h b/ios/Classes/Boost/BoostChannel.h similarity index 93% rename from ios/Classes/1.0/FLBFactory.h rename to ios/Classes/Boost/BoostChannel.h index ac84d18..2a434c5 100644 --- a/ios/Classes/1.0/FLBFactory.h +++ b/ios/Classes/Boost/BoostChannel.h @@ -21,14 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ - - #import <Foundation/Foundation.h> -#import "FLBAbstractFactory.h" - +#import <Flutter/Flutter.h> NS_ASSUME_NONNULL_BEGIN -@interface FLBFactory : NSObject<FLBAbstractFactory> +@interface BoostChannel : NSObject<FlutterPlugin> @end diff --git a/ios/Classes/1.0/FLBFactory.m b/ios/Classes/Boost/BoostChannel.m similarity index 75% rename from ios/Classes/1.0/FLBFactory.m rename to ios/Classes/Boost/BoostChannel.m index c7fb089..9131c69 100644 --- a/ios/Classes/1.0/FLBFactory.m +++ b/ios/Classes/Boost/BoostChannel.m @@ -21,22 +21,15 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#import "BoostChannel.h" +#import "FlutterBoost2.h" -#import "FLBFactory.h" -#import "FLBFlutterViewContainer.h" -#import "FLBFlutterApplication.h" - -@implementation FLBFactory - -- (id<FLBFlutterApplicationInterface>)createApplication:(id<FLB2Platform>)platform -{ - return FLBFlutterApplication.new; +@implementation BoostChannel ++ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar { + [FlutterBoostPlugin2 registerWithRegistrar:registrar]; } - -- (id<FLBFlutterContainer>)createFlutterContainer -{ - return FLBFlutterViewContainer.new; + +- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { + [FlutterBoostPlugin2.sharedInstance handleMethodCall:call result:result]; } - - @end diff --git a/ios/Classes/Boost/FLBFlutterAppDelegate.h b/ios/Classes/Boost/FLB2FlutterAppDelegate.h similarity index 96% rename from ios/Classes/Boost/FLBFlutterAppDelegate.h rename to ios/Classes/Boost/FLB2FlutterAppDelegate.h index 720080f..af670bd 100755 --- a/ios/Classes/Boost/FLBFlutterAppDelegate.h +++ b/ios/Classes/Boost/FLB2FlutterAppDelegate.h @@ -25,7 +25,7 @@ #import <Flutter/Flutter.h> NS_ASSUME_NONNULL_BEGIN -@interface FLBFlutterAppDelegate : FlutterAppDelegate +@interface FLB2FlutterAppDelegate : FlutterAppDelegate // Returns the key window's rootViewController, if it's a FlutterViewController. // Otherwise, returns nil. - (FlutterViewController*)rootFlutterViewController; diff --git a/ios/Classes/Boost/FLBFlutterAppDelegate.m b/ios/Classes/Boost/FLB2FlutterAppDelegate.m similarity index 87% rename from ios/Classes/Boost/FLBFlutterAppDelegate.m rename to ios/Classes/Boost/FLB2FlutterAppDelegate.m index 0561424..b17e4f3 100755 --- a/ios/Classes/Boost/FLBFlutterAppDelegate.m +++ b/ios/Classes/Boost/FLB2FlutterAppDelegate.m @@ -22,13 +22,13 @@ * THE SOFTWARE. */ -#import "FLBFlutterAppDelegate.h" -#import "FlutterBoostPlugin_private.h" +#import "FLB2FlutterAppDelegate.h" +#import "FlutterBoostPlugin2_private.h" -@implementation FLBFlutterAppDelegate +@implementation FLB2FlutterAppDelegate // Returns the key window's rootViewController, if it's a FlutterViewController. // Otherwise, returns nil. - (FlutterViewController*)rootFlutterViewController { - return FlutterBoostPlugin.sharedInstance.application.flutterViewController; + return FlutterBoostPlugin2.sharedInstance.application.flutterViewController; } @end diff --git a/ios/Classes/Boost/FLBFlutterContainerManager.h b/ios/Classes/Boost/FLB2FlutterContainerManager.h similarity index 96% rename from ios/Classes/Boost/FLBFlutterContainerManager.h rename to ios/Classes/Boost/FLB2FlutterContainerManager.h index 3199b87..22a1c2f 100755 --- a/ios/Classes/Boost/FLBFlutterContainerManager.h +++ b/ios/Classes/Boost/FLB2FlutterContainerManager.h @@ -26,7 +26,7 @@ #import "FLBFlutterContainer.h" NS_ASSUME_NONNULL_BEGIN -@interface FLBFlutterContainerManager : NSObject +@interface FLB2FlutterContainerManager : NSObject - (NSString *)peak; - (void)addUnique:(id<FLBFlutterContainer>)vc; diff --git a/ios/Classes/Boost/FLBFlutterContainerManager.m b/ios/Classes/Boost/FLB2FlutterContainerManager.m similarity index 94% rename from ios/Classes/Boost/FLBFlutterContainerManager.m rename to ios/Classes/Boost/FLB2FlutterContainerManager.m index 47ad825..eb9c6d8 100755 --- a/ios/Classes/Boost/FLBFlutterContainerManager.m +++ b/ios/Classes/Boost/FLB2FlutterContainerManager.m @@ -22,14 +22,14 @@ * THE SOFTWARE. */ -#import "FLBFlutterContainerManager.h" +#import "FLB2FlutterContainerManager.h" -@interface FLBFlutterContainerManager() +@interface FLB2FlutterContainerManager() @property (nonatomic,strong) NSMutableArray *idStk; @property (nonatomic,strong) NSMutableDictionary *existedID; @end -@implementation FLBFlutterContainerManager +@implementation FLB2FlutterContainerManager - (instancetype)init { diff --git a/ios/Classes/Boost/FLB2FlutterProvider.h b/ios/Classes/Boost/FLB2FlutterProvider.h index 4deb31f..2771bfc 100755 --- a/ios/Classes/Boost/FLB2FlutterProvider.h +++ b/ios/Classes/Boost/FLB2FlutterProvider.h @@ -23,17 +23,19 @@ */ #import <Foundation/Foundation.h> -#import "FLBFlutterViewProvider.h" @class FlutterViewController; @class FlutterEngine; NS_ASSUME_NONNULL_BEGIN -@protocol FLB2FlutterProvider <FLBFlutterViewProvider> +@protocol FLB2FlutterProvider <NSObject> @required - (FlutterEngine *)engine; - (void)atacheToViewController:(FlutterViewController *)vc; - (void)detach; - (void)prepareEngineIfNeeded; +- (void)pause; +- (void)resume; +- (void)inactive; @end NS_ASSUME_NONNULL_END diff --git a/ios/Classes/Boost/FLB2Platform.h b/ios/Classes/Boost/FLB2Platform.h index b7f3582..ec95473 100755 --- a/ios/Classes/Boost/FLB2Platform.h +++ b/ios/Classes/Boost/FLB2Platform.h @@ -23,13 +23,9 @@ */ #import <Foundation/Foundation.h> -#import "FLBPlatform.h" NS_ASSUME_NONNULL_BEGIN -@protocol FLB2Platform <FLBPlatform> -@optional -- (BOOL)useBoost2; - +@protocol FLB2Platform <NSObject> @required - (void)open:(NSString *)url urlParams:(NSDictionary *)urlParams diff --git a/ios/Classes/Boost/FLBFlutterApplicationInterface.h b/ios/Classes/Boost/FLBFlutterApplicationInterface.h index b42fa4d..ff1f05a 100644 --- a/ios/Classes/Boost/FLBFlutterApplicationInterface.h +++ b/ios/Classes/Boost/FLBFlutterApplicationInterface.h @@ -24,7 +24,7 @@ #import <Foundation/Foundation.h> #import <Flutter/Flutter.h> #import "FLB2Platform.h" -#import "FlutterBoost.h" +#import "FlutterBoost2.h" #import "FLB2FlutterProvider.h" #import "FLBFlutterContainer.h" diff --git a/ios/Classes/Boost/FLBFlutterContainer.h b/ios/Classes/Boost/FLBFlutterContainer.h index 7522566..d3a33a1 100644 --- a/ios/Classes/Boost/FLBFlutterContainer.h +++ b/ios/Classes/Boost/FLBFlutterContainer.h @@ -21,8 +21,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ - - #import <Foundation/Foundation.h> NS_ASSUME_NONNULL_BEGIN diff --git a/ios/Classes/Boost/FLBPlatform.h b/ios/Classes/Boost/FLBPlatform.h deleted file mode 100755 index c440d4b..0000000 --- a/ios/Classes/Boost/FLBPlatform.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Alibaba Group - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import <Foundation/Foundation.h> - -NS_ASSUME_NONNULL_BEGIN -@protocol FLBPlatform <NSObject> - -@required -- (void)openPage:(NSString *)name - params:(NSDictionary *)params - animated:(BOOL)animated - completion:(void (^)(BOOL finished))completion; - -- (void)closePage:(NSString *)uid - animated:(BOOL)animated - params:(NSDictionary *)params - completion:(void (^)(BOOL finished))completion; -@end -NS_ASSUME_NONNULL_END diff --git a/ios/Classes/Boost/FLBTypes.h b/ios/Classes/Boost/FLBTypes.h index 0279714..add3afb 100644 --- a/ios/Classes/Boost/FLBTypes.h +++ b/ios/Classes/Boost/FLBTypes.h @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ - +#import <Foundation/Foundation.h> #ifndef FLBTypes_h #define FLBTypes_h diff --git a/ios/Classes/Boost/FlutterBoost.h b/ios/Classes/Boost/FlutterBoost2.h similarity index 89% rename from ios/Classes/Boost/FlutterBoost.h rename to ios/Classes/Boost/FlutterBoost2.h index a2973a2..e61d846 100755 --- a/ios/Classes/Boost/FlutterBoost.h +++ b/ios/Classes/Boost/FlutterBoost2.h @@ -25,11 +25,9 @@ #ifndef FlutterBoost_h #define FlutterBoost_h -#import "FlutterBoostPlugin.h" -#import "FLBFlutterAppDelegate.h" -#import "FLBFlutterViewContainer.h" -#import "FLBPlatform.h" +#import "FlutterBoostPlugin2.h" +#import "FLB2FlutterAppDelegate.h" #import "FLB2FlutterViewContainer.h" -#import "FLB2Platform.h" +#import "FLBTypes.h" #endif /* FlutterBoost_h */ diff --git a/ios/Classes/Boost/FlutterBoostPlugin.h b/ios/Classes/Boost/FlutterBoostPlugin2.h similarity index 97% rename from ios/Classes/Boost/FlutterBoostPlugin.h rename to ios/Classes/Boost/FlutterBoostPlugin2.h index 60b1933..e0944d0 100755 --- a/ios/Classes/Boost/FlutterBoostPlugin.h +++ b/ios/Classes/Boost/FlutterBoostPlugin2.h @@ -26,7 +26,7 @@ #import "FLB2Platform.h" #import "FLBTypes.h" -@interface FlutterBoostPlugin : NSObject<FlutterPlugin> +@interface FlutterBoostPlugin2 : NSObject<FlutterPlugin> #pragma mark - Initializer + (instancetype)sharedInstance; diff --git a/ios/Classes/Boost/FlutterBoostPlugin.m b/ios/Classes/Boost/FlutterBoostPlugin2.m similarity index 86% rename from ios/Classes/Boost/FlutterBoostPlugin.m rename to ios/Classes/Boost/FlutterBoostPlugin2.m index 10fda83..8a13ab2 100755 --- a/ios/Classes/Boost/FlutterBoostPlugin.m +++ b/ios/Classes/Boost/FlutterBoostPlugin2.m @@ -22,25 +22,23 @@ * THE SOFTWARE. */ -#import "FlutterBoostPlugin.h" -#import "FlutterBoostPlugin_private.h" -#import "FLBFactory.h" +#import "FlutterBoostPlugin2.h" +#import "FlutterBoostPlugin2_private.h" #import "FLB2Factory.h" #import "BoostMessageChannel.h" -#import "FlutterBoostPlugin_private.h" #define NSNull2Nil(_x_) if([_x_ isKindOfClass: NSNull.class]) _x_ = nil; -@interface FlutterBoostPlugin() +@interface FlutterBoostPlugin2() @end -@implementation FlutterBoostPlugin +@implementation FlutterBoostPlugin2 + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar { FlutterMethodChannel* channel = [FlutterMethodChannel methodChannelWithName:@"flutter_boost" binaryMessenger:[registrar messenger]]; - FlutterBoostPlugin* instance = [self.class sharedInstance]; + FlutterBoostPlugin2* instance = [self.class sharedInstance]; instance.methodChannel = channel; [registrar addMethodCallDelegate:instance channel:channel]; } @@ -58,7 +56,7 @@ NSNull2Nil(exts); NSNull2Nil(resultData); NSNull2Nil(uid); - [[FlutterBoostPlugin sharedInstance].application close:uid + [[FlutterBoostPlugin2 sharedInstance].application close:uid result:resultData exts:exts completion:^(BOOL r){ @@ -78,16 +76,16 @@ NSNull2Nil(url); NSNull2Nil(urlParams); NSNull2Nil(exts); - [[FlutterBoostPlugin sharedInstance].application open:url + [[FlutterBoostPlugin2 sharedInstance].application open:url urlParams:urlParams exts:exts reult:result completion:^(BOOL r) {}]; }else if([@"pageOnStart" isEqualToString:call.method]){ NSMutableDictionary *pageInfo = [NSMutableDictionary new]; - pageInfo[@"name"] =[FlutterBoostPlugin sharedInstance].fPagename; - pageInfo[@"params"] = [FlutterBoostPlugin sharedInstance].fParams; - pageInfo[@"uniqueId"] = [FlutterBoostPlugin sharedInstance].fPageId; + pageInfo[@"name"] =[FlutterBoostPlugin2 sharedInstance].fPagename; + pageInfo[@"params"] = [FlutterBoostPlugin2 sharedInstance].fParams; + pageInfo[@"uniqueId"] = [FlutterBoostPlugin2 sharedInstance].fPageId; if(result) result(pageInfo); }else{ result(FlutterMethodNotImplemented); @@ -125,11 +123,7 @@ { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - if([platform respondsToSelector:@selector(useBoost2)] && platform.useBoost2){ - self->_factory = FLB2Factory.new; - }else{ - self->_factory = FLBFactory.new; - } + self->_factory = FLB2Factory.new; self->_application = [self->_factory createApplication:platform]; [self->_application startFlutterWithPlatform:platform onStart:callback]; diff --git a/ios/Classes/Boost/FlutterBoostPlugin_private.h b/ios/Classes/Boost/FlutterBoostPlugin2_private.h similarity index 96% rename from ios/Classes/Boost/FlutterBoostPlugin_private.h rename to ios/Classes/Boost/FlutterBoostPlugin2_private.h index 838fa40..51d7d30 100644 --- a/ios/Classes/Boost/FlutterBoostPlugin_private.h +++ b/ios/Classes/Boost/FlutterBoostPlugin2_private.h @@ -25,8 +25,8 @@ #import "FLBFlutterApplicationInterface.h" #import "FLBAbstractFactory.h" - -@interface FlutterBoostPlugin(){ +#import "FlutterBoostPlugin2.h" +@interface FlutterBoostPlugin2(){ id<FLBFlutterApplicationInterface> _application; id<FLBAbstractFactory> _factory; } diff --git a/ios/Classes/Messaging/BoostMessageChannel.mm b/ios/Classes/Messaging/BoostMessageChannel.mm index 687940a..103f626 100755 --- a/ios/Classes/Messaging/BoostMessageChannel.mm +++ b/ios/Classes/Messaging/BoostMessageChannel.mm @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #import "BoostMessageChannel.h" -#import "FlutterBoostPlugin_private.h" +#import "FlutterBoostPlugin2_private.h" @implementation BoostMessageChannel @@ -37,7 +37,7 @@ + (FlutterMethodChannel *)methodChannel { - return FlutterBoostPlugin.sharedInstance.methodChannel; + return FlutterBoostPlugin2.sharedInstance.methodChannel; } + (void)sendEvent:(NSString *)eventName @@ -162,7 +162,7 @@ } }]; - [FlutterBoostPlugin.sharedInstance.application didInitPageContainer:pageName + [FlutterBoostPlugin2.sharedInstance.application didInitPageContainer:pageName params:params uniqueId:uniqueId]; } @@ -179,7 +179,7 @@ } }]; - [FlutterBoostPlugin.sharedInstance.application willDeallocPageContainer:pageName + [FlutterBoostPlugin2.sharedInstance.application willDeallocPageContainer:pageName params:params uniqueId:uniqueId]; } diff --git a/ios/flutter_boost2.podspec b/ios/flutter_boost2.podspec new file mode 100755 index 0000000..6eb4a0e --- /dev/null +++ b/ios/flutter_boost2.podspec @@ -0,0 +1,32 @@ +# +# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html +# +Pod::Spec.new do |s| + s.name = 'flutter_boost2' + s.version = '0.0.1' + s.summary = 'A new Flutter plugin make flutter better to use!' + s.description = <<-DESC +A new Flutter plugin make flutter better to use! + DESC + s.homepage = 'http://example.com' + s.license = { :file => '../LICENSE.md' } + s.author = { 'Alibaba Xianyu' => 'email@example.com' } + s.source = { :path => '.' } + s.source_files = 'Classes/**/*.{h,m,mm}' + + s.public_header_files = + 'Classes/Boost/FlutterBoostPlugin2.h', + 'Classes/Boost/FLB2Platform.h', + 'Classes/Boost/FLBFlutterContainer.h', + 'Classes/Boost/FLB2FlutterAppDelegate.h', + 'Classes/Boost/FLBTypes.h', + 'Classes/Boost/FlutterBoost2.h', + 'Classes/Boost/BoostChannel.h', + 'Classes/1.5/FLB2FlutterViewContainer.h' + + s.dependency 'Flutter' + s.libraries = 'c++' + + s.ios.deployment_target = '8.0' +end + -- 2.26.2