|
|
|
|
import 'package:mc_common_app/view_models/appointments_view_model.dart';
|
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:mc_common_app/classes/consts.dart';
|
|
|
|
|
import 'package:mc_common_app/config/routes.dart';
|
|
|
|
|
import 'package:mc_common_app/extensions/int_extensions.dart';
|
|
|
|
|
import 'package:mc_common_app/extensions/string_extensions.dart';
|
|
|
|
|
import 'package:mc_common_app/generated/locale_keys.g.dart';
|
|
|
|
|
import 'package:mc_common_app/models/provider_branches_models/branch_detail_model.dart';
|
|
|
|
|
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/widgets/common_widgets/categories_list.dart';
|
|
|
|
|
import 'package:mc_common_app/widgets/common_widgets/provider_details_card.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
class BranchesFragment extends StatelessWidget {
|
|
|
|
|
const BranchesFragment({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Container(
|
|
|
|
|
color: MyColors.backgroundColor,
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: double.infinity,
|
|
|
|
|
child: Consumer(
|
|
|
|
|
builder: (BuildContext context, AppointmentsVM appointmentsVM, Widget? child) {
|
|
|
|
|
return Column(
|
|
|
|
|
children: [
|
|
|
|
|
if (appointmentsVM.branchesFilterOptions.isNotEmpty) ...[
|
|
|
|
|
16.height,
|
|
|
|
|
FiltersList(
|
|
|
|
|
filterList: appointmentsVM.branchesFilterOptions,
|
|
|
|
|
onFilterTapped: (index, selectedFilterId) => appointmentsVM.applyFilterOnBranches(index: index),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
16.height,
|
|
|
|
|
Expanded(
|
|
|
|
|
child: RefreshIndicator(
|
|
|
|
|
onRefresh: () async {
|
|
|
|
|
context.read<AppointmentsVM>().getAllNearBranches(isNeedToRebuild: true, isFromRefresh: true);
|
|
|
|
|
},
|
|
|
|
|
child: Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: MediaQuery.of(context).size.height / 1.37,
|
|
|
|
|
child: appointmentsVM.state == ViewState.busy
|
|
|
|
|
? const Center(child: CircularProgressIndicator())
|
|
|
|
|
: appointmentsVM.nearbyBranches.isEmpty
|
|
|
|
|
? Center(child: LocaleKeys.no_branch.tr().toText(fontSize: 16, color: MyColors.lightTextColor))
|
|
|
|
|
: ListView.separated(
|
|
|
|
|
itemCount: appointmentsVM.nearbyBranches.length,
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
BranchDetailModel branchDetailModel = appointmentsVM.nearbyBranches[index];
|
|
|
|
|
|
|
|
|
|
return ProviderDetailsCard(
|
|
|
|
|
onCardTapped: () {
|
|
|
|
|
navigateWithName(context, AppRoutes.branchDetailPage, arguments: branchDetailModel);
|
|
|
|
|
},
|
|
|
|
|
providerImageUrl: MyAssets.bnCar,
|
|
|
|
|
title: branchDetailModel.branchName ?? "",
|
|
|
|
|
providerLocation: branchDetailModel.distanceKm.toString() + " KM",
|
|
|
|
|
providerName: branchDetailModel.serviceProviderName ?? "",
|
|
|
|
|
providerRatings: "4.9",
|
|
|
|
|
services: branchDetailModel.branchServices,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
separatorBuilder: (context, index) {
|
|
|
|
|
return 12.height;
|
|
|
|
|
},
|
|
|
|
|
padding: const EdgeInsets.all(12),
|
|
|
|
|
)),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|