From 6bdcf5fb814ad1bf18aba8631b686852d1ab63d2 Mon Sep 17 00:00:00 2001 From: "mirza.shafique" Date: Sun, 18 Jun 2023 17:03:04 +0300 Subject: [PATCH] branches list and provider profile 1.0 --- assets/icons/ic_right_up.png | Bin 0 -> 891 bytes lib/classes/consts.dart | 3 + lib/config/routes.dart | 4 + .../{branch2.dart => provider_model.dart} | 20 ++-- lib/models/profile/categroy.dart | 2 +- lib/models/services/branch_model.dart | 75 +++++++++++++++ lib/models/services/near_branch_model.dart | 39 ++++++++ lib/models/services/service_model.dart | 61 ++++++++++++ .../common_widgets/provider_details_card.dart | 88 ++++++++++-------- 9 files changed, 244 insertions(+), 48 deletions(-) create mode 100644 assets/icons/ic_right_up.png rename lib/models/model/{branch2.dart => provider_model.dart} (93%) create mode 100644 lib/models/services/branch_model.dart create mode 100644 lib/models/services/near_branch_model.dart create mode 100644 lib/models/services/service_model.dart diff --git a/assets/icons/ic_right_up.png b/assets/icons/ic_right_up.png new file mode 100644 index 0000000000000000000000000000000000000000..db97df339395967df96b2af2eaa97c1f30aba55a GIT binary patch literal 891 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7uRSEX7WqAsj$Z!;#Vf4nJ zFmD85#;?t9J%NIfC9V-A!TD(=<%vb94CUqJdYO6I#mR{Use1WE>9gP2NHH)l{qS^g z45^s&_O4}Ka3X{2L*XNA0z%Hd$!dy$8yKa`SWT-FIXMKpIAy0eaC$|!Xf!Q7;gz)i zqx`#{D&>{_`-|4)TDsP_RL^5v?;mT) zTZ$PTqA+)e{TKPeT@n6EfYpX!-gLW`Q#Tm)H*TIOzrL1x#eKFP9CzX$J>y%D*L{qg zJz(?E$IZ+uu4;We$ap1V>yHNvS(~$J3K&cyZS5=?qHNggjCKEMekgt6%C}$-?+3XZ z#t-F|AMk!~`~tVELuB!uH~Ek2<%>5mYb>t->RK8iC@~WxyFma${&qZILuyd&>P*~vZQFiu%6?#A)Sh#ElO1`;V3Y5J5(hg|F zY8Rlf1v6&=jVf~msSAt&%0*8EDsw0RvMzp9tY-N5QL&ui*nj;(hGY8`av6@@pJ>AH zI9@3g$aOlz&{N-gk3Hd!ZIxWZNB#@1f&2wx`%QD^^M2smVg67~@Z-Y$;S7)YuUuy6 zv3JsEHu&dZ%X8p|@D@9U$NpD70R@}GfZAtnv1qV-^#AA&hiagbGf`3p=6u|LwrCOG z79)no`b%0FCF&iw@*nuYy}FX&SiIv}pdzm Branch2.fromJson(json.decode(str)); +ProviderModel branch2FromJson(String str) => ProviderModel.fromJson(json.decode(str)); -String branch2ToJson(Branch2 data) => json.encode(data.toJson()); +String branch2ToJson(ProviderModel data) => json.encode(data.toJson()); -class Branch2 { - Branch2({ +class ProviderModel { + ProviderModel({ this.messageStatus, this.totalItemsCount, this.data, @@ -20,13 +20,13 @@ class Branch2 { final int? messageStatus; final int? totalItemsCount; - final Data? data; + final ProviderModelData? data; final String? message; - factory Branch2.fromJson(Map json) => Branch2( + factory ProviderModel.fromJson(Map json) => ProviderModel( messageStatus: json["messageStatus"] == null ? null : json["messageStatus"], totalItemsCount: json["totalItemsCount"] == null ? null : json["totalItemsCount"], - data: json["data"] == null ? null : Data.fromJson(json["data"]), + data: json["data"] == null ? null : ProviderModelData.fromJson(json["data"]), message: json["message"] == null ? null : json["message"], ); @@ -38,8 +38,8 @@ class Branch2 { }; } -class Data { - Data({ +class ProviderModelData { + ProviderModelData({ this.id, this.companyName, this.countryName, @@ -61,7 +61,7 @@ class Data { final String? userId; final List? serviceProviderBranch; - factory Data.fromJson(Map json) => Data( + factory ProviderModelData.fromJson(Map json) => ProviderModelData( id: json["id"] == null ? null : json["id"], companyName: json["companyName"] == null ? null : json["companyName"], countryName: json["countryName"] == null ? null : json["countryName"], diff --git a/lib/models/profile/categroy.dart b/lib/models/profile/categroy.dart index eddcf64..df38b64 100644 --- a/lib/models/profile/categroy.dart +++ b/lib/models/profile/categroy.dart @@ -5,7 +5,7 @@ import 'dart:convert'; import 'package:equatable/equatable.dart'; -import 'package:mc_common_app/models/model/branch2.dart'; +import 'package:mc_common_app/models/model/provider_model.dart'; Category categoryFromJson(String str) => Category.fromJson(json.decode(str)); diff --git a/lib/models/services/branch_model.dart b/lib/models/services/branch_model.dart new file mode 100644 index 0000000..403cdc3 --- /dev/null +++ b/lib/models/services/branch_model.dart @@ -0,0 +1,75 @@ + + +import 'package:mc_common_app/models/services/service_model.dart'; + +class BranchModel { + final int? id; + final int? serviceProviderId; + final String? serviceProviderName; + final String? branchName; + final String? branchDescription; + final int? cityId; + final String? address; + final String? latitude; + final String? longitude; + final double? distanceKm; + final String? openTime; + final String? closeTime; + final int? status; + final dynamic statusText; + final List? branchServices; + + BranchModel({ + this.id, + this.serviceProviderId, + this.serviceProviderName, + this.branchName, + this.branchDescription, + this.cityId, + this.address, + this.latitude, + this.longitude, + this.distanceKm, + this.openTime, + this.closeTime, + this.status, + this.statusText, + this.branchServices, + }); + + factory BranchModel.fromJson(Map json) => BranchModel( + id: json["id"], + serviceProviderId: json["serviceProviderID"], + serviceProviderName: json["serviceProviderName"], + branchName: json["branchName"], + branchDescription: json["branchDescription"], + cityId: json["cityID"], + address: json["address"], + latitude: json["latitude"], + longitude: json["longitude"], + distanceKm: json["distanceKM"]?.toDouble(), + openTime: json["openTime"], + closeTime: json["closeTime"], + status: json["status"], + statusText: json["statusText"], + branchServices: json["branchServices"] == null ? [] : List.from(json["branchServices"]!.map((x) => ServiceModel.fromJson(x))), + ); + + Map toJson() => { + "id": id, + "serviceProviderID": serviceProviderId, + "serviceProviderName": serviceProviderName, + "branchName": branchName, + "branchDescription": branchDescription, + "cityID": cityId, + "address": address, + "latitude": latitude, + "longitude": longitude, + "distanceKM": distanceKm, + "openTime": openTime, + "closeTime": closeTime, + "status": status, + "statusText": statusText, + "branchServices": branchServices == null ? [] : List.from(branchServices!.map((x) => x.toJson())), + }; +} diff --git a/lib/models/services/near_branch_model.dart b/lib/models/services/near_branch_model.dart new file mode 100644 index 0000000..93d9cd6 --- /dev/null +++ b/lib/models/services/near_branch_model.dart @@ -0,0 +1,39 @@ +// To parse this JSON data, do +// +// final nearBrancheModel = nearBrancheModelFromJson(jsonString); + +import 'dart:convert'; + +import 'branch_model.dart'; + +NearBrancheModel nearBrancheModelFromJson(String str) => NearBrancheModel.fromJson(json.decode(str)); + +String nearBrancheModelToJson(NearBrancheModel data) => json.encode(data.toJson()); + +class NearBrancheModel { + final int? messageStatus; + final int? totalItemsCount; + final List? data; + final String? message; + + NearBrancheModel({ + this.messageStatus, + this.totalItemsCount, + this.data, + this.message, + }); + + factory NearBrancheModel.fromJson(Map json) => NearBrancheModel( + messageStatus: json["messageStatus"], + totalItemsCount: json["totalItemsCount"], + data: json["data"] == null ? [] : List.from(json["data"]!.map((x) => BranchModel.fromJson(x))), + message: json["message"], + ); + + Map toJson() => { + "messageStatus": messageStatus, + "totalItemsCount": totalItemsCount, + "data": data == null ? [] : List.from(data!.map((x) => x.toJson())), + "message": message, + }; +} diff --git a/lib/models/services/service_model.dart b/lib/models/services/service_model.dart new file mode 100644 index 0000000..82ed8fe --- /dev/null +++ b/lib/models/services/service_model.dart @@ -0,0 +1,61 @@ +//TODO: this needs to match with ServiceProviderService from backend side +class ServiceModel { + final int? providerBranchServiceId; + final dynamic providerServiceDescription; + final int? serviceCategoryId; + final int? serviceId; + final String? serviceDescription; + final String? serviceDescriptionN; + final int? status; + final dynamic statusText; + final bool? isAllowAppointment; + final int? customerLocationRange; + final int? itemsCount; + bool isExpanded; + + ServiceModel({ + this.providerBranchServiceId, + this.providerServiceDescription, + this.serviceCategoryId, + this.serviceId, + this.serviceDescription, + this.serviceDescriptionN, + this.status, + this.statusText, + this.isAllowAppointment, + this.customerLocationRange, + this.itemsCount, + required this.isExpanded, + }); + + factory ServiceModel.fromJson(Map json) => + ServiceModel( + providerBranchServiceId: json["providerBranchServiceID"], + providerServiceDescription: json["providerServiceDescription"], + serviceCategoryId: json["serviceCategoryID"], + serviceId: json["serviceID"], + serviceDescription: json["serviceDescription"], + serviceDescriptionN: json["serviceDescriptionN"], + status: json["status"], + statusText: json["statusText"], + isAllowAppointment: json["isAllowAppointment"], + customerLocationRange: json["customerLocationRange"], + itemsCount: json["itemsCount"], + isExpanded: false, + ); + + Map toJson() => + { + "providerBranchServiceID": providerBranchServiceId, + "providerServiceDescription": providerServiceDescription, + "serviceCategoryID": serviceCategoryId, + "serviceID": serviceId, + "serviceDescription": serviceDescription, + "serviceDescriptionN": serviceDescriptionN, + "status": status, + "statusText": statusText, + "isAllowAppointment": isAllowAppointment, + "customerLocationRange": customerLocationRange, + "itemsCount": itemsCount, + }; +} \ No newline at end of file diff --git a/lib/widgets/common_widgets/provider_details_card.dart b/lib/widgets/common_widgets/provider_details_card.dart index 594c1a7..69c3048 100644 --- a/lib/widgets/common_widgets/provider_details_card.dart +++ b/lib/widgets/common_widgets/provider_details_card.dart @@ -4,34 +4,44 @@ import 'package:mc_common_app/classes/consts.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/services/service_model.dart'; import 'package:mc_common_app/theme/colors.dart'; import 'package:mc_common_app/widgets/extensions/extensions_widget.dart'; class ProviderDetailsCard extends StatelessWidget { final String providerImageUrl; - final String providerName; + final String title; + final String? providerName; final String providerLocation; final String providerRatings; + + //TODO: items can be make a generaic, so we can add services/items in the future + final List? items; final Function() onCardTapped; const ProviderDetailsCard({ Key? key, required this.providerImageUrl, - required this.providerName, + required this.title, + this.providerName, required this.providerRatings, required this.providerLocation, + this.items, required this.onCardTapped, }) : super(key: key); @override Widget build(BuildContext context) { + //TODO: use pading in listview return Padding( - padding: const EdgeInsets.only( - bottom: 10, - left: 21, - right: 21, - ), + padding: EdgeInsets.zero, + // padding: const EdgeInsets.only( + // bottom: 10, + // left: 21, + // right: 21, + // ), child: Row( + crossAxisAlignment: CrossAxisAlignment.start, children: [ Image.asset( providerImageUrl, @@ -53,14 +63,22 @@ class ProviderDetailsCard extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ - providerName.toText(fontSize: 16, isBold: true), + title.toText(fontSize: 16, isBold: true), Row( children: [ - LocaleKeys.location.tr().toText(color: MyColors.lightTextColor, fontSize: 12), - 2.width, - ":$providerLocation".toText(fontSize: 12), + (LocaleKeys.location.tr() + ":").toText(color: MyColors.lightTextColor, fontSize: 12), + 4.width, + providerLocation.toText(fontSize: 12, isBold: true), ], ), + if (providerName != null) + Row( + children: [ + (LocaleKeys.providers.tr() + ":").toText(color: MyColors.lightTextColor, fontSize: 12), + 4.width, + providerName!.toText(fontSize: 12, isBold: true), + ], + ), ], ), ), @@ -79,36 +97,32 @@ class ProviderDetailsCard extends StatelessWidget { ], ), 8.height, - Row( - children: [ - Expanded( - child: Column( - children: [ + if (items != null) + Column( + children: items! + .take(2) + .map( + (e) => Row( children: [ - MyAssets.maintenanceIcon.buildSvg(), - 8.width, - LocaleKeys.maintenance.tr().toText( - fontSize: 12, - isBold: true, - ), + //TODO: Needs to add icon in the future when added from the provider + // MyAssets.maintenanceIcon.buildSvg(), + // 8.width, + e.serviceDescription.toString().toText( + fontSize: 12, + isBold: true, + ) ], ), - Row( - children: [ - MyAssets.modificationsIcon.buildSvg(), - 8.width, - LocaleKeys.accessories_modifications.tr().toText( - fontSize: 12, - isBold: true, - ), - ], - ) - ], - ), - ), - ], - ), + ) + .toList(), + ), + if (items != null && items!.length > 2) + ("+${items!.length - 2} more").toText( + color: MyColors.primaryColor, + isUnderLine: true, + isBold: true, + ), ], ), ),