You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
|
|
|
|
class MyAppBar extends StatelessWidget implements PreferredSizeWidget {
|
|
|
|
final Function onTap;
|
|
|
|
final Widget action;
|
|
|
|
List<Widget> actions;
|
|
|
|
final Widget bottom;
|
|
|
|
final Widget titleChild;
|
|
|
|
final String title;
|
|
|
|
final double titleSize;
|
|
|
|
final Color titleColor;
|
|
|
|
final Color leadingColor;
|
|
|
|
final Color background;
|
|
|
|
final Size preferredSize;
|
|
|
|
final double toolbarHeight;
|
|
|
|
final bool leading;
|
|
|
|
final Brightness brightness;
|
|
|
|
final Function exit;
|
|
|
|
|
|
|
|
MyAppBar({
|
|
|
|
Key key,
|
|
|
|
this.onTap,
|
|
|
|
this.action,
|
|
|
|
this.actions,
|
|
|
|
this.bottom,
|
|
|
|
this.titleChild,
|
|
|
|
this.title,
|
|
|
|
this.toolbarHeight,
|
|
|
|
this.background = const Color(0xFFF7F7F7),
|
|
|
|
this.leadingColor = Colors.black,
|
|
|
|
this.titleColor = Colors.black,
|
|
|
|
this.titleSize = 18,
|
|
|
|
this.brightness = Brightness.light,
|
|
|
|
this.leading = true,
|
|
|
|
this.exit
|
|
|
|
}) : preferredSize = Size.fromHeight(toolbarHeight ?? kToolbarHeight),
|
|
|
|
super(key: key) {
|
|
|
|
if (actions == null)
|
|
|
|
actions = [];
|
|
|
|
if (action != null) {
|
|
|
|
actions.add(
|
|
|
|
Container(
|
|
|
|
margin: EdgeInsets.only(right: 15),
|
|
|
|
child: GestureDetector(
|
|
|
|
onTap: onTap,
|
|
|
|
child: action,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return AppBar(
|
|
|
|
backgroundColor: background,
|
|
|
|
elevation: 0,
|
|
|
|
brightness: brightness,
|
|
|
|
leading: leading
|
|
|
|
? GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
if(exit == null)
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
else exit();
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
margin: EdgeInsets.only(left: 10),
|
|
|
|
padding: EdgeInsets.all(6),
|
|
|
|
child: Icon(
|
|
|
|
Icons.arrow_back_ios,
|
|
|
|
color: leadingColor,
|
|
|
|
size: 24,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: Container(),
|
|
|
|
titleSpacing: 2,
|
|
|
|
centerTitle: false,
|
|
|
|
leadingWidth: leading ? 56 : 10.w,
|
|
|
|
title: ((title == null || title == "") && titleChild != null)
|
|
|
|
? titleChild
|
|
|
|
: Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: titleColor,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: titleSize,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
actions: actions,
|
|
|
|
bottom: bottom,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|