| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- 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 AppBar(
- title: Text(
- title,
- style: TextStyle(color: Colors.white, fontSize: 16),
- ),
- centerTitle: true,
- leading: BackButton(),
- brightness: Brightness.light,
- backgroundColor: Color(0xFF4875EC),
- elevation: 0,
- iconTheme: IconThemeData(color: Colors.white),
- );
- }
- /**
- * 设置左侧按钮
- */
- _leading(BuildContext context, VoidCallback onPressed) {
- return Column(
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- 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,
- elevation: 0,
- backgroundColor: Color(0xFF4875EC),
- // 返回按钮
- title: Text(
- title,
- style: TextStyle(fontSize: 17),
- ),
- automaticallyImplyLeading: false,
- // 标题
- actions: <Widget>[
- new IconButton( // action button
- padding: EdgeInsets.only(right: 20),
- icon: new Icon(Icons.settings),
- onPressed: rightButtonClick,
- ),
- ],
- );
- }
- /**
- * 关闭页面
- */
- _popThis(BuildContext context){
- Navigator.of(context).pop();
- }
- }
|