import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_nxj_c/helpers/constants.dart';
import 'package:flutter_svg/svg.dart';
import 'dart:io';
///@autor Cc
///标题栏
class CustomAppBarextends PreferredSize {
///显示的标题栏Widget
final WidgetchildView;
///标题
final Stringtitle;
///返回的回调
final FunctioncallPopBack;
///设置右边的显示区域Widget
final WidgetrightWidget;
///显示底部的线
final boolshowBottomLine;
CustomAppBar(
{this.childView,
this.title,
this.callPopBack,
this.rightWidget,
this.showBottomLine})
:super(
preferredSize:
Size.fromHeight((Platform.isIOS ?44.0 : kToolbarHeight)));
@override
Widgetbuild(BuildContext context) {
Widget current =childView;
if (childView ==null) {
current =Container(
margin:EdgeInsets.only(top: MediaQuery.of(context).padding.top),
child:Stack(
children: [
Container(
decoration:BoxDecoration(
color: Colors.transparent,
border:Border(
bottom:BorderSide(
width:0.5,
color:Color((showBottomLine ??true)
? AppColors.borderColor
:0xffffffff),
),
)),
child:Center(
child:Text(
"${title ??"无标题"}",
style: (TextStyle(fontSize:16, fontWeight: FontWeight.w600)),
),
),
),
Center(
child:Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
onPressed: () {
Navigator.pop(context);
callPopBack();
},
icon:SvgPicture.asset(
'assets/icons/common/ic_notify_normal_back.svg'),
),
getRightWidget(),
],
),
),
],
),
);
}
return current;
}
///获取右边的按钮显示区域
WidgetgetRightWidget() {
if (rightWidget ==null) {
return SizedBox();
}else {
return rightWidget;
}
}
}
网友评论