import 'package:deus_app/common/style/gsy_style.dart'; import 'package:flutter/material.dart'; /** * Created with IntelliJ IDEA. * Package: utils * Author: sirai * Create Time: 2019-06-24 16:10 * QQ: 785716471 * Email: 785716471@qq.com * Description:公共的titlebar */ class TitleBar { /** * 仅含 左侧返回按钮 及中间标题 * appBar: TitleBar().backAppbar(context, '个人资料'), * appBar: TitleBar().backAppbar(context, '个人资料',(){}), */ backAppbar(BuildContext context, String title) { return PreferredSize( preferredSize: Size.fromHeight(48), child: AppBar( title: Text( title, style: TextStyle(color: GSYColors.primaryDarkValue, fontSize: 16), ), centerTitle: true, leading: BackButton(), brightness: Brightness.light, backgroundColor: GSYColors.white, elevation: 0, iconTheme: IconThemeData(color: GSYColors.primaryDarkValue), )); } /** * 设置左侧按钮 */ _leading(BuildContext context, VoidCallback onPressed) { return Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( width: 44, padding: EdgeInsets.all(0), child: new IconButton( padding: EdgeInsets.only(left: 16, right: 16), // icon: Image.asset( // 'assets/images/ic_black_left_arrow.png', // fit: BoxFit.contain, // width: 16, // height: 16, // ), icon: Icon(Icons.chevron_left), onPressed: () { if (onPressed == null) { _popThis(context); } else { onPressed(); } }, ), ), ], ); } homeAppBar(String title, VoidCallback rightButtonClick) { return AppBar( centerTitle: true, titleSpacing: 0, backgroundColor:Colors.black, // 返回按钮 title: Text( title, style: TextStyle(fontSize: 17), ), automaticallyImplyLeading: false, // 标题 actions: [ new IconButton( // action button padding: EdgeInsets.only(right: 20), icon: new Icon(Icons.settings), onPressed: rightButtonClick, ), ], ); } /** * 关闭页面 */ _popThis(BuildContext context){ Navigator.of(context).pop(); } }