|
|
|
|
@ -1,5 +1,9 @@
|
|
|
|
|
import 'package:car_provider_app/config/provider_routes.dart';
|
|
|
|
|
import 'package:flutter/gestures.dart';
|
|
|
|
|
import 'package:mc_common_app/classes/consts.dart';
|
|
|
|
|
import 'package:mc_common_app/generated/locale_keys.g.dart';
|
|
|
|
|
import 'package:mc_common_app/utils/app_permission_handler.dart';
|
|
|
|
|
import 'package:mc_common_app/utils/dialogs_and_bottomsheets.dart';
|
|
|
|
|
import 'package:mc_common_app/view_models/service_view_model.dart';
|
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
@ -11,16 +15,50 @@ import 'package:mc_common_app/theme/colors.dart';
|
|
|
|
|
import 'package:mc_common_app/utils/enums.dart';
|
|
|
|
|
import 'package:mc_common_app/utils/navigator.dart';
|
|
|
|
|
import 'package:mc_common_app/utils/utils.dart';
|
|
|
|
|
import 'package:mc_common_app/widgets/button/show_fill_button.dart';
|
|
|
|
|
import 'package:mc_common_app/widgets/common_widgets/app_bar.dart';
|
|
|
|
|
import 'package:mc_common_app/widgets/dropdown/dropdow_field.dart';
|
|
|
|
|
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
|
|
|
|
import 'package:mc_common_app/widgets/tab/role_type_tab.dart';
|
|
|
|
|
import 'package:mc_common_app/widgets/row_with_arrow.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
class BranchListPage extends StatelessWidget {
|
|
|
|
|
const BranchListPage({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
void deleteAdBottomSheet(BuildContext context, int branchID) {
|
|
|
|
|
return actionConfirmationBottomSheet(
|
|
|
|
|
context: context,
|
|
|
|
|
title: LocaleKeys.deleteBranchConfirmation.tr().toText(fontSize: 28, isBold: true, letterSpacing: -1.44),
|
|
|
|
|
subtitle: LocaleKeys.deleteBranchConfirmationMessage.tr(),
|
|
|
|
|
actionButtonYes: Expanded(
|
|
|
|
|
child: ShowFillButton(
|
|
|
|
|
maxHeight: 55,
|
|
|
|
|
title: LocaleKeys.yes.tr(),
|
|
|
|
|
fontSize: 15,
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
await context.read<ServiceVM>().onDeleteBranchPressed(context: context, branchID: branchID ?? -1);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
actionButtonNo: Expanded(
|
|
|
|
|
child: ShowFillButton(
|
|
|
|
|
maxHeight: 55,
|
|
|
|
|
isFilled: false,
|
|
|
|
|
borderColor: MyColors.darkPrimaryColor,
|
|
|
|
|
title: LocaleKeys.no.tr(),
|
|
|
|
|
txtColor: MyColors.darkPrimaryColor,
|
|
|
|
|
fontSize: 15,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
@ -70,65 +108,84 @@ class BranchListPage extends StatelessWidget {
|
|
|
|
|
? Center(child: LocaleKeys.no_branch.tr().toText(fontSize: 16, color: MyColors.lightTextColor))
|
|
|
|
|
: ListView.separated(
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
|
|
|
|
|
BranchDetailModel branchModel = branches[index];
|
|
|
|
|
return Row(
|
|
|
|
|
children: [
|
|
|
|
|
branchModel.branchProfileImage.buildNetworkImage(width: 74, height: 50, fit: BoxFit.cover),
|
|
|
|
|
12.width,
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
Utils.statusContainerChip(
|
|
|
|
|
text: branchModel.branchStatusLabel ?? "",
|
|
|
|
|
chipColor: Utils.getChipColorByBranchStatus(branchModel.branchStatus!),
|
|
|
|
|
),
|
|
|
|
|
InkWell(
|
|
|
|
|
onTap: () async {
|
|
|
|
|
await serviceVM.onDeleteBranchPressed(context: context, branchID: branchModel.id ?? -1);
|
|
|
|
|
},
|
|
|
|
|
child: const Icon(
|
|
|
|
|
Icons.delete,
|
|
|
|
|
color: MyColors.grey70Color,
|
|
|
|
|
return Dismissible(
|
|
|
|
|
key: Key(index.toString()),
|
|
|
|
|
background: const SizedBox(),
|
|
|
|
|
secondaryBackground: Container(
|
|
|
|
|
color: const Color(0xFFDD0505),
|
|
|
|
|
child: Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
|
children: [
|
|
|
|
|
LocaleKeys.delete.tr().toText(fontSize: 15, fontWeight: MyFonts.Medium, height: 23 / 25, color: MyColors.white).margin(right: 23),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
dragStartBehavior: DragStartBehavior.start,
|
|
|
|
|
direction: DismissDirection.endToStart,
|
|
|
|
|
confirmDismiss: (DismissDirection direction) async {
|
|
|
|
|
deleteAdBottomSheet(context, branchModel.id!);
|
|
|
|
|
},
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
branchModel.branchProfileImage.buildNetworkImage(width: 66, height: 53, fit: BoxFit.cover),
|
|
|
|
|
12.width,
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
Utils.statusContainerChip(
|
|
|
|
|
text: branchModel.branchStatusLabel ?? "",
|
|
|
|
|
chipColor: Utils.getChipColorByBranchStatus(branchModel.branchStatus!),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
5.height,
|
|
|
|
|
Text(
|
|
|
|
|
branchModel.branchName ?? "",
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
Flexible(
|
|
|
|
|
child: (branchModel.branchDescription ?? "").toText(
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
color: MyColors.grey70Color,
|
|
|
|
|
maxLines: 2,
|
|
|
|
|
)),
|
|
|
|
|
const Icon(Icons.arrow_forward_rounded, size: 18, color: MyColors.grey70Color),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
2.height,
|
|
|
|
|
// branchModel.distanceKm == null
|
|
|
|
|
// ? const SizedBox()
|
|
|
|
|
// : Row(
|
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
// children: [
|
|
|
|
|
// const Icon(
|
|
|
|
|
// Icons.location_on,
|
|
|
|
|
// color: MyColors.darkPrimaryColor,
|
|
|
|
|
// size: 15,
|
|
|
|
|
// ),
|
|
|
|
|
// 2.width,
|
|
|
|
|
// ("${branchModel.distanceKm} KM").toText(
|
|
|
|
|
// color: MyColors.darkPrimaryColor,
|
|
|
|
|
// fontSize: 10,
|
|
|
|
|
// )
|
|
|
|
|
// ],
|
|
|
|
|
// ),
|
|
|
|
|
// 5.height,
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
(branchModel.branchName ?? "").toText(fontSize: 16, height: 18 / 16),
|
|
|
|
|
],
|
|
|
|
|
).withArrow(isArrowEnabled: true).margin(right: 10),
|
|
|
|
|
(branchModel.branchDescription ?? "").toText(
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
color: MyColors.grey70Color,
|
|
|
|
|
maxLines: 2,
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).toWhiteContainer(width: double.infinity, pading: const EdgeInsets.all(12)).onPress(() async {
|
|
|
|
|
branchModel.countryID = serviceVM.branches!.data!.countryID;
|
|
|
|
|
branchModel.countryName = serviceVM.branches!.data!.countryName;
|
|
|
|
|
navigateWithName(context, ProviderAppRoutes.branchDetail, arguments: branchModel);
|
|
|
|
|
});
|
|
|
|
|
],
|
|
|
|
|
).toWhiteContainer(width: double.infinity, pading: const EdgeInsets.all(12)).onPress(() async {
|
|
|
|
|
branchModel.countryID = serviceVM.branches!.data!.countryID;
|
|
|
|
|
branchModel.countryName = serviceVM.branches!.data!.countryName;
|
|
|
|
|
navigateWithName(context, ProviderAppRoutes.branchDetail, arguments: branchModel);
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
separatorBuilder: (context, index) => 12.height,
|
|
|
|
|
itemCount: branches.length,
|
|
|
|
|
|