Closed renefloor closed 1 year ago
SLVR: fact: go_router >=4.0.0 requires SDK version >=2.17.0 <3.0.0
I think we need to bump the SDK for the build to pass, but I think that an SDK bump should be fine.
@spydon the addition of go_router is one of the reason I could argue to separate the 'MultiBrandDashBook' in a separate package. Lot's of people are depending on go_router and you don't want to get in conflict with their version.
@spydon the addition of go_router is one of the reason I could argue to separate the 'MultiBrandDashBook' in a separate package. Lot's of people are depending on go_router and you don't want to get in conflict with their version.
Maybe we should melosify this repo so that we can have that in here too, but in a separate package. What do you think @erickzanardo?
I've played around a bit more and used it for own on Dashbook implementation. I've found at least 2 minor bugs/improvements.
Also nice to have a MaterialAppBuilder that supplies the router just if you want to customize some more things. Like this:
final MaterialAppBuilder? appBuilder;
@override
Widget build(BuildContext context) {
return appBuilder?.call(_router) ?? MaterialApp.router(
routeInformationProvider: _router.routeInformationProvider,
routeInformationParser: _router.routeInformationParser,
routerDelegate: _router.routerDelegate,
title: 'GoRouter Example',
);
}
Just a small observation, if one presses back at the wrong time it gives you this:
@erickzanardo I didn't remove the old setup, it's no breaking change. The old setup still works, I just changed the internals a bit so you can use it in multiple setups.
Closing this PR after conversation with @erickzanardo. We probably want to customise way more than just this and forking it makes more sense in that case for now. Maybe we can merge it together at some point in the future.
This PR is for discussion and inspiration.
I've done 2 main things,
1. Split the content I've moved the dashbook content from widget.dart to dashbook_content.dart. Having everything in a MaterialApp makes it very easy to build a simple dashbook, but makes it harder to customize. For example it is not possible to supply other localization delegates. Having the DashbookContent separated gives developers an option to further customize the experience to their needs. I would say that this change is very useful and cleans up the code a bit.
2. Create multibrand app (WIP) An example off the multibrand app can be found at: https://renefloor.github.io/dashbook The multi brand app enables a dev to create 1 storybook but with different theming settings. When you switch a brand the current state of the book is kept, but you have now different theming options. When the brand has 2 or more theming options the latest state is stored. In this example GoRouter is used for navigation, this enabled me to update the path in the browser. That means you can always easily navigate to a specific chapter. The url is build using {brand}/{story}/{chapter}. Even though a multibrand app might not be the core usecase of dashbook, I believe structuring navigation this way would also be an improvement for the normal dashbook. For example you can now easily go to https://renefloor.github.io/dashbook/#/hate/container/with%20padding
When you don't think step 2 should be part of this package, I would be willing to make a separate package after the changes of step 1 are published.
Couple of things not working yet: