Reverted Code

pull/3/head
FaizHashmiCS22 2 years ago
parent 92d1e28116
commit 026090b962

@ -4,8 +4,7 @@
import 'dart:convert';
import 'package:mc_common_app/models/profile/categroy.dart';
import 'package:mc_common_app/models/services/branch_model.dart';
import 'package:mc_common_app/models/provider_branches_models/branch_detail_model.dart';
ProviderModel branch2FromJson(String str) => ProviderModel.fromJson(json.decode(str));
@ -26,18 +25,18 @@ class ProviderModel {
factory ProviderModel.fromJson(Map<String, dynamic> json) =>
ProviderModel(
messageStatus: json["messageStatus"] == null ? null : json["messageStatus"],
totalItemsCount: json["totalItemsCount"] == null ? null : json["totalItemsCount"],
messageStatus: json["messageStatus"],
totalItemsCount: json["totalItemsCount"],
data: json["data"] == null ? null : ProviderModelData.fromJson(json["data"]),
message: json["message"] == null ? null : json["message"],
message: json["message"],
);
Map<String, dynamic> toJson() =>
{
"messageStatus": messageStatus == null ? null : messageStatus,
"totalItemsCount": totalItemsCount == null ? null : totalItemsCount,
"messageStatus": messageStatus,
"totalItemsCount": totalItemsCount,
"data": data == null ? null : data!.toJson(),
"message": message == null ? null : message,
"message": message,
};
}
@ -62,29 +61,29 @@ class ProviderModelData {
final int? allDocStatus;
final bool? isValidSubscription;
final String? userId;
final List<BranchModel>? serviceProviderBranch;
final List<BranchDetailModel>? serviceProviderBranch;
factory ProviderModelData.fromJson(Map<String, dynamic> json) =>
ProviderModelData(
id: json["id"] == null ? null : json["id"],
companyName: json["companyName"] == null ? null : json["companyName"],
countryName: json["countryName"] == null ? null : json["countryName"],
countryID: json["countryID"] == null ? null : json["countryID"],
companyDescription: json["companyDescription"] == null ? null : json["companyDescription"],
allDocStatus: json["allDocStatus"] == null ? null : json["allDocStatus"],
isValidSubscription: json["isValidSubscription"] == null ? null : json["isValidSubscription"],
userId: json["userID"] == null ? null : json["userID"],
serviceProviderBranch: json["serviceProviderBranch"] == null ? null : List<BranchModel>.from(json["serviceProviderBranch"].map((x) => BranchModel.fromJson(x))),
id: json["id"],
companyName: json["companyName"],
countryName: json["countryName"],
countryID: json["countryID"],
companyDescription: json["companyDescription"],
allDocStatus: json["allDocStatus"],
isValidSubscription: json["isValidSubscription"],
userId: json["userID"],
serviceProviderBranch: json["serviceProviderBranch"] == null ? null : List<BranchDetailModel>.from(json["serviceProviderBranch"].map((x) => BranchDetailModel.fromJson(x))),
);
Map<String, dynamic> toJson() =>
{
"id": id == null ? null : id,
"companyName": companyName == null ? null : companyName,
"companyDescription": companyDescription == null ? null : companyDescription,
"allDocStatus": allDocStatus == null ? null : allDocStatus,
"isValidSubscription": isValidSubscription == null ? null : isValidSubscription,
"userID": userId == null ? null : userId,
"id": id,
"companyName": companyName,
"companyDescription": companyDescription,
"allDocStatus": allDocStatus,
"isValidSubscription": isValidSubscription,
"userID": userId,
"serviceProviderBranch": serviceProviderBranch == null ? null : List<dynamic>.from(serviceProviderBranch!.map((x) => x.toJson())),
};
}

@ -1,9 +1,9 @@
import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/models/profile/categroy.dart';
import 'package:mc_common_app/models/provider_branches_models/profile/categroy.dart';
import 'package:mc_common_app/models/services/service_model.dart';
import 'package:mc_common_app/utils/enums.dart';
class BranchModel {
class BranchDetailModel {
final int? id;
final int? serviceProviderId;
final String? serviceProviderName;
@ -25,7 +25,7 @@ class BranchModel {
String? countryName;
bool isExpanded;
BranchModel({
BranchDetailModel({
this.id,
this.serviceProviderId,
this.serviceProviderName,
@ -48,7 +48,7 @@ class BranchModel {
required this.isExpanded,
});
factory BranchModel.fromJson(Map<String, dynamic> json) => BranchModel(
factory BranchDetailModel.fromJson(Map<String, dynamic> json) => BranchDetailModel(
id: json["id"],
serviceProviderId: json["serviceProviderID"],
serviceProviderName: json["serviceProviderName"],

@ -6,7 +6,7 @@ import 'dart:convert';
import 'package:equatable/equatable.dart';
import 'package:mc_common_app/models/provider_branches_models/provider_profile_model.dart';
import 'package:mc_common_app/models/services/branch_service_model.dart';
import 'package:mc_common_app/models/services/service_model.dart';
Category categoryFromJson(String str) => Category.fromJson(json.decode(str));
@ -60,7 +60,7 @@ class CategoryData extends Equatable {
dynamic? serviceCategoryImageUrl;
String? branchId;
String? branchName;
List<BranchServiceModel>? services;
List<ServiceModel>? services;
factory CategoryData.fromJson(Map<String, dynamic> json) => CategoryData(
id: json["id"] == null ? null : json["id"],

@ -1,6 +1,42 @@
// To parse this JSON data, do
//
// final itemModel = itemModelFromJson(jsonString);
import 'dart:convert';
class ServiceItemModel {
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;
@ -15,7 +51,7 @@ class ServiceItemModel {
final bool? isAppointmentCustomerLoc;
bool? isUpdateOrSelected;
ServiceItemModel({
ItemData({
this.id,
this.name,
this.price,
@ -31,34 +67,34 @@ class ServiceItemModel {
this.isUpdateOrSelected,
});
factory ServiceItemModel.fromJson(Map<String, dynamic> json) => ServiceItemModel(
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"],
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"],
isUpdateOrSelected: 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,
};
}
"id": id,
"name": name,
"price": price,
"manufactureDate": manufactureDate,
"description": description,
"pictureUrl": pictureUrl,
"companyID": companyId,
"serviceProviderServiceID": serviceProviderServiceId,
"isActive": isActive,
"isAllowAppointment": isAllowAppointment,
"isAppointmentCompanyLoc": isAppointmentCompanyLoc,
"isAppointmentCustomerLoc": isAppointmentCustomerLoc,
};
}

@ -1,3 +1,4 @@
import 'package:mc_common_app/models/services/item_model.dart';
class ServiceModel {
@ -75,4 +76,9 @@ class ServiceModel {
"itemsCount": itemsCount,
"branchServiceItems": serviceItems == null ? [] : List<dynamic>.from(serviceItems!.map((x) => x.toJson())),
};
@override
String toString() {
return 'ServiceModel{serviceProviderServiceId: $serviceProviderServiceId, providerServiceDescription: $providerServiceDescription, categoryId: $categoryId, categoryName: $categoryName, serviceId: $serviceId, serviceDescription: $serviceDescription, serviceDescriptionN: $serviceDescriptionN, serviceStatus: $serviceStatus, statusText: $statusText, isAllowAppointment: $isAllowAppointment, isAllowAppointmentHome: $isAllowAppointmentHome, customerLocationRange: $customerLocationRange, rangePricePerKm: $rangePricePerKm, itemsCount: $itemsCount, serviceItems: $serviceItems, isExpandedOrSelected: $isExpandedOrSelected}';
}
}

@ -4,7 +4,7 @@ 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/branch_service_model.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';
@ -16,7 +16,7 @@ class ProviderDetailsCard extends StatelessWidget {
final String providerRatings;
//TODO: items can be make a generaic, so we can add services/items in the future
final List<BranchServiceModel>? items;
final List<ServiceModel>? services;
final Function() onCardTapped;
const ProviderDetailsCard({
@ -26,7 +26,7 @@ class ProviderDetailsCard extends StatelessWidget {
this.providerName,
required this.providerRatings,
required this.providerLocation,
this.items,
this.services,
required this.onCardTapped,
}) : super(key: key);
@ -97,9 +97,9 @@ class ProviderDetailsCard extends StatelessWidget {
],
),
8.height,
if (items != null)
if (services != null)
Column(
children: items!
children: services!
.take(2)
.map(
(e) =>
@ -117,8 +117,8 @@ class ProviderDetailsCard extends StatelessWidget {
)
.toList(),
),
if (items != null && items!.length > 2)
("+${items!.length - 2} more").toText(
if (services != null && services!.length > 2)
("+${services!.length - 2} more").toText(
color: MyColors.primaryColor,
isUnderLine: true,
isBold: true,

Loading…
Cancel
Save