|
|
|
@ -14,7 +14,7 @@ import 'package:ansu_ui/buttons/as_back_button.dart';
|
|
|
|
|
///title , AppBar 和 AppBarBottom 均为 `null`时不显示scaffold的AppBar
|
|
|
|
|
///
|
|
|
|
|
///只有AppBarBottom时只显示AppBarBottom中的内容
|
|
|
|
|
class ASScaffold extends StatefulWidget {
|
|
|
|
|
class ASScaffold extends StatelessWidget {
|
|
|
|
|
///标题,可为`String`或`Text`
|
|
|
|
|
final dynamic title;
|
|
|
|
|
|
|
|
|
@ -58,30 +58,20 @@ class ASScaffold extends StatefulWidget {
|
|
|
|
|
this.floatingActionButton,
|
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_ASScaffoldState createState() => _ASScaffoldState();
|
|
|
|
|
Widget get _title {
|
|
|
|
|
if (title is String) return Text(title);
|
|
|
|
|
return title ?? SizedBox();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _ASScaffoldState extends State<ASScaffold> {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
key: widget.key,
|
|
|
|
|
endDrawer: widget.endDrawer,
|
|
|
|
|
backgroundColor: widget.backgroundColor,
|
|
|
|
|
bottomNavigationBar: widget.bottomNavigationBar,
|
|
|
|
|
floatingActionButton: widget.floatingActionButton,
|
|
|
|
|
appBar: widget.title == null &&
|
|
|
|
|
widget.appBar == null &&
|
|
|
|
|
widget.appBarBottom == null
|
|
|
|
|
? null
|
|
|
|
|
: widget.appBar ??
|
|
|
|
|
Widget get _appBar {
|
|
|
|
|
if (title == null && appBar == null && appBarBottom == null) return null;
|
|
|
|
|
return appBar ??
|
|
|
|
|
AppBar(
|
|
|
|
|
brightness: Brightness.light,
|
|
|
|
|
backgroundColor: kForegroundColor,
|
|
|
|
|
elevation: 0,
|
|
|
|
|
leading: widget.leading ?? ASBackButton(),
|
|
|
|
|
actions: widget.actions ?? [],
|
|
|
|
|
leading: leading ?? ASBackButton(),
|
|
|
|
|
actions: actions ?? [],
|
|
|
|
|
centerTitle: true,
|
|
|
|
|
title: DefaultTextStyle(
|
|
|
|
|
style: TextStyle(
|
|
|
|
@ -89,17 +79,26 @@ class _ASScaffoldState extends State<ASScaffold> {
|
|
|
|
|
fontSize: 18.sp,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
),
|
|
|
|
|
child: widget.title is String
|
|
|
|
|
? Text(widget.title)
|
|
|
|
|
: widget.title ?? SizedBox(),
|
|
|
|
|
child: _title,
|
|
|
|
|
),
|
|
|
|
|
bottom: widget.appBarBottom ??
|
|
|
|
|
bottom: appBarBottom ??
|
|
|
|
|
PreferredSize(
|
|
|
|
|
child: SizedBox(),
|
|
|
|
|
preferredSize: Size.fromHeight(0),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
body: widget.body,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
key: key,
|
|
|
|
|
endDrawer: endDrawer,
|
|
|
|
|
backgroundColor: backgroundColor,
|
|
|
|
|
bottomNavigationBar: bottomNavigationBar,
|
|
|
|
|
floatingActionButton: floatingActionButton,
|
|
|
|
|
appBar: _appBar,
|
|
|
|
|
body: body,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|