Merge remote-tracking branch 'upstream/master'

This commit is contained in:
PhyoThandar
2020-10-13 11:49:44 +06:30
31 changed files with 1108 additions and 1035 deletions

View File

@@ -154,6 +154,7 @@
"profile.devices":"Devices",
"profile.email":"Email",
"profile.privileges":"Privileges",
"profile.default.delivery.address":"Default Delivery Address",
"Profile End ================================================================":"",
"Package Start ================================================================":"",
@@ -179,6 +180,7 @@
"package.rate":"Rate",
"package.weight":"Weight",
"package.amount":"Amount",
"package.delivery.address":"Delivery Address",
"package.popupmenu.active":"Active Packages",
"package.popupmenu.delivered":"Delivered Packages",
"Package End ================================================================":"",
@@ -292,7 +294,7 @@
"Shipment Start ================================================================":"",
"shipment": "Shipments",
"shipment.title": "Shipments",
"shipment.new": "New Shipment",
"shipment.new": "Request Shipment",
"shipment.new.title": "New Shipment",
"shipment.edit.title": "Edit Shipment",
"shipment.type": "Pickup/Drop-off",
@@ -305,6 +307,14 @@
"shipment.from":"From",
"shipment.to":"To",
"shipment.box.delivery":"Delivery Address",
"shipment.handling.fee":"Handling Fee/Courier Fee",
"shipment.box.cargo.type":"Cargo Types",
"shipment.box.dimemsion":"Dimension",
"shipment.box.shipment.weight":"Shipment Weight",
"shipment.box.length":"Length",
"shipment.box.width":"Width",
"shipment.box.height":"Height",
"shipment.box.add":"Add Box",
"Shipment End ================================================================":"",
"Rate Start ================================================================":"",

View File

@@ -154,6 +154,7 @@
"profile.devices":"ဖုန်းမော်ဒယ်အမျိုးအစားများ",
"profile.email":"အီးမေးလ်",
"profile.privileges":"လုပ်ပိုင်ခွင့်များ",
"profile.default.delivery.address":"အမြဲတမ်း ပို့ဆောင်ရမည့်လိပ်စာ",
"Profile End ================================================================":"",
"Package Start ================================================================":"",
@@ -179,6 +180,7 @@
"package.rate":"Rate",
"package.weight":"Weight",
"package.amount":"Amount",
"package.delivery.address":"ပို့ဆောင်ရမည့်လိပ်စာ",
"package.popupmenu.active":"လာမည့် အထုပ်များ",
"package.popupmenu.delivered":"ပို့ပြီးသော အထုပ်များ",
"Package End ================================================================":"",
@@ -305,6 +307,14 @@
"shipment.from":"From",
"shipment.to":"To",
"shipment.box.delivery":"Delivery Address",
"shipment.handling.fee":"Handling Fee/Courier Fee",
"shipment.box.cargo.type":"Cargo Types",
"shipment.box.dimemsion":"Dimension",
"shipment.box.shipment.weight":"Shipment Weight",
"shipment.box.length":"Length",
"shipment.box.width":"Width",
"shipment.box.height":"Height",
"shipment.box.add":"Add Box",
"Shipment End ================================================================":"",
"Rate Start ================================================================":"",
@@ -374,7 +384,7 @@
"delivery_addresses Start ================================================================":"",
"delivery_addresses": "ပို့ဆောင်ရမည့်လိပ်စာများ",
"delivery_address": "ပို့ဆောင်ရမည့်လိပ်စာ",
"delivery_address": "အမြဲတမ်း ပို့ဆောင်ရမည့် လိပ်စာ",
"delivery_address.full_name": "နာမည် အပြည့်အစုံ",
"delivery_address.address_line1": "လိပ်စာ ၁",
"delivery_address.address_line2": "လိပ်စာ ၂",
@@ -385,7 +395,7 @@
"delivery_address.create": "ပြုလုပ်ရန်",
"delivery_address.update": "ပြုပြင်ရန်",
"delivery_address.new_address":"လိပ်စာ အသစ်",
"delivery_address.change_address": "လိပ်စာပြောင်းပါ",
"delivery_address.change_address": "လိပ်စာပြောင်းမည်",
"delivery_address.delete.confirm":"ပို့ဆောင်ရမည့်လိပ်စာကို ဖျက်မလား?",
"delivery_addresses End ================================================================":"",

View File

@@ -41,6 +41,13 @@ class PackageDataProvider {
payload: {"id": package.id}, token: await getToken());
}
Future<void> changeDeliveryAddress(
String packageID, String deliveryID) async {
return await requestAPI("/packages/change_delivery_address", "PUT",
payload: {"package_id": packageID, "deliver_address_id": deliveryID},
token: await getToken());
}
Future<List<Package>> searchPackage(String term) async {
if (term == null || term == '') return List();

View File

@@ -48,4 +48,9 @@ class PackageServiceImp implements PackageService {
Future<void> deleteProcessing(Package package) {
return packageDataProvider.deleteProcessing(package);
}
@override
Future<void> changeDeliveryAddress(String packageID, String deliveryID) {
return packageDataProvider.changeDeliveryAddress(packageID, deliveryID);
}
}

View File

@@ -8,4 +8,5 @@ abstract class PackageService {
Future<void> updateProcessing(Package package);
Future<void> deleteProcessing(Package package);
Future<List<Package>> searchPackage(String term);
Future<void> changeDeliveryAddress(String packageID, String deliveryID);
}

View File

@@ -41,6 +41,19 @@ class Box {
shipmentNumber + "-" + receiverNumber + " #" + boxNumber;
double get price => rate.toDouble() * weight;
double getShipmentWeight(double volumetricRatio) {
if (length == null ||
length <= 0 ||
width == null ||
width <= 0 ||
height == null ||
height <= 0 ||
volumetricRatio == null ||
volumetricRatio <= 0) return 0;
return (length * width * height) / volumetricRatio;
}
List<ShipmentStatus> shipmentHistory;
Box(

View File

@@ -3,4 +3,15 @@ class Cargo {
int price;
int weight;
Cargo({this.type, this.price, this.weight});
@override
String toString() {
return type;
}
@override
bool operator ==(Object other) => other is Cargo && other.type == type;
@override
int get hashCode => type.hashCode;
}

View File

@@ -13,6 +13,7 @@ class Package {
List<String> photoUrls;
List<ShipmentStatus> shipmentHistory;
String desc;
String deliveryAddressID;
String status;
String shipmentNumber;
@@ -70,7 +71,8 @@ class Package {
this.currentStatusDate,
this.photoUrls,
this.desc,
this.isChecked =false});
this.deliveryAddressID,
this.isChecked = false});
factory Package.fromMap(Map<String, dynamic> map, String docID) {
var _currentStatusDate = (map['current_status_date'] as Timestamp);
@@ -92,6 +94,7 @@ class Package {
remark: map['remark'],
desc: map['desc'],
currentStatus: map['current_status'],
deliveryAddressID: map['delivery_address_id'],
currentStatusDate:
_currentStatusDate != null ? _currentStatusDate.toDate() : null,
photoUrls: _photoUrls,

View File

@@ -1,3 +1,6 @@
import 'package:fcs/domain/entities/cargo.dart';
import 'package:fcs/domain/vo/delivery_address.dart';
List<Day> dayLists = [
Day(id: 1, name: 'Sun'),
Day(id: 2, name: 'Mon'),
@@ -23,24 +26,32 @@ class Setting {
final String termsEng;
final String termsMm;
String about;
double volumetricRatio;
List<String> shipmentTypes;
Map<String, int> cargoTypes;
List<Cargo> get cargoTypesList => cargoTypes.entries
.map((e) => Cargo(type: e.key, price: e.value))
.toList();
Cargo get defaultCargoType =>
cargoTypesList.firstWhere((e) => e.type == "General");
Setting({
this.supportBuildNum,
this.usaAddress,
this.mmAddress,
this.usaContactNumber,
this.mmContactNumber,
this.emailAddress,
this.facebookLink,
this.inviteRequired,
this.appUrl,
this.termsEng,
this.termsMm,
this.about,
this.shipmentTypes,
});
Setting(
{this.supportBuildNum,
this.usaAddress,
this.mmAddress,
this.usaContactNumber,
this.mmContactNumber,
this.emailAddress,
this.facebookLink,
this.inviteRequired,
this.appUrl,
this.termsEng,
this.termsMm,
this.about,
this.shipmentTypes,
this.volumetricRatio,
this.cargoTypes});
factory Setting.fromMap(Map<String, dynamic> map) {
return Setting(
@@ -56,7 +67,11 @@ class Setting {
about: map['about'],
termsEng: map['terms_eng'],
termsMm: map['terms_mm'],
volumetricRatio: map['volumetric_ratio'],
shipmentTypes: List.from(map['shipment_types']),
cargoTypes: map['cargo_types'] == null
? []
: Map<String, int>.from(map['cargo_types']),
);
}

View File

@@ -585,8 +585,7 @@ class _BoxEditorState extends State<BoxEditor> {
DeliveryAddress deliveryAddress =
await Navigator.push(
context,
BottomUpPageRoute(DeliveryAddressList(
deliveryAddress: _deliveryAddress)),
BottomUpPageRoute(DeliveryAddressList()),
);
setState(() {
_deliveryAddress = deliveryAddress;

View File

@@ -1,12 +1,14 @@
import 'package:fcs/domain/entities/cargo.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/app_translations.dart';
import 'package:fcs/pages/main/model/main_model.dart';
import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/widgets/input_text.dart';
import 'package:fcs/pages/widgets/local_dropdown.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/progress.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
class CargoTypeEditor extends StatefulWidget {
final Cargo cargo;
@@ -17,7 +19,6 @@ class CargoTypeEditor extends StatefulWidget {
}
class _CargoTypeEditorState extends State<CargoTypeEditor> {
TextEditingController _typeController = new TextEditingController();
TextEditingController _weightController = new TextEditingController();
bool _isLoading = false;
@@ -28,11 +29,17 @@ class _CargoTypeEditorState extends State<CargoTypeEditor> {
super.initState();
if (widget.cargo != null) {
_cargo = widget.cargo;
_typeController.text = _cargo.type;
_weightController.text = _cargo.weight.toString();
} else {
_loadDefalut();
}
}
_loadDefalut() {
MainModel mainModel = Provider.of<MainModel>(context, listen: false);
_cargo = mainModel.setting.defaultCargoType;
}
@override
void dispose() {
super.dispose();
@@ -40,20 +47,33 @@ class _CargoTypeEditorState extends State<CargoTypeEditor> {
@override
Widget build(BuildContext context) {
final typeBox = InputText(
labelTextKey: 'cargo.type',
iconData: Icons.text_format,
controller: _typeController);
MainModel mainModel = Provider.of<MainModel>(context);
List<Cargo> cargos = mainModel.setting.cargoTypesList;
final rateBox = InputText(
labelTextKey: 'cargo.weight',
iconData: FontAwesomeIcons.weightHanging,
textInputType: TextInputType.number,
controller: _weightController);
var cargoTypeBox = LocalDropdown<Cargo>(
callback: (v) {
setState(() {
_cargo = v;
});
},
iconData: Icons.text_format,
selectedValue: _cargo,
values: cargos,
);
final saveBtn = fcsButton(
context,
getLocalString(context, 'box.cargo.save.btn'),
callack: () {},
callack: () {
_cargo.weight = int.parse(_weightController.text, onError: (s) => 0);
Navigator.pop(context, _cargo);
},
);
return LocalProgress(
inAsyncCall: _isLoading,
@@ -76,7 +96,7 @@ class _CargoTypeEditorState extends State<CargoTypeEditor> {
padding: EdgeInsets.all(18),
child: ListView(
children: <Widget>[
typeBox,
cargoTypeBox,
rateBox,
SizedBox(height: 40),
saveBtn,

View File

@@ -32,7 +32,7 @@ class _CustomerEditorState extends State<CustomerEditor> {
Expanded(
child: DisplayText(
text: widget.customer.phoneNumber,
labelTextKey: getLocalString(context, "customer.phone"),
labelTextKey: "customer.phone",
iconData: Icons.phone,
)),
IconButton(
@@ -72,12 +72,12 @@ class _CustomerEditorState extends State<CustomerEditor> {
phoneNumberBox,
DisplayText(
text: widget.customer.fcsID,
labelTextKey: getLocalString(context, "customer.fcs.id"),
labelTextKey: "customer.fcs.id",
icon: FcsIDIcon(),
),
DisplayText(
text: widget.customer.status,
labelTextKey: getLocalString(context, "customer.status"),
labelTextKey: "customer.status",
iconData: Icons.add_alarm,
),
SizedBox(

View File

@@ -12,12 +12,7 @@ import 'model/delivery_address_model.dart';
import 'delivery_address_row.dart';
class DeliveryAddressList extends StatefulWidget {
final DeliveryAddress deliveryAddress;
final bool forSelection;
const DeliveryAddressList(
{Key key, this.deliveryAddress, this.forSelection = false})
: super(key: key);
const DeliveryAddressList({Key key}) : super(key: key);
@override
_DeliveryAddressListState createState() => _DeliveryAddressListState();
}
@@ -46,7 +41,7 @@ class _DeliveryAddressListState extends State<DeliveryAddressList> {
centerTitle: true,
leading: new IconButton(
icon: new Icon(Icons.close),
onPressed: () => Navigator.pop(context, widget.deliveryAddress),
onPressed: () => Navigator.pop(context),
),
backgroundColor: primaryColor,
title: LocalText(
@@ -83,18 +78,15 @@ class _DeliveryAddressListState extends State<DeliveryAddressList> {
_row(BuildContext context, DeliveryAddress deliveryAddress) {
return Row(
children: [
widget.forSelection
? Container()
: InkWell(
onTap: () => _select(deliveryAddress),
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Icon(Icons.check,
color: deliveryAddress.isDefault
? primaryColor
: Colors.black26),
),
),
InkWell(
onTap: () => _select(deliveryAddress),
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Icon(Icons.check,
color:
deliveryAddress.isDefault ? primaryColor : Colors.black26),
),
),
Expanded(
child: DeliveryAddressRow(
key: ValueKey(deliveryAddress.id),
@@ -106,11 +98,6 @@ class _DeliveryAddressListState extends State<DeliveryAddressList> {
}
_edit(BuildContext context, DeliveryAddress deliveryAddress) {
if (widget.forSelection) {
Navigator.pop(context, deliveryAddress);
return;
}
Navigator.push(
context,
BottomUpPageRoute(
@@ -119,10 +106,6 @@ class _DeliveryAddressListState extends State<DeliveryAddressList> {
}
Future<void> _select(DeliveryAddress deliveryAddress) async {
if (widget.forSelection) {
return;
}
if (deliveryAddress.isDefault) {
Navigator.pop(context);
return;

View File

@@ -15,6 +15,9 @@ class DeliveryAddressModel extends BaseModel {
DeliveryAddress get defalutAddress =>
deliveryAddresses.firstWhere((e) => e.isDefault, orElse: () => null);
DeliveryAddress getLocalDeliveryAddress(String id) =>
deliveryAddresses.firstWhere((e) => e.id == id, orElse: () => null);
@override
void privilegeChanged() {
super.privilegeChanged();
@@ -52,6 +55,12 @@ class DeliveryAddressModel extends BaseModel {
}
}
Future<DeliveryAddress> getDeliveryAddress(String id) async {
String path = "/$user_collection/${user.id}/$delivery_address_collection";
var snap = await Firestore.instance.collection(path).document(id).get();
return DeliveryAddress.fromMap(snap.data, snap.documentID);
}
void initUser(user) {
super.initUser(user);
}

View File

@@ -7,6 +7,7 @@ import 'package:fcs/pages/main/model/main_model.dart';
import 'package:fcs/pages/widgets/display_text.dart';
import 'package:fcs/pages/widgets/input_date.dart';
import 'package:fcs/pages/widgets/input_text.dart';
import 'package:fcs/pages/widgets/local_button.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/popupmenu.dart';
import 'package:fcs/pages/widgets/progress.dart';
@@ -71,16 +72,14 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
var languageModel = Provider.of<LanguageModel>(context);
var mainModel = Provider.of<MainModel>(context);
final createBtn = fcsButton(
context,
getLocalString(context, "FCSshipment.create"),
callack: _create,
final createBtn = LocalButton(
textKey: "FCSshipment.create",
callBack: _create,
);
final updateBtn = fcsButton(
context,
getLocalString(context, "FCSshipment.update"),
callack: _update,
final updateBtn = LocalButton(
textKey: "FCSshipment.update",
callBack: _update,
);
return LocalProgress(

View File

@@ -1,6 +1,7 @@
import 'dart:async';
import 'dart:io';
import 'package:fcs/data/services/services.dart';
import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/domain/vo/message.dart';
import 'package:fcs/helpers/pagination.dart';
import 'package:path/path.dart' as Path;
@@ -290,4 +291,10 @@ class PackageModel extends BaseModel {
Future<void> deleteProcessing(Package package) {
return Services.instance.packageService.deleteProcessing(package);
}
Future<void> changeDeliveryAddress(
Package package, DeliveryAddress deliveryAddress) {
return Services.instance.packageService
.changeDeliveryAddress(package.id, deliveryAddress.id);
}
}

View File

@@ -1,6 +1,13 @@
import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/helpers/theme.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/util.dart';
import 'package:fcs/pages/package/model/package_model.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.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/local_text.dart';
import 'package:fcs/pages/widgets/multi_img_controller.dart';
@@ -27,6 +34,7 @@ class PackageInfo extends StatefulWidget {
class _PackageInfoState extends State<PackageInfo> {
var dateFormatter = new DateFormat('dd MMM yyyy');
Package _package;
DeliveryAddress _deliveryAddress;
bool _isLoading = false;
MultiImgController multiImgController = MultiImgController();
@@ -41,6 +49,12 @@ class _PackageInfoState extends State<PackageInfo> {
_package = package;
multiImgController.setImageUrls = package.photoUrls;
});
if (!widget.isSearchResult) {
DeliveryAddressModel deliveryAddressModel =
Provider.of<DeliveryAddressModel>(context, listen: false);
_deliveryAddress = deliveryAddressModel
.getLocalDeliveryAddress(package.deliveryAddressID);
}
}
@override
@@ -50,6 +64,9 @@ class _PackageInfoState extends State<PackageInfo> {
@override
Widget build(BuildContext context) {
String id = Provider.of<MainModel>(context).user.id;
bool owner = _package.userID == id;
final trackingIdBox = DisplayText(
text: _package.trackingID,
labelTextKey: "package.tracking.id",
@@ -85,6 +102,22 @@ class _PackageInfoState extends State<PackageInfo> {
controller: multiImgController,
title: "Receipt File",
);
final deliveryAddressBox = DefaultDeliveryAddress(
deliveryAddress: _deliveryAddress,
labelKey: "package.delivery.address",
onTap: owner
? () async {
DeliveryAddress d = await Navigator.push<DeliveryAddress>(
context,
BottomUpPageRoute(DeliveryAddressSelection(
deliveryAddress: _deliveryAddress,
)),
);
if (d == null) return;
_changeDeliverayAddress(d);
}
: null,
);
return LocalProgress(
inAsyncCall: _isLoading,
@@ -118,6 +151,7 @@ class _PackageInfoState extends State<PackageInfo> {
_package.photoUrls.length == 0 ? Container() : img,
widget.isSearchResult ? Container() : descBox,
remarkBox,
deliveryAddressBox,
StatusTree(
shipmentHistory: _package.shipmentHistory,
currentStatus: _package.currentStatus),
@@ -133,37 +167,29 @@ class _PackageInfoState extends State<PackageInfo> {
);
}
List<TimelineModel> _models() {
if (_package.shipmentHistory == null) return [];
return _package.shipmentHistory
.map((e) => TimelineModel(
Padding(
padding: const EdgeInsets.all(18.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(e.status,
style: TextStyle(
color: e.done ? primaryColor : Colors.grey,
fontSize: 16,
fontWeight: FontWeight.bold)),
Text(dateFormat.format(e.date)),
],
),
),
iconBackground: e.done ? primaryColor : Colors.grey,
icon: Icon(
e.status == "shipped"
? Ionicons.ios_airplane
: e.status == "delivered"
? MaterialCommunityIcons.truck_fast
: e.status == "packed"
? MaterialCommunityIcons.package
: e.status == "processed"
? FontAwesome.dropbox
: MaterialCommunityIcons.inbox_arrow_down,
color: Colors.white,
)))
.toList();
_changeDeliverayAddress(DeliveryAddress deliveryAddress) async {
if (deliveryAddress == null) return;
setState(() {
_isLoading = true;
});
PackageModel packageModel =
Provider.of<PackageModel>(context, listen: false);
DeliveryAddressModel deliveryAddressModel =
Provider.of<DeliveryAddressModel>(context, listen: false);
try {
await packageModel.changeDeliveryAddress(_package, deliveryAddress);
var da =
await deliveryAddressModel.getDeliveryAddress(deliveryAddress.id);
setState(() {
_deliveryAddress = da;
});
} catch (e) {
showMsgDialog(context, "Error", e.toString());
} finally {
setState(() {
_isLoading = false;
});
}
}
}

View File

@@ -12,6 +12,7 @@ import 'package:fcs/pages/profile/profile_currency_edit.dart';
import 'package:fcs/pages/profile/profile_edit.dart';
import 'package:fcs/pages/staff/model/staff_model.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
import 'package:fcs/pages/widgets/defalut_delivery_address.dart';
import 'package:fcs/pages/widgets/display_text.dart';
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
import 'package:fcs/pages/widgets/local_text.dart';
@@ -176,8 +177,14 @@ class _ProfileState extends State<Profile> {
)
],
),
defalutDeliveryAddress(
context, deliveryAddressModel.defalutAddress),
DefaultDeliveryAddress(
labelKey: "profile.default.delivery.address",
deliveryAddress: deliveryAddressModel.defalutAddress,
onTap: () {
Navigator.push(
context, BottomUpPageRoute(DeliveryAddressList()));
},
),
getPrivilegeBox(context),
SizedBox(height: 15),
logoutbutton,
@@ -189,42 +196,6 @@ class _ProfileState extends State<Profile> {
);
}
Widget defalutDeliveryAddress(
BuildContext context, DeliveryAddress deliveryAddress) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: DisplayText(
labelTextKey: "delivery_address",
iconData: MaterialCommunityIcons.truck_fast,
),
),
Chip(
label: InkWell(
onTap: () => Navigator.push(
context,
BottomUpPageRoute(DeliveryAddressList()),
),
child: LocalText(context, "delivery_address.change_address",
color: primaryColor),
))
],
),
Padding(
padding: const EdgeInsets.only(left: 28.0),
child: deliveryAddress == null
? Container()
: DeliveryAddressRow(
key: ValueKey(deliveryAddress.id),
deliveryAddress: deliveryAddress),
),
],
);
}
Widget getPrivilegeBox(BuildContext context) {
User user = Provider.of<MainModel>(context, listen: false).user;
List<Privilege> _privileges =

View File

@@ -0,0 +1,132 @@
import 'package:fcs/domain/entities/box.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class BoxRow extends StatelessWidget {
final Box box;
const BoxRow({Key key, this.box}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.only(left: 10),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Expanded(
child: new Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: new Row(
children: <Widget>[
new Expanded(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
box.shippingAddress.fullName == null
? ''
: box.shippingAddress.fullName,
style: new TextStyle(
fontSize: 15.0,
color: Colors.black,
fontWeight: FontWeight.bold),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
box.shippingAddress.addressLine1 == null
? ''
: box.shippingAddress.addressLine1,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
box.shippingAddress.addressLine2 == null
? ''
: box.shippingAddress.addressLine2,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
box.shippingAddress.city == null
? ''
: box.shippingAddress.city,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
box.shippingAddress.state == null
? ''
: box.shippingAddress.state,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
box.shippingAddress.phoneNumber == null
? ''
: "Phone:${box.shippingAddress.phoneNumber}",
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
],
),
),
],
),
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
"L${box.length}xW${box.weight}xH${box.height}",
style: new TextStyle(fontSize: 15.0, color: Colors.black),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
box.weight == null
? ''
: "Actual Weight:${box.weight.toString()}lb",
style: new TextStyle(fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
box.shipmentWeight == null
? ''
: "Shipment Weight:${box.shipmentWeight.toString()}lb",
style: new TextStyle(fontSize: 14.0, color: Colors.grey),
),
),
],
)
],
),
],
),
);
}
}

View File

@@ -1,328 +0,0 @@
import 'package:fcs/domain/entities/box.dart';
import 'package:fcs/domain/entities/cargo.dart';
import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/app_translations.dart';
import 'package:fcs/pages/delivery_address/delivery_address_list.dart';
import 'package:fcs/pages/delivery_address/delivery_address_row.dart';
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
import 'package:fcs/pages/widgets/display_text.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/my_data_table.dart';
import 'package:fcs/pages/widgets/progress.dart';
import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:provider/provider.dart';
import '../main/util.dart';
class PickupBoxEditor extends StatefulWidget {
final Box box;
PickupBoxEditor({this.box});
@override
_PickupBoxEditorState createState() => _PickupBoxEditorState();
}
class _PickupBoxEditorState extends State<PickupBoxEditor> {
Box _box;
bool _isLoading = false;
bool isNew;
bool isMixBox = false;
DeliveryAddress _deliveryAddress = new DeliveryAddress();
@override
void initState() {
super.initState();
if (widget.box != null) {
_box = widget.box;
_deliveryAddress = _box.shippingAddress;
isNew = false;
} else {
List<Package> packages = [
// PackageModel.packages[0],
// PackageModel.packages[1],
// PackageModel.packages[2]
];
List<Cargo> _cargoTypes = [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
Cargo(type: 'Dangerous Cargo', weight: 30)
];
var shipmentModel =
Provider.of<DeliveryAddressModel>(context, listen: false);
_deliveryAddress = shipmentModel.deliveryAddresses[1];
isNew = true;
_box = Box(
rate: 0,
weight: 75,
width: 0,
height: 0,
length: 0,
packages: packages,
cargoTypes: _cargoTypes,
shipmentWeight: 0);
}
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(Icons.close),
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: primaryColor,
title: Text(AppTranslations.of(context).text("package.edit.title")),
),
body: Card(
child: Column(
children: <Widget>[
Expanded(
child: ListView(
children: [
ExpansionTile(
title: Text(
'Cargo Types',
style: TextStyle(
color: primaryColor, fontWeight: FontWeight.bold),
),
children: [
Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20),
child: TextFormField(
initialValue: _box.weight.toString(),
textAlign: TextAlign.end,
decoration: InputDecoration(
fillColor: Colors.white,
labelText: 'Actual Weight',
filled: true,
icon: Icon(MaterialCommunityIcons.weight,
color: primaryColor),
)),
),
Container(
padding: EdgeInsets.only(top: 10),
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: MyDataTable(
headingRowHeight: 40,
columnSpacing: 120,
columns: [
MyDataColumn(
label: LocalText(
context,
"cargo.type",
color: Colors.grey,
),
),
MyDataColumn(
label: LocalText(
context,
"cargo.weight",
color: Colors.grey,
),
),
],
rows: getCargoRows(context),
),
),
),
Container(
padding: EdgeInsets.only(top: 20),
child: Align(
alignment: Alignment.bottomRight,
child: FloatingActionButton.extended(
icon: Icon(Icons.add),
label: Text("Add Cargo"),
backgroundColor: primaryColor,
onPressed: () {
// Navigator.of(context).push(
// BottomUpPageRoute(PackageAddition()));
},
),
),
),
SizedBox(height: 25),
],
),
ExpansionTile(
title: Text(
'Box Dimension',
style: TextStyle(
color: primaryColor, fontWeight: FontWeight.bold),
),
children: [
Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20),
child: fcsInputReadOnly(
"Shipment Weight", MaterialCommunityIcons.weight,
value: _box.shipmentWeight.toString()),
),
Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20),
child: TextFormField(
initialValue: _box.width.toString(),
textAlign: TextAlign.end,
decoration: InputDecoration(
fillColor: Colors.white,
labelText: 'Width',
filled: true,
icon: Icon(FontAwesome.arrow_circle_right,
color: primaryColor),
)),
),
Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20),
child: TextFormField(
initialValue: _box.height.toString(),
textAlign: TextAlign.end,
decoration: InputDecoration(
fillColor: Colors.white,
labelText: 'Height',
filled: true,
icon: Icon(FontAwesome.arrow_circle_up,
color: primaryColor),
)),
),
Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20),
child: TextFormField(
initialValue: _box.length.toString(),
textAlign: TextAlign.end,
decoration: InputDecoration(
fillColor: Colors.white,
labelText: 'Length',
filled: true,
icon: Icon(FontAwesome.arrow_circle_left,
color: primaryColor),
)),
),
SizedBox(height: 25),
],
),
makeLocation(context, _deliveryAddress),
],
),
),
widget.box == null
? Align(
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Create New Package'),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
)))
: Container(
child: Column(
children: <Widget>[
Align(
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Update Package'),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
))),
],
))
],
),
),
),
);
}
Widget makeLocation(BuildContext context, DeliveryAddress deliveryAddress) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: DisplayText(
labelTextKey: "shipment.box.delivery",
iconData: MaterialCommunityIcons.truck_fast,
),
),
Chip(
label: InkWell(
onTap: () async {
DeliveryAddress d = await Navigator.push<DeliveryAddress>(
context,
BottomUpPageRoute(DeliveryAddressList(
forSelection: true,
)),
);
setState(() {
this._deliveryAddress = d;
});
},
child: LocalText(context, "delivery_address.change_address",
color: primaryColor),
))
],
),
Padding(
padding: const EdgeInsets.only(left: 28.0),
child: deliveryAddress == null
? Container()
: DeliveryAddressRow(
key: ValueKey(deliveryAddress.id),
deliveryAddress: deliveryAddress),
),
],
);
}
List<MyDataRow> getCargoRows(BuildContext context) {
if (_box == null || _box.cargoTypes == null) {
return [];
}
return _box.cargoTypes.map((c) {
return MyDataRow(
onSelectChanged: (bool selected) {},
cells: [
MyDataCell(new Text(
c.type == null ? "" : c.type,
style: textStyle,
)),
MyDataCell(
new Text(c.weight == null ? "0" : c.weight.toString(),
style: textStyle),
),
],
);
}).toList();
}
}

View File

@@ -0,0 +1,336 @@
import 'package:fcs/domain/entities/box.dart';
import 'package:fcs/domain/entities/cargo.dart';
import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/box/cargo_type_editor.dart';
import 'package:fcs/pages/delivery_address/delivery_address_list.dart';
import 'package:fcs/pages/delivery_address/delivery_address_row.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/widgets/bottom_up_page_route.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/input_text.dart';
import 'package:fcs/pages/widgets/local_button.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/my_data_table.dart';
import 'package:fcs/pages/widgets/progress.dart';
import 'package:fcs/pages/widgets/title_with_add_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:provider/provider.dart';
class ShipmentBoxEditor extends StatefulWidget {
final Box box;
ShipmentBoxEditor({this.box});
@override
_ShipmentBoxEditorState createState() => _ShipmentBoxEditorState();
}
class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
TextEditingController _lengthCtl = new TextEditingController();
TextEditingController _widthCtl = new TextEditingController();
TextEditingController _heightCtl = new TextEditingController();
Box _box;
bool _isLoading = false;
bool _isNew;
bool isMixBox = false;
DeliveryAddress _deliveryAddress = new DeliveryAddress();
double volumetricRatio;
double shipmentWeight;
List<Cargo> cargos;
@override
void initState() {
super.initState();
volumetricRatio =
Provider.of<MainModel>(context, listen: false).setting.volumetricRatio;
shipmentWeight = 0;
cargos = [];
if (widget.box != null) {
_box = widget.box;
_deliveryAddress = _box.shippingAddress;
_isNew = false;
} else {
var shipmentModel =
Provider.of<DeliveryAddressModel>(context, listen: false);
_deliveryAddress = shipmentModel.defalutAddress;
_isNew = true;
_box = Box();
}
_lengthCtl.addListener(_calShipmentWeight);
_widthCtl.addListener(_calShipmentWeight);
_heightCtl.addListener(_calShipmentWeight);
}
_calShipmentWeight() {
double l = double.parse(_lengthCtl.text, (s) => 0);
double w = double.parse(_widthCtl.text, (s) => 0);
double h = double.parse(_heightCtl.text, (s) => 0);
setState(() {
shipmentWeight = l * w * h / volumetricRatio;
});
}
@override
Widget build(BuildContext context) {
double iconSize = 32;
final shipmentWeightBox = DisplayText(
labelTextKey: "shipment.box.shipment.weight",
text: shipmentWeight == null ? "" : shipmentWeight.toStringAsFixed(0),
iconData: MaterialCommunityIcons.weight,
);
final lengthBox = InputText(
labelTextKey: "shipment.box.length",
controller: _lengthCtl,
textInputType: TextInputType.number,
iconData: FontAwesome.arrow_circle_right,
);
final widthBox = InputText(
labelTextKey: "shipment.box.width",
controller: _widthCtl,
textInputType: TextInputType.number,
iconData: FontAwesome.arrow_circle_left,
);
final heightBox = InputText(
labelTextKey: "shipment.box.height",
controller: _heightCtl,
textInputType: TextInputType.number,
iconData: FontAwesome.arrow_circle_up,
);
final createBtn = LocalButton(
textKey: "shipment.box.add",
);
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(
Icons.close,
color: primaryColor,
),
onPressed: () => Navigator.of(context).pop(),
),
shadowColor: Colors.transparent,
backgroundColor: Colors.white,
title: LocalText(
context,
_isNew ? "boxes.new" : "box.edit.title",
fontSize: 20,
color: primaryColor,
),
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: ListView(
children: [
TitleWithAddButton(
iconData: MaterialCommunityIcons.briefcase_check,
titleKey: "shipment.box.cargo.type",
onTap: () async {
Cargo cargo = await Navigator.push<Cargo>(
context, BottomUpPageRoute(CargoTypeEditor()));
if (cargo != null) {
setState(() {
cargos.add(cargo);
});
}
}),
MyDataTable(
headingRowHeight: 40,
columns: [
MyDataColumn(
label: LocalText(
context,
"cargo.type",
color: Colors.grey,
),
),
MyDataColumn(
label: LocalText(
context,
"cargo.weight",
color: Colors.grey,
),
),
],
rows: getCargoRows(context),
),
SizedBox(
height: 30,
),
TitleWithAddButton(
titleKey: "shipment.box.dimemsion",
),
shipmentWeightBox,
lengthBox,
widthBox,
heightBox,
DefaultDeliveryAddress(
deliveryAddress: _deliveryAddress,
onTap: () async {
DeliveryAddress d = await Navigator.push<DeliveryAddress>(
context,
BottomUpPageRoute(DeliveryAddressSelection(
deliveryAddress: _deliveryAddress,
)),
);
if (d == null) return;
setState(() {
this._deliveryAddress = d;
});
}),
createBtn
],
),
),
),
);
}
List<TableRow> getRows(BuildContext context) {
if (cargos == null || cargos == null) {
return [];
}
int total = 0;
var rows = cargos.map((c) {
total += c.weight;
return TableRow(
children: [
Text(
c.type == null ? "" : c.type,
style: textStyle,
),
Align(
alignment: Alignment.centerRight,
child: Text(c.weight == null ? "0" : c.weight.toString(),
style: textStyle)),
IconButton(icon: Icon(Icons.remove), onPressed: () => {})
],
);
}).toList();
var totalRow = TableRow(
children: [
Align(
alignment: Alignment.centerRight,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text("Total Weight",
style: TextStyle(
fontWeight: FontWeight.bold,
)),
),
),
Align(
alignment: Alignment.centerRight,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(total.toString(),
style: TextStyle(fontWeight: FontWeight.bold)),
)),
Container(
width: 50,
child:
new Text(" ", style: TextStyle(fontWeight: FontWeight.bold))),
],
);
rows.add(totalRow);
rows.insert(
0,
TableRow(children: [
Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: LocalText(
context,
"cargo.type",
color: Colors.grey,
),
),
),
Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: LocalText(
context,
"cargo.weight",
color: Colors.grey,
),
),
),
Text("")
]));
return rows;
}
List<MyDataRow> getCargoRows(BuildContext context) {
if (cargos == null || cargos == null) {
return [];
}
int total = 0;
var rows = cargos.map((c) {
total += c.weight;
return MyDataRow(
onSelectChanged: (bool selected) {},
cells: [
MyDataCell(new Text(
c.type == null ? "" : c.type,
style: textStyle,
)),
MyDataCell(
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(c.weight == null ? "0" : c.weight.toString(),
style: textStyle),
IconButton(
icon: Icon(
Icons.remove_circle,
color: primaryColor,
),
onPressed: () => {},
)
],
),
),
],
);
}).toList();
var totalRow = MyDataRow(
onSelectChanged: (bool selected) {},
cells: [
MyDataCell(Align(
alignment: Alignment.centerRight,
child: Text("Total Weight",
style: TextStyle(
fontWeight: FontWeight.bold,
)),
)),
MyDataCell(
Padding(
padding: const EdgeInsets.only(right: 45.0),
child: Align(
alignment: Alignment.centerRight,
child: Text(total.toString(),
style: TextStyle(fontWeight: FontWeight.bold))),
),
),
],
);
rows.add(totalRow);
return rows;
}
}

View File

@@ -4,32 +4,29 @@ import 'package:fcs/domain/entities/cargo.dart';
import 'package:fcs/domain/entities/pickup.dart';
import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/app_translations.dart';
import 'package:fcs/pages/box/model/box_model.dart';
import 'package:fcs/pages/delivery_address/delivery_address_list.dart';
import 'package:fcs/pages/delivery_address/delivery_address_row.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/shipment/model/shipment_model.dart';
import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.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/input_date.dart';
import 'package:fcs/pages/widgets/input_text.dart';
import 'package:fcs/pages/widgets/input_time.dart';
import 'package:fcs/pages/widgets/local_dropdown.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/multi_img_controller.dart';
import 'package:fcs/pages/widgets/multi_img_file.dart';
import 'package:fcs/pages/widgets/progress.dart';
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
import 'package:fcs/pages/widgets/title_with_add_button.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:provider/provider.dart';
import 'package:flutter/material.dart';
import 'pickup_box_editor.dart';
import 'box_row.dart';
import 'shipment_box_editor.dart';
class ShipmentEditor extends StatefulWidget {
final Shipment shipment;
@@ -85,12 +82,6 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
_pickupDate.text = dateFormatter.format(now);
_handlingFeeController.text = numberFormatter.format(_pickUp.handlingFee);
_currVal = _pickUp.radioIndex;
var mainModel = Provider.of<MainModel>(context, listen: false);
// _recipientNameEditingController.text = mainModel.recipient.name;
// _recipientPhoneEditingController.text = mainModel.recipient.phoneNumber;
// _recipientAddressEditingController.text =
// mainModel.recipient.shippingAddress;
} else {
_isNew = true;
List<Cargo> _cargoTypes = [
@@ -112,6 +103,9 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
@override
Widget build(BuildContext context) {
MainModel mainModel = Provider.of<MainModel>(context);
ShipmentModel pickupModel = Provider.of<ShipmentModel>(context);
final fromTimeBox = InputTime(
labelTextKey: 'shipment.from',
iconData: Icons.timer,
@@ -120,18 +114,6 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
final toTimeBox = InputTime(
labelTextKey: 'shipment.to', controller: _toTimeEditingController);
final fromTimeBoxReadOnly = fcsInputReadOnly(
'From',
Icons.timer,
controller: _fromTimeEditingController,
);
final toTimeBoxReadOnly = fcsInputReadOnly(
'To',
null,
controller: _toTimeEditingController,
);
final pickupTimeBox = Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
@@ -151,37 +133,66 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
],
);
final pickupTimeReadOnly = Padding(
padding: const EdgeInsets.only(left: 20.0),
child: Row(
children: <Widget>[
SizedBox(height: 5),
Container(
child: fromTimeBoxReadOnly,
width: 120,
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text('-'),
),
Container(
child: toTimeBoxReadOnly,
width: 120,
),
],
),
final shipmentDateBox = InputDate(
labelTextKey: "shipment.date",
iconData: Icons.date_range,
controller: _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 deliveryAddressBox = DefaultDeliveryAddress(
deliveryAddress: _pickupAddress,
labelKey: "shipment.location",
onTap: () async {
DeliveryAddress d = await Navigator.push<DeliveryAddress>(
context,
BottomUpPageRoute(DeliveryAddressSelection(
deliveryAddress: _pickupAddress,
)),
);
if (d == null) return;
setState(() {
this._pickupAddress = d;
});
},
);
MainModel mainModel = Provider.of<MainModel>(context);
var boxModel = Provider.of<BoxModel>(context);
var handlingFeeBox = DisplayText(
labelTextKey: "shipment.handling.fee",
text: "10",
iconData: FontAwesomeIcons.moneyBill);
var shipmentTypeBox = LocalDropdown<String>(
callback: (v) {
setState(() {
selectedPickupType = v;
});
},
iconData: SimpleLineIcons.direction,
selectedValue: selectedPickupType,
values: pickupModel.pickupTypes,
);
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(Icons.close),
icon: new Icon(
Icons.close,
color: primaryColor,
),
onPressed: () => Navigator.of(context).pop(),
),
shadowColor: Colors.transparent,
@@ -197,214 +208,38 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
padding: const EdgeInsets.all(10.0),
child: ListView(
children: <Widget>[
_isNew
? Container()
: Center(
child: Padding(
padding: const EdgeInsets.only(left: 10.0, top: 8),
child: Text(
'#P200304',
style: TextStyle(
color: Colors.black87,
fontSize: 14,
fontWeight: FontWeight.bold),
),
),
),
widget.shipment == null
? Container()
: widget.shipment.isCourier
? Padding(
padding: const EdgeInsets.only(left: 15.0),
child: fcsInputReadOnly("Handling Fee/Courier Fee",
FontAwesomeIcons.moneyBill,
controller: _handlingFeeController),
)
: Padding(
padding: const EdgeInsets.only(left: 15.0),
child: fcsInputReadOnly("Handling Fee/Courier Fee",
FontAwesomeIcons.moneyBill,
controller: _handlingFeeController),
),
makeDropdown(),
makeLocation(context, _pickupAddress),
InputDate(
labelTextKey: "shipment.date",
iconData: Icons.date_range,
controller: _pickupDate,
),
handlingFeeBox,
shipmentTypeBox,
deliveryAddressBox,
shipmentDateBox,
pickupTimeBox,
_currVal == 3
? Container(
child: DeliveryAddressRow(
deliveryAddress: DeliveryAddress(
fullName: 'FCS Office',
addressLine1: '154-19 64th Ave.',
addressLine2: 'Flushing',
city: 'NY',
state: 'NY',
phoneNumber: '+1 (292)215-2247'),
),
)
: _currVal == 4
? Container(
child: Column(
children: <Widget>[
Container(
padding: EdgeInsets.only(
top: 20, bottom: 15, right: 15),
child: Align(
alignment: Alignment.center,
child: Container(
width: 350,
height: 40,
child: 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,
),
),
),
),
],
))
: Container(),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Text(
'Boxes',
style: TextStyle(
color: primaryColor, fontWeight: FontWeight.bold),
),
Spacer(),
IconButton(
onPressed: () {
Navigator.push(
context,
BottomUpPageRoute(PickupBoxEditor()),
);
},
icon: Icon(
Icons.add,
color: primaryColor,
))
],
localDropoffAddress,
curierDropoffAddress,
TitleWithAddButton(
titleKey: "boxes.name",
iconData: MaterialCommunityIcons.package,
onTap: () => Navigator.push(
context,
BottomUpPageRoute(ShipmentBoxEditor()),
),
),
Column(
children: getBoxList(context, boxModel.boxes),
),
mainModel.isCustomer() || _isNew
? Container()
: ExpansionTile(
title: Text('For FCS'),
children: <Widget>[
widget.shipment != null
? widget.shipment.status == 'Pending'
? Padding(
padding: const EdgeInsets.only(left: 20.0),
child: fcsDropDown("Assigned",
MaterialCommunityIcons.worker),
)
: Container()
: Container(),
Padding(
padding: EdgeInsets.only(left: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
padding: EdgeInsets.only(top: 8),
child: Text(
'Attach Courier Shiping Labels',
style: TextStyle(
color: Colors.black, fontSize: 16),
),
),
Container(
padding: EdgeInsets.only(left: 10),
child: MultiImageFile(
enabled: true,
controller: multiImgController,
title: "Receipt File",
)),
],
),
),
],
Align(
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Create shipment'),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
widget.shipment == null
? Align(
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Create shipment'),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
)))
: Container(
child: Column(
children: <Widget>[
widget.shipment.status == 'Confirmed'
? Align(
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Complete Shipment'),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
)))
: Align(
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Confirm Shipment'),
color: primaryColor,
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
))),
Align(
alignment: Alignment.bottomCenter,
child: Center(
child: Container(
width: 250,
child: FlatButton(
child: Text('Cancel Shipment'),
color: Colors.grey[600],
textColor: Colors.white,
onPressed: () {
Navigator.pop(context);
},
),
)))
],
))
)))
],
),
),
@@ -412,242 +247,14 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
);
}
Widget makeDropdown() {
ShipmentModel pickupModel = Provider.of<ShipmentModel>(context);
return Padding(
padding: const EdgeInsets.only(left: 5.0, right: 0),
child: Row(
children: [
Padding(
padding: const EdgeInsets.only(left: 0, right: 10),
child: Icon(SimpleLineIcons.direction, color: primaryColor),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(right: 18.0),
child: LocalText(
context,
"shipment.type",
color: Colors.black54,
fontSize: 16,
),
),
DropdownButton<String>(
isDense: true,
value: selectedPickupType,
style: TextStyle(color: Colors.black, fontSize: 14),
underline: Container(
height: 1,
color: Colors.grey,
),
onChanged: (String newValue) {
setState(() {
selectedPickupType = newValue;
});
},
isExpanded: true,
items: pickupModel.pickupTypes
.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value ?? "",
overflow: TextOverflow.ellipsis,
style: TextStyle(color: primaryColor)),
);
}).toList(),
),
],
),
),
],
),
);
}
Widget makeLocation(BuildContext context, DeliveryAddress deliveryAddress) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: DisplayText(
labelTextKey: "shipment.location",
iconData: MaterialCommunityIcons.truck_fast,
),
),
Chip(
label: InkWell(
onTap: () async {
DeliveryAddress d = await Navigator.push<DeliveryAddress>(
context,
BottomUpPageRoute(DeliveryAddressList(
forSelection: true,
)),
);
setState(() {
this._pickupAddress = d;
});
},
child: LocalText(context, "delivery_address.change_address",
color: primaryColor),
))
],
),
Padding(
padding: const EdgeInsets.only(left: 28.0),
child: deliveryAddress == null
? Container()
: DeliveryAddressRow(
key: ValueKey(deliveryAddress.id),
deliveryAddress: deliveryAddress),
),
],
);
}
List<Widget> getBoxList(BuildContext context, List<Box> boxes) {
List<Box> _boxes = [boxes[0], boxes[1]];
return _boxes.asMap().entries.map((_box) {
DeliveryAddress shippingAddress = _box.value.shippingAddress;
return boxes.asMap().entries.map((_box) {
return InkWell(
onTap: () {
Navigator.of(context)
.push(BottomUpPageRoute(PickupBoxEditor(box: _box.value)));
.push(BottomUpPageRoute(ShipmentBoxEditor(box: _box.value)));
},
child: Container(
padding: EdgeInsets.only(left: 10),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Expanded(
child: new Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: new Row(
children: <Widget>[
new Expanded(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
shippingAddress.fullName == null
? ''
: shippingAddress.fullName,
style: new TextStyle(
fontSize: 15.0,
color: Colors.black,
fontWeight: FontWeight.bold),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
shippingAddress.addressLine1 == null
? ''
: shippingAddress.addressLine1,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
shippingAddress.addressLine2 == null
? ''
: shippingAddress.addressLine2,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
shippingAddress.city == null
? ''
: shippingAddress.city,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
shippingAddress.state == null
? ''
: shippingAddress.state,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
shippingAddress.phoneNumber == null
? ''
: "Phone:${shippingAddress.phoneNumber}",
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
],
),
),
],
),
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
"L${_box.value.length}xW${_box.value.weight}xH${_box.value.height}",
style: new TextStyle(
fontSize: 15.0, color: Colors.black),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
_box.value.weight == null
? ''
: "Actual Weight:${_box.value.weight.toString()}lb",
style:
new TextStyle(fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
_box.value.shipmentWeight == null
? ''
: "Shipment Weight:${_box.value.shipmentWeight.toString()}lb",
style:
new TextStyle(fontSize: 14.0, color: Colors.grey),
),
),
],
)
],
),
_box.key == _boxes.length - 1
? Container()
: Divider(
color: Colors.black,
)
],
),
),
child: BoxRow(box: _box.value),
);
}).toList();
}

View File

@@ -57,16 +57,6 @@ class _ShipmentListState extends State<ShipmentList> {
// onPressed: () => showPlacesSearch(context),
),
],
// bottom: TabBar(
// unselectedLabelColor: Colors.grey,
// tabs: [
// Tab(
// text: "Upcoming",
// ),
// Tab(text: "Completed"),
// Tab(text: "Canceled"),
// ],
// ),
),
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
@@ -87,14 +77,6 @@ class _ShipmentListState extends State<ShipmentList> {
itemBuilder: (BuildContext context, int index) {
return ShipmentListRow(pickUp: pickupModel.pickups[index]);
}),
// body: TabBarView(
// children: [
// //Icon(Icons.directions_car),
// _upComing(),
// _completed(),
// _canceled()
// ],
// )
),
),
);
@@ -103,67 +85,4 @@ class _ShipmentListState extends State<ShipmentList> {
_newPickup() {
Navigator.of(context).push(BottomUpPageRoute(ShipmentEditor()));
}
Widget _upComing() {
var pickupModel = Provider.of<ShipmentModel>(context);
return Column(
children: <Widget>[
Expanded(
child: new ListView.separated(
separatorBuilder: (context, index) => Divider(
color: Colors.black,
),
scrollDirection: Axis.vertical,
padding: EdgeInsets.only(top: 15),
shrinkWrap: true,
itemCount: pickupModel.upcoming.length,
itemBuilder: (BuildContext context, int index) {
return ShipmentListRow(pickUp: pickupModel.upcoming[index]);
}),
),
],
);
}
Widget _completed() {
var pickupModel = Provider.of<ShipmentModel>(context);
return Column(
children: <Widget>[
Expanded(
child: new ListView.separated(
separatorBuilder: (context, index) => Divider(
color: Colors.black,
),
scrollDirection: Axis.vertical,
padding: EdgeInsets.only(top: 15),
shrinkWrap: true,
itemCount: pickupModel.completed.length,
itemBuilder: (BuildContext context, int index) {
return ShipmentListRow(pickUp: pickupModel.completed[index]);
}),
),
],
);
}
Widget _canceled() {
var pickupModel = Provider.of<ShipmentModel>(context);
return Column(
children: <Widget>[
Expanded(
child: new ListView.separated(
separatorBuilder: (context, index) => Divider(
color: Colors.black,
),
scrollDirection: Axis.vertical,
padding: EdgeInsets.only(top: 15),
shrinkWrap: true,
itemCount: pickupModel.canceled.length,
itemBuilder: (BuildContext context, int index) {
return ShipmentListRow(pickUp: pickupModel.canceled[index]);
}),
),
],
);
}
}

View File

@@ -0,0 +1,2 @@
typedef OnTap();
typedef CallBack = void Function();

View File

@@ -0,0 +1,56 @@
import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/delivery_address/delivery_address_row.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'callbacks.dart';
import 'display_text.dart';
import 'local_text.dart';
class DefaultDeliveryAddress extends StatelessWidget {
final DeliveryAddress deliveryAddress;
final String labelKey;
final OnTap onTap;
const DefaultDeliveryAddress(
{Key key, this.deliveryAddress, this.onTap, this.labelKey})
: super(key: key);
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: DisplayText(
labelTextKey: this.labelKey ?? "delivery_address",
iconData: MaterialCommunityIcons.truck_fast,
),
),
onTap == null
? Container()
: GestureDetector(
onTap: () => onTap(),
child: Chip(
label: LocalText(
context, "delivery_address.change_address",
color: primaryColor)),
)
],
),
Padding(
padding: const EdgeInsets.only(left: 28.0),
child: deliveryAddress == null
? Container()
: DeliveryAddressRow(
key: ValueKey(deliveryAddress.id),
deliveryAddress: deliveryAddress),
),
],
);
}
}

View File

@@ -0,0 +1,85 @@
import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/delivery_address/delivery_address_editor.dart';
import 'package:fcs/pages/delivery_address/delivery_address_row.dart';
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class DeliveryAddressSelection extends StatelessWidget {
final DeliveryAddress deliveryAddress;
const DeliveryAddressSelection({Key key, this.deliveryAddress})
: super(key: key);
@override
Widget build(BuildContext context) {
var shipmentModel = Provider.of<DeliveryAddressModel>(context);
return Scaffold(
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(Icons.close),
onPressed: () => Navigator.pop(context),
),
backgroundColor: primaryColor,
title: LocalText(
context,
"delivery_addresses",
fontSize: 20,
color: Colors.white,
),
),
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
Navigator.of(context)
.push(BottomUpPageRoute(DeliveryAddressEditor()));
},
icon: Icon(Icons.add),
label: LocalText(context, "delivery_address.new_address",
color: Colors.white),
backgroundColor: primaryColor,
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: ListView.separated(
separatorBuilder: (c, i) => Divider(
color: primaryColor,
),
itemCount: shipmentModel.deliveryAddresses.length,
itemBuilder: (context, index) {
return _row(context, shipmentModel.deliveryAddresses[index]);
}),
));
}
_row(BuildContext context, DeliveryAddress _deliveryAddress) {
return InkWell(
onTap: () => _select(context, _deliveryAddress),
child: Row(
children: [
Padding(
padding: const EdgeInsets.all(10.0),
child: Icon(Icons.check,
color: deliveryAddress != null &&
_deliveryAddress.id == deliveryAddress.id
? primaryColor
: Colors.black26),
),
Expanded(
child: DeliveryAddressRow(
key: ValueKey(_deliveryAddress.id),
deliveryAddress: _deliveryAddress,
)),
],
),
);
}
_select(BuildContext context, DeliveryAddress _deliveryAddress) {
Navigator.pop(context, _deliveryAddress);
}
}

View File

@@ -2,7 +2,7 @@ import 'package:fcs/helpers/theme.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'multi_img_controller.dart';
import 'callbacks.dart';
class FcsExpansionTile extends StatefulWidget {
final ValueChanged<bool> onExpansionChanged;

View File

@@ -0,0 +1,56 @@
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'callbacks.dart';
class LocalButton extends StatelessWidget {
final CallBack callBack;
final IconData iconData;
final String textKey;
const LocalButton({Key key, this.callBack, this.iconData, this.textKey})
: super(key: key);
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.only(left: 10, right: 10, top: 10),
child: Container(
height: 45.0,
decoration: BoxDecoration(
color: primaryColor,
shape: BoxShape.rectangle,
),
child: ButtonTheme(
minWidth: 900.0,
height: 100.0,
child: FlatButton(
onPressed: callBack == null ? null : () => callBack(),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
iconData == null
? Container()
: Icon(
iconData,
color: Colors.white,
),
SizedBox(
width: 15,
),
LocalText(
context,
textKey,
color: Colors.white,
fontSize: 16,
),
],
),
),
),
),
);
}
}

View File

@@ -0,0 +1,68 @@
import 'package:fcs/helpers/theme.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'local_text.dart';
class LocalDropdown<T> extends StatelessWidget {
final Function(T) callback;
final IconData iconData;
final T selectedValue;
final List<T> values;
const LocalDropdown(
{Key key, this.callback, this.iconData, this.selectedValue, this.values})
: super(key: key);
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(left: 5.0, right: 0),
child: Row(
children: [
Padding(
padding: const EdgeInsets.only(left: 0, right: 10),
child: Icon(iconData, color: primaryColor),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(right: 18.0),
child: LocalText(
context,
"shipment.type",
color: Colors.black54,
fontSize: 16,
),
),
DropdownButton<T>(
isDense: true,
value: selectedValue,
style: TextStyle(color: Colors.black, fontSize: 14),
underline: Container(
height: 1,
color: Colors.grey,
),
onChanged: (T newValue) {
callback(newValue);
},
isExpanded: true,
items: values.map<DropdownMenuItem<T>>((T value) {
return DropdownMenuItem<T>(
value: value,
child: Text(value==null? "":value.toString(),
overflow: TextOverflow.ellipsis,
style: TextStyle(color: primaryColor)),
);
}).toList(),
),
],
),
),
],
),
);
}
}

View File

@@ -1,9 +1,8 @@
import 'dart:io';
import 'callbacks.dart';
import 'display_image_source.dart';
typedef CallBack = void Function();
class MultiImgController {
List<String> imageUrls;
List<DisplayImageSource> addedFiles = [];

View File

@@ -0,0 +1,52 @@
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'callbacks.dart';
class TitleWithAddButton extends StatelessWidget {
final IconData iconData;
final String titleKey;
final OnTap onTap;
const TitleWithAddButton({Key key, this.iconData, this.titleKey, this.onTap})
: super(key: key);
@override
Widget build(BuildContext context) {
return Row(
children: [
Row(
children: [
Padding(
padding: const EdgeInsets.only(right: 15.0),
child: Icon(
this.iconData,
color: primaryColor,
),
),
LocalText(
context,
titleKey,
color: Colors.black54,
fontSize: 20,
)
],
),
Spacer(),
onTap == null
? Container()
: Padding(
padding: const EdgeInsets.only(right: 25.0),
child: IconButton(
onPressed: () => onTap(),
icon: Icon(
Icons.add_circle,
color: primaryColor,
)),
)
],
);
}
}