|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/classes/colors.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/classes/consts.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/config/routes.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
|
|
|
|
|
|
|
|
|
AppBar AppBarWidget(
|
|
|
|
|
BuildContext context, {
|
|
|
|
|
required String title,
|
|
|
|
|
bool showHomeButton = true,
|
|
|
|
|
bool showLogo = false,
|
|
|
|
|
String? logoPath,
|
|
|
|
|
bool showWorkListSettingButton = false,
|
|
|
|
|
bool showMemberButton = false,
|
|
|
|
|
List<Widget>? actions,
|
|
|
|
|
void Function()? onHomeTapped,
|
|
|
|
|
void Function()? onBackTapped,
|
|
|
|
|
}) {
|
|
|
|
|
return AppBar(
|
|
|
|
|
leadingWidth: 0,
|
|
|
|
|
automaticallyImplyLeading: false,
|
|
|
|
|
surfaceTintColor: Colors.transparent,
|
|
|
|
|
title: Row(
|
|
|
|
|
children: [
|
|
|
|
|
GestureDetector(
|
|
|
|
|
behavior: HitTestBehavior.opaque,
|
|
|
|
|
onTap: Feedback.wrapForTap(() {
|
|
|
|
|
(onBackTapped == null
|
|
|
|
|
? Navigator.maybePop(context)
|
|
|
|
|
: onBackTapped());
|
|
|
|
|
}, context),
|
|
|
|
|
child: const Icon(
|
|
|
|
|
Icons.arrow_back_ios,
|
|
|
|
|
color: MyColors.darkIconColor,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
if (showLogo) 4.width,
|
|
|
|
|
if (showLogo) SvgPicture.asset(logoPath!),
|
|
|
|
|
4.width,
|
|
|
|
|
if (!showLogo)
|
|
|
|
|
title.toText24(color: MyColors.darkTextColor, isBold: true).expanded,
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
centerTitle: false,
|
|
|
|
|
elevation: 0,
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
actions: [
|
|
|
|
|
if (showHomeButton)
|
|
|
|
|
IconButton(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
if (onHomeTapped != null) {
|
|
|
|
|
onHomeTapped();
|
|
|
|
|
} else {
|
|
|
|
|
Navigator.popUntil(
|
|
|
|
|
context,
|
|
|
|
|
ModalRoute.withName(
|
|
|
|
|
ApiConsts.isDependetLogin
|
|
|
|
|
? AppRoutes.mazayaDiscover
|
|
|
|
|
: AppRoutes.dashboard,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
icon: const Icon(Icons.home, color: MyColors.darkIconColor),
|
|
|
|
|
),
|
|
|
|
|
if (showWorkListSettingButton)
|
|
|
|
|
IconButton(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.pushNamed(context, AppRoutes.worklistSettings);
|
|
|
|
|
},
|
|
|
|
|
icon: const Icon(
|
|
|
|
|
Icons.settings_rounded,
|
|
|
|
|
color: MyColors.darkIconColor,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
if (showMemberButton)
|
|
|
|
|
IconButton(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.pushNamed(context, AppRoutes.subordinateLeave);
|
|
|
|
|
},
|
|
|
|
|
icon: const Icon(Icons.people, color: MyColors.textMixColor),
|
|
|
|
|
),
|
|
|
|
|
...actions ?? [],
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|