Initial commit of Flutter project
This commit is contained in:
@@ -1,31 +1,229 @@
|
||||
|
||||
|
||||
import 'package:glowwheels/models/serviceboy_model.dart';
|
||||
|
||||
class Order {
|
||||
final String customerName;
|
||||
final String mobileNumber;
|
||||
final String serviceType;
|
||||
final String service;
|
||||
final String price;
|
||||
final String time;
|
||||
final String id;
|
||||
final User user;
|
||||
final Shop shop;
|
||||
final Service service;
|
||||
final String? address;
|
||||
final String date;
|
||||
final String carName;
|
||||
final String timeSlot;
|
||||
final String status;
|
||||
final String imagePath;
|
||||
ServiceBoy? assignedBoy;
|
||||
final String? serviceBoyId;
|
||||
final DateTime createdAt;
|
||||
final DateTime updatedAt;
|
||||
final ServiceBoy? assignedServiceBoy;
|
||||
|
||||
Order({
|
||||
required this.customerName,
|
||||
required this.mobileNumber,
|
||||
required this.serviceType,
|
||||
required this.id,
|
||||
required this.user,
|
||||
required this.shop,
|
||||
required this.service,
|
||||
required this.price,
|
||||
required this.time,
|
||||
required this.address,
|
||||
required this.date,
|
||||
required this.carName,
|
||||
required this.timeSlot,
|
||||
required this.status,
|
||||
required this.imagePath,
|
||||
this.assignedBoy,
|
||||
required this.serviceBoyId,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
this.assignedServiceBoy,
|
||||
});
|
||||
|
||||
factory Order.fromJson(Map<String, dynamic> json) {
|
||||
return Order(
|
||||
id: json['_id'],
|
||||
user: User.fromJson(json['userId']),
|
||||
shop: Shop.fromJson(json['shopId']),
|
||||
service: Service.fromJson(json['serviceId']),
|
||||
address : json['address'],
|
||||
date: json['date'],
|
||||
timeSlot: json['timeSlot'],
|
||||
status: json['status'],
|
||||
serviceBoyId: json['serviceBoyId'],
|
||||
createdAt: DateTime.parse(json['createdAt']),
|
||||
updatedAt: DateTime.parse(json['updatedAt']),
|
||||
assignedServiceBoy: json['assignedServiceBoy'] != null
|
||||
? ServiceBoy.fromJson(json['assignedServiceBoy'])
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
Order copyWith({
|
||||
String? id,
|
||||
User? user,
|
||||
Shop? shop,
|
||||
Service? service,
|
||||
String? date,
|
||||
String? timeSlot,
|
||||
String? status,
|
||||
String? serviceBoyId,
|
||||
DateTime? createdAt,
|
||||
DateTime? updatedAt,
|
||||
ServiceBoy? assignedServiceBoy,
|
||||
}) {
|
||||
return Order(
|
||||
id: id ?? this.id,
|
||||
user: user ?? this.user,
|
||||
shop: shop ?? this.shop,
|
||||
service: service ?? this.service,
|
||||
date: date ?? this.date,
|
||||
timeSlot: timeSlot ?? this.timeSlot,
|
||||
status: status ?? this.status,
|
||||
serviceBoyId: serviceBoyId ?? this.serviceBoyId,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
updatedAt: updatedAt ?? this.updatedAt,
|
||||
assignedServiceBoy: assignedServiceBoy ?? this.assignedServiceBoy, address: '',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class User {
|
||||
final String id;
|
||||
final String name;
|
||||
final int phone;
|
||||
|
||||
User({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.phone,
|
||||
});
|
||||
|
||||
factory User.fromJson(Map<String, dynamic> json) {
|
||||
return User(
|
||||
id: json['_id'],
|
||||
name: json['name'],
|
||||
phone: json['phone'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Shop {
|
||||
final String id;
|
||||
final String name;
|
||||
final String address;
|
||||
final double latitude;
|
||||
final double longitude;
|
||||
final String phone;
|
||||
final String email;
|
||||
final List<String> images;
|
||||
final int rating;
|
||||
|
||||
Shop({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.address,
|
||||
required this.latitude,
|
||||
required this.longitude,
|
||||
required this.phone,
|
||||
required this.email,
|
||||
required this.images,
|
||||
required this.rating,
|
||||
});
|
||||
|
||||
factory Shop.fromJson(Map<String, dynamic> json) {
|
||||
return Shop(
|
||||
id: json['_id'],
|
||||
name: json['name'],
|
||||
address: json['address'],
|
||||
latitude: json['latitude'].toDouble(),
|
||||
longitude: json['longitude'].toDouble(),
|
||||
phone: json['phone'],
|
||||
email: json['email'],
|
||||
images: List<String>.from(json['images']),
|
||||
rating: json['rating'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Service {
|
||||
final String id;
|
||||
final Vehicle vehicle;
|
||||
final Manufacture manufacture;
|
||||
final Model model;
|
||||
final String serviceName;
|
||||
final int price;
|
||||
final String serviceType;
|
||||
|
||||
Service({
|
||||
required this.id,
|
||||
required this.vehicle,
|
||||
required this.manufacture,
|
||||
required this.model,
|
||||
required this.serviceName,
|
||||
required this.price,
|
||||
required this.serviceType,
|
||||
});
|
||||
|
||||
factory Service.fromJson(Map<String, dynamic> json) {
|
||||
return Service(
|
||||
id: json['_id'],
|
||||
vehicle: Vehicle.fromJson(json['vehicleId']),
|
||||
manufacture: Manufacture.fromJson(json['manufactureId']),
|
||||
model: Model.fromJson(json['modelId']),
|
||||
serviceName: json['serviceName'],
|
||||
price: json['price'],
|
||||
serviceType: json['serviceType'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Vehicle {
|
||||
final String id;
|
||||
final String vehicle;
|
||||
final String image;
|
||||
|
||||
Vehicle({
|
||||
required this.id,
|
||||
required this.vehicle,
|
||||
required this.image,
|
||||
});
|
||||
|
||||
factory Vehicle.fromJson(Map<String, dynamic> json) {
|
||||
return Vehicle(
|
||||
id: json['_id'],
|
||||
vehicle: json['vehicle'],
|
||||
image: json['image'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Manufacture {
|
||||
final String id;
|
||||
final String manufacture;
|
||||
final String image;
|
||||
|
||||
Manufacture({
|
||||
required this.id,
|
||||
required this.manufacture,
|
||||
required this.image,
|
||||
});
|
||||
|
||||
factory Manufacture.fromJson(Map<String, dynamic> json) {
|
||||
return Manufacture(
|
||||
id: json['_id'],
|
||||
manufacture: json['manufacture'],
|
||||
image: json['image'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Model {
|
||||
final String id;
|
||||
final String model;
|
||||
final String image;
|
||||
|
||||
Model({
|
||||
required this.id,
|
||||
required this.model,
|
||||
required this.image,
|
||||
});
|
||||
|
||||
factory Model.fromJson(Map<String, dynamic> json) {
|
||||
return Model(
|
||||
id: json['_id'],
|
||||
model: json['model'],
|
||||
image: json['image'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
42
lib/models/service_boy_response.dart
Normal file
42
lib/models/service_boy_response.dart
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
|
||||
import 'package:glowwheels/models/service_boy_response.dart';
|
||||
import 'package:glowwheels/models/serviceboy_model.dart';
|
||||
|
||||
class ServiceBoyResponse {
|
||||
final String id;
|
||||
final String shopId;
|
||||
final List<ServiceBoy> serviceBoy;
|
||||
final String createdAt;
|
||||
final String updatedAt;
|
||||
|
||||
ServiceBoyResponse({
|
||||
required this.id,
|
||||
required this.shopId,
|
||||
required this.serviceBoy,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
});
|
||||
|
||||
factory ServiceBoyResponse.fromJson(Map<String, dynamic> json) {
|
||||
return ServiceBoyResponse(
|
||||
id: json['_id'],
|
||||
shopId: json['shopId'],
|
||||
serviceBoy: (json['serviceBoy'] as List)
|
||||
.map((e) => ServiceBoy.fromJson(e))
|
||||
.toList(),
|
||||
createdAt: json['createdAt'],
|
||||
updatedAt: json['updatedAt'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'_id': id,
|
||||
'shopId': shopId,
|
||||
'serviceBoy': serviceBoy.map((e) => e.toJson()).toList(),
|
||||
'createdAt': createdAt,
|
||||
'updatedAt': updatedAt,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,27 @@
|
||||
class ServiceBoy {
|
||||
final String id;
|
||||
final String name;
|
||||
final String phone;
|
||||
|
||||
ServiceBoy({required this.name, required this.phone});
|
||||
ServiceBoy({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.phone,
|
||||
});
|
||||
|
||||
factory ServiceBoy.fromJson(Map<String, dynamic> json) {
|
||||
return ServiceBoy(
|
||||
id: json['_id'],
|
||||
name: json['name'],
|
||||
phone: json['phone'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'_id': id,
|
||||
'name': name,
|
||||
'phone': phone,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -2,52 +2,74 @@ import 'package:hive/hive.dart';
|
||||
|
||||
part 'shop_model.g.dart';
|
||||
|
||||
@HiveType(typeId: 1)
|
||||
@HiveType(typeId: 0)
|
||||
class ShopModel {
|
||||
@HiveField(0)
|
||||
final String id;
|
||||
bool success;
|
||||
|
||||
@HiveField(1)
|
||||
final String image;
|
||||
ShopDetails user;
|
||||
|
||||
@HiveField(2)
|
||||
final String mobile;
|
||||
String token;
|
||||
|
||||
@HiveField(3)
|
||||
final String email;
|
||||
|
||||
@HiveField(4)
|
||||
final String shopName;
|
||||
|
||||
@HiveField(5)
|
||||
final String address; // ✅ NEW
|
||||
String message;
|
||||
|
||||
ShopModel({
|
||||
required this.id,
|
||||
required this.image,
|
||||
required this.mobile,
|
||||
required this.email,
|
||||
required this.shopName,
|
||||
required this.address,
|
||||
required this.success,
|
||||
required this.user,
|
||||
required this.token,
|
||||
required this.message,
|
||||
});
|
||||
|
||||
factory ShopModel.fromJson(Map<String, dynamic> json) {
|
||||
return ShopModel(
|
||||
id: json['id'] ?? '',
|
||||
image: json['image'] ?? '',
|
||||
mobile: json['mobile'] ?? '',
|
||||
email: json['email'] ?? '',
|
||||
shopName: json['shopName'] ?? '',
|
||||
address: json['address'] ?? '', // ✅ NEW
|
||||
);
|
||||
}
|
||||
factory ShopModel.fromJson(Map<String, dynamic> json) => ShopModel(
|
||||
success: json['success'],
|
||||
user: ShopDetails.fromJson(json['user']),
|
||||
token: json['token'],
|
||||
message: json['message'],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'success': success,
|
||||
'user': user.toJson(),
|
||||
'token': token,
|
||||
'message': message,
|
||||
};
|
||||
}
|
||||
|
||||
@HiveType(typeId: 1)
|
||||
class ShopDetails {
|
||||
@HiveField(0)
|
||||
String id;
|
||||
|
||||
@HiveField(1)
|
||||
String name;
|
||||
|
||||
@HiveField(2)
|
||||
String email;
|
||||
|
||||
@HiveField(3)
|
||||
String role;
|
||||
|
||||
ShopDetails({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.email,
|
||||
required this.role,
|
||||
});
|
||||
|
||||
factory ShopDetails.fromJson(Map<String, dynamic> json) => ShopDetails(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
email: json['email'],
|
||||
role: json['role'],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'image': image,
|
||||
'mobile': mobile,
|
||||
'name': name,
|
||||
'email': email,
|
||||
'shopName': shopName,
|
||||
'address': address, // ✅ NEW
|
||||
'role': role,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ part of 'shop_model.dart';
|
||||
|
||||
class ShopModelAdapter extends TypeAdapter<ShopModel> {
|
||||
@override
|
||||
final int typeId = 1;
|
||||
final int typeId = 0;
|
||||
|
||||
@override
|
||||
ShopModel read(BinaryReader reader) {
|
||||
@@ -17,31 +17,25 @@ class ShopModelAdapter extends TypeAdapter<ShopModel> {
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return ShopModel(
|
||||
id: fields[0] as String,
|
||||
image: fields[1] as String,
|
||||
mobile: fields[2] as String,
|
||||
email: fields[3] as String,
|
||||
shopName: fields[4] as String,
|
||||
address: fields[5] as String,
|
||||
success: fields[0] as bool,
|
||||
user: fields[1] as ShopDetails,
|
||||
token: fields[2] as String,
|
||||
message: fields[3] as String,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, ShopModel obj) {
|
||||
writer
|
||||
..writeByte(6)
|
||||
..writeByte(0)
|
||||
..write(obj.id)
|
||||
..writeByte(1)
|
||||
..write(obj.image)
|
||||
..writeByte(2)
|
||||
..write(obj.mobile)
|
||||
..writeByte(3)
|
||||
..write(obj.email)
|
||||
..writeByte(4)
|
||||
..write(obj.shopName)
|
||||
..writeByte(5)
|
||||
..write(obj.address);
|
||||
..writeByte(0)
|
||||
..write(obj.success)
|
||||
..writeByte(1)
|
||||
..write(obj.user)
|
||||
..writeByte(2)
|
||||
..write(obj.token)
|
||||
..writeByte(3)
|
||||
..write(obj.message);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -54,3 +48,46 @@ class ShopModelAdapter extends TypeAdapter<ShopModel> {
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
|
||||
class ShopDetailsAdapter extends TypeAdapter<ShopDetails> {
|
||||
@override
|
||||
final int typeId = 1;
|
||||
|
||||
@override
|
||||
ShopDetails read(BinaryReader reader) {
|
||||
final numOfFields = reader.readByte();
|
||||
final fields = <int, dynamic>{
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return ShopDetails(
|
||||
id: fields[0] as String,
|
||||
name: fields[1] as String,
|
||||
email: fields[2] as String,
|
||||
role: fields[3] as String,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, ShopDetails obj) {
|
||||
writer
|
||||
..writeByte(4)
|
||||
..writeByte(0)
|
||||
..write(obj.id)
|
||||
..writeByte(1)
|
||||
..write(obj.name)
|
||||
..writeByte(2)
|
||||
..write(obj.email)
|
||||
..writeByte(3)
|
||||
..write(obj.role);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is ShopDetailsAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
|
||||
67
lib/models/shop_profile_model.dart
Normal file
67
lib/models/shop_profile_model.dart
Normal file
@@ -0,0 +1,67 @@
|
||||
class ShopProfileModel {
|
||||
final String id;
|
||||
final String name;
|
||||
final String description;
|
||||
final String address;
|
||||
final double latitude;
|
||||
final double longitude;
|
||||
final String phone;
|
||||
final String email;
|
||||
final String password;
|
||||
final String role;
|
||||
final List<String> images;
|
||||
final int rating;
|
||||
final DateTime timestamp;
|
||||
|
||||
ShopProfileModel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.description,
|
||||
required this.address,
|
||||
required this.latitude,
|
||||
required this.longitude,
|
||||
required this.phone,
|
||||
required this.email,
|
||||
required this.password,
|
||||
required this.role,
|
||||
required this.images,
|
||||
required this.rating,
|
||||
required this.timestamp,
|
||||
});
|
||||
|
||||
factory ShopProfileModel.fromJson(Map<String, dynamic> json) {
|
||||
return ShopProfileModel(
|
||||
id: json['_id'],
|
||||
name: json['name'],
|
||||
description: json['description'],
|
||||
address: json['address'],
|
||||
latitude: json['latitude'].toDouble(),
|
||||
longitude: json['longitude'].toDouble(),
|
||||
phone: json['phone'],
|
||||
email: json['email'],
|
||||
password: json['password'],
|
||||
role: json['role'],
|
||||
images: List<String>.from(json['images']),
|
||||
rating: json['rating'],
|
||||
timestamp: DateTime.parse(json['timestamp']),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'_id': id,
|
||||
'name': name,
|
||||
'description': description,
|
||||
'address': address,
|
||||
'latitude': latitude,
|
||||
'longitude': longitude,
|
||||
'phone': phone,
|
||||
'email': email,
|
||||
'password': password,
|
||||
'role': role,
|
||||
'images': images,
|
||||
'rating': rating,
|
||||
'timestamp': timestamp.toIso8601String(),
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user