2024-04-12 16:38:20 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2024-05-08 14:01:06 +00:00
|
|
|
import 'package:solian/router.dart';
|
2024-05-03 05:39:52 +00:00
|
|
|
import 'package:solian/utils/theme.dart';
|
2024-04-12 16:38:20 +00:00
|
|
|
import 'package:solian/widgets/navigation_drawer.dart';
|
|
|
|
|
2024-05-03 05:39:52 +00:00
|
|
|
class IndentScaffold extends StatelessWidget {
|
2024-05-08 14:01:06 +00:00
|
|
|
final Widget? body;
|
2024-04-16 12:36:47 +00:00
|
|
|
final Widget? floatingActionButton;
|
2024-05-03 05:39:52 +00:00
|
|
|
final Widget? appBarLeading;
|
2024-04-16 12:36:47 +00:00
|
|
|
final List<Widget>? appBarActions;
|
2024-05-03 05:39:52 +00:00
|
|
|
final bool hideDrawer;
|
2024-05-08 14:01:06 +00:00
|
|
|
final bool showSafeArea;
|
2024-05-03 05:39:52 +00:00
|
|
|
final bool fixedAppBarColor;
|
2024-04-13 16:03:50 +00:00
|
|
|
final String title;
|
2024-04-12 16:38:20 +00:00
|
|
|
|
2024-05-03 05:39:52 +00:00
|
|
|
const IndentScaffold({
|
2024-04-16 12:36:47 +00:00
|
|
|
super.key,
|
2024-05-08 14:01:06 +00:00
|
|
|
this.body,
|
2024-04-16 12:36:47 +00:00
|
|
|
required this.title,
|
|
|
|
this.floatingActionButton,
|
2024-05-03 05:39:52 +00:00
|
|
|
this.appBarLeading,
|
2024-04-16 12:36:47 +00:00
|
|
|
this.appBarActions,
|
2024-05-03 05:39:52 +00:00
|
|
|
this.hideDrawer = false,
|
2024-05-08 14:01:06 +00:00
|
|
|
this.showSafeArea = false,
|
2024-05-03 05:39:52 +00:00
|
|
|
this.fixedAppBarColor = false,
|
2024-04-16 12:36:47 +00:00
|
|
|
});
|
2024-04-12 16:38:20 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-05-08 14:01:06 +00:00
|
|
|
final backButton = IconButton(
|
|
|
|
icon: const Icon(Icons.arrow_back),
|
|
|
|
tooltip: MaterialLocalizations.of(context).backButtonTooltip,
|
|
|
|
onPressed: () {
|
|
|
|
if (SolianRouter.router.canPop()) {
|
|
|
|
SolianRouter.router.pop();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
final drawerButton = Builder(
|
|
|
|
builder: (context) {
|
|
|
|
return IconButton(
|
|
|
|
icon: const Icon(Icons.menu),
|
|
|
|
tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip,
|
|
|
|
onPressed: () {
|
|
|
|
Scaffold.of(context).openDrawer();
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
2024-04-16 12:36:47 +00:00
|
|
|
|
2024-04-12 16:38:20 +00:00
|
|
|
return Scaffold(
|
2024-05-01 16:49:38 +00:00
|
|
|
appBar: AppBar(
|
|
|
|
title: Text(title),
|
2024-05-08 14:01:06 +00:00
|
|
|
leading: appBarLeading ?? (hideDrawer ? backButton : drawerButton),
|
2024-05-01 16:49:38 +00:00
|
|
|
actions: appBarActions,
|
|
|
|
centerTitle: false,
|
2024-05-03 05:39:52 +00:00
|
|
|
elevation: fixedAppBarColor ? 4 : null,
|
2024-05-08 14:01:06 +00:00
|
|
|
automaticallyImplyLeading: false,
|
2024-05-01 16:49:38 +00:00
|
|
|
),
|
2024-04-16 12:36:47 +00:00
|
|
|
floatingActionButton: floatingActionButton,
|
2024-05-03 05:39:52 +00:00
|
|
|
drawer: !hideDrawer ? const SolianNavigationDrawer() : null,
|
|
|
|
drawerScrimColor: SolianTheme.isLargeScreen(context) ? Colors.transparent : null,
|
2024-05-08 14:01:06 +00:00
|
|
|
body: showSafeArea ? SafeArea(child: body ?? Container()) : body,
|
2024-04-12 16:38:20 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|