2024-05-22 15:18:01 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
import 'package:solian/theme.dart';
|
2024-07-12 14:31:45 +00:00
|
|
|
import 'package:solian/widgets/app_bar_leading.dart';
|
2024-06-22 15:59:11 +00:00
|
|
|
import 'package:solian/widgets/app_bar_title.dart';
|
2024-06-27 06:31:15 +00:00
|
|
|
import 'package:solian/widgets/sidebar/sidebar_placeholder.dart';
|
2024-05-22 15:18:01 +00:00
|
|
|
|
2024-07-12 13:59:16 +00:00
|
|
|
class SidebarShell extends StatelessWidget {
|
2024-06-27 06:31:15 +00:00
|
|
|
final bool showAppBar;
|
2024-05-22 15:18:01 +00:00
|
|
|
final GoRouterState state;
|
|
|
|
final Widget child;
|
|
|
|
|
2024-06-27 06:31:15 +00:00
|
|
|
final bool sidebarFirst;
|
|
|
|
final Widget? sidebar;
|
|
|
|
|
2024-07-12 13:59:16 +00:00
|
|
|
const SidebarShell({
|
2024-06-27 06:31:15 +00:00
|
|
|
super.key,
|
|
|
|
required this.child,
|
|
|
|
required this.state,
|
|
|
|
this.showAppBar = true,
|
|
|
|
this.sidebarFirst = false,
|
|
|
|
this.sidebar,
|
|
|
|
});
|
|
|
|
|
|
|
|
List<Widget> buildContent(BuildContext context) {
|
|
|
|
return [
|
|
|
|
Flexible(
|
|
|
|
flex: 2,
|
|
|
|
child: child,
|
|
|
|
),
|
|
|
|
if (SolianTheme.isExtraLargeScreen(context))
|
|
|
|
const VerticalDivider(thickness: 0.3, width: 1),
|
|
|
|
if (SolianTheme.isExtraLargeScreen(context))
|
|
|
|
Flexible(
|
|
|
|
flex: 1,
|
|
|
|
child: sidebar ?? const SidebarPlaceholder(),
|
|
|
|
),
|
|
|
|
];
|
|
|
|
}
|
2024-05-22 15:18:01 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
2024-06-27 06:31:15 +00:00
|
|
|
appBar: showAppBar
|
|
|
|
? AppBar(
|
2024-07-12 14:37:58 +00:00
|
|
|
leading: AppBarLeadingButton.adaptive(context),
|
2024-06-27 06:31:15 +00:00
|
|
|
title: AppBarTitle(state.topRoute?.name?.tr ?? 'page'.tr),
|
|
|
|
centerTitle: false,
|
|
|
|
toolbarHeight: SolianTheme.toolbarHeight(context),
|
|
|
|
)
|
|
|
|
: null,
|
|
|
|
body: SolianTheme.isLargeScreen(context)
|
|
|
|
? Row(
|
|
|
|
children: sidebarFirst
|
|
|
|
? buildContent(context).reversed.toList()
|
|
|
|
: buildContent(context),
|
|
|
|
)
|
|
|
|
: child,
|
2024-05-22 15:18:01 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|