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
///標(biāo)題欄
class CustomAppBarextends PreferredSize {
///顯示的標(biāo)題欄Widget
? final WidgetchildView;
? ///標(biāo)題
? final Stringtitle;
? ///返回的回調(diào)
? final FunctioncallPopBack;
? ///設(shè)置右邊的顯示區(qū)域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 ??"無標(biāo)題"}",
? ? ? ? ? ? ? ? ? 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;
? }
///獲取右邊的按鈕顯示區(qū)域
? WidgetgetRightWidget() {
if (rightWidget ==null) {
return SizedBox();
? ? }else {
return rightWidget;
? ? }
}
}