Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@zhongwuzw
Copy link
Member

@zhongwuzw zhongwuzw commented Jan 20, 2022

In add-to-app scene, if App's root view controller is TabBarViewController, system navigator pop is not work because window's root view controller is not UINavigationController. We can use engineViewController's navigationController instead.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard
Copy link

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.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM but I would appreciate a review from @jmagman or @cyanglaz to make sure I'm not missing something here. I'm a bit rusty on the iOS world right now :)

[((UINavigationController*)viewController) popViewControllerAnimated:isAnimated];

auto engineViewController = static_cast<UIViewController*>([_engine.get() viewController]);
UINavigationController* navigationController = [engineViewController navigationController];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this fall back on UIApplication.sharedApplication.keyWindow.rootViewController if it's nil to match the old behavior?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that what it's doing on line 250?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That code path isn't calling popViewControllerAnimated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this fall back on UIApplication.sharedApplication.keyWindow.rootViewController if it's nil to match the old behavior?

Em, I think we can't match the old behavior, because if UIApplication.sharedApplication.keyWindow.rootViewController is UINavigationController but FlutterViewController's navigationController is nil, like FlutterViewController is presented, it would pop the top native view controller but not presented FlutterViewController

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see, thanks for the explanation.

Copy link
Member

@jmagman jmagman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

[((UINavigationController*)viewController) popViewControllerAnimated:isAnimated];

auto engineViewController = static_cast<UIViewController*>([_engine.get() viewController]);
UINavigationController* navigationController = [engineViewController navigationController];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see, thanks for the explanation.

@jmagman
Copy link
Member

jmagman commented Jan 22, 2022

@gaaclarke do you have any opinions?

@google-cla
Copy link

google-cla bot commented Jan 24, 2022

☹️ Sorry, but only Googlers may change the label cla: yes.

Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, I think this sounds alright. There is just a bit of cleanup needed.

@gaaclarke gaaclarke merged commit 54e1f3f into flutter:main Jan 25, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 25, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 25, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 25, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 25, 2022
UIViewController* engineViewController = [_engine.get() viewController];
UINavigationController* navigationController = [engineViewController navigationController];
if (navigationController) {
[navigationController popViewControllerAnimated:isAnimated];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果是present出来的UINavigationController而且rootViewController是FlutterViewController,这里是没办法关闭的吧?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Translation:

If it is the presented UINavigationController and the rootViewController is the FlutterViewController, there is no way to close it, right?

@rakeyang If you're seeing a specific problem related to this, please file an issue and we'll investigate. Closed PRs aren't usually monitored.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants