Solian/lib/shells/title_shell.dart

59 lines
1.6 KiB
Dart
Raw Permalink Normal View History

2024-06-27 06:31:15 +00:00
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:go_router/go_router.dart';
import 'package:solian/theme.dart';
import 'package:solian/widgets/app_bar_title.dart';
import 'package:solian/widgets/app_bar_leading.dart';
2024-09-08 04:32:21 +00:00
import 'package:solian/widgets/current_state_action.dart';
import 'package:solian/widgets/root_container.dart';
2024-06-27 06:31:15 +00:00
class TitleShell extends StatelessWidget {
final bool showAppBar;
final bool isCenteredTitle;
2024-10-06 17:47:34 +00:00
final bool isResponsive;
2024-08-01 20:42:38 +00:00
final String? title;
final GoRouterState? state;
2024-06-27 06:31:15 +00:00
final Widget child;
const TitleShell({
super.key,
required this.child,
2024-08-01 20:42:38 +00:00
this.title,
this.state,
2024-06-27 06:31:15 +00:00
this.showAppBar = true,
this.isCenteredTitle = false,
2024-10-06 17:47:34 +00:00
this.isResponsive = false,
2024-06-27 06:31:15 +00:00
});
@override
Widget build(BuildContext context) {
assert(state != null || title != null);
2024-10-06 17:47:34 +00:00
final widget = Scaffold(
appBar: showAppBar
? AppBar(
leading: AppBarLeadingButton.adaptive(context),
title: AppBarTitle(
title ?? (state!.topRoute?.name?.tr ?? 'page'.tr),
),
centerTitle: isCenteredTitle,
toolbarHeight: AppTheme.toolbarHeight(context),
actions: [
const BackgroundStateWidget(),
SizedBox(
width: AppTheme.isLargeScreen(context) ? 8 : 16,
2024-09-08 04:32:21 +00:00
),
2024-10-06 17:47:34 +00:00
],
)
: null,
body: child,
2024-06-27 06:31:15 +00:00
);
2024-10-06 17:47:34 +00:00
if (isResponsive) {
return ResponsiveRootContainer(child: widget);
} else {
return RootContainer(child: widget);
}
2024-06-27 06:31:15 +00:00
}
}