Reverted Code

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

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

@ -6,7 +6,7 @@ import 'dart:convert';
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:mc_common_app/models/provider_branches_models/provider_profile_model.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)); Category categoryFromJson(String str) => Category.fromJson(json.decode(str));
@ -60,7 +60,7 @@ class CategoryData extends Equatable {
dynamic? serviceCategoryImageUrl; dynamic? serviceCategoryImageUrl;
String? branchId; String? branchId;
String? branchName; String? branchName;
List<BranchServiceModel>? services; List<ServiceModel>? services;
factory CategoryData.fromJson(Map<String, dynamic> json) => CategoryData( factory CategoryData.fromJson(Map<String, dynamic> json) => CategoryData(
id: json["id"] == null ? null : json["id"], 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 int? id;
final String? name; final String? name;
final String? price; final String? price;
@ -15,7 +51,7 @@ class ServiceItemModel {
final bool? isAppointmentCustomerLoc; final bool? isAppointmentCustomerLoc;
bool? isUpdateOrSelected; bool? isUpdateOrSelected;
ServiceItemModel({ ItemData({
this.id, this.id,
this.name, this.name,
this.price, this.price,
@ -31,34 +67,34 @@ class ServiceItemModel {
this.isUpdateOrSelected, this.isUpdateOrSelected,
}); });
factory ServiceItemModel.fromJson(Map<String, dynamic> json) => ServiceItemModel( factory ItemData.fromJson(Map<String, dynamic> json) => ItemData(
id: json["id"], id: json["id"],
name: json["name"], name: json["name"],
price: json["price"].toString(), price: json["price"].toString(),
manufactureDate: json["manufactureDate"], manufactureDate: json["manufactureDate"],
description: json["description"], description: json["description"],
pictureUrl: json["pictureUrl"], pictureUrl: json["pictureUrl"],
companyId: json["companyID"], companyId: json["companyID"],
serviceProviderServiceId: json["serviceProviderServiceID"], serviceProviderServiceId: json["serviceProviderServiceID"],
isActive: json["isActive"], isActive: json["isActive"],
isAllowAppointment: json["isAllowAppointment"], isAllowAppointment: json["isAllowAppointment"],
isAppointmentCompanyLoc: json["isAppointmentCompanyLoc"], isAppointmentCompanyLoc: json["isAppointmentCompanyLoc"],
isAppointmentCustomerLoc: json["isAppointmentCustomerLoc"], isAppointmentCustomerLoc: json["isAppointmentCustomerLoc"],
isUpdateOrSelected: false, isUpdateOrSelected: false,
); );
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
"id": id, "id": id,
"name": name, "name": name,
"price": price, "price": price,
"manufactureDate": manufactureDate, "manufactureDate": manufactureDate,
"description": description, "description": description,
"pictureUrl": pictureUrl, "pictureUrl": pictureUrl,
"companyID": companyId, "companyID": companyId,
"serviceProviderServiceID": serviceProviderServiceId, "serviceProviderServiceID": serviceProviderServiceId,
"isActive": isActive, "isActive": isActive,
"isAllowAppointment": isAllowAppointment, "isAllowAppointment": isAllowAppointment,
"isAppointmentCompanyLoc": isAppointmentCompanyLoc, "isAppointmentCompanyLoc": isAppointmentCompanyLoc,
"isAppointmentCustomerLoc": isAppointmentCustomerLoc, "isAppointmentCustomerLoc": isAppointmentCustomerLoc,
}; };
} }

@ -1,3 +1,4 @@
import 'package:mc_common_app/models/services/item_model.dart'; import 'package:mc_common_app/models/services/item_model.dart';
class ServiceModel { class ServiceModel {
@ -75,4 +76,9 @@ class ServiceModel {
"itemsCount": itemsCount, "itemsCount": itemsCount,
"branchServiceItems": serviceItems == null ? [] : List<dynamic>.from(serviceItems!.map((x) => x.toJson())), "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/int_extensions.dart';
import 'package:mc_common_app/extensions/string_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/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/theme/colors.dart';
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart'; import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
@ -16,7 +16,7 @@ class ProviderDetailsCard extends StatelessWidget {
final String providerRatings; final String providerRatings;
//TODO: items can be make a generaic, so we can add services/items in the future //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; final Function() onCardTapped;
const ProviderDetailsCard({ const ProviderDetailsCard({
@ -26,7 +26,7 @@ class ProviderDetailsCard extends StatelessWidget {
this.providerName, this.providerName,
required this.providerRatings, required this.providerRatings,
required this.providerLocation, required this.providerLocation,
this.items, this.services,
required this.onCardTapped, required this.onCardTapped,
}) : super(key: key); }) : super(key: key);
@ -97,9 +97,9 @@ class ProviderDetailsCard extends StatelessWidget {
], ],
), ),
8.height, 8.height,
if (items != null) if (services != null)
Column( Column(
children: items! children: services!
.take(2) .take(2)
.map( .map(
(e) => (e) =>
@ -117,8 +117,8 @@ class ProviderDetailsCard extends StatelessWidget {
) )
.toList(), .toList(),
), ),
if (items != null && items!.length > 2) if (services != null && services!.length > 2)
("+${items!.length - 2} more").toText( ("+${services!.length - 2} more").toText(
color: MyColors.primaryColor, color: MyColors.primaryColor,
isUnderLine: true, isUnderLine: true,
isBold: true, isBold: true,

Loading…
Cancel
Save