diff --git a/assets/icons/ic_right_up.png b/assets/icons/ic_right_up.png new file mode 100644 index 0000000..db97df3 Binary files /dev/null and b/assets/icons/ic_right_up.png differ diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index dfcd6c6..a98b2b6 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -49,11 +49,13 @@ class ApiConsts { static String ServiceProviderService_Get = "${baseUrlServices}api/ServiceProviders/ServiceProviderService_Get"; static String BranchesAndServices = "${baseUrlServices}api/ServiceProviders/ServiceProviderDetail_Get"; + static String GetAllNearBranches = "${baseUrlServices}api/ServiceProviders/ServiceProviderBranchDetail_Get"; //Appointment APIs static String serviceProvidersAppointmentGet = "${baseUrlServices}api/ServiceProviders/ServiceProvidersAppointment_Get"; static String serviceCategoryGet = "${baseUrlServices}api/Master/ServiceCategory_Get"; static String serviceItemsGet = "${baseUrlServices}api/ServiceProviders/ServiceItem_Get"; + //ServiceProvidersServiceID as params // static String servicesGet = "${baseUrlServices}api/ServiceProviders/Services_Get"; @@ -197,6 +199,7 @@ class MyAssets { static String icWhatsAppPng = "${assetPath}icons/ic_whatsapp.png"; static String icSmsPng = "${assetPath}icons/ic_sms.png"; static String icFingerprintPng = "${assetPath}icons/ic_fingerprint.png"; + static String icRightUpPng = "${assetPath}icons/ic_right_up.png"; static String applePayPng = "${assetPath}icons/payments/apple_pay.png"; static String installmentsPng = "${assetPath}icons/payments/installments.png"; diff --git a/lib/config/routes.dart b/lib/config/routes.dart index a32a7b2..cb9aee9 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -58,6 +58,10 @@ class AppRoutes { static const String bookAppointmenServicesView = "/bookAppointmenServicesView"; static const String paymentMethodsView = "/paymentMethodsView"; + //Customer APP: Provider & Services + static const String branchDetailPage = "/branchDetailPage"; + static const String providerProfilePage = "/providerProfilePage"; + //Subcriptions static final String mySubscriptionsPage = "/mySubscriptionsPage"; diff --git a/lib/models/model/branch2.dart b/lib/models/model/provider_model.dart similarity index 93% rename from lib/models/model/branch2.dart rename to lib/models/model/provider_model.dart index 2fa672e..352f1e1 100644 --- a/lib/models/model/branch2.dart +++ b/lib/models/model/provider_model.dart @@ -6,12 +6,12 @@ import 'dart:convert'; import 'package:mc_common_app/models/profile/categroy.dart'; -Branch2 branch2FromJson(String str) => 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, + ), ], ), ),