Commit 739e7b00 authored by Jidong Chen's avatar Jidong Chen

opt

parent bd13d022
......@@ -24,11 +24,14 @@
#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
......@@ -24,6 +24,7 @@
#import "FLBFlutterEngineOld.h"
#import "FLBFlutterViewControllerAdaptor.h"
#import <objc/runtime.h>
@interface FLBFlutterEngineOld()
@property (nonatomic,strong) FLBFlutterViewControllerAdaptor *viewController;
......@@ -31,13 +32,22 @@
@implementation FLBFlutterEngineOld
- (instancetype)init
- (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.accessibilityEnable = [platform accessibilityEnable];
[_viewController view];
Class clazz = NSClassFromString(@"GeneratedPluginRegistrant");
if (clazz) {
......
......@@ -33,12 +33,7 @@
- (instancetype)init
{
if (self = [super init]) {
Class class = [self 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);
}
return self;
}
......@@ -114,5 +109,12 @@
}
}
//- (void)onAccessibilityStatusChanged:(NSNotification*)notification {
//// if(self.accessibilityEnable){
//// [self fixed_onAccessibilityStatusChanged:notification];
//// }
//}
@end
......@@ -34,6 +34,7 @@ NS_ASSUME_NONNULL_BEGIN
@required
- (void)setAccessibilityEnable:(BOOL)enable;
- (BOOL)accessibilityEnable;
- (FlutterViewController *)viewController;
- (void)pause;
- (void)resume;
......
......@@ -25,12 +25,14 @@
#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
......
......@@ -25,11 +25,20 @@
#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
......
......@@ -61,7 +61,7 @@
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
self.platform = platform;
self.viewProvider = [[FLBViewProviderFactory new] createViewProvider];
self.viewProvider = [[FLBViewProviderFactory new] createViewProviderWithPlatform:platform];
[self.viewProvider resume];
self.isRendering = YES;
self.isRunning = YES;
......@@ -110,8 +110,6 @@
}
- (BOOL)isTop:(NSString *)pageId
{
return [_manager.peak isEqual:pageId];
......
......@@ -27,7 +27,11 @@
NS_ASSUME_NONNULL_BEGIN
@protocol FLBPlatform <NSObject>
@required
- (BOOL)accessibilityEnable;
- (void)openPage:(NSString *)name
params:(NSDictionary *)params
animated:(BOOL)animated
......
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