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

opt

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