-
Notifications
You must be signed in to change notification settings - Fork 6k
Added the ability to set properties in interface builder for FlutterViewController #19458
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,22 +111,26 @@ - (instancetype)initWithEngine:(FlutterEngine*)engine | |
| 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" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How is this working? Where is
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. _engine is now set in
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, to be clear, |
||
| 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 @@ - (instancetype)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBun | |
| } | ||
|
|
||
| - (instancetype)initWithCoder:(NSCoder*)aDecoder { | ||
| return [self initWithProject:nil nibName:nil bundle:nil]; | ||
| self = [super initWithCoder:aDecoder]; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The properties should be pulled off _viewOpaque = aDecoder->_viewOpaque;
_weakFactory = aDecoder->_weakFactory;
_engine = aDecoder->_engine;
_flutterView = aDecoder->_flutterView;
_isDisplayingFlutterUI = [aDecoder decodeObjectForKey:@"isDisplayingFlutterUI"];
_isHomeIndicatorHidden = [aDecoder decodeObjectForKey:@"isHomeIndicatorHidden"];
_isPresentingViewControllerAnimating = [aDecoder decodeObjectForKey:@"isPresentingViewControllerAnimating"];not re-set up as if it's a newly initialized object (it's being deserialized).
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The NSCoder doesn't have a representation of a full object. It just has what is coming from the xib, so it won't have things like a _weakFactory. The default initWithCoder will use key-value to set properties that have been specified in the xib, you don't need to create custom readers for them.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I never did grok |
||
| return self; | ||
| } | ||
|
|
||
| - (void)awakeFromNib { | ||
| [super awakeFromNib]; | ||
| if (!_engine.get()) { | ||
| [self sharedSetupWithProject:nil]; | ||
| } | ||
| } | ||
|
|
||
| - (instancetype)init { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't
_enginenilhere?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_engine is a smart pointer, it represents nil until this reset function is called on it.