123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:liftmanager/res/colors.dart';
- import 'package:liftmanager/res/dimens.dart';
- import 'package:liftmanager/res/gaps.dart';
- import 'package:liftmanager/utils/theme_utils.dart';
- import 'package:liftmanager/widgets/load_image.dart';
- import 'package:liftmanager/routers/fluro_navigator.dart';
- /// 自定义AppBar
- class MyAppBar extends StatelessWidget implements PreferredSizeWidget {
- const MyAppBar(
- {Key key,
- this.backgroundColor,
- this.title: "",
- this.centerTitle: "",
- this.actions,
- this.onPressed,
- this.fun,
- this.onBack,
- this.isFun:false,
- this.isBack: true})
- : super(key: key);
- final Color backgroundColor;
- final String title;
- final String centerTitle;
- final List<Widget> actions;
- final VoidCallback onPressed;
- final bool isBack;
- final Function fun;
- final bool isFun;
- final VoidCallback onBack;
- @override
- Widget build(BuildContext context) {
- return AnnotatedRegion<SystemUiOverlayStyle>(
- value: SystemUiOverlayStyle.light,
- child:
- Container(
- decoration: BoxDecoration(
- gradient: const LinearGradient(
- colors: [Color(0xFF00D9FF), Color(0xFF0287FF)]),
- ),
- child: SafeArea(
- child: Stack(
- alignment: Alignment.centerLeft,
- children: <Widget>[
- Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Container(
- alignment: centerTitle.isEmpty
- ? Alignment.centerLeft
- : Alignment.center,
- width: double.infinity,
- child: Text(title.isEmpty ? centerTitle : title,
- style: TextStyle(
- fontSize: Dimens.font_sp18,
- color: Colours.dark_text,
- )),
- padding: const EdgeInsets.symmetric(horizontal: 48.0),
- )
- ],
- ),
- isBack
- ? IconButton(
- onPressed: () {
- // FocusScope.of(context).unfocus();
- // if(isFun){
- // fun();
- // }else {
- // Navigator.maybePop(context);
- // }
-
- if(onBack !=null){
- onBack();
- }else if (isFun){
- fun();
- FocusScope.of(context).unfocus();
- }
- else{
- FocusScope.of(context).unfocus();
- NavigatorUtils.goBackWithParams(context, true);
- }
- },
- tooltip: 'Back',
- padding: const EdgeInsets.all(12.0),
- icon: Icon(
- Icons.arrow_back_ios,
- color: Colours.dark_text,
- ),
- )
- : Gaps.empty,
- Positioned(
- right: 0.0,
- child: Theme(
- data: Theme.of(context).copyWith(
- buttonTheme: ButtonThemeData(
- padding: const EdgeInsets.symmetric(horizontal: 16.0),
- minWidth: 60.0,
- )
- ),
- child: rightActions()),
- ),
- ],
- ),
- ),
- ),
- );
- }
- Widget rightActions(){
- if (this.actions != null && this.actions.isNotEmpty) {
- return Row(
- children: this.actions,
- );
- }else{
- return Container();
- }
- }
- @override
- Size get preferredSize => Size.fromHeight(48.0);
- }
|