Commit b5ef7160 authored by Jidong Chen's avatar Jidong Chen

almost done

parent 5173dd21
......@@ -126,10 +126,5 @@
[self.viewProvider inactive];
}
- (void)setAccessibilityEnable:(BOOL)enable
{
[self.viewProvider setAccessibilityEnable:enable];
}
@end
......@@ -47,11 +47,6 @@
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");
......
......@@ -25,21 +25,20 @@
#import <Foundation/Foundation.h>
@class FlutterViewController;
@class FlutterEngine;
NS_ASSUME_NONNULL_BEGIN
#define RELEASE_1_0 1
#define RELEASE_1_0 0
@protocol FLBFlutterProvider <NSObject>
@protocol FLBFlutterViewProvider <NSObject>
@required
- (FlutterViewController *)viewController;
- (void)pause;
- (void)resume;
- (void)inactive;
- (void)prepareEngineIfNeeded;
@end
NS_ASSUME_NONNULL_END
......@@ -29,10 +29,12 @@
#import "FLBMemoryInspector.h"
#import "Service_NavigationService.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
#define FLUTTER_VIEW [FLBFlutterApplication sharedApplication].flutterViewController.view
#define FLUTTER_VC [FLBFlutterApplication sharedApplication].flutterViewController
#define FLUTTER_APP [FLBFlutterApplication sharedApplication]
@interface FLBFlutterViewContainer ()
@property (nonatomic,copy,readwrite) NSString *name;
......@@ -77,7 +79,7 @@ static NSUInteger kInstanceCounter = 0;
kInstanceCounter--;
if([self.class instanceCounter] == 0){
[[FLBStackCache sharedInstance] clear];
[[FLBFlutterApplication sharedApplication] pause];
[FLUTTER_APP pause];
}
}
......@@ -143,7 +145,7 @@ static NSUInteger kInstanceCounter = 0;
uniqueId:[self uniqueIDString]];
[[FLBStackCache sharedInstance] remove:self.uniqueIDString];
[[FLBFlutterApplication sharedApplication] removeViewController:self];
[FLUTTER_APP removeViewController:self];
[self.class instanceCounterDecrease];
}
......@@ -290,7 +292,7 @@ static NSUInteger kInstanceCounter = 0;
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
[[FLBFlutterApplication sharedApplication] resume];
[FLUTTER_APP resume];
}
- (void)viewWillAppear:(BOOL)animated
......@@ -299,10 +301,10 @@ static NSUInteger kInstanceCounter = 0;
self.interactiveGestureActive = true;
}
[[FLBFlutterApplication sharedApplication] resume];
[FLUTTER_APP resume];
//For new page we should attach flutter view in view will appear
//for better performance.
if(![[FLBFlutterApplication sharedApplication] contains:self]){
if(![FLUTTER_APP contains:self]){
[self attatchFlutterView];
}
......@@ -313,10 +315,10 @@ static NSUInteger kInstanceCounter = 0;
params:_params
uniqueId:self.uniqueIDString];
//Save some first time page info.
if(![FlutterBoostConfig sharedInstance].fPagename){
[FlutterBoostConfig sharedInstance].fPagename = _name;
[FlutterBoostConfig sharedInstance].fPageId = self.uniqueIDString;
[FlutterBoostConfig sharedInstance].fParams = _params;
if(![FlutterBoostPlugin sharedInstance].fPagename){
[FlutterBoostPlugin sharedInstance].fPagename = _name;
[FlutterBoostPlugin sharedInstance].fPageId = self.uniqueIDString;
[FlutterBoostPlugin sharedInstance].fParams = _params;
}
[super viewWillAppear:animated];
......@@ -324,7 +326,7 @@ static NSUInteger kInstanceCounter = 0;
- (void)viewDidAppear:(BOOL)animated
{
[[FLBFlutterApplication sharedApplication] resume];
[FLUTTER_APP resume];
//Ensure flutter view is attached.
[self attatchFlutterView];
......@@ -334,7 +336,7 @@ static NSUInteger kInstanceCounter = 0;
params:_params
uniqueId:self.uniqueIDString];
[[FLBFlutterApplication sharedApplication] addUniqueViewController:self];
[FLUTTER_APP addUniqueViewController:self];
[super viewDidAppear:animated];
......
......@@ -32,7 +32,6 @@ NS_ASSUME_NONNULL_BEGIN
- (void)boost_viewWillDisappear:(BOOL)animated;
- (void)boost_viewDidDisappear:(BOOL)animated;
@property (nonatomic,assign) BOOL accessibilityEnable;
@end
......
......@@ -95,11 +95,5 @@
//Override this to avoid unnecessary splash Screen.
}
- (void)fixed_onAccessibilityStatusChanged:(NSNotification*)notification {
if(self.accessibilityEnable){
[self fixed_onAccessibilityStatusChanged:notification];
}
}
@end
......@@ -33,8 +33,6 @@ NS_ASSUME_NONNULL_BEGIN
@protocol FLBFlutterViewProvider <NSObject>
@required
- (void)setAccessibilityEnable:(BOOL)enable;
- (BOOL)accessibilityEnable;
- (FlutterViewController *)viewController;
- (void)pause;
- (void)resume;
......
......@@ -23,7 +23,6 @@
*/
#import "FLBViewProviderFactory.h"
#import "FLBFlutterEngine.h"
#import "FLBFlutterEngineOld.h"
#import "FLBPlatform.h"
......
......@@ -23,10 +23,11 @@
*/
#import <Foundation/Foundation.h>
#import "FLBAbstractFactory.h"
NS_ASSUME_NONNULL_BEGIN
@interface FLB2Factory : NSObject
@interface FLB2Factory : NSObject<FLBAbstractFactory>
@end
......
//
// FLBFactory.m
// flutter_boost
//
// Created by Jidong Chen on 2019/6/11.
//
/*
* 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 "FLB2Factory.h"
#import "FLB2FlutterApplication.h"
#import "FLB2FlutterViewContainer.h"
@implementation FLB2Factory
- (id<FLBFlutterApplicationInterface>)createApplication:(id<FLB2Platform>)platform
{
return FLB2FlutterApplication.new;
}
- (id<FLBFlutterContainer>)createFlutterContainer
{
return FLB2FlutterViewContainer.new;
}
@end
......@@ -32,27 +32,6 @@
NS_ASSUME_NONNULL_BEGIN
@interface FLB2FlutterApplication : NSObject<FLBFlutterApplicationInterface>
@property (nonatomic,strong) id<FLB2Platform> platform;
- (id<FLB2FlutterProvider>)flutterProvider;
#pragma mark - Getters
+ (FLB2FlutterApplication *)sharedApplication;
- (void)startFlutterWithPlatform:(id<FLB2Platform>)platform
onStart:(void (^)(FlutterEngine * _Nonnull))callback;
- (FlutterViewController *)flutterViewController;
#pragma mark - Container Management
- (BOOL)contains:(FLB2FlutterViewContainer *)vc;
- (void)addUniqueViewController:(FLB2FlutterViewContainer *)vc;
- (void)removeViewController:(FLB2FlutterViewContainer *)vc;
- (BOOL)isTop:(NSString *)pageId;
#pragma mark - App Control
- (void)pause;
- (void)resume;
- (void)inactive;
- (BOOL)isRunning;
@end
NS_ASSUME_NONNULL_END
......@@ -30,7 +30,6 @@
@property (nonatomic,strong) FLBFlutterContainerManager *manager;
@property (nonatomic,strong) id<FLB2FlutterProvider> viewProvider;
@property (nonatomic,strong) NSMutableDictionary *pageBuilders;
@property (nonatomic,assign) BOOL isRunning;
@end
......@@ -58,7 +57,7 @@
}
- (void)startFlutterWithPlatform:(id<FLB2Platform>)platform
onStart:(void (^)(FlutterEngine * _Nonnull))callback
onStart:(void (^)(id<FlutterBinaryMessenger,FlutterTextureRegistry,FlutterPluginRegistry> _Nonnull))callback
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
......@@ -73,7 +72,6 @@
{
if (self = [super init]) {
_manager = [FLBFlutterContainerManager new];
_pageBuilders = [NSMutableDictionary new];
}
return self;
}
......@@ -89,17 +87,17 @@
}
- (BOOL)contains:(FLB2FlutterViewContainer *)vc
- (BOOL)contains:(id<FLBFlutterContainer>)vc
{
return [_manager contains:vc];
}
- (void)addUniqueViewController:(FLB2FlutterViewContainer *)vc
- (void)addUniqueViewController:(id<FLBFlutterContainer>)vc
{
return [_manager addUnique:vc];
}
- (void)removeViewController:(FLB2FlutterViewContainer *)vc
- (void)removeViewController:(id<FLBFlutterContainer>)vc
{
return [_manager remove:vc];
}
......
......@@ -28,9 +28,9 @@
#import "FLBFlutterContainerManager.h"
#import "FlutterBoostPlugin_private.h"
#define FLUTTER_VIEW [FLB2FlutterApplication sharedApplication].flutterViewController.view
#define FLUTTER_VC [FLB2FlutterApplication sharedApplication].flutterViewController
#define FLUTTER_APP [FLB2FlutterApplication sharedApplication]
#define FLUTTER_APP [FlutterBoostPlugin sharedInstance].application
#define FLUTTER_VIEW FLUTTER_APP.flutterViewController.view
#define FLUTTER_VC FLUTTER_APP.flutterViewController
@interface FLB2FlutterViewContainer ()
@property (nonatomic,copy,readwrite) NSString *name;
......@@ -91,7 +91,7 @@ static NSUInteger kInstanceCounter = 0;
{
kInstanceCounter--;
if([self.class instanceCounter] == 0){
// [[FLBFlutterApplication sharedApplication] pause];
// [FLUTTER_APP pause];
}
}
......@@ -119,7 +119,7 @@ static NSUInteger kInstanceCounter = 0;
pageName:_name params:_params
uniqueId:[self uniqueIDString]];
[[FLB2FlutterApplication sharedApplication] removeViewController:self];
[FLUTTER_APP removeViewController:self];
[self.class instanceCounterDecrease];
}
......@@ -152,7 +152,7 @@ static NSUInteger kInstanceCounter = 0;
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
[[FLB2FlutterApplication sharedApplication] resume];
[FLUTTER_APP resume];
}
- (void)viewWillAppear:(BOOL)animated
......@@ -163,7 +163,7 @@ static NSUInteger kInstanceCounter = 0;
[self attatchFlutterEngine];
}
[[FLB2FlutterApplication sharedApplication] resume];
[FLUTTER_APP resume];
[self surfaceUpdated:YES];
//For new page we should attach flutter view in view will appear
......
......@@ -23,7 +23,7 @@
*/
#import <Foundation/Foundation.h>
#import "FLBFlutterProvider.h"
#import "FLBFlutterViewProvider.h"
@class FlutterViewController;
@class FlutterEngine;
......@@ -32,16 +32,12 @@ NS_ASSUME_NONNULL_BEGIN
#define RELEASE_1_0 1
@protocol FLB2FlutterProvider <FLBFlutterProvider>
@protocol FLB2FlutterProvider <FLBFlutterViewProvider>
@required
- (FlutterEngine *)engine;
- (void)atacheToViewController:(FlutterViewController *)vc;
- (void)detach;
- (void)pause;
- (void)resume;
- (void)inactive;
- (void)prepareEngineIfNeeded;
@end
......
......@@ -30,8 +30,7 @@ NS_ASSUME_NONNULL_BEGIN
@protocol FLB2Platform <FLBPlatform>
@optional
//Whether to enable accessibility support. Default value is Yes.
- (BOOL)accessibilityEnable;
- (BOOL)userBoost2;
@required
- (void)openPage:(NSString *)name
......
//
// FLBFlutterContainer.h
// flutter_boost
//
// Created by Jidong Chen on 2019/6/11.
//
/*
* 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>
......
......@@ -28,10 +28,6 @@ NS_ASSUME_NONNULL_BEGIN
@protocol FLBPlatform <NSObject>
@optional
//Whether to enable accessibility support. Default value is Yes.
- (BOOL)accessibilityEnable;
@required
- (void)openPage:(NSString *)name
params:(NSDictionary *)params
......
......@@ -25,6 +25,8 @@
#import "FlutterBoostPlugin.h"
#import "FLBResultMediator.h"
#import "FlutterBoostPlugin_private.h"
#import "FLBFactory.h"
#import "FLB2Factory.h"
@implementation FlutterBoostPlugin
......@@ -70,9 +72,18 @@
FlutterTextureRegistry,
FlutterPluginRegistry> engine))callback;
{
//TODO:
[self.application startFlutterWithPlatform:platform
onStart:callback];
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
if([platform respondsToSelector:@selector(userBoost2)] && platform.userBoost2){
_factory = FLB2Factory.new;
}else{
_factory = FLBFactory.new;
}
_application = [_factory createApplication:platform];
[_application startFlutterWithPlatform:platform onStart:callback];
});
}
- (BOOL)isRunning
......
......@@ -27,12 +27,15 @@
#import "FLBResultMediator.h"
#import "FLBAbstractFactory.h"
@interface FlutterBoostPlugin()
@interface FlutterBoostPlugin(){
id<FLBFlutterApplicationInterface> _application;
FLBResultMediator *_resultMediator;
id<FLBAbstractFactory> _factory;
}
- (id<FLBFlutterApplicationInterface>)application;
@property (nonatomic,strong) FLBResultMediator *resultMediator;
@property (nonatomic,strong) id<FLBAbstractFactory> factory;
- (FLBResultMediator *)resultMediator;
- (id<FLBAbstractFactory>)factory;
@property (nonatomic,copy) NSString *fPageId;
@property (nonatomic,copy) NSString *fPagename;
......
......@@ -24,9 +24,11 @@
//Generated by AIOCodeGen.
#import "ServiceGateway.h"
#import "NavigationService_closePage.h"
#import "FLB2FlutterApplication.h"
#import "ServiceGateway.h"
#import "NavigationService_closePage.h"
#import "FlutterBoostPlugin_private.h"
#define FLUTTER_APP [FlutterBoostPlugin sharedInstance].application
@implementation NavigationService_closePage
......@@ -37,7 +39,7 @@
animated:(NSNumber *)animated
{
//Add your handler code here!
[[FLB2FlutterApplication sharedApplication].platform closePage:uniqueId
[FLUTTER_APP.platform closePage:uniqueId
animated:animated.boolValue
params:params
completion:^(BOOL finished) {
......
......@@ -24,17 +24,18 @@
//Generated by AIOCodeGen.
#import "ServiceGateway.h"
#import "NavigationService_openPage.h"
#import "FLB2FlutterApplication.h"
#import "FlutterBoost.h"
#import "ServiceGateway.h"
#import "NavigationService_openPage.h"
#import "Service_NavigationService.h"
#import "FlutterBoostPlugin_private.h"
#define FLUTTER_APP [FlutterBoostPlugin sharedInstance].application
@implementation NavigationService_openPage
- (void)onCall:(void (^)(BOOL))result pageName:(NSString *)pageName params:(NSDictionary *)params animated:(NSNumber *)animated
{
[[FLB2FlutterApplication sharedApplication].platform openPage:pageName
[FLUTTER_APP.platform openPage:pageName
params:params
animated:animated.boolValue
completion:^(BOOL finished) {
......
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