From 7f9d9dba71ed4f94fd732141edaaa947006adefe Mon Sep 17 00:00:00 2001 From: Faiz Hashmi Date: Mon, 2 Sep 2024 14:41:51 +0300 Subject: [PATCH] Fixes --- lib/views/branches/branch_detail_view.dart | 1 + lib/views/branches/provider_profile_view.dart | 76 ++++++++++--------- .../widgets/my_recent_branches_widget.dart | 1 + 3 files changed, 41 insertions(+), 37 deletions(-) diff --git a/lib/views/branches/branch_detail_view.dart b/lib/views/branches/branch_detail_view.dart index 6c16e27..4273f80 100644 --- a/lib/views/branches/branch_detail_view.dart +++ b/lib/views/branches/branch_detail_view.dart @@ -3,6 +3,7 @@ import 'dart:developer'; import 'package:car_customer_app/views/branches/components/branch_reviews_widget.dart'; import 'package:car_customer_app/views/branches/components/items_list_sheet.dart'; +import 'package:mc_common_app/main.dart'; import 'package:mc_common_app/view_models/appointments_view_model.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; diff --git a/lib/views/branches/provider_profile_view.dart b/lib/views/branches/provider_profile_view.dart index 353e001..6421658 100644 --- a/lib/views/branches/provider_profile_view.dart +++ b/lib/views/branches/provider_profile_view.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'package:mc_common_app/models/provider_branches_models/branch_detail_model.dart'; +import 'package:mc_common_app/utils/date_helper.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'; @@ -36,15 +37,13 @@ class _ProviderProfileViewState extends State { Widget build(BuildContext context) { return Consumer( builder: (BuildContext context, AppointmentsVM appointmentsVM, Widget? child) { - if (appointmentsVM.state == ViewState.busy) { + if (appointmentsVM.state == ViewState.busy || appointmentsVM.providerProfileModel == null) { return Scaffold( backgroundColor: MyColors.white, appBar: CustomAppBar( title: LocaleKeys.providerDetails.tr(), ), - body: Center( - child: CircularProgressIndicator(), - ), + body: Center(child: CircularProgressIndicator()), ); } return Scaffold( @@ -87,16 +86,19 @@ class _ProviderProfileViewState extends State { Image.asset(MyAssets.bnCar), 12.height, (appointmentsVM.providerProfileModel!.name ?? appointmentsVM.providerProfileModel!.companyName).toString().toText( - fontSize: 16, - isBold: true, - ), + fontSize: 16, + isBold: true, + ), - if (appointmentsVM.providerProfileModel!.memberSince!.isNotEmpty ) ...[ + if (appointmentsVM.providerProfileModel!.memberSince!.isNotEmpty) ...[ Row( children: [ ("Member Since:").toText(color: MyColors.lightTextColor, fontSize: 12), 4.width, - "${appointmentsVM.providerProfileModel!.memberSince ?? ""}".toText(fontSize: 12, isBold: true), + "${DateHelper.formatAsMonthYear(DateHelper.parseStringToDate(DateHelper.formatDateT(appointmentsVM.providerProfileModel!.memberSince ?? "")))}".toText( + fontSize: 12, + isBold: true, + ), ], ), ], @@ -107,35 +109,35 @@ class _ProviderProfileViewState extends State { 12.height, appointmentsVM.providerProfileModel!.serviceProviderBranch == null ? Center( - child: (LocaleKeys.noBranchFound.tr()).toText( - fontSize: 16, - color: MyColors.lightTextColor, - ), - ) + child: (LocaleKeys.noBranchFound.tr()).toText( + fontSize: 16, + color: MyColors.lightTextColor, + ), + ) : appointmentsVM.providerProfileModel!.serviceProviderBranch!.isEmpty - ? Center(child: Text(LocaleKeys.no_branch.tr())) - : ListView.separated( - itemBuilder: (context, index) { - BranchDetailModel branchModel = appointmentsVM.providerProfileModel!.serviceProviderBranch![index]; - return BranchDetailCard( - onCardTapped: () { - navigateWithName(context, AppRoutes.branchDetailView, arguments: branchModel); - }, - providerImageUrl: MyAssets.bnCar, - title: branchModel.branchName ?? "", - providerLocation: branchModel.distanceKm.toString() + " KM", - providerName: branchModel.serviceProviderName ?? "", - providerRatings: (branchModel.branchRateAvg ?? 0.0), - services: branchModel.branchServices, - ); - }, - separatorBuilder: (context, index) { - return 12.height; - }, - itemCount: appointmentsVM.providerProfileModel!.serviceProviderBranch!.length, - physics: NeverScrollableScrollPhysics(), - shrinkWrap: true, - ) + ? Center(child: Text(LocaleKeys.no_branch.tr())) + : ListView.separated( + itemBuilder: (context, index) { + BranchDetailModel branchModel = appointmentsVM.providerProfileModel!.serviceProviderBranch![index]; + return BranchDetailCard( + onCardTapped: () { + navigateWithName(context, AppRoutes.branchDetailView, arguments: branchModel); + }, + providerImageUrl: MyAssets.bnCar, + title: branchModel.branchName ?? "", + providerLocation: branchModel.distanceKm.toString() + " KM", + providerName: branchModel.serviceProviderName ?? "", + providerRatings: (branchModel.branchRateAvg ?? 0.0), + services: branchModel.branchServices, + ); + }, + separatorBuilder: (context, index) { + return 12.height; + }, + itemCount: appointmentsVM.providerProfileModel!.serviceProviderBranch!.length, + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + ) ], ), ), diff --git a/lib/views/dashboard/widgets/my_recent_branches_widget.dart b/lib/views/dashboard/widgets/my_recent_branches_widget.dart index 4b80435..896372c 100644 --- a/lib/views/dashboard/widgets/my_recent_branches_widget.dart +++ b/lib/views/dashboard/widgets/my_recent_branches_widget.dart @@ -31,6 +31,7 @@ class MyRecentBranchesWidget extends StatelessWidget { .buildNetworkImage( height: 80, width: 80, + fit: BoxFit.cover, ) .toCircle(borderRadius: 100), 8.height,