2024-08-18 17:35:38 +00:00
|
|
|
import 'package:firebase_analytics/firebase_analytics.dart';
|
2024-07-06 12:55:53 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2024-07-12 05:15:46 +00:00
|
|
|
import 'package:go_router/go_router.dart';
|
2024-07-06 12:55:53 +00:00
|
|
|
import 'package:solian/theme.dart';
|
2024-07-12 03:39:44 +00:00
|
|
|
import 'package:solian/widgets/navigation/app_navigation_drawer.dart';
|
2024-07-06 12:55:53 +00:00
|
|
|
|
2024-07-12 03:39:44 +00:00
|
|
|
final GlobalKey<ScaffoldState> rootScaffoldKey = GlobalKey<ScaffoldState>();
|
|
|
|
|
2024-07-06 12:55:53 +00:00
|
|
|
class RootShell extends StatelessWidget {
|
|
|
|
final bool showSidebar;
|
|
|
|
final bool showNavigation;
|
|
|
|
final bool? showBottomNavigation;
|
2024-07-12 05:15:46 +00:00
|
|
|
final GoRouterState state;
|
2024-07-06 12:55:53 +00:00
|
|
|
final Widget child;
|
|
|
|
|
|
|
|
const RootShell({
|
|
|
|
super.key,
|
2024-07-12 05:15:46 +00:00
|
|
|
required this.state,
|
2024-07-06 12:55:53 +00:00
|
|
|
required this.child,
|
|
|
|
this.showSidebar = true,
|
|
|
|
this.showNavigation = true,
|
|
|
|
this.showBottomNavigation,
|
|
|
|
});
|
|
|
|
|
2024-07-12 03:39:44 +00:00
|
|
|
void closeDrawer() {
|
|
|
|
rootScaffoldKey.currentState!.closeDrawer();
|
|
|
|
}
|
|
|
|
|
2024-07-06 12:55:53 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-07-12 05:15:46 +00:00
|
|
|
final routeName = state.topRoute?.name;
|
|
|
|
|
2024-08-18 17:35:38 +00:00
|
|
|
if (routeName != null) {
|
|
|
|
FirebaseAnalytics.instance.logEvent(
|
|
|
|
name: 'screen_view',
|
|
|
|
parameters: {
|
|
|
|
'firebase_screen': routeName,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-07-06 12:55:53 +00:00
|
|
|
return Scaffold(
|
2024-07-12 03:39:44 +00:00
|
|
|
key: rootScaffoldKey,
|
2024-07-12 08:19:54 +00:00
|
|
|
drawer: SolianTheme.isLargeScreen(context)
|
|
|
|
? null
|
2024-07-13 10:54:08 +00:00
|
|
|
: AppNavigationDrawer(routeName: routeName),
|
2024-07-07 06:41:23 +00:00
|
|
|
body: SolianTheme.isLargeScreen(context)
|
|
|
|
? Row(
|
|
|
|
children: [
|
2024-07-12 08:19:54 +00:00
|
|
|
if (showNavigation) AppNavigationDrawer(routeName: routeName),
|
2024-07-07 06:41:23 +00:00
|
|
|
if (showNavigation)
|
|
|
|
const VerticalDivider(thickness: 0.3, width: 1),
|
|
|
|
Expanded(child: child),
|
|
|
|
],
|
|
|
|
)
|
2024-07-12 03:39:44 +00:00
|
|
|
: child,
|
2024-07-06 12:55:53 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|