diff --git a/lib/models/schedule_model.dart b/lib/models/schedule_model.dart index 552d704..6676083 100644 --- a/lib/models/schedule_model.dart +++ b/lib/models/schedule_model.dart @@ -21,14 +21,16 @@ class Schedule { this.message, }); - factory Schedule.fromJson(Map json) => Schedule( + factory Schedule.fromJson(Map json) => + Schedule( messageStatus: json["messageStatus"], totalItemsCount: json["totalItemsCount"], data: json["data"] == null ? [] : List.from(json["data"]!.map((x) => ScheduleData.fromJson(x))), message: json["message"], ); - Map toJson() => { + Map toJson() => + { "messageStatus": messageStatus, "totalItemsCount": totalItemsCount, "data": data == null ? [] : List.from(data!.map((x) => x.toJson())), @@ -73,7 +75,8 @@ class ScheduleData { this.branchId = "", }); - factory ScheduleData.fromJson(Map json) => ScheduleData( + factory ScheduleData.fromJson(Map json) => + ScheduleData( id: json["id"], scheduleName: json["scheduleName"], serviceProviderBranchId: json["serviceProviderBranchID"], @@ -91,7 +94,8 @@ class ScheduleData { scheduleServices: json["scheduleServices"] == null ? [] : List.from(json["scheduleServices"]!.map((x) => ScheduleService.fromJson(x))), ); - Map toJson() => { + Map toJson() => + { "id": id, "scheduleName": scheduleName, "serviceProviderBranchID": serviceProviderBranchId, @@ -111,19 +115,24 @@ class ScheduleData { class ScheduleService { final int? providerServiceId; + // final int? branchScheduleGroupServiceID; final String? providerServiceName; ScheduleService({ this.providerServiceId, + // this.branchScheduleGroupServiceID, this.providerServiceName, }); - factory ScheduleService.fromJson(Map json) => ScheduleService( + factory ScheduleService.fromJson(Map json) => + ScheduleService( providerServiceId: json["providerServiceID"], + // branchScheduleGroupServiceID: json["branchScheduleGroupServiceID"], providerServiceName: json["providerServiceName"], ); - Map toJson() => { + Map toJson() => + { "providerServiceID": providerServiceId, "providerServiceName": providerServiceName, }; @@ -138,12 +147,14 @@ class WeeklyOffDay { this.dayNumber, }); - factory WeeklyOffDay.fromJson(Map json) => WeeklyOffDay( + factory WeeklyOffDay.fromJson(Map json) => + WeeklyOffDay( id: json["id"], dayNumber: json["dayNumber"], ); - Map toJson() => { + Map toJson() => + { "id": id, "dayNumber": dayNumber, }; diff --git a/lib/models/services/item_model.dart b/lib/models/services/item_model.dart new file mode 100644 index 0000000..6bfd075 --- /dev/null +++ b/lib/models/services/item_model.dart @@ -0,0 +1,100 @@ +// To parse this JSON data, do +// +// final itemModel = itemModelFromJson(jsonString); + +import 'dart:convert'; + +ItemModel itemModelFromJson(String str) => ItemModel.fromJson(json.decode(str)); + +String itemModelToJson(ItemModel data) => json.encode(data.toJson()); + +class ItemModel { + final int? messageStatus; + final int? totalItemsCount; + final List? data; + final String? message; + + ItemModel({ + this.messageStatus, + this.totalItemsCount, + this.data, + this.message, + }); + + factory ItemModel.fromJson(Map json) => ItemModel( + messageStatus: json["messageStatus"], + totalItemsCount: json["totalItemsCount"], + data: json["data"] == null ? [] : List.from(json["data"]!.map((x) => ItemData.fromJson(x))), + message: json["message"], + ); + + Map toJson() => { + "messageStatus": messageStatus, + "totalItemsCount": totalItemsCount, + "data": data == null ? [] : List.from(data!.map((x) => x.toJson())), + "message": message, + }; +} + +class ItemData { + final int? id; + final String? name; + final String? price; + final String? manufactureDate; + final String? description; + final dynamic pictureUrl; + final int? companyId; + final int? serviceProviderServiceId; + final bool? isActive; + final bool? isAllowAppointment; + final bool? isAppointmentCompanyLoc; + final bool? isAppointmentCustomerLoc; + bool? isUpdate; + + ItemData({ + this.id, + this.name, + this.price, + this.manufactureDate, + this.description, + this.pictureUrl, + this.companyId, + this.serviceProviderServiceId, + this.isActive, + this.isAllowAppointment, + this.isAppointmentCompanyLoc, + this.isAppointmentCustomerLoc, + this.isUpdate, + }); + + factory ItemData.fromJson(Map json) => ItemData( + id: json["id"], + name: json["name"], + price: json["price"].toString(), + manufactureDate: json["manufactureDate"], + description: json["description"], + pictureUrl: json["pictureUrl"], + companyId: json["companyID"], + serviceProviderServiceId: json["serviceProviderServiceID"], + isActive: json["isActive"], + isAllowAppointment: json["isAllowAppointment"], + isAppointmentCompanyLoc: json["isAppointmentCompanyLoc"], + isAppointmentCustomerLoc: json["isAppointmentCustomerLoc"], + isUpdate: false, + ); + + Map toJson() => { + "id": id, + "name": name, + "price": price, + "manufactureDate": manufactureDate, + "description": description, + "pictureUrl": pictureUrl, + "companyID": companyId, + "serviceProviderServiceID": serviceProviderServiceId, + "isActive": isActive, + "isAllowAppointment": isAllowAppointment, + "isAppointmentCompanyLoc": isAppointmentCompanyLoc, + "isAppointmentCustomerLoc": isAppointmentCustomerLoc, + }; +} diff --git a/lib/models/subscription_model.dart b/lib/models/subscription_model.dart new file mode 100644 index 0000000..d192566 --- /dev/null +++ b/lib/models/subscription_model.dart @@ -0,0 +1,125 @@ +// To parse this JSON data, do +// +// final subscription = subscriptionFromJson(jsonString); + +import 'dart:convert'; + +Subscription subscriptionFromJson(String str) => Subscription.fromJson(json.decode(str)); + +String subscriptionToJson(Subscription data) => json.encode(data.toJson()); + +class SubscriptionModel { + SubscriptionModel({ + this.messageStatus, + this.totalItemsCount, + this.data, + this.message, + }); + + int? messageStatus; + int? totalItemsCount; + List? data; + String? message; + + factory SubscriptionModel.fromJson(Map json) => SubscriptionModel( + messageStatus: json["messageStatus"], + totalItemsCount: json["totalItemsCount"], + data: json["data"] == null ? [] : List.from(json["data"]!.map((x) => Subscription.fromJson(x))), + message: json["message"], + ); + + Map toJson() => { + "messageStatus": messageStatus, + "totalItemsCount": totalItemsCount, + "data": data == null ? [] : List.from(data!.map((x) => x.toJson())), + "message": message, + }; +} + +class Subscription { + Subscription({ + this.id, + this.name, + this.description, + this.durationName, + this.durationDays, + this.price, + this.currency, + this.numberOfBranches, + this.numberOfSubUsers, + this.numberOfAds, + this.countryId, + this.countryName, + this.isSubscribed, + this.subscriptionAppliedId, + this.serviceProviderId, + this.dateStart, + this.dateEnd, + this.isExpired, + this.isActive, + }); + + int? id; + String? name; + String? description; + String? durationName; + int? durationDays; + double? price; + String? currency; + int? numberOfBranches; + int? numberOfSubUsers; + int? numberOfAds; + int? countryId; + String? countryName; + bool? isSubscribed; + int? subscriptionAppliedId; + int? serviceProviderId; + DateTime? dateStart; + DateTime? dateEnd; + bool? isExpired; + bool? isActive; + + factory Subscription.fromJson(Map json) => Subscription( + id: json["id"], + name: json["name"], + description: json["description"], + durationName: json["durationName"], + durationDays: json["durationDays"], + price: json["price"]?.toDouble(), + currency: json["currency"], + numberOfBranches: json["numberOfBranches"], + numberOfSubUsers: json["numberOfSubUsers"], + numberOfAds: json["numberOfAds"], + countryId: json["countryID"], + countryName: json["countryName"]!, + isSubscribed: json["isSubscribed"], + subscriptionAppliedId: json["subscriptionAppliedID"], + serviceProviderId: json["serviceProviderID"], + dateStart: json["dateStart"] == null ? null : DateTime.parse(json["dateStart"]), + dateEnd: json["dateEnd"] == null ? null : DateTime.parse(json["dateEnd"]), + isExpired: json["isExpired"], + isActive: json["isActive"], + ); + + Map toJson() => { + "id": id, + "name": name, + "description": description, + "durationName": durationName, + "durationDays": durationDays, + "price": price, + "currency": currency, + "numberOfBranches": numberOfBranches, + "numberOfSubUsers": numberOfSubUsers, + "numberOfAds": numberOfAds, + "countryID": countryId, + "countryName": countryName, + "isSubscribed": isSubscribed, + "subscriptionAppliedID": subscriptionAppliedId, + "serviceProviderID": serviceProviderId, + "dateStart": dateStart?.toIso8601String(), + "dateEnd": dateEnd?.toIso8601String(), + "isExpired": isExpired, + "isActive": isActive, + }; +} diff --git a/lib/view_models/ad_view_model.dart b/lib/view_models/ad_view_model.dart index faf4a97..60a12bf 100644 --- a/lib/view_models/ad_view_model.dart +++ b/lib/view_models/ad_view_model.dart @@ -96,10 +96,7 @@ class AdVM extends BaseVM { } void removeSpecialServiceCard(int index) { - String option = specialServiceCards - .elementAt(index) - .serviceSelectedId! - .selectedOption; + String option = specialServiceCards.elementAt(index).serviceSelectedId!.selectedOption; for (var value in vehicleAdsSpecialServices) { if (value.name == option) { @@ -205,18 +202,20 @@ class AdVM extends BaseVM { Future getMyAds() async { isFetchingLists = true; + setState(ViewState.busy); myAds = await adsRepo.getAllAds(isMyAds: true); final myActiveAds = myAds.where((element) => element.adPostStatus == AdPostStatus.active).toList(); myActiveAdsForHome = myActiveAds.length >= 3 ? myActiveAds.take(3).toList() : myActiveAds; isFetchingLists = true; - notifyListeners(); + setState(ViewState.idle); } Future getExploreAds() async { + setState(ViewState.busy); exploreAds = await adsRepo.getAllAds(isMyAds: false); myAdsFilteredList = exploreAds; - notifyListeners(); + setState(ViewState.idle); } Future getVehicleTypes() async { @@ -868,10 +867,7 @@ class AdVM extends BaseVM { } void removeDamagePartCard(int index) { - String option = vehicleDamageCards - .elementAt(index) - .partSelectedId! - .selectedOption; + String option = vehicleDamageCards.elementAt(index).partSelectedId!.selectedOption; for (var value in vehicleDamageParts) { if (value.partName == option) { @@ -1003,9 +999,7 @@ class AdVM extends BaseVM { Future convertFileToVehiclePostingImages({required File file}) async { List imageBytes = await file.readAsBytes(); String image = base64Encode(imageBytes); - String fileName = file.path - .split('/') - .last; + String fileName = file.path.split('/').last; VehiclePostingImages vehiclePostingImages = VehiclePostingImages( imageName: fileName, imageStr: image, diff --git a/lib/views/advertisement/ads_list.dart b/lib/views/advertisement/ads_list.dart index 73af6a9..0ae4ecf 100644 --- a/lib/views/advertisement/ads_list.dart +++ b/lib/views/advertisement/ads_list.dart @@ -10,6 +10,7 @@ import 'package:mc_common_app/utils/utils.dart'; import 'package:mc_common_app/view_models/ad_view_model.dart'; import 'package:mc_common_app/widgets/extensions/extensions_widget.dart'; import 'package:provider/provider.dart'; +import 'package:sizer/sizer.dart'; class BuildAdsList extends StatelessWidget { final List adsList; @@ -35,22 +36,26 @@ class BuildAdsList extends StatelessWidget { ], ); } - return ListView.builder( - itemCount: adsList.length, - shrinkWrap: true, - physics: scrollPhysics, - itemBuilder: (BuildContext context, int index) { - return Padding( - padding: const EdgeInsets.only(bottom: 8), - child: AdCard( - adDetails: adsList[index], - isAdsFragment: isAdsFragment, - shouldShowAdStatus: shouldShowAdStatus, - ), - ).onPress(() { + return ListView.separated( + itemCount: adsList.length, + shrinkWrap: true, + physics: scrollPhysics, + itemBuilder: (BuildContext context, int index) { + return AdCard( + adDetails: adsList[index], + isAdsFragment: isAdsFragment, + shouldShowAdStatus: shouldShowAdStatus, + ).onPress( + () { navigateWithName(context, AppRoutes.adsDetailView, arguments: adsList[index]); - }); - }); + }, + ); + }, + separatorBuilder: (BuildContext context, int index) { + return 12.height; + }, + padding: EdgeInsets.symmetric(horizontal: 21), + ); } } @@ -95,7 +100,9 @@ class AdCard extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ - if (isAdsFragment && context.read().isExploreAdsTapped) ...[ + if (isAdsFragment && context + .read() + .isExploreAdsTapped) ...[ Utils.statusContainerChip(text: adDetails.statuslabel!, chipColor: Utils.getChipColorByAdStatus(adDetails.adPostStatus!)), ], if (shouldShowAdStatus) ...[ @@ -132,8 +139,8 @@ class AdCard extends StatelessWidget { ), adDetails.createdOn != null ? DateTime.parse(adDetails.createdOn!).getTimeAgo().toText( - color: MyColors.lightTextColor, - ) + color: MyColors.lightTextColor, + ) : const SizedBox(), ], ), @@ -184,6 +191,6 @@ class AdCard extends StatelessWidget { else const SizedBox(), ], - ).toWhiteContainer(width: double.infinity, allPading: 12, margin: const EdgeInsets.symmetric(horizontal: 21)); + ).toWhiteContainer(width: double.infinity, allPading: 12,); } } diff --git a/lib/widgets/checkbox_with_title_desc.dart b/lib/widgets/checkbox_with_title_desc.dart new file mode 100644 index 0000000..99088aa --- /dev/null +++ b/lib/widgets/checkbox_with_title_desc.dart @@ -0,0 +1,40 @@ +import 'package:flutter/material.dart'; +import 'package:mc_common_app/extensions/string_extensions.dart'; +import 'package:mc_common_app/theme/colors.dart'; + +class CheckBoxWithTitleDescription extends StatelessWidget { + bool isSelected; + String title, description; + Function(bool) onSelection; + + CheckBoxWithTitleDescription({required this.isSelected, required this.title, required this.description, required this.onSelection, Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return SizedBox( + width: double.infinity, + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Checkbox( + value: isSelected, + onChanged: (bool? v) { + onSelection(v ?? false); + }, + ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + title.toText(fontSize: 14, isBold: true), + description.toText(fontSize: 12, color: MyColors.lightTextColor), + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/widgets/common_widgets/my_service_provider.dart b/lib/widgets/common_widgets/my_service_provider.dart index 8881cfb..afcb536 100644 --- a/lib/widgets/common_widgets/my_service_provider.dart +++ b/lib/widgets/common_widgets/my_service_provider.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:mc_common_app/classes/consts.dart'; import 'package:mc_common_app/extensions/int_extensions.dart'; diff --git a/lib/widgets/empty_widget.dart b/lib/widgets/empty_widget.dart new file mode 100644 index 0000000..3e4cac0 --- /dev/null +++ b/lib/widgets/empty_widget.dart @@ -0,0 +1,11 @@ +import 'package:flutter/material.dart'; +import 'package:mc_common_app/extensions/string_extensions.dart'; + +class EmptyWidget extends StatelessWidget { + const EmptyWidget({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Center(child: "No Data Found".toText()); + } +}