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.
71 lines
1.7 KiB
71 lines
1.7 KiB
4 years ago
|
import 'package:flutter/material.dart';
|
||
|
|
||
|
class MyAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||
|
final Function onTap;
|
||
|
final Widget action;
|
||
|
final String title;
|
||
|
final double titleSize;
|
||
|
final Color titleColor;
|
||
|
final Color leadingColor;
|
||
|
final Color background;
|
||
|
final Size preferredSize;
|
||
|
final double toolbarHeight;
|
||
|
MyAppBar({
|
||
|
Key key,
|
||
|
this.onTap,
|
||
|
this.action,
|
||
|
this.title,
|
||
|
this.toolbarHeight,
|
||
|
this.background = const Color(0xFFF7F7F7),
|
||
|
this.leadingColor = Colors.black,
|
||
|
this.titleColor = Colors.black,
|
||
|
this.titleSize = 18,
|
||
|
}) : preferredSize = Size.fromHeight(toolbarHeight ?? kToolbarHeight),
|
||
|
super(key: key);
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return AppBar(
|
||
|
backgroundColor: background,
|
||
|
elevation: 0,
|
||
|
leading: GestureDetector(
|
||
|
onTap: () {
|
||
|
Navigator.of(context).pop();
|
||
|
},
|
||
|
child: Container(
|
||
|
alignment: Alignment.centerRight,
|
||
|
margin: EdgeInsets.only(left: 10),
|
||
|
padding: EdgeInsets.all(6),
|
||
|
child: Icon(
|
||
|
Icons.arrow_back_ios,
|
||
|
color: leadingColor,
|
||
|
size: 24,
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
titleSpacing: 2,
|
||
|
centerTitle: false,
|
||
|
leadingWidth: 56,
|
||
|
title: (title == null || title == "")
|
||
|
? null
|
||
|
: Text(
|
||
|
title,
|
||
|
style: TextStyle(
|
||
|
color: titleColor,
|
||
|
fontSize: titleSize,
|
||
|
),
|
||
|
),
|
||
|
actions: [
|
||
|
if (action != null)
|
||
|
Container(
|
||
|
margin: EdgeInsets.only(right: 15),
|
||
|
child: GestureDetector(
|
||
|
onTap: onTap,
|
||
|
child: action,
|
||
|
),
|
||
|
)
|
||
|
],
|
||
|
);
|
||
|
}
|
||
|
}
|