Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ FLUTTER_EXPORT
*
* @param asset The name of the asset. The name can be hierarchical.
* @param package The name of the package from which the asset originates.
* @returns: The file name to be used for lookup in the main bundle.
* @return The file name to be used for lookup in the main bundle.
*/
- (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package;

Expand Down Expand Up @@ -129,15 +129,19 @@ FLUTTER_EXPORT
* a replacement until the first frame is rendered.
*
* The view used should be appropriate for multiple sizes; an autoresizing mask to
* have a flexible
* width and height will be applied automatically.
*
* If not specified, uses a view generated from `UILaunchStoryboardName` from the
* main bundle's
* `Info.plist` file.
* have a flexible width and height will be applied automatically.
*/
@property(strong, nonatomic) UIView* splashScreenView;

/**
* Attempts to set the `splashScreenView` property from the `UILaunchStoryboardName` from the
* main bundle's `Info.plist` file. This method will not change the value of `splashScreenView`
* if it cannot find a default one from a storyboard or nib.
*
* @return `YES` if successful, `NO` otherwise.
*/
- (BOOL)loadDefaultSplashScreenView;

/**
* Controls whether the created view will be opaque or not.
*
Expand Down
42 changes: 22 additions & 20 deletions shell/platform/darwin/ios/framework/Source/FlutterViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ - (void)loadView {
- (void)installSplashScreenViewIfNecessary {
// Show the launch screen view again on top of the FlutterView if available.
// This launch screen view will be removed once the first Flutter frame is rendered.
if (self.isBeingPresented || self.isMovingToParentViewController) {
if (_splashScreenView && (self.isBeingPresented || self.isMovingToParentViewController)) {
[_splashScreenView.get() removeFromSuperview];
_splashScreenView.reset();
return;
Expand Down Expand Up @@ -305,21 +305,29 @@ - (FlutterView*)flutterView {
}

- (UIView*)splashScreenView {
if (_splashScreenView == nullptr) {
NSString* launchscreenName =
[[[NSBundle mainBundle] infoDictionary] objectForKey:@"UILaunchStoryboardName"];
if (launchscreenName == nil) {
return nil;
}
UIView* splashView = [self splashScreenFromStoryboard:launchscreenName];
if (!splashView) {
splashView = [self splashScreenFromXib:launchscreenName];
}
self.splashScreenView = splashView;
if (!_splashScreenView) {
return nil;
}
return _splashScreenView.get();
}

- (BOOL)loadDefaultSplashScreenView {
NSString* launchscreenName =
[[[NSBundle mainBundle] infoDictionary] objectForKey:@"UILaunchStoryboardName"];
if (launchscreenName == nil) {
return NO;
}
UIView* splashView = [self splashScreenFromStoryboard:launchscreenName];
if (!splashView) {
splashView = [self splashScreenFromXib:launchscreenName];
}
if (!splashView) {
return NO;
}
self.splashScreenView = splashView;
return YES;
}

- (UIView*)splashScreenFromStoryboard:(NSString*)name {
UIStoryboard* storyboard = nil;
@try {
Expand Down Expand Up @@ -347,16 +355,10 @@ - (void)setSplashScreenView:(UIView*)view {
if (!view) {
// Special case: user wants to remove the splash screen view.
[self removeSplashScreenViewIfPresent];
} else if (_splashScreenView) {
FML_LOG(ERROR) << "Attempt to set the FlutterViewController's splash screen multiple times was "
"ignored. The FlutterViewController's splash screen can only be set once. "
"This condition can occur if a running FlutterEngine instance has been "
"passed into the FlutterViewController and a consumer later called "
"[FlutterViewController setSplashScreen:]. Setting the splash screen on a "
"FlutterViewController with an already running engine is not supported, as "
"the rasterizer will already be running by the time the view is shown.";
_splashScreenView.reset();
return;
}

_splashScreenView.reset([view retain]);
_splashScreenView.get().autoresizingMask =
UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
Expand Down