You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.9 KiB
67 lines
1.9 KiB
import 'package:flutter/material.dart';
|
|
import 'package:geolocator/geolocator.dart';
|
|
import 'package:bookatanker/common/settings.dart';
|
|
|
|
|
|
class ConnectedSuppliersModel {
|
|
String supplier_name = '';
|
|
String status='';
|
|
String supplier_address='';
|
|
String supplier_phone_number='';
|
|
String supplier_id='';
|
|
Color text_color=Colors.black;
|
|
double lat=0;
|
|
double lng=0;
|
|
String distrubance_price='';
|
|
String amount_difference='';
|
|
double distanceInMeters=0;
|
|
String displayAddress='';
|
|
bool isFavorite=false;
|
|
|
|
ConnectedSuppliersModel();
|
|
|
|
factory ConnectedSuppliersModel.fromJson(Map<String, dynamic> json){
|
|
ConnectedSuppliersModel rtvm = new ConnectedSuppliersModel();
|
|
|
|
rtvm.supplier_name = json['suppliername'] ?? '';
|
|
rtvm.status = json['status'] ?? '';
|
|
rtvm.supplier_address = json['profile']['office_address'] ?? '';
|
|
rtvm.supplier_phone_number = json['phone'] ?? '';
|
|
rtvm.supplier_id = json['supplierId'] ?? '';
|
|
rtvm.lat = json['latitude'] ?? 0;
|
|
rtvm.lng = json['longitude'] ?? 0;
|
|
rtvm.distrubance_price = json['distrubance_price'] ?? '';
|
|
rtvm.amount_difference = json['amount_difference'] ?? '';
|
|
rtvm.isFavorite = json['favorate'] ?? false;
|
|
|
|
rtvm.distanceInMeters = double.parse((Geolocator.distanceBetween(
|
|
rtvm.lat,
|
|
rtvm.lng,
|
|
AppSettings.userLatitude,
|
|
AppSettings.userLongitude
|
|
) / 1000).toStringAsFixed(2));
|
|
|
|
List<String> parts = rtvm.supplier_address.split(',');
|
|
rtvm.displayAddress = parts[2].trim();
|
|
|
|
if(rtvm.status.toString().toLowerCase()=='pending'){
|
|
rtvm.text_color=Colors.yellow;
|
|
}
|
|
else if(rtvm.status.toString().toLowerCase()=='accepted'){
|
|
rtvm.text_color=Colors.green;
|
|
}
|
|
else if(rtvm.status.toString().toLowerCase()=='rejected'){
|
|
rtvm.text_color=Colors.red;
|
|
}
|
|
else{
|
|
rtvm.status='Connect?';
|
|
rtvm.text_color=primaryColor;
|
|
}
|
|
|
|
|
|
|
|
|
|
return rtvm;
|
|
}
|
|
|
|
} |