Added the ability to set properties in interface builder for FlutterViewController. (flutter/engine#19458)
This commit is contained in:
@@ -78,6 +78,14 @@ FLUTTER_EXPORT
|
||||
nibName:(nullable NSString*)nibName
|
||||
bundle:(nullable NSBundle*)nibBundle NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
/**
|
||||
* Initializer that is called from loading a FlutterViewController from a XIB.
|
||||
*
|
||||
* See also:
|
||||
* https://developer.apple.com/documentation/foundation/nscoding/1416145-initwithcoder?language=objc
|
||||
*/
|
||||
- (instancetype)initWithCoder:(NSCoder*)aDecoder NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
/**
|
||||
* Registers a callback that will be invoked when the Flutter view has been rendered.
|
||||
* The callback will be fired only once.
|
||||
@@ -194,6 +202,17 @@ FLUTTER_EXPORT
|
||||
*/
|
||||
@property(nonatomic, readonly) NSObject<FlutterBinaryMessenger>* binaryMessenger;
|
||||
|
||||
/**
|
||||
* If the `FlutterViewController` creates a `FlutterEngine`, this property
|
||||
* determines if that `FlutterEngine` has `allowHeadlessExecution` set.
|
||||
*
|
||||
* The intention is that this is used with the XIB. Otherwise, a
|
||||
* `FlutterEngine` can just be sent to the init methods.
|
||||
*
|
||||
* See also: `-[FlutterEngine initWithName:project:allowHeadlessExecution:]`
|
||||
*/
|
||||
@property(nonatomic, readonly) BOOL engineAllowHeadlessExecution;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -111,22 +111,26 @@ typedef enum UIAccessibilityContrast : NSInteger {
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)sharedSetupWithProject:(nullable FlutterDartProject*)project {
|
||||
_viewOpaque = YES;
|
||||
_weakFactory = std::make_unique<fml::WeakPtrFactory<FlutterViewController>>(self);
|
||||
_engine.reset([[FlutterEngine alloc] initWithName:@"io.flutter"
|
||||
project:project
|
||||
allowHeadlessExecution:self.engineAllowHeadlessExecution]);
|
||||
_flutterView.reset([[FlutterView alloc] initWithDelegate:_engine opaque:self.isViewOpaque]);
|
||||
[_engine.get() createShell:nil libraryURI:nil];
|
||||
_engineNeedsLaunch = YES;
|
||||
_ongoingTouches = [[NSMutableSet alloc] init];
|
||||
[self loadDefaultSplashScreenView];
|
||||
[self performCommonViewControllerInitialization];
|
||||
}
|
||||
|
||||
- (instancetype)initWithProject:(nullable FlutterDartProject*)project
|
||||
nibName:(nullable NSString*)nibName
|
||||
bundle:(nullable NSBundle*)nibBundle {
|
||||
self = [super initWithNibName:nibName bundle:nibBundle];
|
||||
if (self) {
|
||||
_viewOpaque = YES;
|
||||
_weakFactory = std::make_unique<fml::WeakPtrFactory<FlutterViewController>>(self);
|
||||
_engine.reset([[FlutterEngine alloc] initWithName:@"io.flutter"
|
||||
project:project
|
||||
allowHeadlessExecution:NO]);
|
||||
_flutterView.reset([[FlutterView alloc] initWithDelegate:_engine opaque:self.isViewOpaque]);
|
||||
[_engine.get() createShell:nil libraryURI:nil];
|
||||
_engineNeedsLaunch = YES;
|
||||
_ongoingTouches = [[NSMutableSet alloc] init];
|
||||
[self loadDefaultSplashScreenView];
|
||||
[self performCommonViewControllerInitialization];
|
||||
[self sharedSetupWithProject:project];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -137,7 +141,15 @@ typedef enum UIAccessibilityContrast : NSInteger {
|
||||
}
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder*)aDecoder {
|
||||
return [self initWithProject:nil nibName:nil bundle:nil];
|
||||
self = [super initWithCoder:aDecoder];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)awakeFromNib {
|
||||
[super awakeFromNib];
|
||||
if (!_engine.get()) {
|
||||
[self sharedSetupWithProject:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
|
||||
Reference in New Issue
Block a user