import 'package:ctjt_flutter/common/styles.dart'; import 'package:ctjt_flutter/widget/button.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; /* ---------------------------------页面内标题-------------------------------- */ class PageTitle extends StatelessWidget { static var _defaultPadding = EdgeInsets.only( top: 75.h, bottom: 75.h); PageTitle({Key? key, required this.text, this.padding}) : super(key: key); final String text; final EdgeInsetsGeometry? padding; @override Widget build(BuildContext context) { return Padding( padding: null == this.padding ? _defaultPadding : this.padding!, child: Text(this.text, style: Styles.titleStyle), ); } } /* ----------------------------------状态栏---------------------------------- */ // 预设的几种常见左上角按钮类型枚举 enum LeadingType { Back, Menu, None } class PageHead extends StatelessWidget implements PreferredSizeWidget { static var _defaultSize = Size.fromHeight(125.h); PageHead( {Key? key, this.leadingType = LeadingType.Back, this.leading, this.title}) : super(key: key); final LeadingType leadingType; final Widget? leading; final Widget? title; @override Widget build(BuildContext context) { Widget? leading; if (null != this.leading) { leading = this.leading!; } else { switch (this.leadingType) { case LeadingType.Menu: { leading = IButton( iconSize: Styles.iconBigSize!, icon: const Icon(Icons.menu, color: Styles.primaryColor), onPressed: () { Scaffold.of(context).openDrawer(); }); } break; case LeadingType.Back: { leading = IButton( iconSize: Styles.iconBigSize!, icon: const Icon(Icons.arrow_back_ios, color: Styles.primaryColor), onPressed: () { Navigator.of(context).pop(); }); } break; default: break; } } return PreferredSize( // 设定状态栏大小的容器 child: AppBar( centerTitle: true, leading: leading, title: this.title, elevation: 0, systemOverlayStyle: SystemUiOverlayStyle(statusBarBrightness: Brightness.light), // 是否夜览 backgroundColor: Colors.transparent, // 状态栏设置为透明底色 ), preferredSize: _defaultSize, ); } @override Size get preferredSize => _defaultSize; }