-
Notifications
You must be signed in to change notification settings - Fork 6k
Added the ability to set the initial route via launch urls. #21336
Conversation
83cd04a to
3a2ab05
Compare
f800400 to
4287dd0
Compare
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
ping @goderbauer @chunhtai |
chunhtai
left a comment
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.
Change looks good. just need a test
| #import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterAppDelegate.h" | ||
|
|
||
| #include "flutter/fml/logging.h" | ||
| #import "flutter/fml/logging.h" |
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.
How do we decide whether we use import vs include? I originally thought we always include c++ file and import objective c file
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.
If the file is objective-c or objective-c++ just always use import.
| }]; | ||
| return YES; | ||
| } else { | ||
| FML_LOG(ERROR) << "Attempting to open an URL without a Flutter RootViewController."; |
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.
In what situation this can happen?
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.
It's unlikely but if you edit the storyboard for the iOS project this could happen. Also, if you were doing add to app and you call into a FlutterAppDelegate it could be a problem.
|
@chunhtai tests added, thanks for pushing on that. |
| if ([viewController isKindOfClass:[FlutterViewController class]]) { | ||
| return (FlutterViewController*)viewController; | ||
| - (FlutterViewController*)rootFlutterViewController { | ||
| if (_rootFlutterViewControllerGetter != nil) { |
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.
Is this only used in test? It seems weird that we inject the getter this way, is it possible for the test to override this class and override this method to inject the getter there?
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.
I could, but it's the class I'm testing. In order to do that I'd have to make a partial mock of the class I actually want to test which is weird, too.
I could do more traditional dependency injection and pass in an object that can get the root FlutterViewController in with the FlutterAppDelegate's initializer. This is basically the same thing but with a setter. I wanted to introduce the least amount of overhead possible, that's why it's a pointer check that will basically be ignored with branch prediction. If I always passed the logic through a block or a protocol we would always incur a dynamic dispatch.
|
|
||
| - (void)dealloc { | ||
| [_lifeCycleDelegate release]; | ||
| [_rootFlutterViewControllerGetter release]; |
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.
This class does not create the getter, it seems weird that this class is responsible for destroying it.
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.
It actually does create it in its declaration of the property. This is related to your other comment, too. The file FlutterAppDelegate_Test is a thing called a category which allows you to extend classes or make methods selectively visible. You can think of this as declaring that property as @VisibleForTesting.
c276c88 to
43e792f
Compare
|
@chunhtai let me know what you want to do. You said "looks good" for the code but had some questions on the tests. I just want to make sure you get your concerns addressed before landing this. |
chunhtai
left a comment
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.
LGTM
…lutter#21336)" This reverts commit 25bb31e.
Description
Started setting the intiailRoute and entryPoint via launch urls if no plugin handles the URL.
Related Issues
flutter/flutter#66294 (comment)
Tests
I added the following tests:
Replace this with a list of the tests that you added as part of this PR. A
change in behaviour with no test covering it will likely get reverted
accidentally sooner or later. PRs must include tests for all
changed/updated/fixed behaviors. See testing the engine for instructions on
writing and running engine tests.
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.Breaking Change
Did any tests fail when you ran them? Please read handling breaking changes.