|
|
|
|
@ -1,5 +1,8 @@
|
|
|
|
|
import 'dart:async';
|
|
|
|
|
import 'dart:developer';
|
|
|
|
|
|
|
|
|
|
import 'package:mc_common_app/models/provider_branches_models/branch_detail_model.dart';
|
|
|
|
|
import 'package:mc_common_app/utils/enums.dart';
|
|
|
|
|
import 'package:mc_common_app/view_models/appointments_view_model.dart';
|
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
@ -28,17 +31,19 @@ class _ProviderProfileViewState extends State<ProviderProfileView> {
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
context.read<AppointmentsVM>().getBranchAndServices(widget.providerId);
|
|
|
|
|
scheduleMicrotask(() async => context.read<AppointmentsVM>().getProviderProfileWithBranchesAndServices(widget.providerId));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Consumer(
|
|
|
|
|
builder: (BuildContext context, AppointmentsVM appointmentsVM, Widget? child) {
|
|
|
|
|
// log("appointmentsVM.providerProfileModel!.isFavorite: ${appointmentsVM.providerProfileModel!.isFavorite}");
|
|
|
|
|
if (appointmentsVM.providerProfileModel == null) {
|
|
|
|
|
if (appointmentsVM.state == ViewState.busy) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
backgroundColor: MyColors.white,
|
|
|
|
|
appBar: CustomAppBar(
|
|
|
|
|
title: LocaleKeys.providerDetails.tr(),
|
|
|
|
|
),
|
|
|
|
|
body: Center(
|
|
|
|
|
child: CircularProgressIndicator(),
|
|
|
|
|
),
|
|
|
|
|
@ -51,7 +56,23 @@ class _ProviderProfileViewState extends State<ProviderProfileView> {
|
|
|
|
|
Icon(
|
|
|
|
|
appointmentsVM.providerProfileModel!.isFavorite! ? Icons.favorite : Icons.favorite_border,
|
|
|
|
|
color: appointmentsVM.providerProfileModel!.isFavorite! ? MyColors.darkPrimaryColor : MyColors.black,
|
|
|
|
|
).horPaddingMain().onPress(() {}),
|
|
|
|
|
).horPaddingMain().onPress(() async {
|
|
|
|
|
if (appointmentsVM.providerProfileModel!.isFavorite!) {
|
|
|
|
|
bool status = await appointmentsVM.removeProviderFromFavorite(serviceProviderID: appointmentsVM.providerProfileModel!.id!, context: context);
|
|
|
|
|
|
|
|
|
|
if (status) {
|
|
|
|
|
appointmentsVM.providerProfileModel!.isFavorite = false;
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
bool status = await appointmentsVM.addProviderToFavorite(serviceProviderID: appointmentsVM.providerProfileModel!.id!, context: context);
|
|
|
|
|
|
|
|
|
|
if (status) {
|
|
|
|
|
appointmentsVM.providerProfileModel!.isFavorite = true;
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
body: Container(
|
|
|
|
|
@ -90,16 +111,17 @@ class _ProviderProfileViewState extends State<ProviderProfileView> {
|
|
|
|
|
? Center(child: Text(LocaleKeys.no_branch.tr()))
|
|
|
|
|
: ListView.separated(
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
BranchDetailModel branchModel = appointmentsVM.providerProfileModel!.serviceProviderBranch![index];
|
|
|
|
|
return ProviderDetailsCard(
|
|
|
|
|
onCardTapped: () {
|
|
|
|
|
navigateWithName(context, AppRoutes.branchDetailView, arguments: appointmentsVM.providerProfileModel!.serviceProviderBranch![index]);
|
|
|
|
|
navigateWithName(context, AppRoutes.branchDetailView, arguments: branchModel);
|
|
|
|
|
},
|
|
|
|
|
providerImageUrl: MyAssets.bnCar,
|
|
|
|
|
title: appointmentsVM.providerProfileModel!.serviceProviderBranch![index].branchName ?? "",
|
|
|
|
|
providerLocation: appointmentsVM.providerProfileModel!.serviceProviderBranch![index].distanceKm.toString() + " KM",
|
|
|
|
|
providerName: appointmentsVM.providerProfileModel!.serviceProviderBranch![index].serviceProviderName ?? "",
|
|
|
|
|
providerRatings: "4.9",
|
|
|
|
|
services: appointmentsVM.providerProfileModel!.serviceProviderBranch![index].branchServices,
|
|
|
|
|
title: branchModel.branchName ?? "",
|
|
|
|
|
providerLocation: branchModel.distanceKm.toString() + " KM",
|
|
|
|
|
providerName: branchModel.serviceProviderName ?? "",
|
|
|
|
|
providerRatings: (branchModel.branchRateAvg ?? 0.0),
|
|
|
|
|
services: branchModel.branchServices,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
separatorBuilder: (context, index) {
|
|
|
|
|
|