Skip to content
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

refactor(gui): Enhanced navigation in preparation for Landscape config #417

Merged
merged 13 commits into from
Nov 22, 2023

Conversation

CarlosNihelton
Copy link
Contributor

This PR looks quite silly. Adding the wizard_router dependency for so few routes seem overkill. But the addition of the Landscape config page along with the UI redesign foreseeable in this Figma design will require a more structured and yet flexible navigation/routing scheme.

I believe wizard_router comes in very handy to the rescue due its declarative approach.

Beware that I didn't start yet to update the UI to match the design shown in Figma.

Most of the time the app is expected to navigate from the /startup route straight into the last page of the wizard (the "Subscription Status" page) due the user being somehow subscribed to Pro.

But when there is no active subscription information, the "Subscribe now" page must be shown instead. It allows either applying a pro token manually or acquiring one via a purchase (through MS Store). In both scenarios, there is the option of navigating to the "Config Landscape" page (not yet implemented, but shown in Figma). When either of the two possibilities of subscription (manual token applied or purchased via MS Store) is active, then the "Configure Landscape" button must be present, allowing the user to set or update the Landscape client settings. That requires being able to navigate to the Landscape config page and back.

That could be done with the plain Flutter Navigator API 1.0, but I believe the wizard allows a more declarative approach, easier to reason about, thus that's why I'm investing in it right now.

Notice that I also leverage the WizardRoute's onLoad callback to fetch the latest subscription information from the background agent before showing the page that is most sensitive to that data (the "Subscription status" page). That's a natural fit in my opinion. Previously, that piece of code was mixed up with other business, which didn't feel quite right.

This PR doesn't change any observable behavior, just adds room for more flexible and declarative routing.

Closes UDENG-1783

P.S.: We'll add Landscape config at next. Who knows what creative additions we'll find relevant in the near future ;)

No longer need to import directly from git
Version 0.1.5 already contains the Flutter >3.13 required fixes.
Adding that page is not scope of this PR.
Yet, it's due it that the routing needs to change.
Having the routes defined clarifies the reasoning behind this PR.
No change in behavior so far.
This adds room for more flexible and structured navigation/routing.
Soon Landscape config page will demand such solution.
By calling Wizard.of(context).next()
It doesn't matter anymore which destination it is.
The page calls init already.
Awaiting pumpAndSettle is enough.
SubscriptionStatusPage is sensitive to the current SubscriptionInfo
coming from the background agent.
WizardRoute.onLoad is a natural place to get this kind of information.
Everytime the wizard loads this route, a gRPC call is done
to fetch the latest information.
As a side effect the buildStartup local function becomes simpler.
This exception should no longer be expected.
@CarlosNihelton CarlosNihelton marked this pull request as ready for review November 21, 2023 18:16
Copy link
Member

@d-loose d-loose left a comment

Choose a reason for hiding this comment

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

Besides the small comment above, this looks very good to me! It definitely makes sense to use the wizard here since it simplifies things quite a bit :)

The builder parameter of the MaterialApp constructor does the job.
There is a side effect of not creating the root Navigator.
Which is good since we only rely on the Wizard now.
@CarlosNihelton CarlosNihelton self-assigned this Nov 22, 2023
@CarlosNihelton CarlosNihelton merged commit 12b9f91 into main Nov 22, 2023
32 checks passed
@CarlosNihelton CarlosNihelton deleted the enhanced-navigation-udeng-1783 branch November 22, 2023 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants