app_bar.dart
1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/res/colors.dart';
class MyAppBar extends StatelessWidget {
MyAppBar(this.title, {this.showBack = true,this.backgroundColor=MyColours.color_ffffff,this.fontColor=MyColours.color_131313});
final String title;//标题文字
final bool showBack;//是否显示返回按钮
final Color backgroundColor;//背景色
final Color fontColor;//字体颜色
@override
Widget build(BuildContext context) {
// TODO: implement build
return Container(
width: double.infinity,
color: backgroundColor,
padding: EdgeInsets.symmetric(vertical: ScreenUtil().setHeight(30)),
child: Stack(
alignment: Alignment.center,
children: <Widget>[
Positioned(
left: 0,
child: showBack?GestureDetector(
onTap: () {
Navigator.of(context).pop();
},
behavior: HitTestBehavior.opaque,
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setHeight(15)),
child: Image.asset(
"assets/icon_back.png",
width: ScreenUtil().setWidth(20),
height: ScreenUtil().setHeight(31),
),
),
):Container(),
),
Center(
child: Text(
title,
style: TextStyle(
color: fontColor,
fontSize: ScreenUtil().setSp(34),
fontWeight: FontWeight.normal,
decoration: TextDecoration.none
),
),
)
],
));
}
}