Solian/lib/shells/title_shell.dart

50 lines
1.3 KiB
Dart
Raw Normal View History

2024-06-27 14:31:15 +08: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 12:32:21 +08:00
import 'package:solian/widgets/current_state_action.dart';
2024-06-27 14:31:15 +08:00
class TitleShell extends StatelessWidget {
final bool showAppBar;
final bool isCenteredTitle;
2024-08-02 04:42:38 +08:00
final String? title;
final GoRouterState? state;
2024-06-27 14:31:15 +08:00
final Widget child;
const TitleShell({
super.key,
required this.child,
2024-08-02 04:42:38 +08:00
this.title,
this.state,
2024-06-27 14:31:15 +08:00
this.showAppBar = true,
this.isCenteredTitle = false,
2024-06-27 14:31:15 +08:00
});
@override
Widget build(BuildContext context) {
assert(state != null || title != null);
2024-06-27 14:31:15 +08:00
return Scaffold(
appBar: showAppBar
? AppBar(
2024-07-12 22:37:58 +08:00
leading: AppBarLeadingButton.adaptive(context),
2024-08-02 04:42:38 +08:00
title: AppBarTitle(
title ?? (state!.topRoute?.name?.tr ?? 'page'.tr),
),
centerTitle: isCenteredTitle,
toolbarHeight: AppTheme.toolbarHeight(context),
2024-09-08 12:32:21 +08:00
actions: [
const BackgroundStateWidget(),
SizedBox(
width: AppTheme.isLargeScreen(context) ? 8 : 16,
2024-09-08 12:32:21 +08:00
),
],
2024-07-12 11:39:44 +08:00
)
2024-06-27 14:31:15 +08:00
: null,
body: child,
);
}
}