-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix syncing modal stack when the window is created/recreated #13025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
5091d36
Better sync modal stack on startup
PureWeen d4233a5
- fix up windows modal paths
PureWeen 1ec4e36
- simplify window and add shell tests
PureWeen eaf5575
- add more tests and fix appearing on window
PureWeen abd613f
- cleanup from comments
PureWeen afc1289
- fix tizen
PureWeen f487f60
Update ModalNavigationManager.Tizen.cs
PureWeen e42c881
Update ModalNavigationManager.Tizen.cs
PureWeen cd7b81a
- review comment fixes
PureWeen 54930f8
- remove the if
PureWeen da2bfc6
- add comments
PureWeen f29c92a
- more tests and more code
PureWeen 8c2cebd
- fix up iOS tests
PureWeen 89f3946
- see if this fixes crash on CI
PureWeen e11e7c5
- fix tests
PureWeen fa05ab3
- more tests and fixes for iOS
PureWeen 191f943
Auto-format source code
7a08feb
- fix ordering for replacing root view
PureWeen 6df3b51
- fix scoped fragments
PureWeen d81e3a4
- cleanup code
PureWeen 6f5c3bd
- clarify
PureWeen 3c17453
Merge branch 'main' into fix_modal_syncing
PureWeen c95a7f1
- remove if/debug for window lifecycle exceptions
PureWeen e23da1c
Merge branch 'main' into fix_modal_syncing
PureWeen 2de9c5e
- fix unit test
PureWeen 52b02f8
Merge branch 'main' into fix_modal_syncing
PureWeen bce95de
- cleanup modalwrapper
PureWeen f4fbc5c
- add loaded and unloaded
PureWeen 334b129
Merge branch 'main' into fix_modal_syncing
PureWeen 2a9a11a
- Add better exception if user calls pop modal with no modal page pre…
PureWeen 30ffd8d
- fix test code for dismissing modals
PureWeen c74b697
Merge branch 'main' into fix_modal_syncing
PureWeen bf2e4b5
Merge branch 'main' into fix_modal_syncing
PureWeen 43c148b
- fix define on MaybeNull
PureWeen ee78b12
Merge branch 'main' into fix_modal_syncing
PureWeen ac1e149
- fix up tests related to keyboard
PureWeen 9a39a53
- fix compile error on compatibility
PureWeen a956239
- fix timing of setting parent on modal page
PureWeen 2c45ed8
- fix shell and add tests
PureWeen 2a49b9a
Auto-format source code
f05b2ba
Merge branch 'main' into fix_modal_syncing
PureWeen d39d677
- fix retrieving of CurrentPage
PureWeen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -417,16 +417,19 @@ internal void FinishedAddingWindowToApplication(Application application) | |
|
|
||
| void SendWindowAppearing() | ||
| { | ||
| Page?.SendAppearing(); | ||
| if (Navigation.ModalStack.Count == 0) | ||
| Page?.SendAppearing(); | ||
| } | ||
|
|
||
| void SendWindowDisppearing() | ||
| { | ||
| Page?.SendDisappearing(); | ||
| if (Navigation.ModalStack.Count == 0) | ||
| Page?.SendDisappearing(); | ||
|
|
||
| IsActivated = false; | ||
| } | ||
|
|
||
| void OnModalPopped(Page modalPage) | ||
| internal void OnModalPopped(Page modalPage) | ||
| { | ||
| int index = _visualChildren.IndexOf(modalPage); | ||
| _visualChildren.Remove(modalPage); | ||
|
|
@@ -438,15 +441,15 @@ void OnModalPopped(Page modalPage) | |
| VisualDiagnostics.OnChildRemoved(this, modalPage, index); | ||
| } | ||
|
|
||
| bool OnModalPopping(Page modalPage) | ||
| internal bool OnModalPopping(Page modalPage) | ||
| { | ||
| var args = new ModalPoppingEventArgs(modalPage); | ||
| ModalPopping?.Invoke(this, args); | ||
| Application?.NotifyOfWindowModalEvent(args); | ||
| return args.Cancel; | ||
| } | ||
|
|
||
| void OnModalPushed(Page modalPage) | ||
| internal void OnModalPushed(Page modalPage) | ||
| { | ||
| _visualChildren.Add(modalPage); | ||
| var args = new ModalPushedEventArgs(modalPage); | ||
|
|
@@ -455,21 +458,25 @@ void OnModalPushed(Page modalPage) | |
| VisualDiagnostics.OnChildAdded(this, modalPage); | ||
| } | ||
|
|
||
| void OnModalPushing(Page modalPage) | ||
| internal void OnModalPushing(Page modalPage) | ||
| { | ||
| var args = new ModalPushingEventArgs(modalPage); | ||
| ModalPushing?.Invoke(this, args); | ||
| Application?.NotifyOfWindowModalEvent(args); | ||
| } | ||
|
|
||
| void OnPopCanceled() | ||
| internal void OnPopCanceled() | ||
| { | ||
| PopCanceled?.Invoke(this, EventArgs.Empty); | ||
| } | ||
|
|
||
| void IWindow.Created() | ||
| { | ||
| if (IsCreated) | ||
| throw new InvalidOperationException("Window was already created"); | ||
PureWeen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| IsCreated = true; | ||
| IsDestroyed = false; | ||
|
|
||
| Created?.Invoke(this, EventArgs.Empty); | ||
| OnCreated(); | ||
|
|
@@ -478,13 +485,19 @@ void IWindow.Created() | |
|
|
||
| void IWindow.Activated() | ||
| { | ||
| if (IsActivated) | ||
| throw new InvalidOperationException("Window was already activated"); | ||
|
|
||
| IsActivated = true; | ||
| Activated?.Invoke(this, EventArgs.Empty); | ||
| OnActivated(); | ||
| } | ||
|
|
||
| void IWindow.Deactivated() | ||
| { | ||
| if (!IsActivated) | ||
| throw new InvalidOperationException("Window was already deactivated"); | ||
|
|
||
| IsActivated = false; | ||
| Deactivated?.Invoke(this, EventArgs.Empty); | ||
| OnDeactivated(); | ||
|
|
@@ -499,7 +512,12 @@ void IWindow.Stopped() | |
|
|
||
| void IWindow.Destroying() | ||
| { | ||
| if (IsDestroyed) | ||
| throw new InvalidOperationException("Window was already destroyed"); | ||
|
|
||
| IsDestroyed = true; | ||
| IsCreated = false; | ||
|
|
||
| SendWindowDisppearing(); | ||
| Destroying?.Invoke(this, EventArgs.Empty); | ||
| OnDestroying(); | ||
|
|
@@ -613,8 +631,6 @@ void OnPageChanged(Page? oldPage, Page? newPage) | |
| _menuBarTracker.Target = newPage; | ||
| } | ||
|
|
||
| ModalNavigationManager.SettingNewPage(); | ||
|
|
||
| if (newPage != null) | ||
| { | ||
| newPage.HandlerChanged += OnPageHandlerChanged; | ||
|
|
@@ -676,58 +692,14 @@ protected override IReadOnlyList<Page> GetModalStack() | |
| return _owner.ModalNavigationManager.ModalStack; | ||
| } | ||
|
|
||
| protected override async Task<Page?> OnPopModal(bool animated) | ||
| protected override Task<Page?> OnPopModal(bool animated) | ||
| { | ||
| Page modal = _owner.ModalNavigationManager.ModalStack[_owner.ModalNavigationManager.ModalStack.Count - 1]; | ||
| if (_owner.OnModalPopping(modal)) | ||
| { | ||
| _owner.OnPopCanceled(); | ||
| return null; | ||
| } | ||
|
|
||
| Page? nextPage; | ||
| if (modal.NavigationProxy.ModalStack.Count == 1) | ||
| { | ||
| nextPage = _owner.Page; | ||
| } | ||
| else | ||
| { | ||
| nextPage = _owner.ModalNavigationManager.ModalStack[_owner.ModalNavigationManager.ModalStack.Count - 2]; | ||
| } | ||
|
|
||
| Page result = await _owner.ModalNavigationManager.PopModalAsync(animated); | ||
| result.Parent = null; | ||
| _owner.OnModalPopped(result); | ||
|
|
||
| modal.SendNavigatedFrom(new NavigatedFromEventArgs(nextPage)); | ||
| nextPage?.SendNavigatedTo(new NavigatedToEventArgs(modal)); | ||
|
|
||
| return result; | ||
| return _owner.ModalNavigationManager.PopModalAsync(animated); | ||
|
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. I moved all of this code into |
||
| } | ||
|
|
||
| protected override async Task OnPushModal(Page modal, bool animated) | ||
| protected override Task OnPushModal(Page modal, bool animated) | ||
| { | ||
| _owner.OnModalPushing(modal); | ||
|
|
||
| modal.Parent = _owner; | ||
|
|
||
| if (modal.NavigationProxy.ModalStack.Count == 0) | ||
| { | ||
| modal.NavigationProxy.Inner = this; | ||
| await _owner.ModalNavigationManager.PushModalAsync(modal, animated); | ||
| _owner.Page?.SendNavigatedFrom(new NavigatedFromEventArgs(modal)); | ||
| modal.SendNavigatedTo(new NavigatedToEventArgs(_owner.Page)); | ||
| } | ||
| else | ||
| { | ||
| var previousModalPage = modal.NavigationProxy.ModalStack[modal.NavigationProxy.ModalStack.Count - 1]; | ||
| await _owner.ModalNavigationManager.PushModalAsync(modal, animated); | ||
| modal.NavigationProxy.Inner = this; | ||
| previousModalPage.SendNavigatedFrom(new NavigatedFromEventArgs(modal)); | ||
| modal.SendNavigatedTo(new NavigatedToEventArgs(previousModalPage)); | ||
| } | ||
|
|
||
| _owner.OnModalPushed(modal); | ||
| return _owner.ModalNavigationManager.PushModalAsync(modal, animated); | ||
| } | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.