Surface/lib/widgets/navigation/app_scaffold.dart

53 lines
1.6 KiB
Dart
Raw Normal View History

2024-11-09 10:28:45 +00:00
import 'package:easy_localization/easy_localization.dart';
2024-11-08 16:09:46 +00:00
import 'package:flutter/material.dart';
2024-11-09 10:28:45 +00:00
import 'package:go_router/go_router.dart';
2024-11-08 16:09:46 +00:00
import 'package:responsive_framework/responsive_framework.dart';
2024-11-09 10:28:45 +00:00
import 'package:surface/widgets/dialog.dart';
2024-11-08 16:09:46 +00:00
import 'package:surface/widgets/navigation/app_background.dart';
import 'package:surface/widgets/navigation/app_bottom_navigation.dart';
class AppScaffold extends StatelessWidget {
final PreferredSizeWidget? appBar;
2024-11-09 10:28:45 +00:00
final String? title;
2024-11-08 16:09:46 +00:00
final Widget? body;
2024-11-09 10:28:45 +00:00
final bool autoImplyAppBar;
final bool showBottomNavigation;
const AppScaffold({
super.key,
this.appBar,
this.title,
this.body,
this.autoImplyAppBar = false,
this.showBottomNavigation = false,
});
2024-11-08 16:09:46 +00:00
@override
Widget build(BuildContext context) {
2024-11-09 10:28:45 +00:00
final isShowBottomNavigation = (showBottomNavigation)
2024-11-08 16:09:46 +00:00
? ResponsiveBreakpoints.of(context).smallerOrEqualTo(MOBILE)
: false;
2024-11-09 10:28:45 +00:00
final state = GoRouter.maybeOf(context);
2024-11-08 16:09:46 +00:00
return AppBackground(
child: Scaffold(
2024-11-09 10:28:45 +00:00
appBar: appBar ??
(autoImplyAppBar
? AppBar(
title: title != null
? Text(title!)
: state != null
? Text(
('screen${state.routerDelegate.currentConfiguration.last.route.name?.capitalize()}')
.tr(),
)
: null)
: null),
2024-11-08 16:09:46 +00:00
body: body,
bottomNavigationBar:
isShowBottomNavigation ? AppBottomNavigationBar() : null,
),
);
}
}