Commit 78c23ac1 authored by Jidong Chen's avatar Jidong Chen

update

parent 1ac64c20
......@@ -23,17 +23,19 @@
*/
#import "FLBFactory.h"
#import "FLBFlutterViewContainer.h"
#import "FLBFlutterApplication.h"
@implementation FLBFactory
- (id<FLBFlutterApplicationInterface>)createApplication:(id<FLB2Platform>)platform
{
return FLBFlutterApplication.new;
}
- (id<FLB2FlutterProvider>)createFlutterProvider:(id<FLB2Platform>)platform
- (id<FLBFlutterContainer>)createFlutterContainer
{
return FLBFlutterViewContainer.new;
}
@end
......@@ -23,13 +23,14 @@
*/
#import <Foundation/Foundation.h>
#import <Flutter/Flutter.h>
#import "FLBFlutterApplicationInterface.h"
NS_ASSUME_NONNULL_BEGIN
@interface FLBFlutterApplication : NSObject<FLBFlutterApplicationInterface>
@end
NS_ASSUME_NONNULL_END
......@@ -23,47 +23,36 @@
*/
#import "FLBFlutterApplication.h"
#import "FlutterBoost.h"
#import "FLBFlutterContainerManager.h"
#import "FLBFlutterEngine.h"
#import "FLBViewProviderFactory.h"
@interface FLBFlutterApplication()
@property (nonatomic,strong) FLBFlutterContainerManager *manager;
@property (nonatomic,strong) id<FLB2FlutterProvider> viewProvider;
@property (nonatomic,strong) id<FLBFlutterViewProvider> viewProvider;
@property (nonatomic,assign) BOOL isRendering;
@property (nonatomic,assign) BOOL isRunning;
@end
@implementation FLBFlutterApplication
+ (FLBFlutterApplication *)sharedApplication
{
static FLBFlutterApplication *instance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance = [self new];
});
return instance;
}
- (BOOL)isRunning
{
return _isRunning;
}
- (id)flutterProvider
{
return _viewProvider;
}
- (void)startFlutterWithPlatform:(id<FLB2Platform>)platform
onStart:(void (^)(id<FlutterBinaryMessenger,FlutterTextureRegistry,FlutterPluginRegistry> _Nonnull))callback
- (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 = [[FLBFlutterEngine alloc] init];
_isRunning = YES;
if(callback) callback(self.viewProvider.engine);
self.viewProvider = [[FLBViewProviderFactory new] createViewProviderWithPlatform:platform];
[self.viewProvider resume];
self.isRendering = YES;
self.isRunning = YES;
if(callback) callback(self.viewProvider.viewController);
});
}
......@@ -85,18 +74,23 @@
return [self flutterViewController].view;
}
- (FlutterViewController *)flutterViewController
{
return self.viewProvider.viewController;
}
- (BOOL)contains:(FLBFlutterViewContainer *)vc
- (BOOL)contains:(id<FLBFlutterContainer>)vc
{
return [_manager contains:vc];
}
- (void)addUniqueViewController:(FLBFlutterViewContainer *)vc
- (void)addUniqueViewController:(id<FLBFlutterContainer>)vc
{
return [_manager addUnique:vc];
}
- (void)removeViewController:(FLBFlutterViewContainer *)vc
- (void)removeViewController:(id<FLBFlutterContainer>)vc
{
return [_manager remove:vc];
}
......@@ -109,12 +103,22 @@
- (void)pause
{
if(!_isRendering) return;
[self.viewProvider pause];
_isRendering = NO;
}
- (void)resume
{
if(_isRendering) return;
[self.viewProvider resume];
_isRendering = YES;
}
- (void)inactive
......@@ -122,9 +126,10 @@
[self.viewProvider inactive];
}
- (FlutterViewController *)flutterViewController
- (void)setAccessibilityEnable:(BOOL)enable
{
return self.flutterProvider.engine.viewController;
[self.viewProvider setAccessibilityEnable:enable];
}
@end
......@@ -23,11 +23,15 @@
*/
#import <Foundation/Foundation.h>
#import "FLBFlutterProvider.h"
#import "FLBFlutterViewProvider.h"
NS_ASSUME_NONNULL_BEGIN
@interface FLBFlutterEngine : NSObject<FLBFlutterProvider>
#if RELEASE_1_0
@interface FLBFlutterEngine : NSObject<FLBFlutterViewProvider>
@end
#endif
NS_ASSUME_NONNULL_END
......@@ -24,12 +24,13 @@
#import "FLBFlutterEngine.h"
#import <Flutter/Flutter.h>
#import "FLBFlutterViewContainer.h"
#import "FLBFlutterViewControllerAdaptor.h"
#if RELEASE_1_0
@interface FLBFlutterEngine()
@property (nonatomic,strong) FLBFlutterViewControllerAdaptor *viewController;
@property (nonatomic,strong) FlutterEngine *engine;
@property (nonatomic,strong) FLBFlutterViewContainer *dummy;
@end
@implementation FLBFlutterEngine
......@@ -42,14 +43,15 @@
if (self = [super init]) {
_engine = [[FlutterEngine alloc] initWithName:@"io.flutter" project:nil];
[_engine runWithEntrypoint:nil];
_dummy = [[FLBFlutterViewContainer alloc] initWithEngine:_engine
nibName:nil
bundle:nil];
_viewController = [[FLBFlutterViewControllerAdaptor alloc] initWithEngine:_engine
nibName:nil
bundle:nil];
[_viewController view];
Class clazz = NSClassFromString(@"GeneratedPluginRegistrant");
if (clazz) {
if ([clazz respondsToSelector:NSSelectorFromString(@"registerWithRegistry:")]) {
[clazz performSelector:NSSelectorFromString(@"registerWithRegistry:")
withObject:_engine];
withObject:_viewController];
}
}
}
......@@ -58,14 +60,23 @@
#pragma clang diagnostic pop
}
- (FlutterViewController *)viewController
{
return _viewController;
}
- (void)pause
{
[[_engine lifecycleChannel] sendMessage:@"AppLifecycleState.pause"];
//TODO: [[_engine.get() lifecycleChannel] sendMessage:@"AppLifecycleState.paused"];
[self.viewController boost_viewWillDisappear:NO];
[self.viewController boost_viewDidDisappear:NO];
}
- (void)resume
{
[[_engine lifecycleChannel] sendMessage:@"AppLifecycleState.resume"];
//TODO: [[_engine.get() lifecycleChannel] sendMessage:@"AppLifecycleState.resumed"];
[self.viewController boost_viewWillAppear:NO];
[self.viewController boost_viewDidAppear:NO];
}
- (void)inactive
......@@ -73,31 +84,10 @@
[[_engine lifecycleChannel] sendMessage:@"AppLifecycleState.inactive"];
}
- (FlutterEngine *)engine
{
return _engine;
}
- (void)atacheToViewController:(FlutterViewController *)vc
{
if(_engine.viewController != vc){
_engine.viewController = vc;
}
}
- (void)detach
{
if(_engine.viewController != _dummy){
_engine.viewController = _dummy;
}
}
- (void)prepareEngineIfNeeded
- (void)setAccessibilityEnable:(BOOL)enable
{
[self detach];
[_dummy surfaceUpdated:YES];
self.viewController.accessibilityEnable = enable;
}
@end
#endif
/*
* 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
/*
* 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];
if([platform respondsToSelector:@selector(accessibilityEnable)]){
_viewController.accessibilityEnable = [platform accessibilityEnable];
}else{
_viewController.accessibilityEnable = YES;
}
[_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];
}
- (void)setAccessibilityEnable:(BOOL)enable
{
self.viewController.accessibilityEnable = enable;
}
@end
......@@ -23,25 +23,12 @@
*/
#import <UIKit/UIKit.h>
#import <Flutter/Flutter.h>
#import "FLBFlutterContainer.h"
NS_ASSUME_NONNULL_BEGIN
@interface FLBFlutterViewContainer : FlutterViewController
@property (nonatomic,copy,readonly) NSString *name;
@property (nonatomic,strong,readonly) NSDictionary *params;
@property (nonatomic,copy,readonly) NSString *uniqueIDString;
/*
You must call this one time to set flutter page name
and params.
*/
- (void)setName:(NSString *)name params:(NSDictionary *)params;
- (void)surfaceUpdated:(BOOL)appeared;
@interface FLBFlutterViewContainer : UIViewController<FLBFlutterContainer>
@end
......
......@@ -24,9 +24,11 @@
#import "FLBFlutterViewContainer.h"
#import "FLBFlutterApplication.h"
#import "FLBStackCache.h"
#import "FLBStackCacheObjectImg.h"
#import "FLBMemoryInspector.h"
#import "Service_NavigationService.h"
#import "FlutterBoostConfig.h"
#import "FLBFlutterViewContainerManager.h"
#define FLUTTER_VIEW [FLBFlutterApplication sharedApplication].flutterViewController.view
#define FLUTTER_VC [FLBFlutterApplication sharedApplication].flutterViewController
......@@ -35,30 +37,13 @@
@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
- (instancetype)init
{
[FLUTTER_APP.flutterProvider prepareEngineIfNeeded];
if(self = [super initWithEngine:FLUTTER_APP.flutterProvider.engine
nibName:nil
bundle:nil]){
[self _setup];
}
return self;
}
- (instancetype)initWithCoder:(NSCoder *)aDecoder{
if (self = [super initWithCoder: aDecoder]) {
NSAssert(NO, @"unsupported init method!");
[self _setup];
}
return self;
}
- (void)setName:(NSString *)name params:(NSDictionary *)params
{
if(!_name && name){
......@@ -83,7 +68,7 @@ static NSUInteger kInstanceCounter = 0;
{
kInstanceCounter++;
if(kInstanceCounter == 1){
// [FLUTTER_APP resume];
[FLUTTER_APP resume];
}
}
......@@ -91,7 +76,8 @@ static NSUInteger kInstanceCounter = 0;
{
kInstanceCounter--;
if([self.class instanceCounter] == 0){
// [[FLBFlutterApplication sharedApplication] pause];
[[FLBStackCache sharedInstance] clear];
[[FLBFlutterApplication sharedApplication] pause];
}
}
......@@ -105,6 +91,43 @@ static NSUInteger kInstanceCounter = 0;
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
......@@ -119,6 +142,7 @@ static NSUInteger kInstanceCounter = 0;
pageName:_name params:_params
uniqueId:[self uniqueIDString]];
[[FLBStackCache sharedInstance] remove:self.uniqueIDString];
[[FLBFlutterApplication sharedApplication] removeViewController:self];
[self.class instanceCounterDecrease];
......@@ -126,26 +150,140 @@ static NSUInteger kInstanceCounter = 0;
- (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)attatchFlutterEngine
- (void)attatchFlutterView
{
[FLUTTER_APP.flutterProvider prepareEngineIfNeeded];
[FLUTTER_APP.flutterProvider atacheToViewController:self];
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];
}
- (void)detatchFlutterEngine
- (BOOL)showSnapShotVew
{
[FLUTTER_APP.flutterProvider detach];
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
......@@ -157,18 +295,19 @@ static NSUInteger kInstanceCounter = 0;
- (void)viewWillAppear:(BOOL)animated
{
if([FLUTTER_APP contains:self]){
[self detatchFlutterEngine];
}else{
[self attatchFlutterEngine];
if(self.navigationController.interactivePopGestureRecognizer.state == UIGestureRecognizerStateBegan){
self.interactiveGestureActive = true;
}
[[FLBFlutterApplication sharedApplication] resume];
[self surfaceUpdated:YES];
[[FLBFlutterApplication sharedApplication] resume];
//For new page we should attach flutter view in view will appear
//for better performance.
if(![[FLBFlutterApplication sharedApplication] contains:self]){
[self attatchFlutterView];
}
[self showSnapShotVew];
[Service_NavigationService willShowPageContainer:^(NSNumber *result) {}
pageName:_name
params:_params
......@@ -185,21 +324,49 @@ static NSUInteger kInstanceCounter = 0;
- (void)viewDidAppear:(BOOL)animated
{
[FLUTTER_APP addUniqueViewController:self];
[[FLBFlutterApplication sharedApplication] resume];
//Ensure flutter view is attached.
[self attatchFlutterEngine];
[self surfaceUpdated:YES];
[self attatchFlutterView];
[Service_NavigationService didShowPageContainer:^(NSNumber *result) {}
pageName:_name
params:_params
uniqueId:self.uniqueIDString];
[[FLBFlutterApplication sharedApplication] 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];
}
[Service_NavigationService willDisappearPageContainer:^(NSNumber *result) {}
pageName:_name
params:_params
......@@ -210,12 +377,16 @@ static NSUInteger kInstanceCounter = 0;
- (void)viewDidDisappear:(BOOL)animated
{
[self detatchFlutterEngine];
[Service_NavigationService didDisappearPageContainer:^(NSNumber *result) {}
pageName:_name
params:_params
uniqueId:self.uniqueIDString];
[self clearCurrentScreenShotImage];
[super viewDidDisappear:animated];
[FLUTTER_APP inactive];
self.interactiveGestureActive = NO;
}
#pragma mark - FLBViewControllerResultHandler
......@@ -228,14 +399,5 @@ static NSUInteger kInstanceCounter = 0;
params:@{}];
}
- (void)installSplashScreenViewIfNecessary {
//Do nothing.
}
- (BOOL)loadDefaultSplashScreenView
{
return NO;
}
@end
/*
* 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;
@property (nonatomic,assign) BOOL accessibilityEnable;
@end
NS_ASSUME_NONNULL_END
/*
* 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.
}
- (void)fixed_onAccessibilityStatusChanged:(NSNotification*)notification {
if(self.accessibilityEnable){
[self fixed_onAccessibilityStatusChanged:notification];
}
}
@end
/*
* 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
- (void)setAccessibilityEnable:(BOOL)enable;
- (BOOL)accessibilityEnable;
- (FlutterViewController *)viewController;
- (void)pause;
- (void)resume;
- (void)inactive;
@end
NS_ASSUME_NONNULL_END
/*
* 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
/*
* 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 "FLBFlutterEngine.h"
#import "FLBFlutterEngineOld.h"
#import "FLBPlatform.h"
@implementation FLBViewProviderFactory
- (id<FLBFlutterViewProvider>)createViewProviderWithPlatform:(id<FLBPlatform>)platform
{
#if RELEASE_1_0
return [FLBFlutterEngine new];
#else
return [[FLBFlutterEngineOld alloc] initWithPlatform:platform];
#endif
}
- (id<FLBFlutterViewProvider>)createViewProvider
{
#if RELEASE_1_0
return [FLBFlutterEngine new];
#else
return [FLBFlutterEngineOld new];
#endif
}
@end
/*
* 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
/*
* 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
......@@ -33,10 +33,8 @@ NS_ASSUME_NONNULL_BEGIN
@protocol FLBAbstractFactory <NSObject>
@required
- (id<FLBFlutterApplicationInterface>)createApplication:(id<FLB2Platform>)platform;
- (id<FLB2FlutterProvider>)createFlutterProvider:(id<FLB2Platform>)platform;
- (id<FLBFlutterContainer>)createFlutterContainer;
@end
......
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