-
Notifications
You must be signed in to change notification settings - Fork 3
Allow a Coordinator to be requested to finish #39
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
base: main
Are you sure you want to change the base?
Changes from 5 commits
2995b19
1aef92b
1281eeb
9f5390f
ebb13ac
cabe102
dd684f9
016353e
f8b84e0
b3f9469
419e2a9
1f265fd
3c997ff
30e8eef
8a9b184
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 |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using Float.Core.Extensions; | ||
| using static Float.Core.UX.ICoordinator; | ||
|
|
||
| namespace Float.Core.UX | ||
| { | ||
|
|
@@ -117,6 +118,35 @@ public override string ToString() | |
| return $"[{GetType()}, Children: {string.Join(",", childCoordinators)}]"; | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public override CoordinatorRequestFinishStatus HandleFinishRequested(ICoordinator coordinator, EventArgs eventArgs) | ||
| { | ||
| WaitingToFinishEventArgs = eventArgs; | ||
|
|
||
| CoordinatorRequestFinishStatus? status = null; | ||
|
|
||
| foreach (var eachChild in ChildCoordinators) | ||
| { | ||
| if (eachChild is Coordinator childCoordinator) | ||
| { | ||
| var freshStatus = childCoordinator.HandleFinishRequested(this, eventArgs); | ||
|
|
||
| if (status == null) | ||
| { | ||
| status = freshStatus; | ||
| } | ||
|
|
||
| // If every child finishes with the same status we can return that, otherwise unknown seems to be the best option. | ||
| if (freshStatus != status) | ||
| { | ||
| status = CoordinatorRequestFinishStatus.Unknown; | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
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. @EBusch We're probably missing a call to the base implementation here. When you add that, you may have an issue with
|
||
| return status ?? base.HandleFinishRequested(coordinator, eventArgs); | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| protected override void Finish(EventArgs args) | ||
| { | ||
|
|
@@ -149,6 +179,12 @@ protected virtual void HandleChildFinish(object sender, EventArgs args) | |
| { | ||
| RemoveChild(child); | ||
| } | ||
|
|
||
| if (!HasChildren && WaitingToFinishEventArgs != null) | ||
| { | ||
| Finish(WaitingToFinishEventArgs); | ||
| WaitingToFinishEventArgs = null; | ||
| } | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.