add update shipments

This commit is contained in:
Sai Naw Wun
2020-10-18 02:38:46 +06:30
parent fa9738f307
commit 4f8bde40b0
37 changed files with 596 additions and 455 deletions

View File

@@ -321,6 +321,7 @@
"Shipment Start ================================================================":"", "Shipment Start ================================================================":"",
"shipment": "Shipments", "shipment": "Shipments",
"shipment.title": "Shipments", "shipment.title": "Shipments",
"shipment.number": "Shipment number",
"shipment.new": "New shipment", "shipment.new": "New shipment",
"shipment.new.title": "New Shipment", "shipment.new.title": "New Shipment",
"shipment.edit.title": "Edit Shipment", "shipment.edit.title": "Edit Shipment",
@@ -329,6 +330,8 @@
"shipment.date.time": "Pickup date/Time", "shipment.date.time": "Pickup date/Time",
"shipment.time": "Pickup time", "shipment.time": "Pickup time",
"shipment.location": "Pickup address", "shipment.location": "Pickup address",
"shipment.location.dropoff": "Local dropoff address",
"shipment.courier.dropoff":"Courier dropoff",
"shipment.location_time": "Pickup Location / Time", "shipment.location_time": "Pickup Location / Time",
"shipment.information": "Pickup information", "shipment.information": "Pickup information",
"shipment.recipient_information": "Recipient informations", "shipment.recipient_information": "Recipient informations",
@@ -349,6 +352,7 @@
"shipment.create":"Create shipment", "shipment.create":"Create shipment",
"shipment.update":"Update shipment", "shipment.update":"Update shipment",
"shipment.info":"Shipment Info", "shipment.info":"Shipment Info",
"shipment.cancel.confirm":"Cancel this shipment?",
"Shipment End ================================================================":"", "Shipment End ================================================================":"",
"Rate Start ================================================================":"", "Rate Start ================================================================":"",

View File

@@ -321,15 +321,18 @@
"Shipment Start ================================================================":"", "Shipment Start ================================================================":"",
"shipment": "ပို့ဆောင်ခြင်းများ", "shipment": "ပို့ဆောင်ခြင်းများ",
"shipment.title": "ပို့ဆောင်ခြင်းများ", "shipment.title": "ပို့ဆောင်ခြင်းများ",
"shipment.number": "ပို့ဆောင်ခြင်း နံပါတ်",
"shipment.new": "ပို့ဆောင်ခြင်း အသစ်", "shipment.new": "ပို့ဆောင်ခြင်း အသစ်",
"shipment.new.title": "ပို့ဆောင်ခြင်း အသစ်", "shipment.new.title": "ပို့ဆောင်ခြင်း အသစ်",
"shipment.edit.title": "ပို့ဆောင်ခြင်း ပြင်ဆင်ခြင်း", "shipment.edit.title": "ပို့ဆောင်ခြင်း ပြင်ဆင်ခြင်း",
"shipment.type": "Pickup/Drop-off ရွေးရန်", "shipment.type": "Pickup/Drop-off",
"shipment.date": "Pickup နေ့စွဲ", "shipment.date": "Pickup နေ့စွဲ",
"shipment.date.time": "Pickup နေ့စွဲ/အချိန်", "shipment.date.time": "Pickup နေ့စွဲ/အချိန်",
"shipment.time": "Pickup အချိန်", "shipment.time": "Pickup အချိန်",
"shipment.location_time": "Pickup location / Time", "shipment.location_time": "Pickup location / Time",
"shipment.location": "Pickup လိပ်စာ", "shipment.location": "Pickup လိပ်စာ",
"shipment.location.dropoff": "Local dropoff လိပ်စာ",
"shipment.courier.dropoff":"Courier dropoff",
"shipment.information": "Pickup informations", "shipment.information": "Pickup informations",
"shipment.recipient_information": "Recipient informations", "shipment.recipient_information": "Recipient informations",
"shipment.from":"အချိန်(မှ)", "shipment.from":"အချိန်(မှ)",
@@ -349,6 +352,7 @@
"shipment.create":"ပို့ဆောင်ခြင်း ပြုလုပ်မည်", "shipment.create":"ပို့ဆောင်ခြင်း ပြုလုပ်မည်",
"shipment.update":"ပို့ဆောင်ခြင်းပြုပြင်မည်", "shipment.update":"ပို့ဆောင်ခြင်းပြုပြင်မည်",
"shipment.info":"ပို့ဆောင်ခြင်း", "shipment.info":"ပို့ဆောင်ခြင်း",
"shipment.cancel.confirm":"ပို့ဆောင်ခြင်း ပိတ်သိမ်းမလား?",
"Shipment End ================================================================":"", "Shipment End ================================================================":"",
"Rate Start ================================================================":"", "Rate Start ================================================================":"",

View File

@@ -1,6 +1,6 @@
import 'package:fcs/localization/app_translations_delegate.dart'; import 'package:fcs/localization/app_translations_delegate.dart';
import 'package:fcs/localization/transalation.dart'; import 'package:fcs/localization/transalation.dart';
import 'package:fcs/pages/box/model/box_model.dart'; import 'package:fcs/pages/carton/model/carton_model.dart';
import 'package:fcs/pages/chat/model/message_model.dart'; import 'package:fcs/pages/chat/model/message_model.dart';
import 'package:fcs/pages/contact/model/contact_model.dart'; import 'package:fcs/pages/contact/model/contact_model.dart';
import 'package:fcs/pages/customer/model/customer_model.dart'; import 'package:fcs/pages/customer/model/customer_model.dart';
@@ -44,7 +44,7 @@ class _AppState extends State<App> {
final LanguageModel lanuguageModel = new LanguageModel(); final LanguageModel lanuguageModel = new LanguageModel();
final ShipmentModel shipmentModel = new ShipmentModel(); final ShipmentModel shipmentModel = new ShipmentModel();
final ShipmentRateModel shipmentRateModel = new ShipmentRateModel(); final ShipmentRateModel shipmentRateModel = new ShipmentRateModel();
final BoxModel boxModel = new BoxModel(); final CartonModel boxModel = new CartonModel();
final MessageModel messageModel = new MessageModel(); final MessageModel messageModel = new MessageModel();
final InvoiceModel invoiceModel = new InvoiceModel(); final InvoiceModel invoiceModel = new InvoiceModel();
final CustomerModel customerModel = new CustomerModel(); final CustomerModel customerModel = new CustomerModel();

View File

@@ -22,7 +22,7 @@ class ShipmentDataProvider {
} }
Future<void> cancelShipment(Shipment shipment) async { Future<void> cancelShipment(Shipment shipment) async {
return await requestAPI("/shipment_cancel", "PUT", return await requestAPI("/shipments/cancel", "PUT",
payload: shipment.toMap(), token: await getToken()); payload: shipment.toMap(), token: await getToken());
} }

View File

@@ -12,12 +12,13 @@ const cargo_types_collection = "cargo_types";
const custom_duties_collection = "custom_duties"; const custom_duties_collection = "custom_duties";
const discounts_by_weights_collection = "discounts_by_weight"; const discounts_by_weights_collection = "discounts_by_weight";
const shipments_collection = "shipments"; const shipments_collection = "shipments";
const boxes_collection = "boxes"; const cartons_collection = "cartons";
// docs // docs
const setting_doc_id = "setting"; const setting_doc_id = "setting";
const rate_doc_id = "rate"; const rate_doc_id = "rate";
// user's status
const user_requested_status = "requested"; const user_requested_status = "requested";
const user_invited_status = "invited"; const user_invited_status = "invited";
const user_disabled_status = "disabled"; const user_disabled_status = "disabled";
@@ -64,10 +65,18 @@ const privilege_receiving = "rc";
// Pickup types // Pickup types
const shipment_local_pickup = "Local pickup"; const shipment_local_pickup = "Local pickup";
const shipment_courier_pickup = "Courier pickup"; const shipment_courier_pickup = "Courier pickup";
const shipment_local_dropoff = "Local drop-off"; const shipment_local_dropoff = "Local drop off";
const shipment_courier_dropoff = "Courier drop-off"; const shipment_courier_dropoff = "Courier drop off";
//Carton types //Carton types
const carton_from_packages = "From packages"; const carton_from_packages = "From packages";
const carton_from_shipments = "From shipments"; const carton_from_shipments = "From shipments";
const carton_mix_box = "Mix carton"; const carton_mix_box = "Mix carton";
// shipment status
const shipment_pending_status = "pending";
const shipment_confirmed_status = "confirmed";
const shipment_pickuped_status = "pickuped";
const shipment_packed_status = "packed";
const shipment_shipped_status = "shipped";
const shipment_delivered_status = "delivered";

View File

@@ -1,3 +1,5 @@
import 'dart:convert';
class CargoType { class CargoType {
String id; String id;
String name; String name;
@@ -11,7 +13,8 @@ class CargoType {
return CargoType( return CargoType(
id: id, id: id,
name: map['name'], name: map['name'],
rate: (map['rate'] ?? 0).toDouble(), rate: map['rate']?.toDouble() ?? 0,
weight: map['weight']?.toDouble() ?? 0,
); );
} }
CargoType({this.id, this.name, this.rate, this.weight}); CargoType({this.id, this.name, this.rate, this.weight});
@@ -25,6 +28,10 @@ class CargoType {
}; };
} }
CargoType clone() {
return CargoType.fromMap(toMap(), this.id);
}
@override @override
bool operator ==(Object other) => other is CargoType && other.id == id; bool operator ==(Object other) => other is CargoType && other.id == id;

View File

@@ -7,7 +7,7 @@ import 'package:fcs/domain/vo/delivery_address.dart';
import 'cargo_type.dart'; import 'cargo_type.dart';
import 'package.dart'; import 'package.dart';
class Box { class Carton {
String id; String id;
String shipmentNumber; String shipmentNumber;
String senderFCSID; String senderFCSID;
@@ -91,7 +91,7 @@ class Box {
List<ShipmentStatus> shipmentHistory; List<ShipmentStatus> shipmentHistory;
Box( Carton(
{this.id, {this.id,
this.shipmentNumber, this.shipmentNumber,
this.senderFCSID, this.senderFCSID,
@@ -132,13 +132,18 @@ class Box {
'width': width, 'width': width,
'height': height, 'height': height,
'delivery_address': deliveryAddress.toMap(), 'delivery_address': deliveryAddress.toMap(),
'carton_type': cartonType,
}; };
} }
factory Box.fromMap(Map<String, dynamic> map, String docID) { factory Carton.fromMap(Map<String, dynamic> map, String docID) {
var _arrivedDate = (map['arrived_date'] as Timestamp); var _arrivedDate = (map['arrived_date'] as Timestamp);
var da = map['delivery_address'];
return Box( var _da = da != null ? DeliveryAddress.fromMap(da, da["id"]) : null;
var cargoTypesMaps = List<Map<String, dynamic>>.from(map['cargo_types']);
var cargoTypes =
cargoTypesMaps.map((e) => CargoType.fromMap(e, e["id"])).toList();
return Carton(
id: docID, id: docID,
arrivedDate: _arrivedDate != null ? _arrivedDate.toDate() : null, arrivedDate: _arrivedDate != null ? _arrivedDate.toDate() : null,
shipmentNumber: map['shipment_number'], shipmentNumber: map['shipment_number'],
@@ -149,6 +154,8 @@ class Box {
height: map['height'], height: map['height'],
userName: map['user_name'], userName: map['user_name'],
fcsID: map['fcs_id'], fcsID: map['fcs_id'],
cartonType: map['carton_type']); cartonType: map['carton_type'],
deliveryAddress: _da,
cargoTypes: cargoTypes);
} }
} }

View File

@@ -23,24 +23,25 @@ class Setting {
final String termsEng; final String termsEng;
final String termsMm; final String termsMm;
String about; String about;
String courierWebsite;
List<String> shipmentTypes; List<String> shipmentTypes;
Setting({ Setting(
this.supportBuildNum, {this.supportBuildNum,
this.usaAddress, this.usaAddress,
this.mmAddress, this.mmAddress,
this.usaContactNumber, this.usaContactNumber,
this.mmContactNumber, this.mmContactNumber,
this.emailAddress, this.emailAddress,
this.facebookLink, this.facebookLink,
this.inviteRequired, this.inviteRequired,
this.appUrl, this.appUrl,
this.termsEng, this.termsEng,
this.termsMm, this.termsMm,
this.about, this.about,
this.shipmentTypes, this.shipmentTypes,
}); this.courierWebsite});
factory Setting.fromMap(Map<String, dynamic> map) { factory Setting.fromMap(Map<String, dynamic> map) {
return Setting( return Setting(
@@ -57,6 +58,7 @@ class Setting {
termsEng: map['terms_eng'], termsEng: map['terms_eng'],
termsMm: map['terms_mm'], termsMm: map['terms_mm'],
shipmentTypes: List.from(map['shipment_types']), shipmentTypes: List.from(map['shipment_types']),
courierWebsite: map['courier_website'],
); );
} }

View File

@@ -1,9 +1,7 @@
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:fcs/domain/entities/box.dart'; import 'package:fcs/domain/entities/carton.dart';
import 'package:fcs/domain/vo/delivery_address.dart'; import 'package:fcs/domain/vo/delivery_address.dart';
import 'cargo_type.dart';
class Shipment { class Shipment {
String id; String id;
String shipmentNumber; String shipmentNumber;
@@ -22,7 +20,7 @@ class Shipment {
String currentStatus; String currentStatus;
bool isCourier; bool isCourier;
int radioIndex; int radioIndex;
List<Box> boxes; List<Carton> boxes;
Shipment( Shipment(
{this.id, {this.id,
@@ -40,12 +38,15 @@ class Shipment {
this.pickupDate, this.pickupDate,
this.isCourier = false, this.isCourier = false,
this.radioIndex = 1, this.radioIndex = 1,
this.pickupAddress,
this.boxes}); this.boxes});
int get last => DateTime.now().difference(pickupDate).inDays; int get last => DateTime.now().difference(pickupDate).inDays;
factory Shipment.fromMap(Map<String, dynamic> map, String id) { factory Shipment.fromMap(Map<String, dynamic> map, String id) {
var pd = (map['pickup_date'] as Timestamp); var pd = (map['pickup_date'] as Timestamp);
var pa = map['pickup_address'];
var _pa = pa != null ? DeliveryAddress.fromMap(pa, pa["id"]) : null;
return Shipment( return Shipment(
id: id, id: id,
userName: map['user_name'], userName: map['user_name'],
@@ -54,14 +55,17 @@ class Shipment {
pickupDate: pd == null ? null : pd.toDate(), pickupDate: pd == null ? null : pd.toDate(),
pickupTimeStart: map['pickup_time_start'], pickupTimeStart: map['pickup_time_start'],
pickupTimeEnd: map['pickup_time_end'], pickupTimeEnd: map['pickup_time_end'],
currentStatus: map['current_status']); currentStatus: map['current_status'],
shipmentType: map['shipment_type'],
pickupAddress: _pa);
} }
Map<String, dynamic> toMap() { Map<String, dynamic> toMap() {
List _boxes = boxes.map((l) => l.toMap()).toList(); List _boxes = boxes.map((l) => l.toMap()).toList();
return { return {
"id": id, "id": id,
'boxes': _boxes, 'cartons': _boxes,
'shipment_type': shipmentType, 'shipment_type': shipmentType,
'pickup_address': pickupAddress.toMap(), 'pickup_address': pickupAddress.toMap(),
"pickup_date": pickupDate?.toUtc()?.toIso8601String(), "pickup_date": pickupDate?.toUtc()?.toIso8601String(),

View File

@@ -1,5 +1,5 @@
import 'package:fcs/domain/constants.dart'; import 'package:fcs/domain/constants.dart';
import 'package:fcs/domain/entities/box.dart'; import 'package:fcs/domain/entities/carton.dart';
import 'package:fcs/domain/entities/cargo_type.dart'; import 'package:fcs/domain/entities/cargo_type.dart';
import 'package:fcs/domain/entities/package.dart'; import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/domain/entities/user.dart'; import 'package:fcs/domain/entities/user.dart';
@@ -30,10 +30,10 @@ import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart'; import 'package:flutter_icons/flutter_icons.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'cargo_type_editor.dart'; import 'cargo_type_editor.dart';
import 'model/box_model.dart'; import 'model/carton_model.dart';
class BoxEditor extends StatefulWidget { class BoxEditor extends StatefulWidget {
final Box box; final Carton box;
BoxEditor({this.box}); BoxEditor({this.box});
@override @override
@@ -45,7 +45,7 @@ class _BoxEditorState extends State<BoxEditor> {
TextEditingController _heightController = new TextEditingController(); TextEditingController _heightController = new TextEditingController();
TextEditingController _lengthController = new TextEditingController(); TextEditingController _lengthController = new TextEditingController();
Box _box; Carton _box;
bool _isLoading = false; bool _isLoading = false;
bool isNew; bool isNew;
DeliveryAddress _deliveryAddress = new DeliveryAddress(); DeliveryAddress _deliveryAddress = new DeliveryAddress();
@@ -53,12 +53,12 @@ class _BoxEditorState extends State<BoxEditor> {
String _selectShipmentNumber; String _selectShipmentNumber;
String _selectedCartonType; String _selectedCartonType;
List<Package> _packages = []; List<Package> _packages = [];
List<Box> _shipmentBoxes = []; List<Carton> _shipmentBoxes = [];
List<Box> _mixBoxes = []; List<Carton> _mixBoxes = [];
List<CargoType> _cargoTypes = []; List<CargoType> _cargoTypes = [];
double volumetricRatio = 0; double volumetricRatio = 0;
double shipmentWeight = 0; double shipmentWeight = 0;
Box _selectedShipmentBox; Carton _selectedShipmentBox;
@override @override
void initState() { void initState() {
@@ -74,7 +74,7 @@ class _BoxEditorState extends State<BoxEditor> {
}); });
//for shipment boxes //for shipment boxes
var boxModel = Provider.of<BoxModel>(context, listen: false); var boxModel = Provider.of<CartonModel>(context, listen: false);
_shipmentBoxes = [ _shipmentBoxes = [
boxModel.boxeList[0], boxModel.boxeList[0],
boxModel.boxeList[1], boxModel.boxeList[1],
@@ -142,7 +142,7 @@ class _BoxEditorState extends State<BoxEditor> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var languageModel = Provider.of<LanguageModel>(context); var languageModel = Provider.of<LanguageModel>(context);
var boxModel = Provider.of<BoxModel>(context); var boxModel = Provider.of<CartonModel>(context);
var shipmentBox = Container( var shipmentBox = Container(
child: DropdownButtonFormField( child: DropdownButtonFormField(

View File

@@ -1,4 +1,4 @@
import 'package:fcs/domain/entities/box.dart'; import 'package:fcs/domain/entities/carton.dart';
import 'package:fcs/domain/entities/cargo_type.dart'; import 'package:fcs/domain/entities/cargo_type.dart';
import 'package:fcs/domain/entities/package.dart'; import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/domain/vo/delivery_address.dart'; import 'package:fcs/domain/vo/delivery_address.dart';
@@ -22,12 +22,12 @@ import 'package:timeline_list/timeline.dart';
import 'package:timeline_list/timeline_model.dart'; import 'package:timeline_list/timeline_model.dart';
import 'box_editor.dart'; import 'box_editor.dart';
import 'model/box_model.dart'; import 'model/carton_model.dart';
final DateFormat dateFormat = DateFormat("d MMM yyyy"); final DateFormat dateFormat = DateFormat("d MMM yyyy");
class BoxInfo extends StatefulWidget { class BoxInfo extends StatefulWidget {
final Box box; final Carton box;
BoxInfo({this.box}); BoxInfo({this.box});
@override @override
@@ -36,12 +36,12 @@ class BoxInfo extends StatefulWidget {
class _BoxInfoState extends State<BoxInfo> { class _BoxInfoState extends State<BoxInfo> {
bool _isLoading = false; bool _isLoading = false;
Box _box; Carton _box;
String _selectedCartonType; String _selectedCartonType;
String _shipmentNumber; String _shipmentNumber;
List<Package> _packages = []; List<Package> _packages = [];
List<Box> _mixBoxes = []; List<Carton> _mixBoxes = [];
Box _selectedShipmentBox = new Box(); Carton _selectedShipmentBox = new Carton();
List<CargoType> _cargoTypes = []; List<CargoType> _cargoTypes = [];
DeliveryAddress _deliveryAddress = new DeliveryAddress(); DeliveryAddress _deliveryAddress = new DeliveryAddress();
TextEditingController _widthController = new TextEditingController(); TextEditingController _widthController = new TextEditingController();
@@ -67,7 +67,7 @@ class _BoxInfoState extends State<BoxInfo> {
}); });
//for shipment boxes //for shipment boxes
var boxModel = Provider.of<BoxModel>(context, listen: false); var boxModel = Provider.of<CartonModel>(context, listen: false);
_selectedShipmentBox = boxModel.boxeList[0]; _selectedShipmentBox = boxModel.boxeList[0];
//for mix boxes //for mix boxes

View File

@@ -1,5 +1,5 @@
import 'package:fcs/helpers/theme.dart'; import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/box/model/box_model.dart'; import 'package:fcs/pages/carton/model/carton_model.dart';
import 'package:fcs/pages/widgets/local_popup_menu_button.dart'; import 'package:fcs/pages/widgets/local_popup_menu_button.dart';
import 'package:fcs/pages/widgets/local_popupmenu.dart'; import 'package:fcs/pages/widgets/local_popupmenu.dart';
import 'package:fcs/pages/widgets/local_text.dart'; import 'package:fcs/pages/widgets/local_text.dart';
@@ -25,10 +25,10 @@ class _BoxListState extends State<BoxList> {
super.initState(); super.initState();
_controller.addListener(() async { _controller.addListener(() async {
if (_controller.position.pixels == _controller.position.maxScrollExtent) { if (_controller.position.pixels == _controller.position.maxScrollExtent) {
Provider.of<BoxModel>(context, listen: false).loadMore(); Provider.of<CartonModel>(context, listen: false).loadMore();
} }
}); });
Provider.of<BoxModel>(context, listen: false).initData(); Provider.of<CartonModel>(context, listen: false).initData();
} }
@override @override
@@ -38,7 +38,7 @@ class _BoxListState extends State<BoxList> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var boxModel = Provider.of<BoxModel>(context); var boxModel = Provider.of<CartonModel>(context);
final popupMenu = LocalPopupMenuButton( final popupMenu = LocalPopupMenuButton(
popmenus: [ popmenus: [
LocalPopupMenu( LocalPopupMenu(

View File

@@ -1,4 +1,4 @@
import 'package:fcs/domain/entities/box.dart'; import 'package:fcs/domain/entities/carton.dart';
import 'package:fcs/pages/main/util.dart'; import 'package:fcs/pages/main/util.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -6,7 +6,7 @@ import 'package:intl/intl.dart';
import 'box_info.dart'; import 'box_info.dart';
class BoxListRow extends StatefulWidget { class BoxListRow extends StatefulWidget {
final Box box; final Carton box;
const BoxListRow({this.box}); const BoxListRow({this.box});
@override @override
@@ -15,7 +15,7 @@ class BoxListRow extends StatefulWidget {
class _BoxListRowState extends State<BoxListRow> { class _BoxListRowState extends State<BoxListRow> {
final double dotSize = 15.0; final double dotSize = 15.0;
Box _box = new Box(); Carton _box = new Carton();
final DateFormat dateFormat = new DateFormat("dd MMM yyyy"); final DateFormat dateFormat = new DateFormat("dd MMM yyyy");
@override @override

View File

@@ -40,7 +40,7 @@ class _CargoTypeEditorState extends State<CargoTypeEditor> {
_loadDefalut() { _loadDefalut() {
ShipmentRateModel shipmentRateModel = ShipmentRateModel shipmentRateModel =
Provider.of<ShipmentRateModel>(context, listen: false); Provider.of<ShipmentRateModel>(context, listen: false);
_cargo = shipmentRateModel.rate.defaultCargoType; _cargo = shipmentRateModel.rate.defaultCargoType.clone();
} }
@override @override

View File

@@ -2,7 +2,7 @@ import 'dart:async';
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:fcs/domain/constants.dart'; import 'package:fcs/domain/constants.dart';
import 'package:fcs/domain/entities/box.dart'; import 'package:fcs/domain/entities/carton.dart';
import 'package:fcs/domain/entities/cargo_type.dart'; import 'package:fcs/domain/entities/cargo_type.dart';
import 'package:fcs/domain/entities/package.dart'; import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/domain/vo/message.dart'; import 'package:fcs/domain/vo/message.dart';
@@ -12,11 +12,11 @@ import 'package:fcs/helpers/paginator.dart';
import 'package:fcs/pages/main/model/base_model.dart'; import 'package:fcs/pages/main/model/base_model.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
class BoxModel extends BaseModel { class CartonModel extends BaseModel {
List<Box> _boxes = []; List<Carton> _boxes = [];
final log = Logger('BoxModel'); final log = Logger('CartonModel');
List<Box> get boxes => List<Carton> get boxes =>
_selectedIndex == 1 ? _boxes : List<Box>.from(_delivered.values); _selectedIndex == 1 ? _boxes : List<Carton>.from(_delivered.values);
Paginator _delivered; Paginator _delivered;
int _selectedIndex = 1; int _selectedIndex = 1;
@@ -35,8 +35,8 @@ class BoxModel extends BaseModel {
// PackageModel.packages[2] // PackageModel.packages[2]
]; ];
List<Box> boxeList = [ List<Carton> boxeList = [
Box( Carton(
shipmentNumber: "A202", shipmentNumber: "A202",
receiverNumber: "3", receiverNumber: "3",
receiverName: "Ko Myo Min", receiverName: "Ko Myo Min",
@@ -68,7 +68,7 @@ class BoxModel extends BaseModel {
CargoType(name: 'Medicine', weight: 20), CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous', weight: 30) CargoType(name: 'Dangerous', weight: 30)
]), ]),
Box( Carton(
shipmentNumber: "A203", shipmentNumber: "A203",
receiverNumber: "3", receiverNumber: "3",
receiverName: "Ko Myo Min", receiverName: "Ko Myo Min",
@@ -100,7 +100,7 @@ class BoxModel extends BaseModel {
CargoType(name: 'Medicine', weight: 20), CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous', weight: 30) CargoType(name: 'Dangerous', weight: 30)
]), ]),
Box( Carton(
shipmentNumber: "A204", shipmentNumber: "A204",
receiverNumber: "3", receiverNumber: "3",
receiverName: "Ko Myo Min", receiverName: "Ko Myo Min",
@@ -132,7 +132,7 @@ class BoxModel extends BaseModel {
CargoType(name: 'Medicine', weight: 20), CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous', weight: 30) CargoType(name: 'Dangerous', weight: 30)
]), ]),
Box( Carton(
shipmentNumber: "A202", shipmentNumber: "A202",
receiverNumber: "2", receiverNumber: "2",
receiverName: "Ma Aye", receiverName: "Ma Aye",
@@ -163,7 +163,7 @@ class BoxModel extends BaseModel {
CargoType(name: 'Medicine', weight: 20), CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous', weight: 30) CargoType(name: 'Dangerous', weight: 30)
]), ]),
Box( Carton(
shipmentNumber: "A202", shipmentNumber: "A202",
receiverNumber: "2", receiverNumber: "2",
receiverName: "Ma Aye", receiverName: "Ma Aye",
@@ -193,7 +193,7 @@ class BoxModel extends BaseModel {
CargoType(name: 'Medicine', weight: 20), CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous', weight: 30) CargoType(name: 'Dangerous', weight: 30)
]), ]),
Box( Carton(
shipmentNumber: "A202", shipmentNumber: "A202",
receiverNumber: "2", receiverNumber: "2",
receiverName: "Ma Aye", receiverName: "Ma Aye",
@@ -223,7 +223,7 @@ class BoxModel extends BaseModel {
CargoType(name: 'Medicine', weight: 20), CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous', weight: 30) CargoType(name: 'Dangerous', weight: 30)
]), ]),
Box( Carton(
shipmentNumber: "A201", shipmentNumber: "A201",
receiverNumber: "1", receiverNumber: "1",
receiverName: "Ko Wai", receiverName: "Ko Wai",
@@ -253,7 +253,7 @@ class BoxModel extends BaseModel {
CargoType(name: 'Medicine', weight: 20), CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous', weight: 30) CargoType(name: 'Dangerous', weight: 30)
]), ]),
Box( Carton(
shipmentNumber: "A201", shipmentNumber: "A201",
receiverNumber: "1", receiverNumber: "1",
receiverName: "Ko Wai", receiverName: "Ko Wai",
@@ -285,21 +285,21 @@ class BoxModel extends BaseModel {
]), ]),
]; ];
List<Box> get completed { List<Carton> get completed {
return boxes.where((e) => e.status == "Delivered").toList() return boxes.where((e) => e.status == "Delivered").toList()
..sort((e1, e2) { ..sort((e1, e2) {
return e2.packageNumber.compareTo(e1.packageNumber); return e2.packageNumber.compareTo(e1.packageNumber);
}); });
} }
List<Box> get processed { List<Carton> get processed {
return boxes.where((e) => e.status == "Packed").toList() return boxes.where((e) => e.status == "Packed").toList()
..sort((e1, e2) { ..sort((e1, e2) {
return e2.packageNumber.compareTo(e1.packageNumber); return e2.packageNumber.compareTo(e1.packageNumber);
}); });
} }
List<Box> get upcoming { List<Carton> get upcoming {
return boxes return boxes
.where((e) => .where((e) =>
e.status == "Packed" || e.status == "Packed" ||
@@ -344,7 +344,7 @@ class BoxModel extends BaseModel {
.orderBy("date", descending: true); .orderBy("date", descending: true);
var paginator = new Paginator(pageQuery, rowPerLoad: 20, toObj: (data, id) { var paginator = new Paginator(pageQuery, rowPerLoad: 20, toObj: (data, id) {
var m = Message.fromMap(data, id); var m = Message.fromMap(data, id);
return Box( return Carton(
id: m.id, id: m.id,
shipmentNumber: m.message, shipmentNumber: m.message,
boxNumber: "1", boxNumber: "1",
@@ -359,7 +359,7 @@ class BoxModel extends BaseModel {
Future<void> _loadBoxes() async { Future<void> _loadBoxes() async {
if (user == null || !user.hasCarton()) return; if (user == null || !user.hasCarton()) return;
String path = "/$boxes_collection/"; String path = "/$cartons_collection/";
if (listener != null) listener.cancel(); if (listener != null) listener.cancel();
_boxes = []; _boxes = [];
try { try {
@@ -369,8 +369,8 @@ class BoxModel extends BaseModel {
.listen((QuerySnapshot snapshot) { .listen((QuerySnapshot snapshot) {
_boxes.clear(); _boxes.clear();
_boxes = snapshot.documents.map((documentSnapshot) { _boxes = snapshot.documents.map((documentSnapshot) {
var s = var s = Carton.fromMap(
Box.fromMap(documentSnapshot.data, documentSnapshot.documentID); documentSnapshot.data, documentSnapshot.documentID);
return s; return s;
}).toList(); }).toList();
notifyListeners(); notifyListeners();
@@ -384,11 +384,11 @@ class BoxModel extends BaseModel {
if (user == null || !user.hasCarton()) return null; if (user == null || !user.hasCarton()) return null;
var pageQuery = Firestore.instance var pageQuery = Firestore.instance
.collection("/$boxes_collection") .collection("/$cartons_collection")
.where("is_delivered", isEqualTo: true) .where("is_delivered", isEqualTo: true)
.where("is_deleted", isEqualTo: false); .where("is_deleted", isEqualTo: false);
var paginator = new Paginator(pageQuery, rowPerLoad: 20, toObj: (data, id) { var paginator = new Paginator(pageQuery, rowPerLoad: 20, toObj: (data, id) {
return Box.fromMap(data, id); return Carton.fromMap(data, id);
}); });
return paginator; return paginator;
} }
@@ -419,4 +419,15 @@ class BoxModel extends BaseModel {
if (_delivered != null) _delivered.close(); if (_delivered != null) _delivered.close();
_boxes = []; _boxes = [];
} }
Future<List<Carton>> getCartons(String shipmentID) async {
String path = "/$cartons_collection";
var querySnap = await Firestore.instance
.collection(path)
.where("shipment_id", isEqualTo: shipmentID)
.getDocuments();
return querySnap.documents
.map((e) => Carton.fromMap(e.data, e.documentID))
.toList();
}
} }

View File

@@ -1,4 +1,4 @@
import 'package:fcs/domain/entities/box.dart'; import 'package:fcs/domain/entities/carton.dart';
import 'package:fcs/domain/entities/cargo_type.dart'; import 'package:fcs/domain/entities/cargo_type.dart';
import 'package:fcs/domain/entities/package.dart'; import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/domain/vo/delivery_address.dart'; import 'package:fcs/domain/vo/delivery_address.dart';
@@ -25,7 +25,7 @@ import 'package:timeline_list/timeline_model.dart';
final DateFormat dateFormat = DateFormat("d MMM yyyy"); final DateFormat dateFormat = DateFormat("d MMM yyyy");
class DeliveryInfo extends StatefulWidget { class DeliveryInfo extends StatefulWidget {
final Box box; final Carton box;
DeliveryInfo({this.box}); DeliveryInfo({this.box});
@override @override
@@ -34,12 +34,12 @@ class DeliveryInfo extends StatefulWidget {
class _DeliveryInfoState extends State<DeliveryInfo> { class _DeliveryInfoState extends State<DeliveryInfo> {
bool _isLoading = false; bool _isLoading = false;
Box _box; Carton _box;
String _selectedCartonType; String _selectedCartonType;
String _shipmentNumber; String _shipmentNumber;
List<Package> _packages = []; List<Package> _packages = [];
List<Box> _mixBoxes = []; List<Carton> _mixBoxes = [];
Box _selectedShipmentBox = new Box(); Carton _selectedShipmentBox = new Carton();
List<CargoType> _cargoTypes = []; List<CargoType> _cargoTypes = [];
DeliveryAddress _deliveryAddress = new DeliveryAddress(); DeliveryAddress _deliveryAddress = new DeliveryAddress();
TextEditingController _widthController = new TextEditingController(); TextEditingController _widthController = new TextEditingController();

View File

@@ -1,5 +1,4 @@
import 'package:fcs/domain/entities/box.dart'; import 'package:fcs/domain/entities/carton.dart';
import 'package:fcs/pages/box/box_editor.dart';
import 'package:fcs/pages/main/util.dart'; import 'package:fcs/pages/main/util.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -8,7 +7,7 @@ import 'package:intl/intl.dart';
import 'delivery_info.dart'; import 'delivery_info.dart';
class DeliveryListRow extends StatefulWidget { class DeliveryListRow extends StatefulWidget {
final Box box; final Carton box;
const DeliveryListRow({this.box}); const DeliveryListRow({this.box});
@override @override
@@ -17,7 +16,7 @@ class DeliveryListRow extends StatefulWidget {
class _DeliveryListRowState extends State<DeliveryListRow> { class _DeliveryListRowState extends State<DeliveryListRow> {
final double dotSize = 15.0; final double dotSize = 15.0;
Box _box = new Box(); Carton _box = new Carton();
final DateFormat dateFormat = new DateFormat("dd MMM yyyy"); final DateFormat dateFormat = new DateFormat("dd MMM yyyy");
@override @override

View File

@@ -2,7 +2,7 @@ import 'dart:async';
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:fcs/domain/constants.dart'; import 'package:fcs/domain/constants.dart';
import 'package:fcs/domain/entities/box.dart'; import 'package:fcs/domain/entities/carton.dart';
import 'package:fcs/domain/entities/cargo_type.dart'; import 'package:fcs/domain/entities/cargo_type.dart';
import 'package:fcs/domain/entities/package.dart'; import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/domain/vo/message.dart'; import 'package:fcs/domain/vo/message.dart';
@@ -13,10 +13,10 @@ import 'package:fcs/pages/main/model/base_model.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
class DeliveryModel extends BaseModel { class DeliveryModel extends BaseModel {
List<Box> _cartons = []; List<Carton> _cartons = [];
final log = Logger('BoxModel'); final log = Logger('BoxModel');
List<Box> get cartons => List<Carton> get cartons =>
_selectedIndex == 1 ? _cartons : List<Box>.from(_delivered.values); _selectedIndex == 1 ? _cartons : List<Carton>.from(_delivered.values);
Paginator _delivered; Paginator _delivered;
int _selectedIndex = 1; int _selectedIndex = 1;
@@ -35,8 +35,8 @@ class DeliveryModel extends BaseModel {
// PackageModel.packages[2] // PackageModel.packages[2]
]; ];
List<Box> cartonList = [ List<Carton> cartonList = [
Box( Carton(
shipmentNumber: "A202", shipmentNumber: "A202",
receiverNumber: "3", receiverNumber: "3",
receiverName: "Ko Myo Min", receiverName: "Ko Myo Min",
@@ -68,7 +68,7 @@ class DeliveryModel extends BaseModel {
CargoType(name: 'Medicine', weight: 20), CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous', weight: 30) CargoType(name: 'Dangerous', weight: 30)
]), ]),
Box( Carton(
shipmentNumber: "A203", shipmentNumber: "A203",
receiverNumber: "3", receiverNumber: "3",
receiverName: "Ko Myo Min", receiverName: "Ko Myo Min",
@@ -100,7 +100,7 @@ class DeliveryModel extends BaseModel {
CargoType(name: 'Medicine', weight: 20), CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous', weight: 30) CargoType(name: 'Dangerous', weight: 30)
]), ]),
Box( Carton(
shipmentNumber: "A204", shipmentNumber: "A204",
receiverNumber: "3", receiverNumber: "3",
receiverName: "Ko Myo Min", receiverName: "Ko Myo Min",
@@ -132,7 +132,7 @@ class DeliveryModel extends BaseModel {
CargoType(name: 'Medicine', weight: 20), CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous', weight: 30) CargoType(name: 'Dangerous', weight: 30)
]), ]),
Box( Carton(
shipmentNumber: "A202", shipmentNumber: "A202",
receiverNumber: "2", receiverNumber: "2",
receiverName: "Ma Aye", receiverName: "Ma Aye",
@@ -163,7 +163,7 @@ class DeliveryModel extends BaseModel {
CargoType(name: 'Medicine', weight: 20), CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous', weight: 30) CargoType(name: 'Dangerous', weight: 30)
]), ]),
Box( Carton(
shipmentNumber: "A202", shipmentNumber: "A202",
receiverNumber: "2", receiverNumber: "2",
receiverName: "Ma Aye", receiverName: "Ma Aye",
@@ -193,7 +193,7 @@ class DeliveryModel extends BaseModel {
CargoType(name: 'Medicine', weight: 20), CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous', weight: 30) CargoType(name: 'Dangerous', weight: 30)
]), ]),
Box( Carton(
shipmentNumber: "A202", shipmentNumber: "A202",
receiverNumber: "2", receiverNumber: "2",
receiverName: "Ma Aye", receiverName: "Ma Aye",
@@ -223,7 +223,7 @@ class DeliveryModel extends BaseModel {
CargoType(name: 'Medicine', weight: 20), CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous', weight: 30) CargoType(name: 'Dangerous', weight: 30)
]), ]),
Box( Carton(
shipmentNumber: "A201", shipmentNumber: "A201",
receiverNumber: "1", receiverNumber: "1",
receiverName: "Ko Wai", receiverName: "Ko Wai",
@@ -253,7 +253,7 @@ class DeliveryModel extends BaseModel {
CargoType(name: 'Medicine', weight: 20), CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous', weight: 30) CargoType(name: 'Dangerous', weight: 30)
]), ]),
Box( Carton(
shipmentNumber: "A201", shipmentNumber: "A201",
receiverNumber: "1", receiverNumber: "1",
receiverName: "Ko Wai", receiverName: "Ko Wai",
@@ -317,7 +317,7 @@ class DeliveryModel extends BaseModel {
.orderBy("date", descending: true); .orderBy("date", descending: true);
var paginator = new Paginator(pageQuery, rowPerLoad: 20, toObj: (data, id) { var paginator = new Paginator(pageQuery, rowPerLoad: 20, toObj: (data, id) {
var m = Message.fromMap(data, id); var m = Message.fromMap(data, id);
return Box( return Carton(
id: m.id, id: m.id,
shipmentNumber: m.message, shipmentNumber: m.message,
boxNumber: "1", boxNumber: "1",
@@ -332,7 +332,7 @@ class DeliveryModel extends BaseModel {
Future<void> _loadBoxes() async { Future<void> _loadBoxes() async {
if (user == null || !user.hasDeliveries()) return; if (user == null || !user.hasDeliveries()) return;
String path = "/$boxes_collection/"; String path = "/$cartons_collection/";
if (listener != null) listener.cancel(); if (listener != null) listener.cancel();
_cartons = []; _cartons = [];
try { try {
@@ -342,8 +342,8 @@ class DeliveryModel extends BaseModel {
.listen((QuerySnapshot snapshot) { .listen((QuerySnapshot snapshot) {
_cartons.clear(); _cartons.clear();
_cartons = snapshot.documents.map((documentSnapshot) { _cartons = snapshot.documents.map((documentSnapshot) {
var s = var s = Carton.fromMap(
Box.fromMap(documentSnapshot.data, documentSnapshot.documentID); documentSnapshot.data, documentSnapshot.documentID);
return s; return s;
}).toList(); }).toList();
notifyListeners(); notifyListeners();
@@ -357,11 +357,11 @@ class DeliveryModel extends BaseModel {
if (user == null || !user.hasDeliveries()) return null; if (user == null || !user.hasDeliveries()) return null;
var pageQuery = Firestore.instance var pageQuery = Firestore.instance
.collection("/$boxes_collection") .collection("/$cartons_collection")
.where("is_delivered", isEqualTo: true) .where("is_delivered", isEqualTo: true)
.where("is_deleted", isEqualTo: false); .where("is_deleted", isEqualTo: false);
var paginator = new Paginator(pageQuery, rowPerLoad: 20, toObj: (data, id) { var paginator = new Paginator(pageQuery, rowPerLoad: 20, toObj: (data, id) {
return Box.fromMap(data, id); return Carton.fromMap(data, id);
}); });
return paginator; return paginator;
} }

View File

@@ -1,14 +1,14 @@
import 'package:fcs/domain/entities/box.dart'; import 'package:fcs/domain/entities/carton.dart';
import 'package:fcs/helpers/theme.dart'; import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/app_translations.dart'; import 'package:fcs/localization/app_translations.dart';
import 'package:fcs/pages/box/model/box_model.dart'; import 'package:fcs/pages/carton/model/carton_model.dart';
import 'package:fcs/pages/widgets/progress.dart'; import 'package:fcs/pages/widgets/progress.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class BoxAddition extends StatefulWidget { class BoxAddition extends StatefulWidget {
final Box box; final Carton box;
BoxAddition({this.box}); BoxAddition({this.box});
@override @override
@@ -16,7 +16,7 @@ class BoxAddition extends StatefulWidget {
} }
class _BoxAdditionState extends State<BoxAddition> { class _BoxAdditionState extends State<BoxAddition> {
Box _box = new Box(); Carton _box = new Carton();
bool _isLoading = false; bool _isLoading = false;
@override @override
@@ -34,7 +34,7 @@ class _BoxAdditionState extends State<BoxAddition> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var boxModel = Provider.of<BoxModel>(context); var boxModel = Provider.of<CartonModel>(context);
return LocalProgress( return LocalProgress(
inAsyncCall: _isLoading, inAsyncCall: _isLoading,
child: Scaffold( child: Scaffold(

View File

@@ -1,4 +1,4 @@
import 'package:fcs/domain/entities/box.dart'; import 'package:fcs/domain/entities/carton.dart';
import 'package:fcs/domain/entities/cargo_type.dart'; import 'package:fcs/domain/entities/cargo_type.dart';
import 'package:fcs/domain/entities/custom_duty.dart'; import 'package:fcs/domain/entities/custom_duty.dart';
import 'package:fcs/domain/entities/discount.dart'; import 'package:fcs/domain/entities/discount.dart';
@@ -63,7 +63,7 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
Invoice _invoice; Invoice _invoice;
bool _isLoading = false; bool _isLoading = false;
List<Box> _boxes = []; List<Carton> _boxes = [];
bool isSwitched = false; bool isSwitched = false;
int deliveryfee = 0; int deliveryfee = 0;
double customFee = 10.0; double customFee = 10.0;
@@ -76,7 +76,7 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
PaymentMethod paymentMethod; PaymentMethod paymentMethod;
double volumetricRatio = 0; double volumetricRatio = 0;
List<Box> selectedBoxes = []; List<Carton> selectedBoxes = [];
List<CustomDuty> customs = []; List<CustomDuty> customs = [];
List<CargoType> _cargoTypes = [ List<CargoType> _cargoTypes = [
@@ -130,7 +130,7 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
} }
_boxes = [ _boxes = [
Box( Carton(
shipmentNumber: "A202", shipmentNumber: "A202",
receiverNumber: "3", receiverNumber: "3",
receiverName: "Ko Myo Min", receiverName: "Ko Myo Min",
@@ -152,7 +152,7 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
CargoType(name: 'Medicine', weight: 20), CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous Cargo', weight: 30) CargoType(name: 'Dangerous Cargo', weight: 30)
]), ]),
Box( Carton(
shipmentNumber: "A202", shipmentNumber: "A202",
receiverNumber: "3", receiverNumber: "3",
receiverName: "Ko Myo Min", receiverName: "Ko Myo Min",

View File

@@ -1,4 +1,4 @@
import 'package:fcs/domain/entities/box.dart'; import 'package:fcs/domain/entities/carton.dart';
import 'package:fcs/domain/entities/cargo_type.dart'; import 'package:fcs/domain/entities/cargo_type.dart';
import 'package:fcs/domain/entities/custom_duty.dart'; import 'package:fcs/domain/entities/custom_duty.dart';
import 'package:fcs/domain/entities/discount.dart'; import 'package:fcs/domain/entities/discount.dart';
@@ -63,7 +63,7 @@ class _InvoiceInfoPageState extends State<InvoiceInfoPage> {
Invoice _invoice; Invoice _invoice;
bool _isLoading = false; bool _isLoading = false;
List<Box> _boxes = []; List<Carton> _boxes = [];
bool isSwitched = false; bool isSwitched = false;
int deliveryfee = 0; int deliveryfee = 0;
double customFee = 0; double customFee = 0;
@@ -75,7 +75,7 @@ class _InvoiceInfoPageState extends State<InvoiceInfoPage> {
PaymentMethod paymentMethod; PaymentMethod paymentMethod;
double volumetricRatio = 0; double volumetricRatio = 0;
List<Box> selectedBoxes = []; List<Carton> selectedBoxes = [];
List<CustomDuty> customs = []; List<CustomDuty> customs = [];
List<CargoType> _cargoTypes = [ List<CargoType> _cargoTypes = [
@@ -122,7 +122,7 @@ class _InvoiceInfoPageState extends State<InvoiceInfoPage> {
} }
_boxes = [ _boxes = [
Box( Carton(
shipmentNumber: "A202", shipmentNumber: "A202",
receiverNumber: "3", receiverNumber: "3",
receiverName: "Ko Myo Min", receiverName: "Ko Myo Min",
@@ -144,7 +144,7 @@ class _InvoiceInfoPageState extends State<InvoiceInfoPage> {
CargoType(name: 'Medicine', weight: 20), CargoType(name: 'Medicine', weight: 20),
CargoType(name: 'Dangerous Cargo', weight: 30) CargoType(name: 'Dangerous Cargo', weight: 30)
]), ]),
Box( Carton(
shipmentNumber: "A202", shipmentNumber: "A202",
receiverNumber: "3", receiverNumber: "3",
receiverName: "Ko Myo Min", receiverName: "Ko Myo Min",

View File

@@ -7,7 +7,7 @@ import 'package:fcs/domain/entities/user.dart';
import 'package:fcs/helpers/shared_pref.dart'; import 'package:fcs/helpers/shared_pref.dart';
import 'package:fcs/helpers/theme.dart'; import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/transalation.dart'; import 'package:fcs/localization/transalation.dart';
import 'package:fcs/pages/box/box_list.dart'; import 'package:fcs/pages/carton/box_list.dart';
import 'package:fcs/pages/chat/message_detail.dart'; import 'package:fcs/pages/chat/message_detail.dart';
import 'package:fcs/pages/chat/model/message_model.dart'; import 'package:fcs/pages/chat/model/message_model.dart';
import 'package:fcs/pages/customer/customer_list.dart'; import 'package:fcs/pages/customer/customer_list.dart';

View File

@@ -97,11 +97,10 @@ class _PackageListState extends State<PackageList> {
child: ListView.separated( child: ListView.separated(
controller: _controller, controller: _controller,
separatorBuilder: (context, index) => Divider( separatorBuilder: (context, index) => Divider(
color: Colors.black, color: Colors.grey,
height: 1,
), ),
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
padding: EdgeInsets.only(top: 15),
shrinkWrap: true,
itemCount: packages.length, itemCount: packages.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return PackageListRow( return PackageListRow(

View File

@@ -1,9 +1,10 @@
import 'package:fcs/domain/entities/package.dart'; import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/pages/package/package_info.dart'; import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/main/util.dart'; import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart'; import 'package:fcs/pages/package/package_info.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
typedef CallbackPackageSelect(Package package); typedef CallbackPackageSelect(Package package);
@@ -19,68 +20,76 @@ class PackageListRow extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return InkWell(
padding: EdgeInsets.only(left: 15, right: 15), onTap: () {
child: InkWell( if (callbackPackageSelect != null) {
onTap: () { callbackPackageSelect(package);
if (callbackPackageSelect != null) { return;
callbackPackageSelect(package); }
return; Navigator.push(
} context,
Navigator.push( CupertinoPageRoute(
context, builder: (context) => PackageInfo(package: package)),
CupertinoPageRoute(builder: (context) => PackageInfo(package: package)), );
); },
}, child: Container(
child: Row( padding: EdgeInsets.only(left: 15, right: 15),
children: <Widget>[ child: Column(
Expanded( children: [
child: new Padding( Row(
padding: const EdgeInsets.symmetric(vertical: 16.0), children: <Widget>[
child: new Row( Expanded(
child: new Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: new Row(
children: <Widget>[
Icon(Octicons.package, color: primaryColor),
SizedBox(width: 8),
new Expanded(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
package.id == null ? '' : package.trackingID,
style: new TextStyle(
fontSize: 15.0, color: Colors.black),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
package.market == null ? '' : package.market,
style: new TextStyle(
fontSize: 15.0, color: Colors.black),
),
),
],
),
),
],
),
),
),
Column(
children: <Widget>[ children: <Widget>[
new Expanded( Padding(
child: new Column( padding: const EdgeInsets.all(3.0),
crossAxisAlignment: CrossAxisAlignment.start, child: getStatus(package.currentStatus),
children: <Widget>[ ),
Padding( Padding(
padding: const EdgeInsets.only(left: 8.0), padding: const EdgeInsets.all(0),
child: new Text( child: new Text(
package.id == null ? '' : package.trackingID, dateFormat.format(package.currentStatusDate),
style: new TextStyle( style:
fontSize: 15.0, color: Colors.black), new TextStyle(fontSize: 15.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
package.market == null ? '' : package.market,
style: new TextStyle(
fontSize: 15.0, color: Colors.black),
),
),
],
), ),
), ),
], ],
), )
),
),
Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(3.0),
child: getStatus(package.currentStatus),
),
Padding(
padding: const EdgeInsets.all(0),
child: new Text(
dateFormat.format(package.currentStatusDate),
style: new TextStyle(fontSize: 15.0, color: Colors.grey),
),
),
], ],
) ),
], ],
), ),
), ),

View File

@@ -1,12 +1,5 @@
import 'package:fcs/domain/entities/cargo_type.dart'; import 'package:fcs/domain/entities/cargo_type.dart';
import 'package:fcs/domain/entities/custom_duty.dart';
import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/helpers/theme.dart'; import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/box/cargo_type_editor.dart';
import 'package:fcs/pages/delivery_address/delivery_address_editor.dart';
import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/rates/custom_editor.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
import 'package:fcs/pages/widgets/local_text.dart'; import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/progress.dart'; import 'package:fcs/pages/widgets/progress.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
@@ -14,7 +7,6 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'cargo_editor.dart'; import 'cargo_editor.dart';
import 'custom_row.dart';
import 'model/shipment_rate_model.dart'; import 'model/shipment_rate_model.dart';
class CargoTypeList extends StatefulWidget { class CargoTypeList extends StatefulWidget {

View File

@@ -1,4 +1,4 @@
import 'package:fcs/domain/entities/box.dart'; import 'package:fcs/domain/entities/carton.dart';
import 'package:fcs/domain/entities/cargo_type.dart'; import 'package:fcs/domain/entities/cargo_type.dart';
import 'package:fcs/domain/entities/rate.dart'; import 'package:fcs/domain/entities/rate.dart';
import 'package:fcs/helpers/theme.dart'; import 'package:fcs/helpers/theme.dart';
@@ -56,7 +56,8 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
double w = double.parse(_widthController.text, (s) => 0); double w = double.parse(_widthController.text, (s) => 0);
double h = double.parse(_heightController.text, (s) => 0); double h = double.parse(_heightController.text, (s) => 0);
_cargoType.weight = double.tryParse(_actualWeightCtl.text) ?? 0; _cargoType.weight = double.tryParse(_actualWeightCtl.text) ?? 0;
Box box = Box(cargoTypes: [_cargoType], length: l, width: w, height: h); Carton box =
Carton(cargoTypes: [_cargoType], length: l, width: w, height: h);
var amount = box.calAmount(rate); var amount = box.calAmount(rate);
var shipmentWeight = box.getShipmentWeight(rate.volumetricRatio); var shipmentWeight = box.getShipmentWeight(rate.volumetricRatio);
var effectiveWeight = var effectiveWeight =

View File

@@ -1,9 +1,9 @@
import 'package:fcs/domain/entities/box.dart'; import 'package:fcs/domain/entities/carton.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class BoxRow extends StatelessWidget { class BoxRow extends StatelessWidget {
final Box box; final Carton box;
const BoxRow({Key key, this.box}) : super(key: key); const BoxRow({Key key, this.box}) : super(key: key);
@@ -27,9 +27,7 @@ class BoxRow extends StatelessWidget {
Padding( Padding(
padding: const EdgeInsets.only(left: 8.0), padding: const EdgeInsets.only(left: 8.0),
child: new Text( child: new Text(
box.deliveryAddress.fullName == null box.deliveryAddress?.fullName ?? "",
? ''
: box.deliveryAddress.fullName,
style: new TextStyle( style: new TextStyle(
fontSize: 15.0, fontSize: 15.0,
color: Colors.black, color: Colors.black,
@@ -39,9 +37,7 @@ class BoxRow extends StatelessWidget {
Padding( Padding(
padding: const EdgeInsets.only(left: 8.0), padding: const EdgeInsets.only(left: 8.0),
child: new Text( child: new Text(
box.deliveryAddress.addressLine1 == null box.deliveryAddress?.addressLine1 ?? "",
? ''
: box.deliveryAddress.addressLine1,
style: new TextStyle( style: new TextStyle(
fontSize: 14.0, color: Colors.grey), fontSize: 14.0, color: Colors.grey),
), ),
@@ -49,9 +45,7 @@ class BoxRow extends StatelessWidget {
Padding( Padding(
padding: const EdgeInsets.only(left: 8.0), padding: const EdgeInsets.only(left: 8.0),
child: new Text( child: new Text(
box.deliveryAddress.addressLine2 == null box.deliveryAddress?.addressLine2 ?? "",
? ''
: box.deliveryAddress.addressLine2,
style: new TextStyle( style: new TextStyle(
fontSize: 14.0, color: Colors.grey), fontSize: 14.0, color: Colors.grey),
), ),
@@ -59,9 +53,7 @@ class BoxRow extends StatelessWidget {
Padding( Padding(
padding: const EdgeInsets.only(left: 8.0), padding: const EdgeInsets.only(left: 8.0),
child: new Text( child: new Text(
box.deliveryAddress.city == null box.deliveryAddress?.city ?? "",
? ''
: box.deliveryAddress.city,
style: new TextStyle( style: new TextStyle(
fontSize: 14.0, color: Colors.grey), fontSize: 14.0, color: Colors.grey),
), ),
@@ -69,9 +61,7 @@ class BoxRow extends StatelessWidget {
Padding( Padding(
padding: const EdgeInsets.only(left: 8.0), padding: const EdgeInsets.only(left: 8.0),
child: new Text( child: new Text(
box.deliveryAddress.state == null box.deliveryAddress?.state ?? "",
? ''
: box.deliveryAddress.state,
style: new TextStyle( style: new TextStyle(
fontSize: 14.0, color: Colors.grey), fontSize: 14.0, color: Colors.grey),
), ),
@@ -79,9 +69,7 @@ class BoxRow extends StatelessWidget {
Padding( Padding(
padding: const EdgeInsets.only(left: 8.0), padding: const EdgeInsets.only(left: 8.0),
child: new Text( child: new Text(
box.deliveryAddress.phoneNumber == null box.deliveryAddress?.phoneNumber ?? "",
? ''
: "Phone:${box.deliveryAddress.phoneNumber}",
style: new TextStyle( style: new TextStyle(
fontSize: 14.0, color: Colors.grey), fontSize: 14.0, color: Colors.grey),
), ),

View File

@@ -117,6 +117,7 @@ class ShipmentModel extends BaseModel {
var q = Firestore.instance var q = Firestore.instance
.collection("$path") .collection("$path")
.where("is_delivered", isEqualTo: false) .where("is_delivered", isEqualTo: false)
.where("is_canceled", isEqualTo: false)
.where("is_deleted", isEqualTo: false); .where("is_deleted", isEqualTo: false);
if (forCustomer) { if (forCustomer) {
@@ -144,6 +145,21 @@ class ShipmentModel extends BaseModel {
shipment_courier_dropoff shipment_courier_dropoff
]; ];
Future<Shipment> getShipment(String shipmentID) async {
String path = "/$shipments_collection";
try {
var ref = Firestore.instance.collection("$path").document(shipmentID);
var snap = await ref.get(source: Source.server);
if (snap.exists) {
var s = Shipment.fromMap(snap.data, snap.documentID);
return s;
}
} catch (e) {
log.warning("Error!! $e");
}
return null;
}
void initUser(user) { void initUser(user) {
super.initUser(user); super.initUser(user);
} }
@@ -155,4 +171,8 @@ class ShipmentModel extends BaseModel {
Future<void> updateShipment(Shipment shipment) { Future<void> updateShipment(Shipment shipment) {
return Services.instance.shipmentService.updateShipment(shipment); return Services.instance.shipmentService.updateShipment(shipment);
} }
Future<void> cancelShipment(Shipment shipment) {
return Services.instance.shipmentService.cancelShipment(shipment);
}
} }

View File

@@ -1,8 +1,8 @@
import 'package:fcs/domain/entities/box.dart'; import 'package:fcs/domain/entities/carton.dart';
import 'package:fcs/domain/entities/cargo_type.dart'; import 'package:fcs/domain/entities/cargo_type.dart';
import 'package:fcs/domain/vo/delivery_address.dart'; import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/helpers/theme.dart'; import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/box/cargo_type_editor.dart'; import 'package:fcs/pages/carton/cargo_type_editor.dart';
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart'; import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
import 'package:fcs/pages/rates/model/shipment_rate_model.dart'; import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
import 'package:fcs/pages/widgets/defalut_delivery_address.dart'; import 'package:fcs/pages/widgets/defalut_delivery_address.dart';
@@ -20,7 +20,7 @@ import 'package:flutter_icons/flutter_icons.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class ShipmentBoxEditor extends StatefulWidget { class ShipmentBoxEditor extends StatefulWidget {
final Box box; final Carton box;
ShipmentBoxEditor({this.box}); ShipmentBoxEditor({this.box});
@override @override
@@ -32,7 +32,7 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
TextEditingController _widthCtl = new TextEditingController(); TextEditingController _widthCtl = new TextEditingController();
TextEditingController _heightCtl = new TextEditingController(); TextEditingController _heightCtl = new TextEditingController();
Box _box; Carton _box;
bool _isLoading = false; bool _isLoading = false;
bool _isNew; bool _isNew;
double volumetricRatio = 0; double volumetricRatio = 0;
@@ -57,7 +57,7 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
Provider.of<DeliveryAddressModel>(context, listen: false); Provider.of<DeliveryAddressModel>(context, listen: false);
_isNew = true; _isNew = true;
_box = Box(cargoTypes: []); _box = Carton(cargoTypes: []);
_box.deliveryAddress = shipmentModel.defalutAddress; _box.deliveryAddress = shipmentModel.defalutAddress;
_lengthCtl.text = "12"; _lengthCtl.text = "12";

View File

@@ -1,9 +1,8 @@
import 'package:fcs/domain/constants.dart'; import 'package:fcs/domain/constants.dart';
import 'package:fcs/domain/entities/box.dart'; import 'package:fcs/domain/entities/carton.dart';
import 'package:fcs/domain/entities/shipment.dart'; import 'package:fcs/domain/entities/shipment.dart';
import 'package:fcs/domain/vo/delivery_address.dart'; import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/helpers/theme.dart'; import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/box/model/box_model.dart';
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart'; import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
import 'package:fcs/pages/main/model/main_model.dart'; import 'package:fcs/pages/main/model/main_model.dart';
import 'package:fcs/pages/main/util.dart'; import 'package:fcs/pages/main/util.dart';
@@ -11,24 +10,23 @@ import 'package:fcs/pages/shipment/model/shipment_model.dart';
import 'package:fcs/pages/widgets/defalut_delivery_address.dart'; import 'package:fcs/pages/widgets/defalut_delivery_address.dart';
import 'package:fcs/pages/widgets/delivery_address_selection.dart'; import 'package:fcs/pages/widgets/delivery_address_selection.dart';
import 'package:fcs/pages/widgets/display_text.dart'; import 'package:fcs/pages/widgets/display_text.dart';
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
import 'package:fcs/pages/widgets/input_date.dart'; import 'package:fcs/pages/widgets/input_date.dart';
import 'package:fcs/pages/widgets/input_time.dart'; import 'package:fcs/pages/widgets/input_time.dart';
import 'package:fcs/pages/widgets/local_button.dart'; import 'package:fcs/pages/widgets/local_button.dart';
import 'package:fcs/pages/widgets/local_dropdown.dart';
import 'package:fcs/pages/widgets/local_radio_buttons.dart'; import 'package:fcs/pages/widgets/local_radio_buttons.dart';
import 'package:fcs/pages/widgets/local_text.dart'; import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/local_title.dart'; import 'package:fcs/pages/widgets/local_title.dart';
import 'package:fcs/pages/widgets/multi_img_controller.dart';
import 'package:fcs/pages/widgets/progress.dart'; import 'package:fcs/pages/widgets/progress.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';
import 'box_row.dart'; import 'box_row.dart';
import 'shipment_box_editor.dart'; import 'shipment_box_editor.dart';
import 'widgets.dart';
class ShipmentEditor extends StatefulWidget { class ShipmentEditor extends StatefulWidget {
final Shipment shipment; final Shipment shipment;
@@ -40,55 +38,37 @@ class ShipmentEditor extends StatefulWidget {
class _ShipmentEditorState extends State<ShipmentEditor> { class _ShipmentEditorState extends State<ShipmentEditor> {
var dateFormatter = new DateFormat('dd MMM yyyy'); var dateFormatter = new DateFormat('dd MMM yyyy');
final numberFormatter = new NumberFormat("#,###"); var timeFormatter = new DateFormat('jm');
MultiImgController multiImgController = MultiImgController();
TextEditingController _addressEditingController = new TextEditingController();
TextEditingController _fromTimeEditingController = TextEditingController _fromTimeEditingController =
new TextEditingController(); new TextEditingController();
TextEditingController _toTimeEditingController = new TextEditingController(); TextEditingController _toTimeEditingController = new TextEditingController();
TextEditingController _noOfPackageEditingController =
new TextEditingController();
TextEditingController _weightEditingController = new TextEditingController();
TextEditingController _recipientNameEditingController =
new TextEditingController();
TextEditingController _recipientPhoneEditingController =
new TextEditingController();
TextEditingController _recipientAddressEditingController =
new TextEditingController();
TextEditingController _pickupDate = new TextEditingController(); TextEditingController _pickupDate = new TextEditingController();
TextEditingController _handlingFeeController = new TextEditingController();
Shipment _shipment; Shipment _shipment;
bool _isLoading = false; bool _isLoading = false;
var now = new DateTime.now(); var now = new DateTime.now();
bool _isNew; bool _isNew;
int _currVal = 1;
String _selectedShipmentType; String _selectedShipmentType;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_selectedShipmentType = shipment_local_pickup;
if (widget.shipment != null) { if (widget.shipment != null) {
_isNew = false; _isNew = false;
_shipment = widget.shipment; _shipment = widget.shipment;
_addressEditingController.text = _shipment.address; _selectedShipmentType = _shipment.shipmentType;
_fromTimeEditingController.text = _shipment.pickupTimeStart; _fromTimeEditingController.text = _shipment.pickupTimeStart;
_toTimeEditingController.text = _shipment.pickupTimeEnd; _toTimeEditingController.text = _shipment.pickupTimeEnd;
_noOfPackageEditingController.text = _shipment.numberOfPackage.toString();
_weightEditingController.text = _shipment.weight.toString();
_pickupDate.text = dateFormatter.format(_shipment.pickupDate ?? now); _pickupDate.text = dateFormatter.format(_shipment.pickupDate ?? now);
// _handlingFeeController.text =
// numberFormatter.format(_shipment.handlingFee);
_currVal = _shipment.radioIndex;
} else { } else {
_isNew = true; _isNew = true;
_selectedShipmentType = shipment_local_pickup;
_pickupDate.text = dateFormatter.format(now); _pickupDate.text = dateFormatter.format(now);
_fromTimeEditingController.text = "${(now.hour)}:${(now.minute)}"; _fromTimeEditingController.text = "${timeFormatter.format(now)}";
_toTimeEditingController.text = "${(now.hour)}:${(now.minute)}"; _toTimeEditingController.text = "${timeFormatter.format(now)}";
_shipment = Shipment(boxes: []); _shipment = Shipment(boxes: []);
var shipmentModel = var shipmentModel =
Provider.of<DeliveryAddressModel>(context, listen: false); Provider.of<DeliveryAddressModel>(context, listen: false);
@@ -106,7 +86,11 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
MainModel mainModel = Provider.of<MainModel>(context); MainModel mainModel = Provider.of<MainModel>(context);
ShipmentModel pickupModel = Provider.of<ShipmentModel>(context); ShipmentModel pickupModel = Provider.of<ShipmentModel>(context);
final shipmentNumberBox = getShipmentNumberStatus(context, _shipment);
bool isLocalPickup = _selectedShipmentType == shipment_local_pickup;
bool isCourierPickup = _selectedShipmentType == shipment_courier_pickup;
bool isLocalDropoff = _selectedShipmentType == shipment_local_dropoff;
bool isCourierDropoff = _selectedShipmentType == shipment_courier_dropoff;
final fromTimeBox = InputTime( final fromTimeBox = InputTime(
labelTextKey: 'shipment.from', labelTextKey: 'shipment.from',
iconData: Icons.timer, iconData: Icons.timer,
@@ -124,20 +108,17 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
iconData: Icons.date_range, iconData: Icons.date_range,
controller: _pickupDate, controller: _pickupDate,
); );
final localDropoffAddress = DisplayText( final curierDropoffAddress = Padding(
iconData: Icons.location_on, padding: EdgeInsets.all(8),
labelTextKey: "Local Dropoff Address", child: FloatingActionButton.extended(
text: mainModel.setting.usaAddress); onPressed: _openCourierWebsite,
final curierDropoffAddress = FloatingActionButton.extended( icon: Icon(Icons.open_in_new, color: primaryColor),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, label: Text(
onPressed: () {}, 'Visit courier websie \nfor nearest drop-off',
icon: Icon(Icons.arrow_right), style: TextStyle(fontSize: 16, color: primaryColor),
label: Text( ),
'Visit courier websie for nearest drop-off', backgroundColor: Colors.white,
style: TextStyle(fontSize: 12), ));
),
backgroundColor: primaryColor,
);
final pickupAddressBox = DefaultDeliveryAddress( final pickupAddressBox = DefaultDeliveryAddress(
deliveryAddress: _shipment.pickupAddress, deliveryAddress: _shipment.pickupAddress,
iconData: Icons.location_on, iconData: Icons.location_on,
@@ -156,28 +137,22 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
}); });
}, },
); );
var boxModel = Provider.of<BoxModel>(context); var localDropoffAddressBox = Row(children: [
var handlingFeeBox = DisplayText( FcsIDIcon(),
labelTextKey: "shipment.handling.fee", Expanded(
text: "10", child: DisplayText(
iconData: FontAwesomeIcons.moneyBill); text: mainModel.setting.usaAddress,
var shipmentTypeBox = LocalDropdown<String>( ),
callback: (v) { )
setState(() { ]);
_selectedShipmentType = v;
});
},
iconData: SimpleLineIcons.direction,
selectedValue: _selectedShipmentType,
values: pickupModel.shipmentTypes,
);
final createBtn = LocalButton( final createBtn = LocalButton(
textKey: "shipment.create", textKey: "shipment.create",
callBack: _create, callBack: _save,
); );
final updateBtn = LocalButton( final updateBtn = LocalButton(
textKey: "shipment.update", textKey: "shipment.update",
callBack: _save,
); );
return LocalProgress( return LocalProgress(
@@ -205,6 +180,7 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
padding: const EdgeInsets.all(10.0), padding: const EdgeInsets.all(10.0),
child: ListView( child: ListView(
children: <Widget>[ children: <Widget>[
_isNew ? Container() : Center(child: shipmentNumberBox),
LocalTitle(textKey: "shipment.type"), LocalTitle(textKey: "shipment.type"),
LocalRadioButtons( LocalRadioButtons(
values: pickupModel.shipmentTypes, values: pickupModel.shipmentTypes,
@@ -214,16 +190,28 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
_selectedShipmentType = v; _selectedShipmentType = v;
}); });
}), }),
// handlingFeeBox, ...(isLocalDropoff
// shipmentTypeBox, ? [
LocalTitle(textKey: "shipment.location"), LocalTitle(textKey: "shipment.location.dropoff"),
pickupAddressBox, localDropoffAddressBox
LocalTitle(textKey: "shipment.date.time"), ]
pickupDateBox, : []),
fromTimeBox, ...(isCourierDropoff
toTimeBox, ? [
// localDropoffAddress, LocalTitle(textKey: "shipment.courier.dropoff"),
// curierDropoffAddress, curierDropoffAddress
]
: []),
...(isCourierPickup || isLocalPickup
? [
LocalTitle(textKey: "shipment.location"),
pickupAddressBox,
LocalTitle(textKey: "shipment.date.time"),
pickupDateBox,
fromTimeBox,
toTimeBox,
]
: []),
LocalTitle( LocalTitle(
textKey: "boxes.name", textKey: "boxes.name",
trailing: IconButton( trailing: IconButton(
@@ -232,7 +220,7 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
color: primaryColor, color: primaryColor,
), ),
onPressed: () async { onPressed: () async {
Box box = await Navigator.push( Carton box = await Navigator.push(
context, context,
CupertinoPageRoute( CupertinoPageRoute(
builder: (context) => ShipmentBoxEditor()), builder: (context) => ShipmentBoxEditor()),
@@ -252,11 +240,11 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
); );
} }
List<Widget> getBoxList(BuildContext context, List<Box> boxes) { List<Widget> getBoxList(BuildContext context, List<Carton> boxes) {
return boxes.asMap().entries.map((_box) { return boxes.asMap().entries.map((_box) {
return InkWell( return InkWell(
onTap: () async { onTap: () async {
Box box = await Navigator.of(context).push(CupertinoPageRoute( Carton box = await Navigator.of(context).push(CupertinoPageRoute(
builder: (context) => ShipmentBoxEditor(box: _box.value))); builder: (context) => ShipmentBoxEditor(box: _box.value)));
_saveBox(box); _saveBox(box);
}, },
@@ -267,7 +255,7 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
onTap: () => _removeBox(_box.value), onTap: () => _removeBox(_box.value),
child: Padding( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Icon(Icons.remove, color: primaryColor), child: Icon(Icons.remove_circle, color: primaryColor),
), ),
), ),
], ],
@@ -276,24 +264,25 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
}).toList(); }).toList();
} }
_addBox(Box box) { _addBox(Carton box) {
if (box == null) return; if (box == null) return;
box.cartonType = carton_from_shipments;
_shipment.boxes.add(box); _shipment.boxes.add(box);
setState(() {}); setState(() {});
} }
_saveBox(Box box) { _saveBox(Carton box) {
if (box == null) return; if (box == null) return;
setState(() {}); setState(() {});
} }
_removeBox(Box box) { _removeBox(Carton box) {
if (box == null) return; if (box == null) return;
_shipment.boxes.remove(box); _shipment.boxes.remove(box);
setState(() {}); setState(() {});
} }
_create() async { _save() async {
_shipment.shipmentType = this._selectedShipmentType; _shipment.shipmentType = this._selectedShipmentType;
_shipment.pickupDate = dateFormatter.parse(_pickupDate.text); _shipment.pickupDate = dateFormatter.parse(_pickupDate.text);
_shipment.pickupTimeStart = _fromTimeEditingController.text; _shipment.pickupTimeStart = _fromTimeEditingController.text;
@@ -307,9 +296,9 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
if (_isNew) { if (_isNew) {
await shipmentModel.createShipment(_shipment); await shipmentModel.createShipment(_shipment);
} else { } else {
await shipmentModel.createShipment(_shipment); await shipmentModel.updateShipment(_shipment);
} }
Navigator.pop(context); Navigator.pop(context, true);
} catch (e) { } catch (e) {
showMsgDialog(context, "Error", e.toString()); showMsgDialog(context, "Error", e.toString());
} finally { } finally {
@@ -318,4 +307,9 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
}); });
} }
} }
_openCourierWebsite() {
MainModel mainModel = Provider.of<MainModel>(context, listen: false);
launch("${mainModel.setting.courierWebsite}");
}
} }

View File

@@ -1,17 +1,18 @@
import 'package:fcs/domain/constants.dart'; import 'package:fcs/domain/constants.dart';
import 'package:fcs/domain/entities/box.dart'; import 'package:fcs/domain/entities/carton.dart';
import 'package:fcs/domain/entities/shipment.dart'; import 'package:fcs/domain/entities/shipment.dart';
import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/helpers/theme.dart'; import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/box/model/box_model.dart'; import 'package:fcs/pages/carton/model/carton_model.dart';
import 'package:fcs/pages/main/model/main_model.dart'; import 'package:fcs/pages/main/model/main_model.dart';
import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/shipment/model/shipment_model.dart'; import 'package:fcs/pages/shipment/model/shipment_model.dart';
import 'package:fcs/pages/widgets/defalut_delivery_address.dart'; import 'package:fcs/pages/widgets/defalut_delivery_address.dart';
import 'package:fcs/pages/widgets/delivery_address_selection.dart';
import 'package:fcs/pages/widgets/display_text.dart'; import 'package:fcs/pages/widgets/display_text.dart';
import 'package:fcs/pages/widgets/input_date.dart'; import 'package:fcs/pages/widgets/fcs_id_icon.dart';
import 'package:fcs/pages/widgets/input_time.dart'; import 'package:fcs/pages/widgets/local_button.dart';
import 'package:fcs/pages/widgets/local_dropdown.dart'; import 'package:fcs/pages/widgets/local_dropdown.dart';
import 'package:fcs/pages/widgets/local_popup_menu_button.dart';
import 'package:fcs/pages/widgets/local_popupmenu.dart';
import 'package:fcs/pages/widgets/local_radio_buttons.dart'; import 'package:fcs/pages/widgets/local_radio_buttons.dart';
import 'package:fcs/pages/widgets/local_text.dart'; import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/local_title.dart'; import 'package:fcs/pages/widgets/local_title.dart';
@@ -23,8 +24,11 @@ import 'package:flutter_icons/flutter_icons.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';
import 'box_row.dart'; import 'box_row.dart';
import 'shipment_editor.dart';
import 'widgets.dart';
class ShipmentInfo extends StatefulWidget { class ShipmentInfo extends StatefulWidget {
final Shipment shipment; final Shipment shipment;
@@ -38,6 +42,7 @@ class _ShipmentInfoState extends State<ShipmentInfo> {
var dateFormatter = new DateFormat('dd MMM yyyy'); var dateFormatter = new DateFormat('dd MMM yyyy');
final numberFormatter = new NumberFormat("#,###"); final numberFormatter = new NumberFormat("#,###");
MultiImgController multiImgController = MultiImgController(); MultiImgController multiImgController = MultiImgController();
var timeFormatter = new DateFormat('jm');
TextEditingController _addressEditingController = new TextEditingController(); TextEditingController _addressEditingController = new TextEditingController();
TextEditingController _fromTimeEditingController = TextEditingController _fromTimeEditingController =
@@ -59,14 +64,11 @@ class _ShipmentInfoState extends State<ShipmentInfo> {
bool _isLoading = false; bool _isLoading = false;
var now = new DateTime.now(); var now = new DateTime.now();
int _currVal = 1;
String _selectedShipmentType;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_selectedShipmentType = shipment_local_pickup;
_shipment = widget.shipment; _shipment = widget.shipment;
_loadCartons(_shipment.id);
if (widget.shipment != null) { if (widget.shipment != null) {
_addressEditingController.text = _shipment.address; _addressEditingController.text = _shipment.address;
@@ -77,10 +79,17 @@ class _ShipmentInfoState extends State<ShipmentInfo> {
_pickupDate.text = dateFormatter.format(_shipment.pickupDate ?? now); _pickupDate.text = dateFormatter.format(_shipment.pickupDate ?? now);
// _handlingFeeController.text = // _handlingFeeController.text =
// numberFormatter.format(_shipment.handlingFee); // numberFormatter.format(_shipment.handlingFee);
_currVal = _shipment.radioIndex;
} }
} }
_loadCartons(String shipmentID) async {
CartonModel cartonModel = Provider.of<CartonModel>(context, listen: false);
var cartons = await cartonModel.getCartons(shipmentID);
setState(() {
_shipment.boxes = cartons;
});
}
@override @override
void dispose() { void dispose() {
super.dispose(); super.dispose();
@@ -90,70 +99,61 @@ class _ShipmentInfoState extends State<ShipmentInfo> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
MainModel mainModel = Provider.of<MainModel>(context); MainModel mainModel = Provider.of<MainModel>(context);
ShipmentModel pickupModel = Provider.of<ShipmentModel>(context); ShipmentModel pickupModel = Provider.of<ShipmentModel>(context);
bool isLocalPickup = _shipment.shipmentType == shipment_local_pickup;
bool isCourierPickup = _shipment.shipmentType == shipment_courier_pickup;
bool isLocalDropoff = _shipment.shipmentType == shipment_local_dropoff;
bool isCourierDropoff = _shipment.shipmentType == shipment_courier_dropoff;
final fromTimeBox = InputTime( final shipmentNumberBox = getShipmentNumberStatus(context, _shipment);
labelTextKey: 'shipment.from',
iconData: Icons.timer,
controller: _fromTimeEditingController);
final toTimeBox = Container( final fromTimeBox = DisplayText(
width: 150, labelTextKey: 'shipment.from',
child: InputTime( iconData: Icons.timer,
iconData: Icons.timer_off, text: _shipment.pickupTimeStart,
labelTextKey: 'shipment.to', );
controller: _toTimeEditingController)); final toTimeBox = DisplayText(
labelTextKey: 'shipment.to',
iconData: Icons.timer_off,
text: _shipment.pickupTimeEnd,
);
final pickupDateBox = InputDate( final pickupDateBox = DisplayText(
labelTextKey: "shipment.date", labelTextKey: "shipment.date",
iconData: Icons.date_range, iconData: Icons.date_range,
controller: _pickupDate, text: dateFormatter.format(_shipment.pickupDate),
);
final localDropoffAddress = DisplayText(
iconData: Icons.location_on,
labelTextKey: "Local Dropoff Address",
text: mainModel.setting.usaAddress);
final curierDropoffAddress = FloatingActionButton.extended(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onPressed: () {},
icon: Icon(Icons.arrow_right),
label: Text(
'Visit courier websie for nearest drop-off',
style: TextStyle(fontSize: 12),
),
backgroundColor: primaryColor,
); );
var localDropoffAddressBox = Row(children: [
FcsIDIcon(),
Expanded(
child: DisplayText(
text: mainModel.setting.usaAddress,
),
)
]);
final curierDropoffAddress = Padding(
padding: EdgeInsets.all(8),
child: FloatingActionButton.extended(
onPressed: _openCourierWebsite,
icon: Icon(Icons.open_in_new, color: primaryColor),
label: Text(
'Visit courier websie \nfor nearest drop-off',
style: TextStyle(fontSize: 16, color: primaryColor),
),
backgroundColor: Colors.white,
));
final pickupAddressBox = DefaultDeliveryAddress( final pickupAddressBox = DefaultDeliveryAddress(
deliveryAddress: _shipment.pickupAddress, deliveryAddress: _shipment.pickupAddress,
iconData: Icons.location_on, iconData: Icons.location_on,
labelKey: "shipment.location", labelKey: "shipment.location",
onTap: () async {
DeliveryAddress address = await Navigator.push<DeliveryAddress>(
context,
CupertinoPageRoute(
builder: (context) => DeliveryAddressSelection(
deliveryAddress: _shipment.pickupAddress,
)),
);
if (address == null) return;
setState(() {
_shipment.pickupAddress = address;
});
},
); );
var boxModel = Provider.of<BoxModel>(context); var boxModel = Provider.of<CartonModel>(context);
var handlingFeeBox = DisplayText( var handlingFeeBox = DisplayText(
labelTextKey: "shipment.handling.fee", labelTextKey: "shipment.handling.fee",
text: "10", text: "10",
iconData: FontAwesomeIcons.moneyBill); iconData: FontAwesomeIcons.moneyBill);
var shipmentTypeBox = LocalDropdown<String>( final cancelBtn = LocalButton(
callback: (v) { textKey: "btn.cancel",
setState(() { callBack: _cancel,
_selectedShipmentType = v;
});
},
iconData: SimpleLineIcons.direction,
selectedValue: _selectedShipmentType,
values: pickupModel.shipmentTypes,
); );
return LocalProgress( return LocalProgress(
@@ -180,44 +180,55 @@ class _ShipmentInfoState extends State<ShipmentInfo> {
IconButton( IconButton(
icon: Icon(Icons.edit, color: primaryColor), icon: Icon(Icons.edit, color: primaryColor),
onPressed: _edit, onPressed: _edit,
) ),
]), ]),
body: Padding( body: Padding(
padding: const EdgeInsets.all(10.0), padding: const EdgeInsets.all(10.0),
child: ListView( child: ListView(
children: <Widget>[ children: <Widget>[
shipmentNumberBox,
LocalTitle(textKey: "shipment.type"), LocalTitle(textKey: "shipment.type"),
LocalRadioButtons( LocalRadioButtons(
values: pickupModel.shipmentTypes, readOnly: true,
selectedValue: _selectedShipmentType, values: pickupModel.shipmentTypes,
callback: (v) { selectedValue: _shipment.shipmentType,
setState(() { ),
_selectedShipmentType = v;
});
}),
// handlingFeeBox, // handlingFeeBox,
// shipmentTypeBox, // shipmentTypeBox,
LocalTitle(textKey: "shipment.location"), ...(isLocalDropoff
pickupAddressBox, ? [
LocalTitle(textKey: "shipment.date.time"), LocalTitle(textKey: "shipment.location.dropoff"),
pickupDateBox, localDropoffAddressBox
fromTimeBox, ]
toTimeBox, : []),
...(isCourierDropoff
? [
LocalTitle(textKey: "shipment.courier.dropoff"),
curierDropoffAddress
]
: []),
...(isCourierPickup || isLocalPickup
? [
LocalTitle(textKey: "shipment.location"),
pickupAddressBox,
LocalTitle(textKey: "shipment.date.time"),
pickupDateBox,
fromTimeBox,
toTimeBox,
]
: []),
// localDropoffAddress, // localDropoffAddress,
// curierDropoffAddress, // curierDropoffAddress,
LocalTitle( LocalTitle(
textKey: "boxes.name", textKey: "boxes.name",
trailing: IconButton(
icon: Icon(
Icons.add_circle,
color: primaryColor,
),
onPressed: () async {},
),
), ),
// Column( Column(
// children: getBoxList(context, _shipment.boxes), children: getBoxList(context, _shipment.boxes),
// ), ),
_shipment.currentStatus == shipment_pending_status
? cancelBtn
: Container()
], ],
), ),
), ),
@@ -225,24 +236,62 @@ class _ShipmentInfoState extends State<ShipmentInfo> {
); );
} }
List<Widget> getBoxList(BuildContext context, List<Box> boxes) { List<Widget> getBoxList(BuildContext context, List<Carton> boxes) {
if (boxes == null) return [];
return boxes.asMap().entries.map((_box) { return boxes.asMap().entries.map((_box) {
return InkWell( return Row(
onTap: () async {}, children: [
child: Row( Expanded(child: BoxRow(box: _box.value)),
children: [ ],
Expanded(child: BoxRow(box: _box.value)),
InkWell(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Icon(Icons.remove, color: primaryColor),
),
),
],
),
); );
}).toList(); }).toList();
} }
_edit() {} _edit() async {
bool updated = await Navigator.push<bool>(
context,
CupertinoPageRoute(
builder: (context) => ShipmentEditor(
shipment: _shipment,
)),
);
if (updated ?? false) {
ShipmentModel shipmentModel =
Provider.of<ShipmentModel>(context, listen: false);
Shipment s = await shipmentModel.getShipment(_shipment.id);
setState(() {
_shipment = s;
});
await _loadCartons(s.id);
}
}
_cancel() {
showConfirmDialog(context, "shipment.cancel.confirm", () {
_cancelShipment();
});
}
_cancelShipment() async {
setState(() {
_isLoading = true;
});
try {
ShipmentModel shipmentModel =
Provider.of<ShipmentModel>(context, listen: false);
await shipmentModel.cancelShipment(_shipment);
Navigator.pop(context, true);
} catch (e) {
showMsgDialog(context, "Error", e.toString());
} finally {
setState(() {
_isLoading = false;
});
}
}
_openCourierWebsite() {
MainModel mainModel = Provider.of<MainModel>(context, listen: false);
launch("${mainModel.setting.courierWebsite}");
}
} }

View File

@@ -101,14 +101,14 @@ class _ShipmentListState extends State<ShipmentList> {
child: ListView.separated( child: ListView.separated(
controller: _controller, controller: _controller,
separatorBuilder: (context, index) => Divider( separatorBuilder: (context, index) => Divider(
color: Colors.black, color: Colors.grey,
height: 1,
), ),
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
padding: EdgeInsets.only(top: 15),
shrinkWrap: true,
itemCount: shipmentModel.shipments.length, itemCount: shipmentModel.shipments.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return ShipmentListRow( return ShipmentListRow(
key: ValueKey(shipmentModel.shipments[index].id),
pickUp: shipmentModel.shipments[index]); pickUp: shipmentModel.shipments[index]);
}), }),
onRefresh: () => onRefresh: () =>

View File

@@ -1,49 +1,25 @@
import 'package:fcs/domain/entities/shipment.dart'; import 'package:fcs/domain/entities/shipment.dart';
import 'package:fcs/helpers/theme.dart'; import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart'; import 'package:flutter_icons/flutter_icons.dart';
import '../main/util.dart'; import '../main/util.dart';
import 'shipment_editor.dart';
import 'shipment_info.dart'; import 'shipment_info.dart';
class ShipmentListRow extends StatefulWidget { class ShipmentListRow extends StatelessWidget {
final Shipment pickUp; final Shipment pickUp;
const ShipmentListRow({this.pickUp}); const ShipmentListRow({Key key, this.pickUp}) : super(key: key);
@override
_ShipmentListRowState createState() => _ShipmentListRowState();
}
class _ShipmentListRowState extends State<ShipmentListRow> {
final double dotSize = 15.0;
Shipment _pickUp = new Shipment();
@override
void initState() {
super.initState();
// PickUpModel pickUpModel = Provider.of<PickUpModel>(context, listen: false);
if (widget.pickUp != null) {
_pickUp = widget.pickUp;
// pickUpModel.pickups.forEach((b) {
// if (widget.pickUp.id == b.id) {
// _pickUp = b;
// }
// });
}
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return InkWell(
padding: EdgeInsets.only(left: 15, right: 15), onTap: () {
child: InkWell( Navigator.of(context).push(CupertinoPageRoute(
onTap: () { builder: (context) => ShipmentInfo(shipment: pickUp)));
Navigator.of(context).push(CupertinoPageRoute( },
builder: (context) => ShipmentInfo(shipment: _pickUp))); child: Container(
}, padding: EdgeInsets.only(left: 15, right: 15),
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
@@ -64,7 +40,7 @@ class _ShipmentListRowState extends State<ShipmentListRow> {
Padding( Padding(
padding: const EdgeInsets.only(left: 8.0), padding: const EdgeInsets.only(left: 8.0),
child: new Text( child: new Text(
_pickUp.shipmentNumber, pickUp.shipmentNumber,
style: new TextStyle( style: new TextStyle(
fontSize: 15.0, color: Colors.black), fontSize: 15.0, color: Colors.black),
), ),
@@ -72,9 +48,9 @@ class _ShipmentListRowState extends State<ShipmentListRow> {
Padding( Padding(
padding: const EdgeInsets.only(left: 10.0, top: 10), padding: const EdgeInsets.only(left: 10.0, top: 10),
child: new Text( child: new Text(
_pickUp.id == null pickUp.id == null
? '' ? ''
: "Last ${_pickUp.last} days", : "Last ${pickUp.last} days",
style: new TextStyle( style: new TextStyle(
fontSize: 15.0, color: Colors.grey), fontSize: 15.0, color: Colors.grey),
), ),
@@ -90,23 +66,23 @@ class _ShipmentListRowState extends State<ShipmentListRow> {
children: <Widget>[ children: <Widget>[
Padding( Padding(
padding: const EdgeInsets.all(0), padding: const EdgeInsets.all(0),
child: getStatus(_pickUp.currentStatus), child: getStatus(pickUp.currentStatus),
), ),
Padding( Padding(
padding: const EdgeInsets.only(left: 8.0, top: 5, bottom: 5), padding: const EdgeInsets.only(left: 8.0, top: 5, bottom: 5),
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
new Text( new Text(
_pickUp.weight == null pickUp.weight == null
? '' ? ''
: _pickUp.weight.toString() + 'lb - ', : pickUp.weight.toString() + 'lb - ',
style: style:
new TextStyle(fontSize: 15.0, color: Colors.grey), new TextStyle(fontSize: 15.0, color: Colors.grey),
), ),
new Text( new Text(
_pickUp.numberOfPackage == null pickUp.numberOfPackage == null
? "" ? ""
: _pickUp.numberOfPackage.toString() + ' packages', : pickUp.numberOfPackage.toString() + ' packages',
style: style:
new TextStyle(fontSize: 15.0, color: Colors.grey), new TextStyle(fontSize: 15.0, color: Colors.grey),
), ),

View File

@@ -0,0 +1,24 @@
import 'package:fcs/domain/entities/shipment.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:flutter/material.dart';
Widget getShipmentNumberStatus(BuildContext context, Shipment shipment) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
LocalText(
context,
'',
text: shipment.shipmentNumber ?? "",
color: primaryColor,
fontSize: 18,
fontWeight: FontWeight.bold,
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Chip(label: Text(shipment.currentStatus ?? "")),
),
],
);
}

View File

@@ -3,6 +3,7 @@ import 'package:fcs/localization/app_translations.dart';
import 'package:fcs/pages/main/model/language_model.dart'; import 'package:fcs/pages/main/model/language_model.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class InputTime extends StatelessWidget { class InputTime extends StatelessWidget {
@@ -42,18 +43,25 @@ class InputTime extends StatelessWidget {
var initialDate = TimeOfDay.now(); var initialDate = TimeOfDay.now();
if (controller != null) { if (controller != null) {
try { try {
var values = controller.text.split(":"); final format = DateFormat.jm(); //"6:00 AM"
initialDate = TimeOfDay( initialDate =
hour: int.parse(values[0]), minute: int.parse(values[1])); TimeOfDay.fromDateTime(format.parse(controller.text));
// var values = controller.text.split(":");
// initialDate = TimeOfDay(
// hour: int.parse(values[0]), minute: int.parse(values[1]));
} catch (e) {} // ignore error } catch (e) {} // ignore error
} }
var t = await showTimePicker( TimeOfDay t = await showTimePicker(
initialTime: initialDate, initialTime: initialDate,
context: context, context: context,
); );
if (t != null && controller != null) { if (t != null && controller != null) {
controller.text = "${t.hour} : ${t.minute}"; final format = DateFormat.jm(); //"6:00 AM"
final now = new DateTime.now();
final dt =
DateTime(now.year, now.month, now.day, t.hour, t.minute);
controller.text = "${format.format(dt)}";
} }
}, },
controller: controller, controller: controller,

View File

@@ -10,11 +10,13 @@ class LocalPopupMenuButton extends StatefulWidget {
final PopupMenuCallback popupMenuCallback; final PopupMenuCallback popupMenuCallback;
final List<LocalPopupMenu> popmenus; final List<LocalPopupMenu> popmenus;
final bool multiSelect; final bool multiSelect;
final IconData buttonIcon;
const LocalPopupMenuButton( const LocalPopupMenuButton(
{Key key, {Key key,
this.popupMenuCallback, this.popupMenuCallback,
this.popmenus, this.popmenus,
this.buttonIcon,
this.multiSelect = false}) this.multiSelect = false})
: super(key: key); : super(key: key);
@@ -69,7 +71,7 @@ class _LocalPopupMenuButtonState extends State<LocalPopupMenuButton> {
fit: StackFit.expand, fit: StackFit.expand,
children: <Widget>[ children: <Widget>[
Icon( Icon(
Icons.filter_list, widget.buttonIcon ?? Icons.filter_list,
color: primaryColor, color: primaryColor,
), ),
hightlight hightlight

View File

@@ -7,14 +7,22 @@ class LocalRadioButtons<T> extends StatelessWidget {
final IconData iconData; final IconData iconData;
final T selectedValue; final T selectedValue;
final List<T> values; final List<T> values;
final bool readOnly;
final bool hideUnselected;
const LocalRadioButtons( const LocalRadioButtons(
{Key key, this.callback, this.iconData, this.selectedValue, this.values}) {Key key,
this.callback,
this.iconData,
this.selectedValue,
this.values,
this.readOnly = false,
this.hideUnselected = true})
: super(key: key); : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column(children: getChildren()); return Column(children: readOnly ? getReadonlyChildren() : getChildren());
} }
List<Widget> getChildren() { List<Widget> getChildren() {
@@ -38,4 +46,28 @@ class LocalRadioButtons<T> extends StatelessWidget {
))) )))
.toList(); .toList();
} }
List<Widget> getReadonlyChildren() {
return values
.toList()
.map((e) => hideUnselected && e == selectedValue
? SizedBox(
height: 30,
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Icon(
e == selectedValue ? Icons.check : Icons.remove,
color:
e == selectedValue ? primaryColor : Colors.grey,
),
),
Text(e.toString()),
]),
)
: Container())
.toList();
}
} }