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/view_models/service_view_model.dart'; import 'package:mc_common_app/widgets/common_widgets/app_bar.dart'; import 'package:mc_common_app/widgets/extensions/extensions_widget.dart'; import 'package:provider/provider.dart'; import 'package:easy_localization/easy_localization.dart'; class BranchAppointmentFragment extends StatelessWidget { const BranchAppointmentFragment({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: const CustomAppBar( title: "Select Branch", isRemoveBackButton: true, ), body: SizedBox( width: double.infinity, height: double.infinity, child: Column( children: [ Expanded( child: Consumer( builder: (context, ServiceVM serviceVM, _) { if (serviceVM.state == ViewState.busy) { return const Center(child: CircularProgressIndicator()); } else { List branches = []; if (serviceVM.branches!.data != null) { branches = serviceVM.branches!.data!.serviceProviderBranch!.where((element) => 3 == element.statusId).toList(); } return RefreshIndicator( onRefresh: () async => serviceVM.getBranchAndServices(), child: branches.isEmpty ? Center( child: LocaleKeys.noBranchFound.tr().toText(fontSize: 16, color: MyColors.lightTextColor, fontWeight: MyFonts.Medium), ) : ListView.separated( itemBuilder: (context, index) { return Row( children: [ branches[index].branchProfileImage.buildNetworkImage(width: 66, height: 53, fit: BoxFit.cover), // Container( // width: 74, // height: 50, // decoration: const BoxDecoration( // color: MyColors.darkPrimaryColor, // borderRadius: BorderRadius.all(Radius.circular(8)), // ), // padding: const EdgeInsets.all(6), // child: SvgPicture.asset( // MyAssets.icBranches, // color: Colors.white, // ), // ), 12.width, Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ // Row( // children: [ // const Icon( // Icons.place, // size: 12, // color: MyColors.darkPrimaryColor, // ), // Geolocator.distanceBetween(AppState().currentLocation.latitude, AppState().currentLocation.latitude, double.parse(branches[index].latitude ?? "0"), // double.parse(branches[index].longitude ?? "0")) // .toStringAsFixed(2) // .toText( // fontSize: 12, // color: MyColors.darkPrimaryColor, // ) // ], // ), Text( branches[index].branchName ?? "", style: const TextStyle( fontSize: 14, fontWeight: FontWeight.bold, ), ), "Tap to view".toText(fontSize: 10, color: MyColors.grey70Color), ], ), ), 12.width, ], ).toContainer(borderRadius: 0, isShadowEnabled: true).onPress(() async { branches[index].countryID = serviceVM.branches!.data!.countryID; branches[index].countryName = serviceVM.branches!.data!.countryName; navigateWithName(context, AppRoutes.appointment, arguments: branches[index]); }); }, separatorBuilder: (context, index) { return 12.height; }, itemCount: branches.length, padding: const EdgeInsets.only(left: 21, right: 21, top: 8), ), ); } }, ), ), ], ), ), ); } }