classes added from provider

merge-requests/13/head
mirza.shafique 2 years ago
parent dba5492995
commit ff9b906211

@ -21,14 +21,16 @@ class Schedule {
this.message,
});
factory Schedule.fromJson(Map<String, dynamic> json) => Schedule(
factory Schedule.fromJson(Map<String, dynamic> json) =>
Schedule(
messageStatus: json["messageStatus"],
totalItemsCount: json["totalItemsCount"],
data: json["data"] == null ? [] : List<ScheduleData>.from(json["data"]!.map((x) => ScheduleData.fromJson(x))),
message: json["message"],
);
Map<String, dynamic> toJson() => {
Map<String, dynamic> toJson() =>
{
"messageStatus": messageStatus,
"totalItemsCount": totalItemsCount,
"data": data == null ? [] : List<dynamic>.from(data!.map((x) => x.toJson())),
@ -73,7 +75,8 @@ class ScheduleData {
this.branchId = "",
});
factory ScheduleData.fromJson(Map<String, dynamic> json) => ScheduleData(
factory ScheduleData.fromJson(Map<String, dynamic> json) =>
ScheduleData(
id: json["id"],
scheduleName: json["scheduleName"],
serviceProviderBranchId: json["serviceProviderBranchID"],
@ -91,7 +94,8 @@ class ScheduleData {
scheduleServices: json["scheduleServices"] == null ? [] : List<ScheduleService>.from(json["scheduleServices"]!.map((x) => ScheduleService.fromJson(x))),
);
Map<String, dynamic> toJson() => {
Map<String, dynamic> 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<String, dynamic> json) => ScheduleService(
factory ScheduleService.fromJson(Map<String, dynamic> json) =>
ScheduleService(
providerServiceId: json["providerServiceID"],
// branchScheduleGroupServiceID: json["branchScheduleGroupServiceID"],
providerServiceName: json["providerServiceName"],
);
Map<String, dynamic> toJson() => {
Map<String, dynamic> toJson() =>
{
"providerServiceID": providerServiceId,
"providerServiceName": providerServiceName,
};
@ -138,12 +147,14 @@ class WeeklyOffDay {
this.dayNumber,
});
factory WeeklyOffDay.fromJson(Map<String, dynamic> json) => WeeklyOffDay(
factory WeeklyOffDay.fromJson(Map<String, dynamic> json) =>
WeeklyOffDay(
id: json["id"],
dayNumber: json["dayNumber"],
);
Map<String, dynamic> toJson() => {
Map<String, dynamic> toJson() =>
{
"id": id,
"dayNumber": dayNumber,
};

@ -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<ItemData>? data;
final String? message;
ItemModel({
this.messageStatus,
this.totalItemsCount,
this.data,
this.message,
});
factory ItemModel.fromJson(Map<String, dynamic> json) => ItemModel(
messageStatus: json["messageStatus"],
totalItemsCount: json["totalItemsCount"],
data: json["data"] == null ? [] : List<ItemData>.from(json["data"]!.map((x) => ItemData.fromJson(x))),
message: json["message"],
);
Map<String, dynamic> toJson() => {
"messageStatus": messageStatus,
"totalItemsCount": totalItemsCount,
"data": data == null ? [] : List<dynamic>.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<String, dynamic> 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<String, dynamic> 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,
};
}

@ -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<Subscription>? data;
String? message;
factory SubscriptionModel.fromJson(Map<String, dynamic> json) => SubscriptionModel(
messageStatus: json["messageStatus"],
totalItemsCount: json["totalItemsCount"],
data: json["data"] == null ? [] : List<Subscription>.from(json["data"]!.map((x) => Subscription.fromJson(x))),
message: json["message"],
);
Map<String, dynamic> toJson() => {
"messageStatus": messageStatus,
"totalItemsCount": totalItemsCount,
"data": data == null ? [] : List<dynamic>.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<String, dynamic> 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<String, dynamic> 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,
};
}

@ -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<void> 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<void> getExploreAds() async {
setState(ViewState.busy);
exploreAds = await adsRepo.getAllAds(isMyAds: false);
myAdsFilteredList = exploreAds;
notifyListeners();
setState(ViewState.idle);
}
Future<void> 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<VehiclePostingImages> convertFileToVehiclePostingImages({required File file}) async {
List<int> 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,

@ -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<AdDetailsModel> 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<AdVM>().isExploreAdsTapped) ...[
if (isAdsFragment && context
.read<AdVM>()
.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,);
}
}

@ -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),
],
),
),
],
),
);
}
}

@ -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';

@ -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());
}
}
Loading…
Cancel
Save