-
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
Changes from 2 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,5 +1,6 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Threading.Tasks; | ||
| using Float.Core.Extensions; | ||
|
|
||
| namespace Float.Core.UX | ||
|
|
@@ -15,6 +16,11 @@ public abstract class CoordinatorParent : Coordinator, ICoordinatorParent | |
| /// </summary> | ||
| readonly List<ICoordinator> childCoordinators = new (); | ||
|
|
||
| /// <summary> | ||
| /// The event args that have been used as we are waiting to finish all the children before closing the parent. | ||
| /// </summary> | ||
| EventArgs waitingToFinishEventArgs = null; | ||
|
|
||
|
EBusch marked this conversation as resolved.
Outdated
|
||
| /// <summary> | ||
| /// Gets a value indicating whether this <see cref="CoordinatorParent"/> has children. | ||
| /// </summary> | ||
|
|
@@ -117,6 +123,33 @@ public override string ToString() | |
| return $"[{GetType()}, Children: {string.Join(",", childCoordinators)}]"; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Handles the finish request. | ||
| /// </summary> | ||
| /// <param name="coordinator">The calling coordinator.</param> | ||
| /// <param name="eventArgs">The event args.</param> | ||
| /// <returns>A value indicating whether this finished.</returns> | ||
|
EBusch marked this conversation as resolved.
Outdated
|
||
| public override bool HandleFinishRequested(ICoordinator coordinator, EventArgs eventArgs) | ||
| { | ||
| var didFinish = true; | ||
|
|
||
| waitingToFinishEventArgs = eventArgs; | ||
|
|
||
| foreach (var eachChild in ChildCoordinators) | ||
| { | ||
| if (eachChild is Coordinator childCoordinator) | ||
| { | ||
| var finished = childCoordinator.HandleFinishRequested(childCoordinator, eventArgs); | ||
|
EBusch marked this conversation as resolved.
Outdated
|
||
| if (!finished) | ||
| { | ||
| didFinish = false; | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
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 didFinish; | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| protected override void Finish(EventArgs args) | ||
| { | ||
|
|
@@ -149,6 +182,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.