refactor: Make router static
This commit is contained in:
parent
d2247018e6
commit
d6b48091c4
3 changed files with 308 additions and 298 deletions
|
|
@ -26,6 +26,10 @@ class FluffyChatApp extends StatelessWidget {
|
|||
/// in with qr code or magic link.
|
||||
static bool gotInitialLink = false;
|
||||
|
||||
// Router must be outside of build method so that hot reload does not reset
|
||||
// the current path.
|
||||
static final GoRouter router = GoRouter(routes: AppRoutes.routes);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ThemeBuilder(
|
||||
|
|
@ -37,11 +41,11 @@ class FluffyChatApp extends StatelessWidget {
|
|||
scrollBehavior: CustomScrollBehavior(),
|
||||
localizationsDelegates: L10n.localizationsDelegates,
|
||||
supportedLocales: L10n.supportedLocales,
|
||||
routerConfig: GoRouter(routes: AppRoutes(clients).routes),
|
||||
routerConfig: router,
|
||||
builder: (context, child) => Matrix(
|
||||
context: context,
|
||||
clients: clients,
|
||||
child: child,
|
||||
child: testWidget ?? child,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -4,16 +4,20 @@ import 'package:fluffychat/config/themes.dart';
|
|||
|
||||
class SideViewLayout extends StatelessWidget {
|
||||
final Widget mainView;
|
||||
final Widget? sideView;
|
||||
final Widget sideView;
|
||||
final bool hideSideView;
|
||||
|
||||
const SideViewLayout({Key? key, required this.mainView, this.sideView})
|
||||
: super(key: key);
|
||||
const SideViewLayout({
|
||||
Key? key,
|
||||
required this.mainView,
|
||||
required this.sideView,
|
||||
required this.hideSideView,
|
||||
}) : super(key: key);
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final sideView = this.sideView;
|
||||
final hideSideView =
|
||||
!FluffyThemes.isThreeColumnMode(context) || sideView == null;
|
||||
const sideViewWidth = 360.0;
|
||||
final threeColumnMode = FluffyThemes.isThreeColumnMode(context);
|
||||
return Stack(
|
||||
children: [
|
||||
AnimatedPositioned(
|
||||
|
|
@ -22,7 +26,7 @@ class SideViewLayout extends StatelessWidget {
|
|||
top: 0,
|
||||
left: 0,
|
||||
bottom: 0,
|
||||
right: hideSideView ? 0 : sideViewWidth,
|
||||
right: !threeColumnMode || hideSideView ? 0 : sideViewWidth,
|
||||
child: ClipRRect(child: mainView),
|
||||
),
|
||||
AnimatedPositioned(
|
||||
|
|
@ -31,12 +35,10 @@ class SideViewLayout extends StatelessWidget {
|
|||
bottom: 0,
|
||||
top: 0,
|
||||
right: 0,
|
||||
left: !FluffyThemes.isThreeColumnMode(context) && sideView != null
|
||||
left: !threeColumnMode && !hideSideView ? 0 : null,
|
||||
width: hideSideView
|
||||
? 0
|
||||
: null,
|
||||
width: sideView == null
|
||||
? 0
|
||||
: !FluffyThemes.isThreeColumnMode(context)
|
||||
: !threeColumnMode
|
||||
? null
|
||||
: sideViewWidth,
|
||||
child: Container(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue