Merge remote-tracking branch 'upstream/master'

This commit is contained in:
PhyoThandar
2020-10-12 09:19:20 +06:30
70 changed files with 2505 additions and 1755 deletions

View File

@@ -570,7 +570,7 @@ class _BoxEditorState extends State<BoxEditor> {
),
Column(
children: [
DeliveryAddressRow(shippingAddress: _deliveryAddress),
DeliveryAddressRow(deliveryAddress: _deliveryAddress),
Container(
padding: EdgeInsets.only(top: 20, bottom: 15, right: 15),
child: Align(
@@ -659,7 +659,7 @@ class _BoxEditorState extends State<BoxEditor> {
return addresses.asMap().entries.map((s) {
return InkWell(
onTap: () {},
child: DeliveryAddressRow(shippingAddress: s.value, index: s.key),
child: DeliveryAddressRow(deliveryAddress: s.value),
);
}).toList();
}

View File

@@ -4,6 +4,7 @@ import 'package:fcs/pages/box/model/box_model.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/progress.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
@@ -38,7 +39,7 @@ class _BoxListState extends State<BoxList> {
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(Icons.close),
icon: new Icon(CupertinoIcons.back),
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: primaryColor,

View File

@@ -12,6 +12,7 @@ import 'package:fcs/pages/package/package_info.dart';
import 'package:fcs/pages/profile/profile_page.dart';
import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
@@ -45,6 +46,10 @@ class MessageDetail extends StatelessWidget {
return Scaffold(
appBar: AppBar(
leading: new IconButton(
icon: new Icon(CupertinoIcons.back),
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: primaryColor,
elevation: .9,
title: Text(
@@ -170,6 +175,7 @@ class MessageDetail extends StatelessWidget {
PackageModel packageModel =
Provider.of<PackageModel>(context, listen: false);
Package p = await packageModel.getPackage(message.messageID);
if (p == null) return;
Navigator.push<bool>(context, BottomUpPageRoute(PackageInfo(package: p)));
}
if (message.messageType == message_type_profile &&

View File

@@ -2,6 +2,7 @@ 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/widgets/progress.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
@@ -35,7 +36,7 @@ class _DeliverListState extends State<DeliverList> {
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(Icons.close),
icon: new Icon(CupertinoIcons.back),
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: primaryColor,

View File

@@ -23,25 +23,28 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
TextEditingController _address2Controller = new TextEditingController();
TextEditingController _cityController = new TextEditingController();
TextEditingController _stateController = new TextEditingController();
TextEditingController _countryController = new TextEditingController();
TextEditingController _phoneController = new TextEditingController();
DeliveryAddress _deliveryAddress = new DeliveryAddress();
bool _isLoading = false;
bool _isNew = true;
@override
void initState() {
super.initState();
if (widget.deliveryAddress != null) {
_isNew = false;
_deliveryAddress = widget.deliveryAddress;
_nameController.text = _deliveryAddress.fullName;
_address1Controller.text = _deliveryAddress.addressLine1;
_address2Controller.text = _deliveryAddress.addressLine2;
_cityController.text = _deliveryAddress.city;
_stateController.text = _deliveryAddress.state;
_countryController.text = _deliveryAddress.country;
_phoneController.text = _deliveryAddress.phoneNumber;
} else {
_cityController.text = "Yangon";
_stateController.text = "Yangon";
}
}
@@ -52,9 +55,9 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
@override
Widget build(BuildContext context) {
final usaAddress = InputText(
final fullName = InputText(
labelTextKey: 'delivery_address.full_name',
iconData: Icons.text_format,
iconData: MaterialCommunityIcons.account_arrow_left,
controller: _nameController);
final addressLine1 = InputText(
@@ -77,14 +80,10 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
iconData: Entypo.location,
controller: _stateController);
final countryBox = InputText(
labelTextKey: 'delivery_address.country',
iconData: Entypo.flag,
controller: _countryController);
final phoneNumberBox = InputText(
labelTextKey: 'delivery_address.phonenumber',
iconData: Icons.phone,
textInputType: TextInputType.phone,
controller: _phoneController);
final createBtn = fcsButton(
@@ -100,52 +99,43 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
);
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(Icons.close),
onPressed: () => Navigator.of(context).pop(),
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(Icons.close),
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: primaryColor,
title: LocalText(
context,
'delivery_address',
color: Colors.white,
fontSize: 20,
),
actions: [IconButton(icon: Icon(Icons.delete), onPressed: _delete)],
),
backgroundColor: primaryColor,
title: LocalText(
context,
'user.form.shipping_address',
color: Colors.white,
fontSize: 20,
),
),
body: Card(
child: Column(
children: <Widget>[
Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 10.0, right: 10),
child: ListView(children: <Widget>[
usaAddress,
SizedBox(height: 5),
addressLine1,
SizedBox(height: 5),
addressLine2,
SizedBox(height: 5),
cityBox,
SizedBox(height: 5),
regionBox,
SizedBox(height: 5),
countryBox,
SizedBox(height: 5),
phoneNumberBox,
SizedBox(height: 10),
]),
)),
widget.deliveryAddress == null ? createBtn : updateBtn,
body: Padding(
padding: const EdgeInsets.only(left: 10.0, right: 10),
child: ListView(children: <Widget>[
fullName,
SizedBox(height: 5),
phoneNumberBox,
SizedBox(height: 10),
addressLine1,
SizedBox(height: 5),
addressLine2,
SizedBox(height: 5),
cityBox,
SizedBox(height: 5),
regionBox,
SizedBox(height: 5),
_isNew ? createBtn : updateBtn,
SizedBox(height: 10)
],
]),
),
),
),
);
));
}
DeliveryAddress _getPayload() {
@@ -158,7 +148,6 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
deliveryAddress.addressLine2 = _address2Controller.text;
deliveryAddress.city = _cityController.text;
deliveryAddress.state = _stateController.text;
deliveryAddress.country = _countryController.text;
deliveryAddress.phoneNumber = _phoneController.text;
} catch (e) {
showMsgDialog(context, "Error", e.toString()); // shold never happen
@@ -180,10 +169,6 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
await showMsgDialog(context, "Error", "Invalid state!");
return false;
}
if (deliveryAddress.country == null) {
await showMsgDialog(context, "Error", "Invalid country!");
return false;
}
if (deliveryAddress.phoneNumber == null) {
await showMsgDialog(context, "Error", "Invalid phone number!");
return false;
@@ -216,7 +201,6 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
Future<void> _update() async {
DeliveryAddress deliveryAddress = _getPayload();
print('deliveryAddress => ${deliveryAddress.country}');
bool valid = await _validate(deliveryAddress);
if (!valid) {
return;
@@ -237,4 +221,26 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
});
}
}
_delete() {
showConfirmDialog(context, "delivery_address.delete.confirm", _deleteDA);
}
_deleteDA() async {
setState(() {
_isLoading = true;
});
try {
DeliveryAddressModel deliveryAddressModel =
Provider.of<DeliveryAddressModel>(context, listen: false);
await deliveryAddressModel.deleteDeliveryAddress(_deliveryAddress);
Navigator.pop(context);
} catch (e) {
showMsgDialog(context, "Error", e.toString());
} finally {
setState(() {
_isLoading = false;
});
}
}
}

View File

@@ -13,8 +13,11 @@ import 'delivery_address_row.dart';
class DeliveryAddressList extends StatefulWidget {
final DeliveryAddress deliveryAddress;
final bool forSelection;
const DeliveryAddressList({Key key, this.deliveryAddress}) : super(key: key);
const DeliveryAddressList(
{Key key, this.deliveryAddress, this.forSelection = false})
: super(key: key);
@override
_DeliveryAddressListState createState() => _DeliveryAddressListState();
}
@@ -53,53 +56,91 @@ class _DeliveryAddressListState extends State<DeliveryAddressList> {
color: Colors.white,
),
),
body: Column(
children: <Widget>[
Expanded(
child: Column(
children:
getAddressList(context, shipmentModel.deliveryAddresses),
),
),
Container(
padding: EdgeInsets.only(top: 20, bottom: 15, right: 15),
child: Align(
alignment: Alignment.bottomRight,
child: Container(
width: 130,
height: 40,
child: FloatingActionButton.extended(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onPressed: () {
Navigator.push(
context,
BottomUpPageRoute(DeliveryAddressEditor()),
);
},
icon: Icon(Icons.add),
label: Text(
getLocalString(context, 'delivery_address.new_address'),
style: TextStyle(fontSize: 12),
),
backgroundColor: primaryColor,
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]);
}),
)),
);
}
List<Widget> getAddressList(
BuildContext context, List<DeliveryAddress> addresses) {
return addresses.asMap().entries.map((s) {
return InkWell(
onTap: () {
// Navigator.pop(context, s.value);
},
child: DeliveryAddressRow(shippingAddress: s.value, index: s.key),
);
}).toList();
_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),
),
),
Expanded(
child: DeliveryAddressRow(
key: ValueKey(deliveryAddress.id),
deliveryAddress: deliveryAddress,
selectionCallback: (d) => _edit(context, deliveryAddress)),
),
],
);
}
_edit(BuildContext context, DeliveryAddress deliveryAddress) {
if (widget.forSelection) {
Navigator.pop(context, deliveryAddress);
return;
}
Navigator.push(
context,
BottomUpPageRoute(
DeliveryAddressEditor(deliveryAddress: deliveryAddress)),
);
}
Future<void> _select(DeliveryAddress deliveryAddress) async {
if (widget.forSelection) {
return;
}
if (deliveryAddress.isDefault) {
Navigator.pop(context);
return;
}
setState(() {
_isLoading = true;
});
var deliveryAddressModel =
Provider.of<DeliveryAddressModel>(context, listen: false);
try {
await deliveryAddressModel.selectDefalutDeliveryAddress(deliveryAddress);
Navigator.pop(context);
} catch (e) {
showMsgDialog(context, "Error", e.toString());
} finally {
setState(() {
_isLoading = false;
});
}
}
}

View File

@@ -1,146 +1,78 @@
import 'package:fcs/domain/vo/delivery_address.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/helpers/theme.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'delivery_address_editor.dart';
typedef SelectionCallback(DeliveryAddress deliveryAddress);
class DeliveryAddressRow extends StatelessWidget {
final DeliveryAddress shippingAddress;
final int index;
const DeliveryAddressRow({Key key, this.shippingAddress, this.index})
final DeliveryAddress deliveryAddress;
final SelectionCallback selectionCallback;
const DeliveryAddressRow(
{Key key, this.deliveryAddress, this.selectionCallback})
: super(key: key);
@override
Widget build(BuildContext context) {
var deliveryAddressModel = Provider.of<DeliveryAddressModel>(context);
return Container(
padding: EdgeInsets.only(left: 10, right: 10),
child: Column(
return InkWell(
onTap: selectionCallback == null
? null
: () => this.selectionCallback(deliveryAddress),
child: Row(
children: <Widget>[
Row(
children: <Widget>[
Expanded(
child: new Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: Row(
children: <Widget>[
InkWell(
onTap: () {
Navigator.pop(context, shippingAddress);
},
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.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.country == null
? ''
: shippingAddress.country,
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),
),
),
],
),
),
],
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
line(context, deliveryAddress.fullName,
iconData: MaterialCommunityIcons.account_arrow_left,
color: primaryColor,
fontSize: 16),
line(context, deliveryAddress.phoneNumber,
iconData: Icons.phone, color: primaryColor, fontSize: 16),
SizedBox(
height: 5,
),
),
IconButton(
padding: EdgeInsets.only(right: 30),
icon: Icon(Icons.edit, color: Colors.black45),
onPressed: () {
Navigator.push(
context,
BottomUpPageRoute(DeliveryAddressEditor(
deliveryAddress: shippingAddress)),
);
}),
IconButton(
padding: EdgeInsets.only(right: 30),
icon: Icon(Icons.delete, color: Colors.black45),
onPressed: () async {
await deliveryAddressModel
.deleteDeliveryAddress(shippingAddress);
})
],
line(context, deliveryAddress.addressLine1,
iconData: Icons.location_on),
line(
context,
deliveryAddress.addressLine2,
),
line(
context,
deliveryAddress.city,
),
line(context, deliveryAddress.state),
],
),
),
index == null
? Container()
: index == deliveryAddressModel.deliveryAddresses.length - 1
? Container()
: Divider(color: Colors.black)
],
),
);
}
Widget line(BuildContext context, String text,
{IconData iconData, Color color, double fontSize}) {
return Row(
children: [
iconData == null
? SizedBox(width: 40)
: Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8),
child: Icon(iconData, color: Colors.black38),
),
Flexible(
child: TextLocalStyle(
context,
text ?? "",
fontSize: fontSize ?? 14,
color: color,
),
),
],
);
}
}

View File

@@ -12,12 +12,21 @@ class DeliveryAddressModel extends BaseModel {
StreamSubscription<QuerySnapshot> listener;
DeliveryAddress get defalutAddress =>
deliveryAddresses.firstWhere((e) => e.isDefault, orElse: () => null);
@override
void privilegeChanged() {
super.privilegeChanged();
_loadDeliveryAddresses();
}
@override
logout() async {
if (listener != null) await listener.cancel();
deliveryAddresses = [];
}
Future<void> _loadDeliveryAddresses() async {
if (user == null) return;
String path = "$delivery_address_collection/";
@@ -61,4 +70,9 @@ class DeliveryAddressModel extends BaseModel {
return Services.instance.deliveryAddressService
.deleteDeliveryAddress(deliveryAddress);
}
Future<void> selectDefalutDeliveryAddress(DeliveryAddress deliveryAddress) {
return Services.instance.deliveryAddressService
.selectDefalutDeliveryAddress(deliveryAddress);
}
}

View File

@@ -4,6 +4,7 @@ import 'package:fcs/pages/discount/model/discount_model.dart';
import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
import 'package:fcs/pages/widgets/progress.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
@@ -29,7 +30,7 @@ class _DiscountListState extends State<DiscountList> {
AppTranslations.of(context).text("discount.title"),
),
leading: new IconButton(
icon: new Icon(Icons.close),
icon: new Icon(CupertinoIcons.back),
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: primaryColor,

View File

@@ -131,7 +131,9 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: primaryColor)),
fillColor: Colors.white,
labelStyle: languageModel.isEng ? labelStyle : labelStyleMM,
labelStyle: languageModel.isEng
? newLabelStyle(color: Colors.black54, fontSize: 20)
: newLabelStyleMM(color: Colors.black54, fontSize: 20),
labelText: AppTranslations.of(context)
.text('FCSshipment.shipment_type'),
icon: Icon(Ionicons.ios_airplane, color: primaryColor)),

View File

@@ -20,7 +20,7 @@ class FcsShipmentModel extends BaseModel {
}
Future<void> _loadFcsShipments() async {
if (user == null) return;
if (user == null || !user.hasFcsShipments()) return;
String path = "/$fcs_shipment_collection/";
if (listener != null) listener.cancel();
fcsShipments = [];
@@ -49,6 +49,7 @@ class FcsShipmentModel extends BaseModel {
@override
logout() async {
if (listener != null) await listener.cancel();
fcsShipments = [];
}

View File

@@ -8,6 +8,7 @@ import 'package:fcs/pages/user_search/user_serach.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/progress.dart';
import 'package:flutter/cupertino.dart';
import 'package:provider/provider.dart';
import 'package:flutter/material.dart';
@@ -45,7 +46,7 @@ class _InvoiceListState extends State<InvoiceList> {
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(Icons.close),
icon: new Icon(CupertinoIcons.back),
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: primaryColor,

View File

@@ -2,7 +2,9 @@ import 'dart:async';
import 'dart:io';
import 'package:fcs/data/services/services.dart';
import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/domain/entities/user.dart';
import 'package:fcs/helpers/shared_pref.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/transalation.dart';
import 'package:fcs/pages/box/box_list.dart';
@@ -17,23 +19,27 @@ import 'package:fcs/pages/fcs_shipment/fcs_shipment_list.dart';
import 'package:fcs/pages/invoice/invoce_list.dart';
import 'package:fcs/pages/main/model/language_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/package/package_info.dart';
import 'package:fcs/pages/package/package_list.dart';
import 'package:fcs/pages/processing/processing_list.dart';
import 'package:fcs/pages/rates/shipment_rates.dart';
import 'package:fcs/pages/receiving/receiving_list.dart';
import 'package:fcs/pages/shipment/shipment_list.dart';
import 'package:fcs/pages/staff/staff_list.dart';
import 'package:fcs/pages/widgets/task_button.dart';
import 'package:fcs/pages/widgets/badge.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
import 'package:fcs/pages/widgets/bottom_widgets.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/progress.dart';
import 'package:fcs/pages/widgets/right_left_page_rout.dart';
import 'package:fcs/pages/widgets/task_button.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:intl/intl.dart';
import 'package:logging/logging.dart';
import 'package:provider/provider.dart';
@@ -52,10 +58,12 @@ class HomePage extends StatefulWidget {
class _HomePageState extends State<HomePage> {
final log = Logger('_HomePageState');
bool login = false;
bool customer = true;
bool _isLoading = false;
List<bool> isSelected = [true, false];
static FlutterLocalNotificationsPlugin _flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
TextEditingController _searchCtl = TextEditingController();
List<bool> isFcs = [false];
@override
void initState() {
@@ -73,6 +81,18 @@ class _HomePageState extends State<HomePage> {
mainModel.setMessaginToken = token;
});
_initLocalNotifications();
_loadStaffMode(mainModel.isCustomer());
}
_loadStaffMode(bool isCustomer) async {
bool staffMode = await SharedPref.getStaffMode();
setState(() {
if (isCustomer) {
isFcs[0] = false;
} else {
isFcs[0] = staffMode ?? false;
}
});
}
String notiUserID, notiUserName;
@@ -189,7 +209,6 @@ class _HomePageState extends State<HomePage> {
if (user == null) {
return Container();
}
customer = Provider.of<MainModel>(context).isCustomer();
login = Provider.of<MainModel>(context).isLogin();
LanguageModel languageModel = Provider.of<LanguageModel>(context);
@@ -204,25 +223,36 @@ class _HomePageState extends State<HomePage> {
icon: Octicons.package,
btnCallback: () => Navigator.of(context).push<void>(
CupertinoPageRoute(builder: (context) => PackageList())));
final packagesBtnFcs = TaskButton("package.btn.name",
icon: Octicons.package,
btnCallback: () => Navigator.of(context).push<void>(CupertinoPageRoute(
builder: (context) => PackageList(
onlyFcs: true,
))));
final receivingBtn = TaskButton("receiving.title",
icon: Octicons.package,
icon: MaterialCommunityIcons.inbox_arrow_down,
btnCallback: () => Navigator.of(context).push<void>(
CupertinoPageRoute(builder: (context) => ReceivingList())));
final processingBtn = TaskButton("processing.title",
icon: Octicons.package,
icon: FontAwesome.dropbox,
btnCallback: () => Navigator.of(context).push<void>(
CupertinoPageRoute(builder: (context) => ProcessingList())));
final boxesBtn = TaskButton("boxes.name",
final cartonBtn = TaskButton("boxes.name",
icon: MaterialCommunityIcons.package,
btnCallback: () =>
Navigator.of(context).push(BottomUpPageRoute(BoxList())));
btnCallback: () => Navigator.of(context)
.push<void>(CupertinoPageRoute(builder: (context) => BoxList())));
final pickUpBtn = TaskButton("shipment",
final shipmentBtn = TaskButton("shipment",
icon: SimpleLineIcons.direction,
btnCallback: () =>
Navigator.of(context).push(BottomUpPageRoute(ShipmentList())));
btnCallback: () => Navigator.of(context)
.push(CupertinoPageRoute(builder: (context) => ShipmentList())));
final shipmentBtnFcs = TaskButton("shipment",
icon: SimpleLineIcons.direction,
btnCallback: () => Navigator.of(context)
.push(CupertinoPageRoute(builder: (context) => ShipmentList())));
final shipmentCostBtn = TaskButton("rate",
icon: FontAwesomeIcons.calculator,
@@ -231,21 +261,19 @@ class _HomePageState extends State<HomePage> {
final fcsShipmentBtn = TaskButton("FCSshipment.title",
icon: Ionicons.ios_airplane,
btnCallback: () => Navigator.of(context).push<void>(CupertinoPageRoute(
btnCallback: () => Navigator.of(context).push(CupertinoPageRoute(
builder: (context) => FcsShipmentList(),
)));
final notiBtnOrg =
TaskButton("message.btn", icon: Icons.message, btnCallback: () {
MessageModel messageModel =
Provider.of<MessageModel>(context, listen: false);
messageModel.initQuery(user.id);
Navigator.push(
context,
BottomUpPageRoute(MessageDetail(
messageModel: messageModel,
)),
).then((value) {
Navigator.of(context)
.push(CupertinoPageRoute(
builder: (context) => MessageDetail(messageModel: messageModel),
))
.then((value) {
if (user.userUnseenCount > 0) {
messageModel.seenMessages(user.id, true);
}
@@ -272,128 +300,205 @@ class _HomePageState extends State<HomePage> {
final invoicesBtn = TaskButton("invoices.btn",
icon: FontAwesomeIcons.fileInvoice,
btnCallback: () =>
Navigator.of(context).push(BottomUpPageRoute(InvoiceList())));
btnCallback: () => Navigator.of(context).push<void>(
CupertinoPageRoute(builder: (context) => InvoiceList())));
final invoicesBtnFcs = TaskButton("invoices.btn",
icon: FontAwesomeIcons.fileInvoice,
btnCallback: () => Navigator.of(context).push<void>(
CupertinoPageRoute(builder: (context) => InvoiceList())));
final discountBtn = TaskButton("discount.btn",
icon: Entypo.price_ribbon,
btnCallback: () =>
Navigator.of(context).push(BottomUpPageRoute(DiscountList())));
btnCallback: () => Navigator.of(context).push<void>(
CupertinoPageRoute(builder: (context) => DiscountList())));
final deliveryBtn = TaskButton("delivery.title",
icon: MaterialCommunityIcons.truck_fast,
btnCallback: () =>
Navigator.of(context).push(BottomUpPageRoute(DeliverList())));
btnCallback: () => Navigator.of(context).push<void>(
CupertinoPageRoute(builder: (context) => DeliverList())));
List<Widget> widgets = [];
if (user != null) {
// true ? widgets.add(pickUpBtn) : "";
!customer ? widgets.add(fcsShipmentBtn) : "";
customer ? widgets.add(notiBtn) : "";
user.hasStaffs() ? widgets.add(staffBtn) : "";
widgets.add(shipmentCostBtn);
user.hasPackages() ? widgets.add(packagesBtn) : "";
user.hasPackages() ? widgets.add(receivingBtn) : "";
user.hasPackages() ? widgets.add(processingBtn) : "";
true ? widgets.add(boxesBtn) : "";
true ? widgets.add(deliveryBtn) : "";
user.hasCustomers() ? widgets.add(customersBtn) : "";
true ? widgets.add(invoicesBtn) : "";
// true ? widgets.add(discountBtn) : "";
}
widgets.add(notiBtn);
widgets.add(packagesBtn);
widgets.add(shipmentBtn);
widgets.add(invoicesBtn);
widgets.add(faqBtn);
return OfflineRedirect(
child: FlavorBanner(
child: Scaffold(
appBar: AppBar(
elevation: 0,
backgroundColor: primaryColor,
title: ClipRRect(
child: Image.asset("assets/logo.jpg", height: 40),
borderRadius: new BorderRadius.circular(30.0),
),
actions: login
? <Widget>[
ToggleButtons(
children: <Widget>[
Image.asset(
'icons/flags/png/us.png',
package: 'country_icons',
fit: BoxFit.fitWidth,
width: 25,
),
Image.asset(
'icons/flags/png/mm.png',
package: 'country_icons',
fit: BoxFit.fitWidth,
width: 25,
)
],
onPressed: _langChange,
isSelected: languageModel.currentState,
selectedBorderColor: Colors.white24,
),
IconButton(
onPressed: () {
Navigator.of(context)
.push(RightLeftPageRoute(Profile()));
},
iconSize: 30,
icon: Icon(Icons.account_circle),
),
]
: <Widget>[
ToggleButtons(
children: <Widget>[
Image.asset(
'icons/flags/png/us.png',
package: 'country_icons',
fit: BoxFit.fitWidth,
width: 25,
),
Image.asset(
'icons/flags/png/mm.png',
package: 'country_icons',
fit: BoxFit.fitWidth,
width: 25,
)
],
onPressed: _langChange,
isSelected: languageModel.currentState,
),
FlatButton(
onPressed: () {
Navigator.of(context)
.push(BottomUpPageRoute(SigninPage()));
},
child: Text(
"Sign In",
style: siginButtonStyle,
),
widgets.add(shipmentCostBtn);
List<Widget> widgetsFcs = [];
if (user.hasPackages()) widgetsFcs.add(packagesBtnFcs);
if (user.hasShipment()) widgetsFcs.add(shipmentBtnFcs);
if (user.hasInvoices()) widgetsFcs.add(invoicesBtnFcs);
if (user.hasFcsShipments()) widgetsFcs.add(fcsShipmentBtn);
if (user.hasReceiving()) widgetsFcs.add(receivingBtn);
if (user.hasProcessing()) widgetsFcs.add(processingBtn);
if (user.hasCarton()) widgetsFcs.add(cartonBtn);
if (user.hasDeliveries()) widgetsFcs.add(deliveryBtn);
if (user.hasCustomers()) widgetsFcs.add(customersBtn);
if (user.hasAdmin()) widgetsFcs.add(discountBtn);
if (user.hasStaffs()) widgetsFcs.add(staffBtn);
final fcsToggle = ToggleButtons(
selectedColor: Colors.white,
color: Colors.blue,
children: <Widget>[
Icon(MaterialCommunityIcons.worker),
],
onPressed: (i) => this.setState(() {
isFcs[0] = !isFcs[0];
SharedPref.saveStaffMode(isFcs[0]);
}),
isSelected: isFcs,
selectedBorderColor: Colors.white24,
);
final langToggle = ToggleButtons(
children: <Widget>[
Image.asset(
'icons/flags/png/us.png',
package: 'country_icons',
fit: BoxFit.fitWidth,
width: 25,
),
Image.asset(
'icons/flags/png/mm.png',
package: 'country_icons',
fit: BoxFit.fitWidth,
width: 25,
)
],
onPressed: _langChange,
isSelected: languageModel.currentState,
selectedBorderColor: Colors.white24,
);
final signinBtn = FlatButton(
onPressed: () {
Navigator.of(context).push(BottomUpPageRoute(SigninPage()));
},
child: Text(
"Sign In",
style: siginButtonStyle,
),
);
final profileBtn = IconButton(
onPressed: () {
Navigator.of(context).push(RightLeftPageRoute(Profile()));
},
iconSize: 30,
icon: Icon(Icons.account_circle),
);
var searchInput = Row(children: [
Expanded(
child: Padding(
padding: const EdgeInsets.only(bottom: 3, left: 5, right: 5, top: 3),
child: Theme(
data: new ThemeData(
primaryColor: primaryColor,
primaryColorDark: primaryColor,
),
child: TextField(
style: TextStyle(color: Colors.white),
controller: _searchCtl,
scrollPadding: EdgeInsets.all(0),
decoration: new InputDecoration(
enabledBorder: const OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(30)),
borderSide:
const BorderSide(color: Colors.white, width: 1.5),
),
focusedBorder: const OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(30)),
borderSide:
const BorderSide(color: Colors.white, width: 1.5),
),
contentPadding: EdgeInsets.only(top: 1, bottom: 1),
isDense: true,
hintText: getLocalString(context, "home.search"),
hintStyle: languageModel.isEng
? newLabelStyle(color: Colors.white60)
: newLabelStyleMM(color: Colors.white60),
prefixIcon: const Icon(
Icons.search,
color: Colors.grey,
),
suffixIcon: InkWell(
onTap: () => {_searchCtl.clear()},
child: const Icon(
Icons.close,
color: Colors.grey,
),
),
suffixStyle: const TextStyle(color: primaryColor)),
),
),
),
),
InkWell(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: LocalText(
context,
"home.search.btn",
color: Colors.white,
),
),
onTap: _lookup,
)
]);
widgets.insert(0, searchInput);
return LocalProgress(
inAsyncCall: _isLoading,
child: OfflineRedirect(
child: FlavorBanner(
child: Scaffold(
appBar: AppBar(
elevation: 0,
backgroundColor: primaryColor,
title: ClipRRect(
child: Image.asset("assets/logo.jpg", height: 40),
borderRadius: new BorderRadius.circular(30.0),
),
actions: login
? user.isCustomer()
? <Widget>[
langToggle,
profileBtn,
]
: <Widget>[
fcsToggle,
langToggle,
profileBtn,
]
: <Widget>[
langToggle,
signinBtn,
]),
body: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Color(0xd0272262),
Color(0xfa272262),
],
),
),
child: ListView(
children: <Widget>[
Column(children: [
Wrap(
alignment: WrapAlignment.center,
children: isFcs[0] ? widgetsFcs : widgets,
),
]),
body: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Color(0xd0272262),
Color(0xfa272262),
SizedBox(height: 50),
BottomWidgets(),
],
),
),
child: ListView(
children: <Widget>[
Column(children: [
Wrap(
alignment: WrapAlignment.center,
children: widgets,
),
]),
BottomWidgets(),
],
))),
))),
),
),
);
}
@@ -408,4 +513,34 @@ class _HomePageState extends State<HomePage> {
isSelected[index] = !isSelected[index];
});
}
_lookup() async {
setState(() {
_isLoading = true;
});
try {
String term = _searchCtl.text;
if (term == null || term.trim() == "") return;
var packageModel = Provider.of<PackageModel>(context, listen: false);
Package package = await packageModel.lookupPackage(term);
if (package == null) {
showMsgDialog(context, "Not found", "Tracking ID - '$term' not found!");
return;
}
Navigator.push(
context,
BottomUpPageRoute(PackageInfo(
package: package,
isSearchResult: true,
)),
);
} catch (e) {
showMsgDialog(context, "Error", e.toString());
} finally {
setState(() {
_isLoading = false;
});
}
}
}

View File

@@ -162,8 +162,13 @@ class MainModel extends ChangeNotifier {
notifyListeners();
}
Future<void> updateProfile(String newUserName) async {
await Services.instance.authService.updateProfile(newUserName);
Future<void> updateProfileName(String newUserName) async {
await Services.instance.authService.updateProfileName(newUserName);
notifyListeners();
}
Future<void> updatePreferredCurrency(String currency) async {
await Services.instance.authService.updatePreferredCurrency(currency);
notifyListeners();
}
}

View File

@@ -1,6 +1,8 @@
import 'dart:async';
import 'dart:io';
import 'package:fcs/data/services/services.dart';
import 'package:fcs/domain/vo/message.dart';
import 'package:fcs/helpers/pagination.dart';
import 'package:path/path.dart' as Path;
import 'package:cloud_firestore/cloud_firestore.dart';
@@ -15,37 +17,97 @@ class PackageModel extends BaseModel {
final log = Logger('PackageModel');
StreamSubscription<QuerySnapshot> listener;
StreamSubscription<QuerySnapshot> customerPackageListener;
Pagination pagination;
List<Package> packages = [];
List<Package> customerPackages = [];
List<Package> deliveredPackages = [];
bool endOfDeliveredPackages = false;
bool isLoading = false;
@override
void privilegeChanged() {
super.privilegeChanged();
_loadPackages();
_loadCustomerPackages();
}
@override
logout() async {
if (listener != null) await listener.cancel();
if (customerPackageListener != null) await customerPackageListener.cancel();
if (pagination != null) pagination.close();
packages = [];
customerPackages = [];
deliveredPackages = [];
}
Future<void> initDeliveredPackages() {
if (pagination != null) pagination.close();
deliveredPackages = [];
endOfDeliveredPackages = false;
isLoading = false;
var pageQuery = Firestore.instance
.collection("/$packages_collection")
// .collection(
// "/users/8OTfsbVvsUOn1SLxy1OrKk7Y_yNKkVoGalPcIlcHnAY/messages")
// .orderBy("date", descending: true);
.where("is_delivered", isEqualTo: true)
.where("is_deleted", isEqualTo: false);
if (user.isCustomer()) {
pageQuery = pageQuery.where("user_id", isEqualTo: user.id);
}
pageQuery = pageQuery.orderBy("current_status_date", descending: true);
pagination = new Pagination(pageQuery, rowPerLoad: 20);
pagination.stream.listen((doc) {
if (doc == null) {
endOfDeliveredPackages = true;
} else {
deliveredPackages.add(Package.fromMap(doc.data, doc.documentID));
// var m = Message.fromMap(doc.data, doc.documentID);
// deliveredPackages.add(Package(
// id: m.id,
// status: package_delivered_status,
// currentStatus: package_delivered_status,
// currentStatusDate: m.date,
// trackingID: (count++).toString(),
// market: m.message));
}
});
return null;
}
Future<bool> loadMoreDeliveredPackages() {
if (pagination != null && !isLoading && !endOfDeliveredPackages) {
isLoading = true;
notifyListeners();
pagination.load().then((value) {
isLoading = false;
notifyListeners();
});
}
return null;
}
Future<void> _loadPackages() async {
if (user == null) return;
String path = "";
if (user.isCustomer()) {
path = "/$user_collection/${user.id}/$packages_collection";
} else {
path = "/$packages_collection";
}
if (user == null ||
!user.hasPackages() ||
!user.hasReceiving() ||
!user.hasProcessing()) return;
String path = "/$packages_collection";
if (listener != null) listener.cancel();
packages = [];
try {
listener = Firestore.instance
var q = Firestore.instance
.collection("$path")
.where("is_delivered", isEqualTo: false)
.snapshots()
.listen((QuerySnapshot snapshot) {
.where("is_deleted", isEqualTo: false);
listener = q.snapshots().listen((QuerySnapshot snapshot) {
packages.clear();
packages = snapshot.documents.map((documentSnapshot) {
var package = Package.fromMap(
@@ -59,14 +121,36 @@ class PackageModel extends BaseModel {
}
}
Future<void> _loadCustomerPackages() async {
if (user == null) return;
String path = "/$packages_collection";
if (customerPackageListener != null) customerPackageListener.cancel();
customerPackages = [];
try {
var q = Firestore.instance
.collection("$path")
.where("is_delivered", isEqualTo: false)
.where("is_deleted", isEqualTo: false)
.where("user_id", isEqualTo: user.id);
customerPackageListener = q.snapshots().listen((QuerySnapshot snapshot) {
customerPackages.clear();
customerPackages = snapshot.documents.map((documentSnapshot) {
var package = Package.fromMap(
documentSnapshot.data, documentSnapshot.documentID);
return package;
}).toList();
notifyListeners();
});
} catch (e) {
log.warning("Error!! $e");
}
}
Future<Package> getPackage(String id) async {
if (user == null) return null;
String path = "";
if (user.isCustomer()) {
path = "/$user_collection/${user.id}/$packages_collection";
} else {
path = "/$packages_collection";
}
String path = "/$packages_collection";
try {
DocumentSnapshot snap =
await Firestore.instance.collection("$path").document(id).get();
@@ -80,6 +164,44 @@ class PackageModel extends BaseModel {
return null;
}
Future<Package> lookupPackage(String trackingID) async {
if (user == null) return null;
String path = "/$packages_collection";
try {
var qsnap = await Firestore.instance
.collection("$path")
.where("tracking_id", isEqualTo: trackingID)
.where("has_user_id", isEqualTo: false)
.where("is_deleted", isEqualTo: false)
.getDocuments(source: Source.server);
if (qsnap.documents.length > 0) {
var snap = qsnap.documents[0];
if (snap.exists) {
var package = Package.fromMap(snap.data, snap.documentID);
return package;
}
}
qsnap = await Firestore.instance
.collection("$path")
.where("tracking_id", isEqualTo: trackingID)
.where("user_id", isEqualTo: user.id)
.where("is_deleted", isEqualTo: false)
.getDocuments(source: Source.server);
if (qsnap.documents.length > 0) {
var snap = qsnap.documents[0];
if (snap.exists) {
var package = Package.fromMap(snap.data, snap.documentID);
return package;
}
}
} catch (e) {
log.warning("Error!! $e");
}
return null;
}
Future<List<User>> searchUser(String term) {
return Services.instance.userService.searchUser(term);
}
@@ -93,23 +215,74 @@ class PackageModel extends BaseModel {
.createPackages(packages, user.fcsID);
}
Future<void> completeProcessing(
Package package, List<File> files, List<String> deletedUrls) async {
Future<void> createReceiving(
User user, Package package, List<File> files) async {
if (user != null) {
package.fcsID = user.fcsID;
}
if (files != null) {
if (files.length > 5) throw Exception("Exceed number of file upload");
package.photoUrls = package.photoUrls == null ? [] : package.photoUrls;
for (File f in files) {
String path = Path.join(pkg_files_path, package.userID, package.id);
String path = Path.join(pkg_files_path);
String url = await uploadStorage(path, f);
package.photoUrls.add(url);
}
}
return Services.instance.packageService.createReceiving(package);
}
Future<void> updateReceiving(User user, Package package, List<File> files,
List<String> deletedUrls) async {
if (user != null) {
package.fcsID = user.fcsID;
}
if (deletedUrls != null) {
for (String url in deletedUrls) {
package.photoUrls.remove(url);
}
await deleteStorageFromUrls(deletedUrls);
}
if (files != null) {
if (files.length > 5) throw Exception("Exceed number of file upload");
package.photoUrls = package.photoUrls == null ? [] : package.photoUrls;
for (File f in files) {
String path = Path.join(pkg_files_path);
String url = await uploadStorage(path, f);
package.photoUrls.add(url);
}
}
await Services.instance.packageService.updateReceiving(package);
}
Future<void> deleteReceiving(Package package) {
return Services.instance.packageService.deleteReceiving(package);
}
Future<void> updateProcessing(
Package package, List<File> files, List<String> deletedUrls) async {
if (deletedUrls != null) {
for (String url in deletedUrls) {
package.photoUrls.remove(url);
}
await deleteStorageFromUrls(deletedUrls);
}
if (files != null) {
if (files.length > 5) throw Exception("Exceed number of file upload");
package.photoUrls = package.photoUrls == null ? [] : package.photoUrls;
for (File f in files) {
String path = Path.join(pkg_files_path);
String url = await uploadStorage(path, f);
package.photoUrls.add(url);
}
package.photoUrls.removeWhere((e) => deletedUrls.contains(e));
}
await request("/packages", "PUT",
payload: package.toJson(), token: await getToken());
await Services.instance.packageService.updateProcessing(package);
}
Future<void> deletePackage(Package package) {
return Services.instance.packageService.deletePackage(package);
Future<void> deleteProcessing(Package package) {
return Services.instance.packageService.deleteProcessing(package);
}
}

View File

@@ -228,8 +228,8 @@ class _PackageEditorPageState extends State<PackageEditorPage> {
_package.desc = _descCtl.text;
_package.remark = _remarkCtl.text;
_package.market = selectedMarket;
await packageModel.completeProcessing(_package,
multiImgController.getAddedFile, multiImgController.getDeletedUrl);
// await packageModel.completeProcessing(_package,
// multiImgController.getAddedFile, multiImgController.getDeletedUrl);
Navigator.pop(context);
} catch (e) {
showMsgDialog(context, "Error", e.toString());
@@ -251,7 +251,7 @@ class _PackageEditorPageState extends State<PackageEditorPage> {
PackageModel packageModel =
Provider.of<PackageModel>(context, listen: false);
try {
await packageModel.deletePackage(_package);
// await packageModel.deletePackage(_package);
Navigator.pop<bool>(context, true);
} catch (e) {
showMsgDialog(context, "Error", e.toString());

View File

@@ -1,28 +1,24 @@
import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/main/model/main_model.dart';
import 'package:fcs/pages/package/package_editor.dart';
import 'package:fcs/pages/main/util.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/multi_img_controller.dart';
import 'package:fcs/pages/widgets/multi_img_file.dart';
import 'package:fcs/pages/widgets/progress.dart';
import 'package:fcs/pages/widgets/status_tree.dart';
import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import 'package:timeline_list/timeline.dart';
import 'package:timeline_list/timeline_model.dart';
import 'model/package_model.dart';
final DateFormat dateFormat = DateFormat("d MMM yyyy");
class PackageInfo extends StatefulWidget {
final isSearchResult;
final Package package;
PackageInfo({this.package});
PackageInfo({this.package, this.isSearchResult = false});
@override
_PackageInfoState createState() => _PackageInfoState();
@@ -54,8 +50,6 @@ class _PackageInfoState extends State<PackageInfo> {
@override
Widget build(BuildContext context) {
bool isCustomer = Provider.of<MainModel>(context).isCustomer();
final trackingIdBox = DisplayText(
text: _package.trackingID,
labelTextKey: "package.tracking.id",
@@ -109,14 +103,6 @@ class _PackageInfoState extends State<PackageInfo> {
fontSize: 20,
color: primaryColor,
),
actions: <Widget>[
isCustomer
? Container()
: IconButton(
icon: Icon(Icons.edit, color: primaryColor),
onPressed: _gotoEditor,
)
],
),
body: Card(
child: Column(
@@ -126,29 +112,15 @@ class _PackageInfoState extends State<PackageInfo> {
padding: const EdgeInsets.all(10.0),
child: ListView(children: <Widget>[
trackingIdBox,
customerNameBox,
marketBox,
widget.isSearchResult ? Container() : customerNameBox,
widget.isSearchResult ? Container() : marketBox,
statusBox,
_package.photoUrls.length == 0 ? Container() : img,
descBox,
widget.isSearchResult ? Container() : descBox,
remarkBox,
ExpansionTile(
initiallyExpanded: true,
title: Text(
'Status',
style: TextStyle(
color: primaryColor, fontWeight: FontWeight.bold),
),
children: <Widget>[
Container(
padding: EdgeInsets.only(left: 20),
height: 400,
child: Timeline(
children: _models(),
position: TimelinePosition.Left),
),
],
),
StatusTree(
shipmentHistory: _package.shipmentHistory,
currentStatus: _package.currentStatus),
SizedBox(
height: 20,
)
@@ -185,27 +157,13 @@ class _PackageInfoState extends State<PackageInfo> {
? Ionicons.ios_airplane
: e.status == "delivered"
? MaterialCommunityIcons.truck_fast
: e.status == "processed"
? MaterialIcons.check
: Octicons.package,
: e.status == "packed"
? MaterialCommunityIcons.package
: e.status == "processed"
? FontAwesome.dropbox
: MaterialCommunityIcons.inbox_arrow_down,
color: Colors.white,
)))
.toList();
}
_gotoEditor() async {
bool deleted = await Navigator.push<bool>(
context,
BottomUpPageRoute(PackageEditorPage(
package: widget.package,
)));
if (deleted ?? false) {
Navigator.pop(context);
} else {
PackageModel packageModel =
Provider.of<PackageModel>(context, listen: false);
Package p = await packageModel.getPackage(_package.id);
initPackage(p);
}
}
}

View File

@@ -1,14 +1,12 @@
import 'package:fcs/domain/entities/package.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/package/model/package_model.dart';
import 'package:fcs/pages/package/package_info.dart';
import 'package:fcs/pages/package/package_list_row.dart';
import 'package:fcs/pages/package/package_new.dart';
import 'package:fcs/pages/package_search/package_serach.dart';
import 'package:fcs/pages/user_search/user_serach.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.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_text.dart';
import 'package:fcs/pages/widgets/progress.dart';
import 'package:flutter/cupertino.dart';
@@ -16,16 +14,29 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class PackageList extends StatefulWidget {
final bool onlyFcs;
const PackageList({Key key, this.onlyFcs = false}) : super(key: key);
@override
_PackageListState createState() => _PackageListState();
}
class _PackageListState extends State<PackageList> {
bool _isLoading = false;
bool _showDelivered = false;
var _controller = ScrollController();
@override
void initState() {
super.initState();
Provider.of<PackageModel>(context, listen: false).initDeliveredPackages();
_controller.addListener(() {
if (_showDelivered &&
_controller.position.pixels == _controller.position.maxScrollExtent) {
Provider.of<PackageModel>(context, listen: false)
.loadMoreDeliveredPackages();
}
});
}
@override
@@ -36,7 +47,20 @@ class _PackageListState extends State<PackageList> {
@override
Widget build(BuildContext context) {
var packageModel = Provider.of<PackageModel>(context);
bool isCustomer = context.select((MainModel m) => m.isCustomer());
bool onlyFcs = widget.onlyFcs;
var packages = _showDelivered
? packageModel.deliveredPackages
: onlyFcs ? packageModel.packages : packageModel.customerPackages;
final popupMenu = LocalPopupMenuButton(
popmenus: [
LocalPopupMenu(
id: 1, textKey: "package.popupmenu.active", selected: true),
LocalPopupMenu(id: 2, textKey: "package.popupmenu.delivered")
],
popupMenuCallback: (p) => this.setState(() {
_showDelivered = p.id == 2;
}),
);
return LocalProgress(
inAsyncCall: _isLoading,
@@ -55,9 +79,8 @@ class _PackageListState extends State<PackageList> {
color: Colors.white,
),
actions: <Widget>[
isCustomer
? Container()
: IconButton(
onlyFcs
? IconButton(
icon: Icon(
Icons.search,
color: Colors.white,
@@ -65,41 +88,45 @@ class _PackageListState extends State<PackageList> {
iconSize: 30,
onPressed: () => searchPackage(context,
callbackPackageSelect: _searchCallback),
),
)
: Container(),
popupMenu
],
),
floatingActionButton: isCustomer
? Container()
: FloatingActionButton.extended(
onPressed: () {
_newPackage();
},
icon: Icon(Icons.add),
label: Text(
AppTranslations.of(context).text("package.create.title")),
backgroundColor: primaryColor,
),
body: new ListView.separated(
separatorBuilder: (context, index) => Divider(
color: Colors.black,
),
scrollDirection: Axis.vertical,
padding: EdgeInsets.only(top: 15),
shrinkWrap: true,
itemCount: packageModel.packages.length,
itemBuilder: (BuildContext context, int index) {
return PackageListRow(
key: ValueKey(packageModel.packages[index].id),
package: packageModel.packages[index],
);
})),
);
}
_newPackage() {
Navigator.push(
context,
BottomUpPageRoute(PackageNew()),
body: Column(
children: [
Expanded(
child: ListView.separated(
controller: _controller,
separatorBuilder: (context, index) => Divider(
color: Colors.black,
),
scrollDirection: Axis.vertical,
padding: EdgeInsets.only(top: 15),
shrinkWrap: true,
itemCount: packages.length,
itemBuilder: (BuildContext context, int index) {
return PackageListRow(
key: ValueKey(packages[index].id),
package: packages[index],
);
}),
),
packageModel.isLoading
? Container(
padding: EdgeInsets.all(8),
color: primaryColor,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Loading...",
style: TextStyle(color: Colors.white)),
],
),
)
: Container(),
],
)),
);
}

View File

@@ -5,6 +5,7 @@ import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/market/market_editor.dart';
import 'package:fcs/pages/market/model/market_model.dart';
import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/widgets/barcode_scanner.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
import 'package:fcs/pages/widgets/input_text.dart';
import 'package:fcs/pages/widgets/local_text.dart';
@@ -163,13 +164,8 @@ class _TrackingIDPageState extends State<TrackingIDPage> {
}
try {
String barcode = await BarcodeScanner.scan();
String barcode = await scanBarcode();
if (barcode != null) {
String gs = String.fromCharCode(29);
if (barcode.contains(gs)) {
var codes = barcode.split(gs);
barcode = codes.length >= 2 ? codes[1] : barcode;
}
setState(() {
_transcationIDCtl.text = barcode;
});

View File

@@ -4,6 +4,7 @@ import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/package/model/package_model.dart';
import 'package:fcs/pages/package/package_list_row.dart';
import 'package:fcs/pages/widgets/barcode_scanner.dart';
import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:permission_handler/permission_handler.dart';
@@ -147,13 +148,8 @@ class PackageSearchDelegate extends SearchDelegate<Package> {
// Barcode bc = barcodes.firstWhere((element) => true);
// String barcode;
// if (bc != null) barcode = bc.rawValue;
String barcode = await BarcodeScanner.scan();
String barcode = await scanBarcode();
if (barcode != null) {
String gs = String.fromCharCode(29);
if (barcode.contains(gs)) {
var codes = barcode.split(gs);
barcode = codes.length >= 2 ? codes[1] : barcode;
}
query = barcode;
showResults(context);
}

View File

@@ -1,13 +1,16 @@
import 'package:fcs/domain/entities/market.dart';
import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/domain/entities/user.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/market/market_editor.dart';
import 'package:fcs/pages/market/model/market_model.dart';
import 'package:fcs/pages/package/model/package_model.dart';
import 'package:fcs/pages/package/tracking_id_page.dart';
import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/user_search/user_serach.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
import 'package:fcs/pages/widgets/display_text.dart';
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
import 'package:fcs/pages/widgets/input_text.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/multi_img_controller.dart';
@@ -31,6 +34,7 @@ class _ProcessingEditorState extends State<ProcessingEditor> {
TextEditingController _descCtl = new TextEditingController();
Package _package;
User _user;
bool _isLoading = false;
@override
@@ -41,6 +45,10 @@ class _ProcessingEditorState extends State<ProcessingEditor> {
_descCtl.text = _package.desc;
_remarkCtl.text = _package.remark;
multiImgController.setImageUrls = _package.photoUrls;
_user = User(
fcsID: _package.fcsID ?? "",
name: _package.userName ?? "",
phoneNumber: _package.phoneNumber ?? "");
}
final DateFormat dateFormat = DateFormat("d MMM yyyy");
@@ -50,21 +58,39 @@ class _ProcessingEditorState extends State<ProcessingEditor> {
@override
Widget build(BuildContext context) {
var fcsIDBox = Row(
children: <Widget>[
Expanded(
child: DisplayText(
text: _user.fcsID,
labelTextKey: "processing.fcs.id",
icon: FcsIDIcon(),
)),
IconButton(
icon: Icon(Icons.search, color: primaryColor),
onPressed: () => searchUser(context, callbackUserSelect: (u) {
setState(() {
this._user = u;
});
})),
],
);
final namebox = DisplayText(
text: _user.name,
labelTextKey: "processing.name",
iconData: Icons.person,
);
final phoneNumberBox = DisplayText(
text: _user.phoneNumber,
labelTextKey: "processing.phone",
iconData: Icons.phone,
);
final trackingIdBox = DisplayText(
text: _package.trackingID,
labelTextKey: "processing.tracking.id",
iconData: MaterialCommunityIcons.barcode_scan,
);
final statusBox = DisplayText(
text: _package.currentStatus,
labelTextKey: "processing.status",
iconData: AntDesign.exclamationcircleo,
);
final customerNameBox = DisplayText(
text: _package.userName,
labelTextKey: "processing.name",
iconData: Icons.perm_identity,
);
final completeProcessingBtn = fcsButton(
context,
getLocalString(context, 'processing.edit.complete.btn'),
@@ -101,44 +127,19 @@ class _ProcessingEditorState extends State<ProcessingEditor> {
fontSize: 20,
color: primaryColor,
),
actions: [
IconButton(
icon: Icon(Icons.delete, color: primaryColor),
onPressed: _delete,
)
],
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: ListView(
children: [
trackingIdBox,
customerNameBox,
statusBox,
Divider(),
Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: LocalText(
context,
"processing.edit.sub_title",
color: primaryColor,
fontSize: 16,
fontWeight: FontWeight.w700,
),
),
),
Padding(
padding: const EdgeInsets.only(left: 18.0, right: 10),
child: Column(
children: [
marketDropdown(),
descBox,
remarkBox,
img,
],
),
),
fcsIDBox,
namebox,
phoneNumberBox,
marketDropdown(),
descBox,
remarkBox,
img,
completeProcessingBtn,
SizedBox(
height: 20,
@@ -159,51 +160,63 @@ class _ProcessingEditorState extends State<ProcessingEditor> {
markets.insert(0, selectedMarket);
}
return Row(
children: [
Padding(
padding: const EdgeInsets.only(right: 18.0),
child: LocalText(
context,
"processing.market",
color: primaryColor,
fontSize: 16,
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(Icons.store, color: primaryColor),
),
),
Container(
width: 150,
child: DropdownButton<String>(
value: selectedMarket,
style: TextStyle(color: Colors.black, fontSize: 14),
underline: Container(
height: 1,
color: Colors.grey,
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(right: 18.0),
child: LocalText(
context,
"processing.market",
color: Colors.black54,
fontSize: 16,
),
),
DropdownButton<String>(
isDense: true,
value: selectedMarket,
style: TextStyle(color: Colors.black, fontSize: 14),
underline: Container(
height: 1,
color: Colors.grey,
),
onChanged: (String newValue) {
setState(() {
if (newValue == MANAGE_MARKET) {
selectedMarket = null;
_manageMarket();
return;
}
selectedMarket = newValue;
});
},
isExpanded: true,
items: markets.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value ?? "",
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: value == MANAGE_MARKET
? secondaryColor
: primaryColor)),
);
}).toList(),
),
],
),
onChanged: (String newValue) {
setState(() {
if (newValue == MANAGE_MARKET) {
selectedMarket = null;
_manageMarket();
return;
}
selectedMarket = newValue;
});
},
isExpanded: true,
items: markets.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value ?? "",
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: value == MANAGE_MARKET
? secondaryColor
: primaryColor)),
);
}).toList(),
),
),
],
],
),
);
}
@@ -219,16 +232,21 @@ class _ProcessingEditorState extends State<ProcessingEditor> {
showMsgDialog(context, "Error", "Expected some description");
return;
}
if (_user.fcsID == null || _user.fcsID == "") {
showMsgDialog(context, "Error", "Expected FCS-ID");
return;
}
setState(() {
_isLoading = true;
});
PackageModel packageModel =
Provider.of<PackageModel>(context, listen: false);
try {
_package.fcsID = _user.fcsID;
_package.desc = _descCtl.text;
_package.remark = _remarkCtl.text;
_package.market = selectedMarket;
await packageModel.completeProcessing(_package,
await packageModel.updateProcessing(_package,
multiImgController.getAddedFile, multiImgController.getDeletedUrl);
Navigator.pop(context);
} catch (e) {
@@ -239,26 +257,4 @@ class _ProcessingEditorState extends State<ProcessingEditor> {
});
}
}
_delete() {
showConfirmDialog(context, "processing.delete.confirm", _deletePackage);
}
_deletePackage() async {
setState(() {
_isLoading = true;
});
PackageModel packageModel =
Provider.of<PackageModel>(context, listen: false);
try {
await packageModel.deletePackage(_package);
Navigator.pop<bool>(context, true);
} catch (e) {
showMsgDialog(context, "Error", e.toString());
} finally {
setState(() {
_isLoading = false;
});
}
}
}

View File

@@ -1,6 +1,6 @@
import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/helpers/theme.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/display_text.dart';
@@ -8,12 +8,11 @@ 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:fcs/pages/widgets/status_tree.dart';
import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import 'package:timeline_list/timeline.dart';
import 'package:timeline_list/timeline_model.dart';
import 'processing_editor.dart';
@@ -53,8 +52,6 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
@override
Widget build(BuildContext context) {
bool isCustomer = Provider.of<MainModel>(context).isCustomer();
final trackingIdBox = DisplayText(
text: _package.trackingID,
labelTextKey: "processing.tracking.id",
@@ -65,11 +62,6 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
labelTextKey: "processing.name",
iconData: Icons.perm_identity,
);
final statusBox = DisplayText(
text: _package.currentStatus,
labelTextKey: "processing.status",
iconData: AntDesign.exclamationcircleo,
);
final marketBox = DisplayText(
text: _package.market ?? "-",
labelTextKey: "processing.market",
@@ -109,12 +101,14 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
color: primaryColor,
),
actions: <Widget>[
isCustomer
? Container()
: IconButton(
icon: Icon(Icons.edit, color: primaryColor),
onPressed: _gotoEditor,
)
IconButton(
icon: Icon(Icons.delete, color: primaryColor),
onPressed: _delete,
),
IconButton(
icon: Icon(Icons.edit, color: primaryColor),
onPressed: _gotoEditor,
),
],
),
body: Card(
@@ -127,27 +121,12 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
trackingIdBox,
customerNameBox,
marketBox,
statusBox,
_package.photoUrls.length == 0 ? Container() : img,
descBox,
remarkBox,
ExpansionTile(
initiallyExpanded: true,
title: Text(
'Status',
style: TextStyle(
color: primaryColor, fontWeight: FontWeight.bold),
),
children: <Widget>[
Container(
padding: EdgeInsets.only(left: 20),
height: 400,
child: Timeline(
children: _models(),
position: TimelinePosition.Left),
),
],
),
StatusTree(
shipmentHistory: _package.shipmentHistory,
currentStatus: _package.currentStatus),
SizedBox(
height: 20,
)
@@ -160,36 +139,26 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
);
}
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 == "processed"
? MaterialIcons.check
: Octicons.package,
color: Colors.white,
)))
.toList();
_delete() {
showConfirmDialog(context, "processing.delete.confirm", _deletePackage);
}
_deletePackage() async {
setState(() {
_isLoading = true;
});
PackageModel packageModel =
Provider.of<PackageModel>(context, listen: false);
try {
await packageModel.deleteProcessing(_package);
Navigator.pop<bool>(context, true);
} catch (e) {
showMsgDialog(context, "Error", e.toString());
} finally {
setState(() {
_isLoading = false;
});
}
}
_gotoEditor() async {

View File

@@ -1,10 +1,8 @@
import 'package:fcs/domain/entities/package.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/package/model/package_model.dart';
import 'package:fcs/pages/package/package_info.dart';
import 'package:fcs/pages/package/package_new.dart';
import 'package:fcs/pages/package_search/package_serach.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
import 'package:fcs/pages/widgets/local_text.dart';
@@ -13,6 +11,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'processing_info.dart';
import 'processing_list_row.dart';
class ProcessingList extends StatefulWidget {
@@ -91,7 +90,7 @@ class _ProcessingListState extends State<ProcessingList> {
if (_package == null) return;
Navigator.push(
context,
BottomUpPageRoute(PackageInfo(package: _package)),
BottomUpPageRoute(ProcessingInfo(package: _package)),
);
}
}

View File

@@ -0,0 +1,129 @@
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/app_translations.dart';
import 'package:fcs/pages/main/model/language_model.dart';
import 'package:fcs/pages/main/model/main_model.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/progress.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:fcs/pages/main/util.dart';
typedef void ProfileCallback();
enum Currency { USD, MMK }
class ProfileCurrencyEdit extends StatefulWidget {
@override
_ProfileCurrencyEditState createState() => _ProfileCurrencyEditState();
}
class _ProfileCurrencyEditState extends State<ProfileCurrencyEdit> {
final TextEditingController nameController = new TextEditingController();
bool _loading = false;
@override
void initState() {
super.initState();
MainModel mainModel = Provider.of<MainModel>(context, listen: false);
if (mainModel.user.preferCurrency == "MMK") {
_currency = Currency.MMK;
} else {
_currency = Currency.USD;
}
}
Currency _currency = Currency.USD;
@override
Widget build(BuildContext context) {
final saveBtn =
fcsButton(context, getLocalString(context, "btn.save"), callack: _save);
return LocalProgress(
inAsyncCall: _loading,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
title: LocalText(
context,
"profile.edit.currency.title",
fontSize: 20,
color: primaryColor,
),
backgroundColor: Colors.white,
shadowColor: Colors.transparent,
leading: IconButton(
icon: Icon(
CupertinoIcons.back,
size: 35,
color: primaryColor,
),
onPressed: () => Navigator.of(context).pop(),
),
),
body: Column(
children: <Widget>[
InkWell(
onTap: () => setState(() {
_currency = Currency.USD;
}),
child: ListTile(
title: Text('USD'),
leading: Radio(
activeColor: primaryColor,
value: Currency.USD,
groupValue: _currency,
onChanged: (Currency value) {
setState(() {
_currency = value;
});
},
),
),
),
InkWell(
onTap: () => setState(() {
_currency = Currency.MMK;
}),
child: ListTile(
title: const Text('MMK'),
leading: Radio(
activeColor: primaryColor,
value: Currency.MMK,
groupValue: _currency,
onChanged: (Currency value) {
setState(() {
_currency = value;
});
},
),
),
),
Padding(
padding: const EdgeInsets.all(18.0),
child: saveBtn,
),
],
),
),
);
}
_save() async {
setState(() {
_loading = true;
});
try {
await Provider.of<MainModel>(context, listen: false)
.updatePreferredCurrency(_currency.toString().split(".").last);
Navigator.pop(context);
} catch (e) {
showMsgDialog(context, "Error", e.toString());
} finally {
setState(() {
_loading = false;
});
}
}
}

View File

@@ -96,7 +96,7 @@ class _ProfileEditState extends State<ProfileEdit> {
});
try {
await Provider.of<MainModel>(context, listen: false)
.updateProfile(nameController.text);
.updateProfileName(nameController.text);
Navigator.pop(context);
} catch (e) {
showMsgDialog(context, "Error", e.toString());

View File

@@ -1,21 +1,25 @@
import 'package:fcs/domain/entities/role.dart';
import 'package:fcs/domain/entities/user.dart';
import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/localization/app_translations.dart';
import 'package:fcs/domain/vo/privilege.dart';
import 'package:fcs/localization/transalation.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/language_model.dart';
import 'package:fcs/pages/main/model/main_model.dart';
import 'package:fcs/pages/main/util.dart';
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/display_text.dart';
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/progress.dart';
import 'package:fcs/pages/main/util.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:provider/provider.dart';
import '../../helpers/theme.dart';
@@ -33,8 +37,6 @@ class _ProfileState extends State<Profile> {
String selectedLanguage;
TextEditingController bizNameController = new TextEditingController();
DeliveryAddress _deliveryAddress = new DeliveryAddress();
static final List<String> languagesList = Translation().supportedLanguages;
static final List<String> languageCodesList =
Translation().supportedLanguagesCodes;
@@ -56,12 +58,6 @@ class _ProfileState extends State<Profile> {
@override
void initState() {
super.initState();
var shipmentModel =
Provider.of<DeliveryAddressModel>(context, listen: false);
if (shipmentModel.deliveryAddresses.length != 0) {
_deliveryAddress = shipmentModel.deliveryAddresses[0];
}
}
@override
@@ -70,11 +66,19 @@ class _ProfileState extends State<Profile> {
if (mainModel.user == null) {
return Container();
}
DeliveryAddressModel deliveryAddressModel =
Provider.of<DeliveryAddressModel>(context);
final namebox = DisplayText(
text: mainModel.user.name,
text: mainModel.user.name + " (${mainModel.user.status})",
labelTextKey: "profile.name",
iconData: Icons.person,
);
final currencyBox = DisplayText(
text: mainModel.user.preferCurrency,
labelTextKey: "profile.currency",
iconData: FontAwesome5.money_bill_alt,
);
final phonenumberbox = DisplayText(
text: mainModel.user.phone,
@@ -142,42 +146,40 @@ class _ProfileState extends State<Profile> {
),
shadowColor: Colors.transparent,
backgroundColor: Colors.white,
actions: <Widget>[],
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
child: ListView(
children: <Widget>[
Expanded(
child: ListView(
shrinkWrap: true,
children: <Widget>[
Row(
children: <Widget>[
Expanded(child: namebox),
Padding(
padding: const EdgeInsets.only(right: 0),
child: IconButton(
icon: Icon(Icons.edit, color: Colors.grey),
onPressed: _editName),
)
],
),
mainModel.isCustomer()
? Container()
: getPrivilegeBox(context),
getShippingAddressList(context),
phonenumberbox,
fcsIDBox,
usaShippingAddressBox,
DisplayText(
text: mainModel.user.status,
labelTextKey: "customer.status",
iconData: Icons.add_alarm,
),
],
),
Row(
children: <Widget>[
Expanded(child: namebox),
Padding(
padding: const EdgeInsets.only(right: 0),
child: IconButton(
icon: Icon(Icons.edit, color: Colors.grey),
onPressed: _editName),
)
],
),
phonenumberbox,
fcsIDBox,
usaShippingAddressBox,
Row(
children: <Widget>[
Expanded(child: currencyBox),
Padding(
padding: const EdgeInsets.only(right: 0),
child: IconButton(
icon: Icon(Icons.edit, color: Colors.grey),
onPressed: _editCurrency),
)
],
),
defalutDeliveryAddress(
context, deliveryAddressModel.defalutAddress),
getPrivilegeBox(context),
SizedBox(height: 15),
logoutbutton,
SizedBox(height: 25)
],
@@ -187,221 +189,104 @@ class _ProfileState extends State<Profile> {
);
}
Widget getShippingAddressList(BuildContext context) {
var languageModel = Provider.of<LanguageModel>(context);
return ListTileTheme(
contentPadding: EdgeInsets.all(10),
child: ExpansionTile(
title: Text(
getLocalString(context, 'delivery_addresses'),
style: languageModel.isEng
? TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
fontStyle: FontStyle.normal,
)
: TextStyle(
fontSize: 15.0,
fontWeight: FontWeight.bold,
fontStyle: FontStyle.normal,
fontFamily: "Myanmar3"),
),
children: <Widget>[
showDeliveryAddress(_deliveryAddress),
Container(
padding: EdgeInsets.only(top: 20, bottom: 15, right: 15),
child: Align(
alignment: Alignment.bottomRight,
child: Container(
width: 130,
height: 40,
child: FloatingActionButton.extended(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onPressed: () async {
DeliveryAddress deliveryAddress = await Navigator.push(
context,
BottomUpPageRoute(DeliveryAddressList(
deliveryAddress: _deliveryAddress)),
);
setState(() {
_deliveryAddress = deliveryAddress;
});
},
label: LocalText(context,
'delivery_address.change_address',
fontSize: 12,
color: Colors.white,
),
backgroundColor: primaryColor,
),
Widget defalutDeliveryAddress(
BuildContext context, DeliveryAddress deliveryAddress) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: DisplayText(
labelTextKey: "delivery_address",
iconData: MaterialCommunityIcons.truck_fast,
),
),
)
],
),
);
}
Widget showDeliveryAddress(DeliveryAddress deliveryAddress) {
return Container(
padding: EdgeInsets.only(left: 10, right: 10),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Expanded(
child: new Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: Row(
children: <Widget>[
new Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
deliveryAddress.fullName == null
? ''
: deliveryAddress.fullName,
style: new TextStyle(
fontSize: 15.0,
color: Colors.black,
fontWeight: FontWeight.bold),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
deliveryAddress.addressLine1 == null
? ''
: deliveryAddress.addressLine1,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
deliveryAddress.addressLine2 == null
? ''
: deliveryAddress.addressLine2,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
deliveryAddress.city == null
? ''
: deliveryAddress.city,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
deliveryAddress.state == null
? ''
: deliveryAddress.state,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
deliveryAddress.country == null
? ''
: deliveryAddress.country,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
deliveryAddress.phoneNumber == null
? ''
: "Phone:${deliveryAddress.phoneNumber}",
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
],
),
],
),
),
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),
),
],
);
}
List<Privilege> privileges = [
Privilege(name: 'Manage shipment'),
Privilege(name: 'Manage pickups'),
Privilege(name: 'Manage packages'),
Privilege(name: 'Manage deliveries'),
Privilege(name: 'Admin')
];
Widget getPrivilegeBox(BuildContext context) {
var languageModel = Provider.of<LanguageModel>(context);
User user = Provider.of<MainModel>(context, listen: false).user;
List<Privilege> _privileges =
Provider.of<StaffModel>(context, listen: false).privileges;
return ListTileTheme(
contentPadding: EdgeInsets.all(10),
child: ExpansionTile(
title: Text(
AppTranslations.of(context).text("profile.privilege"),
style: languageModel.isEng
? TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
fontStyle: FontStyle.normal,
)
: TextStyle(
fontSize: 15.0,
fontWeight: FontWeight.bold,
fontStyle: FontStyle.normal,
fontFamily: "Myanmar3"),
if (user == null || user.isCustomer()) return Container();
List<Privilege> privileges = [];
user.privileges.forEach((e) {
var p = _privileges.firstWhere((p) => p.id == e, orElse: () => null);
if (p != null) {
privileges.add(p);
}
});
return Column(
children: <Widget>[
DisplayText(
labelTextKey: "profile.privileges",
iconData: MaterialCommunityIcons.clipboard_check_outline,
),
children: <Widget>[
Align(
alignment: Alignment.topLeft,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: getRowPrivilegeWidget(privileges)),
),
)
],
),
Padding(
padding: const EdgeInsets.only(left: 30.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: getRowPrivilegeWidget(privileges)),
)
],
);
}
List<Widget> getRowPrivilegeWidget(List<Privilege> privileges) {
return privileges.map((p) {
return Container(
padding: EdgeInsets.all(8.0),
padding: EdgeInsets.all(3.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(p.name,
style: TextStyle(fontSize: 16.0, fontStyle: FontStyle.normal)),
SizedBox(
width: 30,
Icon(
p.iconData,
color: Colors.black38,
),
Container(
child: Text(
"- ${p.desc}",
style: TextStyle(fontSize: 16.0, fontStyle: FontStyle.normal),
SizedBox(
width: 10,
),
Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text("${p.name}",
style: TextStyle(
fontSize: 16.0,
fontStyle: FontStyle.normal,
color: primaryColor,
)),
Text(
"${p.desc}",
style: TextStyle(
fontSize: 14.0,
fontStyle: FontStyle.normal,
color: Colors.black38),
),
],
),
)
],
@@ -415,7 +300,7 @@ class _ProfileState extends State<Profile> {
_showToast(title);
}
void _showToast(String title) {
_showToast(String title) {
final ScaffoldState scaffold = key.currentState;
scaffold.showSnackBar(
SnackBar(
@@ -431,6 +316,11 @@ class _ProfileState extends State<Profile> {
.push<void>(CupertinoPageRoute(builder: (context) => ProfileEdit()));
}
_editCurrency() {
Navigator.of(context).push<void>(
CupertinoPageRoute(builder: (context) => ProfileCurrencyEdit()));
}
_logout() {
showConfirmDialog(context, "profile.logout.confirm", () async {
setState(() {

View File

@@ -2,8 +2,10 @@ import 'package:barcode_scan/barcode_scan.dart';
import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/domain/entities/user.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/user_search/user_serach.dart';
import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/package/model/package_model.dart';
import 'package:fcs/pages/user_search/user_serach.dart';
import 'package:fcs/pages/widgets/barcode_scanner.dart';
import 'package:fcs/pages/widgets/display_text.dart';
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
import 'package:fcs/pages/widgets/input_text.dart';
@@ -18,22 +20,38 @@ import 'package:provider/provider.dart';
typedef void FindCallBack();
class ReceivingNew extends StatefulWidget {
const ReceivingNew();
class ReceivingEditor extends StatefulWidget {
final Package package;
const ReceivingEditor({this.package});
@override
_ReceivingNewState createState() => _ReceivingNewState();
_ReceivingEditorState createState() => _ReceivingEditorState();
}
class _ReceivingNewState extends State<ReceivingNew> {
class _ReceivingEditorState extends State<ReceivingEditor> {
Package package = Package();
bool _isLoading = false;
bool _isNew;
User user;
TextEditingController _transcationIDCtl = new TextEditingController();
TextEditingController _trackingIDCtl = new TextEditingController();
TextEditingController _remarkCtl = new TextEditingController();
MultiImgController multiImgController = MultiImgController();
MultiImgController _multiImgController = MultiImgController();
@override
void initState() {
super.initState();
_isNew = widget.package == null;
if (!_isNew) {
package = widget.package;
_trackingIDCtl.text = package.trackingID;
_remarkCtl.text = package.remark;
_multiImgController.setImageUrls = package.photoUrls;
user = User(
fcsID: package.fcsID,
name: package.userName,
phoneNumber: package.phoneNumber);
} else {
package = new Package();
}
}
@override
@@ -64,7 +82,7 @@ class _ReceivingNewState extends State<ReceivingNew> {
Expanded(
child: InputText(
labelTextKey: "receiving.tracking.id",
controller: _transcationIDCtl,
controller: _trackingIDCtl,
)),
IconButton(
icon: Icon(MaterialCommunityIcons.barcode_scan,
@@ -80,8 +98,8 @@ class _ReceivingNewState extends State<ReceivingNew> {
controller: _remarkCtl);
final img = MultiImageFile(
enabled: true,
controller: multiImgController,
title: "Receipt File",
controller: _multiImgController,
title: "Receiving",
);
final namebox = DisplayText(
text: user != null ? user.name : "",
@@ -97,7 +115,13 @@ class _ReceivingNewState extends State<ReceivingNew> {
final createButton = fcsButton(
context,
getLocalString(context, 'receiving.create_btn'),
callack: _create,
callack: _save,
);
final updateButton = fcsButton(
context,
getLocalString(context, 'receiving.update_btn'),
callack: _save,
);
return LocalProgress(
@@ -113,7 +137,7 @@ class _ReceivingNewState extends State<ReceivingNew> {
backgroundColor: Colors.white,
title: LocalText(
context,
"receiving.new",
_isNew ? "receiving.new" : "receiving.update",
fontSize: 20,
color: primaryColor,
),
@@ -137,7 +161,7 @@ class _ReceivingNewState extends State<ReceivingNew> {
SizedBox(
height: 20,
),
createButton,
_isNew ? createButton : updateButton,
SizedBox(
height: 10,
),
@@ -161,16 +185,10 @@ class _ReceivingNewState extends State<ReceivingNew> {
}
try {
String barcode = await BarcodeScanner.scan();
String barcode = await scanBarcode();
if (barcode != null) {
String gs = String.fromCharCode(29);
if (barcode.contains(gs)) {
var codes = barcode.split(gs);
barcode = codes.length >= 2 ? codes[1] : barcode;
}
setState(() {
_transcationIDCtl.text = barcode;
_trackingIDCtl.text = barcode;
});
}
} catch (e) {
@@ -178,18 +196,31 @@ class _ReceivingNewState extends State<ReceivingNew> {
}
}
_create() async {
if (user == null) {
showMsgDialog(context, "Error", "Invalid user!");
_save() async {
package.trackingID = _trackingIDCtl.text;
package.remark = _remarkCtl.text;
if (package.trackingID == null || package.trackingID == "") {
showMsgDialog(context, "Error", "Invalid tracking ID!");
return;
}
setState(() {
_isLoading = true;
});
// PackageModel packageModel =
// Provider.of<PackageModel>(context, listen: false);
PackageModel packageModel =
Provider.of<PackageModel>(context, listen: false);
try {
// await packageModel.createPackages(user, packages);
if (_isNew) {
await packageModel.createReceiving(
user, package, _multiImgController.getAddedFile);
} else {
package.id = widget.package.id;
await packageModel.updateReceiving(
user,
package,
_multiImgController.getAddedFile,
_multiImgController.getDeletedUrl);
}
Navigator.pop(context);
} catch (e) {
showMsgDialog(context, "Error", e.toString());

View File

@@ -0,0 +1,171 @@
import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/helpers/theme.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/package/package_editor.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/multi_img_controller.dart';
import 'package:fcs/pages/widgets/multi_img_file.dart';
import 'package:fcs/pages/widgets/progress.dart';
import 'package:fcs/pages/widgets/status_tree.dart';
import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import 'package:timeline_list/timeline.dart';
import 'package:timeline_list/timeline_model.dart';
import 'receiving_editor.dart';
final DateFormat dateFormat = DateFormat("d MMM yyyy");
class ReceivingInfo extends StatefulWidget {
final Package package;
ReceivingInfo({this.package});
@override
_ReceivingInfoState createState() => _ReceivingInfoState();
}
class _ReceivingInfoState extends State<ReceivingInfo> {
Package _package;
bool _isLoading = false;
MultiImgController multiImgController = MultiImgController();
@override
void initState() {
super.initState();
initPackage(widget.package);
}
initPackage(Package package) {
multiImgController.setImageUrls = package.photoUrls;
setState(() {
_package = package;
});
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
bool isCustomer = Provider.of<MainModel>(context).isCustomer();
final trackingIdBox = DisplayText(
text: _package.trackingID,
labelTextKey: "package.tracking.id",
iconData: MaterialCommunityIcons.barcode_scan,
);
final customerNameBox = DisplayText(
text: _package.userName,
labelTextKey: "package.create.name",
iconData: Icons.perm_identity,
);
final remarkBox = DisplayText(
text: _package.remark ?? "-",
labelTextKey: "package.edit.remark",
iconData: Entypo.new_message,
);
final img = MultiImageFile(
enabled: false,
controller: multiImgController,
title: "Receipt File",
);
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(Icons.close, color: primaryColor, size: 30),
onPressed: () => Navigator.of(context).pop(),
),
shadowColor: Colors.transparent,
backgroundColor: Colors.white,
title: LocalText(
context,
"receiving.info",
fontSize: 20,
color: primaryColor,
),
actions: isCustomer
? null
: <Widget>[
IconButton(
icon: Icon(Icons.delete, color: primaryColor),
onPressed: _delete,
),
IconButton(
icon: Icon(Icons.edit, color: primaryColor),
onPressed: _edit,
)
],
),
body: Card(
child: Column(
children: <Widget>[
Expanded(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: ListView(children: <Widget>[
trackingIdBox,
_package.userID != null ? customerNameBox : Container(),
_package.photoUrls.length == 0 ? Container() : img,
remarkBox,
StatusTree(
shipmentHistory: _package.shipmentHistory,
currentStatus: _package.currentStatus),
SizedBox(
height: 20,
)
]),
)),
],
),
),
),
);
}
_edit() async {
await Navigator.push(
context,
BottomUpPageRoute(ReceivingEditor(
package: widget.package,
)),
);
PackageModel packageModel =
Provider.of<PackageModel>(context, listen: false);
var pkg = await packageModel.getPackage(widget.package.id);
initPackage(pkg);
}
_delete() {
showConfirmDialog(context, "receiving.delete.confirm", _deleteReceiving);
}
_deleteReceiving() async {
setState(() {
_isLoading = true;
});
try {
PackageModel packageModel =
Provider.of<PackageModel>(context, listen: false);
await packageModel.deleteReceiving(_package);
Navigator.pop(context);
} catch (e) {
showMsgDialog(context, "Error", e.toString());
} finally {
setState(() {
_isLoading = false;
});
}
}
}

View File

@@ -1,10 +1,7 @@
import 'package:fcs/domain/entities/package.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/package/model/package_model.dart';
import 'package:fcs/pages/package/package_info.dart';
import 'package:fcs/pages/package/package_new.dart';
import 'package:fcs/pages/package_search/package_serach.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
import 'package:fcs/pages/widgets/local_text.dart';
@@ -13,8 +10,9 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'receiving_info.dart';
import 'receiving_list_row.dart';
import 'receiving_new.dart';
import 'receiving_editor.dart';
class ReceivingList extends StatefulWidget {
@override
@@ -76,8 +74,8 @@ class _ReceivingListState extends State<ReceivingList> {
_newReceiving();
},
icon: Icon(Icons.add),
label: Text(
AppTranslations.of(context).text("receiving.new")),
label:
LocalText(context, "receiving.new", color: Colors.white),
backgroundColor: primaryColor,
),
body: new ListView.separated(
@@ -100,7 +98,7 @@ class _ReceivingListState extends State<ReceivingList> {
_newReceiving() {
Navigator.push(
context,
BottomUpPageRoute(ReceivingNew()),
BottomUpPageRoute(ReceivingEditor()),
);
}
@@ -110,7 +108,7 @@ class _ReceivingListState extends State<ReceivingList> {
if (_package == null) return;
Navigator.push(
context,
BottomUpPageRoute(PackageInfo(package: _package)),
BottomUpPageRoute(ReceivingInfo(package: _package)),
);
}
}

View File

@@ -1,10 +1,11 @@
import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/pages/package/package_info.dart';
import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'receiving_info.dart';
typedef CallbackPackageSelect(Package package);
class ReceivingListRow extends StatelessWidget {
@@ -28,7 +29,7 @@ class ReceivingListRow extends StatelessWidget {
}
Navigator.push(
context,
BottomUpPageRoute(PackageInfo(package: package)),
BottomUpPageRoute(ReceivingInfo(package: package)),
);
},
child: Row(

View File

@@ -1,6 +1,7 @@
import 'dart:async';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:fcs/domain/constants.dart';
import 'package:fcs/domain/entities/cargo.dart';
import 'package:fcs/domain/entities/pickup.dart';
import 'package:fcs/domain/vo/radio.dart';
@@ -31,6 +32,13 @@ class ShipmentModel extends BaseModel {
),
];
List<String> pickupTypes = [
shipment_local_pickup,
shipment_courier_pickup,
shipment_local_dropoff,
shipment_courier_dropoff
];
List<RadioGroup> get radioGroups {
List<RadioGroup> radioGroups = [
RadioGroup(

View File

@@ -4,13 +4,16 @@ 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:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:provider/provider.dart';
import '../main/util.dart';
@@ -30,14 +33,14 @@ class _PickupBoxEditorState extends State<PickupBoxEditor> {
bool isNew;
bool isMixBox = false;
DeliveryAddress _shippingAddress = new DeliveryAddress();
DeliveryAddress _deliveryAddress = new DeliveryAddress();
@override
void initState() {
super.initState();
if (widget.box != null) {
_box = widget.box;
_shippingAddress = _box.shippingAddress;
_deliveryAddress = _box.shippingAddress;
isNew = false;
} else {
@@ -55,7 +58,7 @@ class _PickupBoxEditorState extends State<PickupBoxEditor> {
var shipmentModel =
Provider.of<DeliveryAddressModel>(context, listen: false);
_shippingAddress = shipmentModel.deliveryAddresses[1];
_deliveryAddress = shipmentModel.deliveryAddresses[1];
isNew = true;
_box = Box(
@@ -111,7 +114,7 @@ class _PickupBoxEditorState extends State<PickupBoxEditor> {
fillColor: Colors.white,
labelText: 'Actual Weight',
filled: true,
icon: Icon(FontAwesomeIcons.weightHanging,
icon: Icon(MaterialCommunityIcons.weight,
color: primaryColor),
)),
),
@@ -170,7 +173,7 @@ class _PickupBoxEditorState extends State<PickupBoxEditor> {
Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20),
child: fcsInputReadOnly(
"Shipment Weight", FontAwesomeIcons.weightHanging,
"Shipment Weight", MaterialCommunityIcons.weight,
value: _box.shipmentWeight.toString()),
),
Padding(
@@ -182,7 +185,7 @@ class _PickupBoxEditorState extends State<PickupBoxEditor> {
fillColor: Colors.white,
labelText: 'Width',
filled: true,
icon: Icon(FontAwesomeIcons.arrowCircleRight,
icon: Icon(FontAwesome.arrow_circle_right,
color: primaryColor),
)),
),
@@ -195,7 +198,7 @@ class _PickupBoxEditorState extends State<PickupBoxEditor> {
fillColor: Colors.white,
labelText: 'Height',
filled: true,
icon: Icon(FontAwesomeIcons.arrowAltCircleUp,
icon: Icon(FontAwesome.arrow_circle_up,
color: primaryColor),
)),
),
@@ -208,46 +211,14 @@ class _PickupBoxEditorState extends State<PickupBoxEditor> {
fillColor: Colors.white,
labelText: 'Length',
filled: true,
icon: Icon(FontAwesomeIcons.arrowCircleUp,
icon: Icon(FontAwesome.arrow_circle_left,
color: primaryColor),
)),
),
SizedBox(height: 25),
],
),
ExpansionTile(
title: Text(
'Shipment Address',
style: TextStyle(
color: primaryColor, fontWeight: FontWeight.bold),
),
children: [
DeliveryAddressRow(shippingAddress: _shippingAddress),
Container(
padding:
EdgeInsets.only(top: 20, bottom: 15, right: 15),
child: Align(
alignment: Alignment.bottomRight,
child: Container(
width: 120,
height: 40,
child: FloatingActionButton.extended(
materialTapTargetSize:
MaterialTapTargetSize.shrinkWrap,
onPressed: () {},
icon: Icon(Icons.add),
label: Text(
'Select\nAddress',
style: TextStyle(fontSize: 12),
),
backgroundColor: primaryColor,
),
),
),
),
SizedBox(height: 25),
],
),
makeLocation(context, _deliveryAddress),
],
),
),
@@ -292,6 +263,48 @@ class _PickupBoxEditorState extends State<PickupBoxEditor> {
);
}
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 [];

View File

@@ -1,3 +1,4 @@
import 'package:fcs/domain/constants.dart';
import 'package:fcs/domain/entities/box.dart';
import 'package:fcs/domain/entities/cargo.dart';
import 'package:fcs/domain/entities/pickup.dart';
@@ -5,13 +6,17 @@ 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/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_text.dart';
import 'package:fcs/pages/widgets/multi_img_controller.dart';
import 'package:fcs/pages/widgets/multi_img_file.dart';
@@ -27,8 +32,8 @@ import 'package:flutter/material.dart';
import 'pickup_box_editor.dart';
class ShipmentEditor extends StatefulWidget {
final Shipment pickUp;
ShipmentEditor({this.pickUp});
final Shipment shipment;
ShipmentEditor({this.shipment});
@override
_ShipmentEditorState createState() => _ShipmentEditorState();
@@ -58,17 +63,20 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
Shipment _pickUp;
bool _isLoading = false;
var now = new DateTime.now();
bool isNew;
DeliveryAddress _shippingAddress = new DeliveryAddress();
bool _isNew;
DeliveryAddress _pickupAddress = new DeliveryAddress();
int _currVal = 1;
String selectedPickupType;
@override
void initState() {
super.initState();
if (widget.pickUp != null) {
isNew = false;
_pickUp = widget.pickUp;
selectedPickupType = shipment_local_pickup;
if (widget.shipment != null) {
_isNew = false;
_pickUp = widget.shipment;
_addressEditingController.text = _pickUp.address;
_fromTimeEditingController.text = _pickUp.fromTime;
_toTimeEditingController.text = _pickUp.toTime;
@@ -84,7 +92,7 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
// _recipientAddressEditingController.text =
// mainModel.recipient.shippingAddress;
} else {
isNew = true;
_isNew = true;
List<Cargo> _cargoTypes = [
Cargo(type: 'General Cargo', weight: 25),
Cargo(type: 'Medicine', weight: 20),
@@ -94,7 +102,7 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
}
var shipmentModel =
Provider.of<DeliveryAddressModel>(context, listen: false);
_shippingAddress = shipmentModel.deliveryAddresses[1];
_pickupAddress = shipmentModel.defalutAddress;
}
@override
@@ -104,17 +112,13 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
@override
Widget build(BuildContext context) {
var pickupModel = Provider.of<ShipmentModel>(context);
final fromTimeBox = InputText(
final fromTimeBox = InputTime(
labelTextKey: 'shipment.from',
iconData: Icons.timer,
controller: _fromTimeEditingController);
final toTimeBox = InputText(
labelTextKey: 'shipment.to',
iconData: null,
controller: _toTimeEditingController);
final toTimeBox = InputTime(
labelTextKey: 'shipment.to', controller: _toTimeEditingController);
final fromTimeBoxReadOnly = fcsInputReadOnly(
'From',
@@ -128,25 +132,23 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
controller: _toTimeEditingController,
);
final pickupTime = Padding(
padding: const EdgeInsets.only(left: 20.0),
child: Row(
children: <Widget>[
Container(
child: fromTimeBox,
width: 120,
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text('-'),
),
Container(
padding: EdgeInsets.only(left: 20),
child: toTimeBox,
width: 120,
),
],
),
final pickupTimeBox = Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
child: fromTimeBox,
width: 120,
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text('-'),
),
Container(
padding: EdgeInsets.only(left: 20),
child: toTimeBox,
width: 120,
),
],
);
final pickupTimeReadOnly = Padding(
@@ -170,54 +172,6 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
),
);
final noOfPackageBoxReadonly = fcsInputReadOnly(
'Number of Packages',
Octicons.package,
controller: _noOfPackageEditingController,
);
final requestDateBox = Container(
child: InkWell(
onTap: () {
DatePicker.showDatePicker(
context,
showTitleActions: true,
currentTime: _pickupDate.text == ""
? null
: dateFormatter.parse(_pickupDate.text),
minTime: DateTime.now(),
maxTime: DateTime(2030, 12, 31),
onConfirm: (date) {},
locale: LocaleType.en,
);
},
child: TextFormField(
controller: _pickupDate,
autofocus: false,
cursorColor: primaryColor,
style: textStyle,
enabled: false,
keyboardType: TextInputType.datetime,
decoration: new InputDecoration(
border: InputBorder.none,
focusedBorder: InputBorder.none,
labelText: AppTranslations.of(context).text("shipment.date"),
// labelStyle: languageModel.isEng ? labelStyle : labelStyleMM,
contentPadding:
EdgeInsets.symmetric(vertical: 10.0, horizontal: 0.0),
icon: Icon(
Icons.date_range,
color: primaryColor,
)),
validator: (value) {
if (value.isEmpty) {
return AppTranslations.of(context).text("do.form.date");
}
return null;
},
),
));
MainModel mainModel = Provider.of<MainModel>(context);
var boxModel = Provider.of<BoxModel>(context);
@@ -230,386 +184,165 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
icon: new Icon(Icons.close),
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: primaryColor,
title: LocalText(context, "shipment.edit.title",
fontSize: 18, color: Colors.white),
shadowColor: Colors.transparent,
backgroundColor: Colors.white,
title: LocalText(
context,
_isNew ? "shipment.new.title" : "shipment.edit.title",
fontSize: 20,
color: primaryColor,
),
),
body: Card(
child: Column(
body: Padding(
padding: const EdgeInsets.all(10.0),
child: ListView(
children: <Widget>[
Expanded(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: ListView(children: <Widget>[
Center(child: nameWidget("mainModel.customer.name")),
Center(child: nameWidget("mainModel.customer.phoneNumber")),
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.pickUp == null
? Container()
: widget.pickUp.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),
),
ExpansionTile(
title: Text(
'Pickup/Drop-off',
style: TextStyle(
color: primaryColor, fontWeight: FontWeight.bold),
),
children: <Widget>[
Container(
child: Wrap(
children: pickupModel.radioGroups
.map((t) => RadioListTile(
title: Text("${t.text}"),
groupValue: _currVal,
activeColor: primaryColor,
value: t.index,
onChanged: (val) {
setState(() {
_currVal = val;
});
},
))
.toList(),
_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),
),
),
],
),
_currVal == 3
? Container(
child: DeliveryAddressRow(
shippingAddress: DeliveryAddress(
fullName: 'FCS Office',
addressLine1: '154-19 64th Ave.',
addressLine2: 'Flushing',
city: 'NY',
state: 'NY',
phoneNumber: '+1 (292)215-2247'),
),
),
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),
)
: _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,
),
: 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,
),
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(),
ExpansionTile(
title: Text(
'Package Information',
),
),
],
))
: Container(),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Text(
'Boxes',
style: TextStyle(
color: primaryColor, fontWeight: FontWeight.bold),
),
children: <Widget>[
Column(
children: getBoxList(context, boxModel.boxes),
),
Container(
padding:
EdgeInsets.only(top: 20, bottom: 15, right: 15),
child: Align(
alignment: Alignment.bottomRight,
child: Container(
width: 120,
height: 40,
child: FloatingActionButton.extended(
materialTapTargetSize:
MaterialTapTargetSize.shrinkWrap,
icon: Icon(Icons.add),
onPressed: () {
Navigator.push(
context,
BottomUpPageRoute(PickupBoxEditor()),
);
},
label: Text(
'Add Package',
style: TextStyle(fontSize: 12),
Spacer(),
IconButton(
onPressed: () {
Navigator.push(
context,
BottomUpPageRoute(PickupBoxEditor()),
);
},
icon: Icon(
Icons.add,
color: primaryColor,
))
],
),
),
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),
),
),
backgroundColor: primaryColor,
),
Container(
padding: EdgeInsets.only(left: 10),
child: MultiImageFile(
enabled: true,
controller: multiImgController,
title: "Receipt File",
)),
],
),
),
),
SizedBox(height: 10.0),
],
),
_currVal == 3 || _currVal == 4
? Container()
: ExpansionTile(
title: Text(
'Pickup Location / Time',
style: TextStyle(
color: primaryColor,
fontWeight: FontWeight.bold),
),
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 20.0),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Icon(
Icons.location_on,
color: primaryColor,
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text('Pickup Address'),
),
],
),
Padding(
padding: const EdgeInsets.only(left: 10.0),
child: DeliveryAddressRow(
shippingAddress: _shippingAddress),
),
Container(
padding: EdgeInsets.only(
top: 20, bottom: 15, right: 15),
child: Align(
alignment: Alignment.bottomRight,
child: Container(
width: 120,
height: 40,
child: FloatingActionButton.extended(
materialTapTargetSize:
MaterialTapTargetSize.shrinkWrap,
onPressed: () {},
icon: Icon(Icons.add),
label: Text(
'Select\nAddress',
style: TextStyle(fontSize: 12),
),
backgroundColor: primaryColor,
),
),
),
),
],
),
// child: ExpansionTile(
// leading: Icon(
// Icons.location_on,
// color: primaryColor,
// ),
// title: Text('My Address'),
// children: [
// Padding(
// padding: const EdgeInsets.only(left: 10.0),
// child: ShippingAddressRow(
// shippingAddress: _shippingAddress),
// ),
// Container(
// padding: EdgeInsets.only(
// top: 20, bottom: 15, right: 15),
// child: Align(
// alignment: Alignment.bottomRight,
// child: Container(
// width: 120,
// height: 40,
// child: FloatingActionButton.extended(
// materialTapTargetSize:
// MaterialTapTargetSize.shrinkWrap,
// onPressed: () {},
// icon: Icon(Icons.add),
// label: Text(
// 'Select\nAddress',
// style: TextStyle(fontSize: 12),
// ),
// backgroundColor: primaryColor,
// ),
// ),
// ),
// ),
// ],
// ),
),
widget.pickUp == null
? pickupTime
: widget.pickUp.status == 'Pending'
? pickupTime
: pickupTimeReadOnly,
Padding(
padding: const EdgeInsets.only(left: 20.0),
child: Column(
children: <Widget>[
SizedBox(height: 5),
Container(height: 50.0, child: requestDateBox)
],
),
),
SizedBox(height: 15.0),
],
),
// ExpansionTile(
// title: Text(
// 'Package Information',
// style: TextStyle(
// color: primaryColor, fontWeight: FontWeight.bold),
// ),
// children: <Widget>[
// Padding(
// padding: const EdgeInsets.only(left: 20.0),
// child: widget.pickUp == null
// ? noOfPackageBox
// : widget.pickUp.status == 'Pending'
// ? noOfPackageBox
// : noOfPackageBoxReadonly,
// ),
// Padding(
// padding: const EdgeInsets.only(left: 20.0),
// child: widget.pickUp == null
// ? fcsInput("Total Weight (lb)",
// FontAwesomeIcons.weightHanging,
// controller: _weightEditingController)
// : widget.pickUp.status == 'Pending'
// ? fcsInput("Total Weight (lb)",
// FontAwesomeIcons.weightHanging,
// controller: _weightEditingController)
// : fcsInputReadOnly("Total Weight (lb)",
// FontAwesomeIcons.weightHanging,
// controller: _weightEditingController),
// ),
// Padding(
// padding: const EdgeInsets.only(left: 20.0),
// child: fcsInput("Remark", MaterialCommunityIcons.note),
// ),
// Padding(
// padding: const EdgeInsets.only(left: 3.0),
// child: ExpansionTile(
// leading: Icon(
// SimpleLineIcons.location_pin,
// color: primaryColor,
// ),
// title: Text(
// 'Shipping Address',
// ),
// children: [
// ShippingAddressRow(
// shippingAddress: _shippingAddress),
// Container(
// padding: EdgeInsets.only(
// top: 20, bottom: 15, right: 15),
// child: Align(
// alignment: Alignment.bottomRight,
// child: Container(
// width: 130,
// height: 40,
// child: FloatingActionButton.extended(
// materialTapTargetSize:
// MaterialTapTargetSize.shrinkWrap,
// onPressed: () {},
// icon: Icon(Icons.add),
// label: Text(
// 'Add Shipping\nAddress',
// style: TextStyle(fontSize: 12),
// ),
// backgroundColor: primaryColor,
// ),
// ),
// ),
// ),
// ],
// ),
// ),
// SizedBox(height: 10.0),
// ],
// ),
mainModel.isCustomer()
? Container()
: ExpansionTile(
title: Text('For FCS'),
children: <Widget>[
widget.pickUp != null
? widget.pickUp.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",
)),
],
),
),
],
),
]),
)),
widget.pickUp == null
],
),
widget.shipment == null
? Align(
alignment: Alignment.bottomCenter,
child: Center(
@@ -627,7 +360,7 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
: Container(
child: Column(
children: <Widget>[
widget.pickUp.status == 'Confirmed'
widget.shipment.status == 'Confirmed'
? Align(
alignment: Alignment.bottomCenter,
child: Center(
@@ -679,6 +412,104 @@ 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]];

View File

@@ -4,6 +4,7 @@ import 'package:fcs/pages/shipment/model/shipment_model.dart';
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/progress.dart';
import 'package:flutter/cupertino.dart';
import 'package:provider/provider.dart';
import 'package:flutter/material.dart';
@@ -40,7 +41,7 @@ class _ShipmentListState extends State<ShipmentList> {
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(Icons.close),
icon: new Icon(CupertinoIcons.back),
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: primaryColor,
@@ -72,7 +73,7 @@ class _ShipmentListState extends State<ShipmentList> {
_newPickup();
},
icon: Icon(Icons.add),
label: Text(AppTranslations.of(context).text("shipment.new")),
label: LocalText(context, "shipment.new", color: Colors.white),
backgroundColor: primaryColor,
),
body: new ListView.separated(

View File

@@ -41,7 +41,7 @@ class _ShipmentListRowState extends State<ShipmentListRow> {
child: InkWell(
onTap: () {
Navigator.of(context)
.push(BottomUpPageRoute(ShipmentEditor(pickUp: _pickUp)));
.push(BottomUpPageRoute(ShipmentEditor(shipment: _pickUp)));
},
child: Row(
children: <Widget>[

View File

@@ -3,8 +3,8 @@ import 'dart:async';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:fcs/data/services/services.dart';
import 'package:fcs/domain/constants.dart';
import 'package:fcs/domain/entities/role.dart';
import 'package:fcs/domain/entities/user.dart';
import 'package:fcs/domain/vo/privilege.dart';
import 'package:fcs/helpers/firebase_helper.dart';
import 'package:fcs/pages/main/model/base_model.dart';
import 'package:logging/logging.dart';
@@ -58,8 +58,6 @@ class StaffModel extends BaseModel {
}
Future<void> _loadPrivileges() async {
if (user == null || !user.hasStaffs()) return;
try {
privilegeListener = Firestore.instance
.collection("/$privilege_collection")

View File

@@ -1,10 +1,10 @@
import 'package:fcs/domain/entities/role.dart';
import 'package:fcs/domain/entities/user.dart';
import 'package:fcs/domain/vo/privilege.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/app_translations.dart';
import 'package:fcs/pages/main/model/language_model.dart';
import 'package:fcs/pages/staff/model/staff_model.dart';
import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/staff/model/staff_model.dart';
import 'package:fcs/pages/widgets/display_text.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:fcs/pages/widgets/progress.dart';
@@ -68,16 +68,22 @@ class _StaffEditorState extends State<StaffEditor> {
p.isChecked = value;
});
}),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Text(
p.name,
style: TextStyle(fontSize: 15.0, color: primaryColor),
),
Text(p.desc,
style: TextStyle(fontSize: 13, color: Colors.grey[600]))
],
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: Icon(p.iconData, size: 50, color: Colors.black38),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Text(
p.name,
style: TextStyle(fontSize: 15.0, color: primaryColor),
),
Text(p.desc,
style: TextStyle(fontSize: 13, color: Colors.grey[600]))
],
),
),
],
),
@@ -192,6 +198,9 @@ class _StaffEditorState extends State<StaffEditor> {
Column(
children: showprivilegeList(context),
),
SizedBox(
height: 10,
),
Container(
child: isNew ? addButton : updateButton,
),

View File

@@ -1,17 +1,15 @@
import 'package:fcs/domain/entities/user.dart';
import 'package:fcs/localization/app_translations.dart';
import 'package:fcs/helpers/theme.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/local_text.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/widgets/progress.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import 'staff_editor.dart';
class StaffList extends StatefulWidget {

View File

@@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
Widget badgeCounter(Widget child, int counter) {
return Container(
width: 120,
height: 140,
child: new Stack(
children: <Widget>[
child,

View File

@@ -0,0 +1,18 @@
import 'package:barcode_scan/barcode_scan.dart';
Future<String> scanBarcode() async {
try {
String barcode = await BarcodeScanner.scan();
if (barcode == null) return null;
String gs = String.fromCharCode(29);
if (barcode.contains(gs)) {
var codes = barcode.split(gs);
barcode = codes.length >= 2 ? codes[1] : barcode;
}
return barcode;
} catch (e) {
print('error: $e');
return null;
}
}

View File

@@ -63,10 +63,12 @@ class DisplayText extends StatelessWidget {
AppTranslations.of(context).text(labelTextKey),
style: labelStyle,
),
Text(
text,
style: textStyle,
),
text == null
? Container()
: Text(
text,
style: textStyle,
),
],
),
),

View File

@@ -73,7 +73,9 @@ class InputDate extends StatelessWidget {
labelText: labelTextKey == null
? null
: AppTranslations.of(context).text(labelTextKey),
labelStyle: languageModel.isEng ? labelStyle : labelStyleMM,
labelStyle: languageModel.isEng
? newLabelStyle(color: Colors.black54, fontSize: 20)
: newLabelStyleMM(color: Colors.black54, fontSize: 20),
icon: iconData == null
? null
: Icon(

View File

@@ -49,7 +49,9 @@ class InputText extends StatelessWidget {
labelText: labelTextKey == null
? null
: AppTranslations.of(context).text(labelTextKey),
labelStyle: languageModel.isEng ? labelStyle : labelStyleMM,
labelStyle: languageModel.isEng
? newLabelStyle(color: Colors.black54, fontSize: 20)
: newLabelStyleMM(color: Colors.black54, fontSize: 20),
icon: iconData == null
? null
: Icon(

View File

@@ -0,0 +1,98 @@
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/app_translations.dart';
import 'package:fcs/pages/main/model/language_model.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class InputTime extends StatelessWidget {
final String labelTextKey;
final IconData iconData;
final TextEditingController controller;
final FormFieldValidator<String> validator;
final int maxLines;
final bool withBorder;
final Color borderColor;
final TextInputType textInputType;
final bool autoFocus;
const InputTime(
{Key key,
this.labelTextKey,
this.iconData,
this.controller,
this.validator,
this.maxLines = 1,
this.withBorder = false,
this.borderColor,
this.autoFocus = false,
this.textInputType})
: super(key: key);
@override
Widget build(BuildContext context) {
var languageModel = Provider.of<LanguageModel>(context);
return Padding(
padding: const EdgeInsets.only(top: 15.0, bottom: 5),
child: TextFormField(
readOnly: true,
onTap: () async {
FocusScope.of(context).unfocus();
var initialDate = TimeOfDay.now();
if (controller != null) {
try {
var values = controller.text.split(":");
initialDate = TimeOfDay(
hour: int.parse(values[0]), minute: int.parse(values[1]));
} catch (e) {} // ignore error
}
var t = await showTimePicker(
initialTime: initialDate,
context: context,
);
if (t != null && controller != null) {
controller.text = "${t.hour} : ${t.minute}";
}
},
controller: controller,
autofocus: autoFocus,
cursorColor: primaryColor,
style: textStyle,
maxLines: maxLines,
keyboardType: textInputType,
decoration: new InputDecoration(
// hintText: '',
hintStyle: TextStyle(
height: 1.5,
),
labelText: labelTextKey == null
? null
: AppTranslations.of(context).text(labelTextKey),
labelStyle: languageModel.isEng
? newLabelStyle(color: Colors.black54, fontSize: 20)
: newLabelStyleMM(color: Colors.black54, fontSize: 20),
icon: iconData == null
? null
: Icon(
iconData,
color: primaryColor,
),
enabledBorder: withBorder
? OutlineInputBorder(
borderSide: BorderSide(color: primaryColor, width: 1.0),
)
: UnderlineInputBorder(
borderSide: BorderSide(color: primaryColor, width: 1.0)),
focusedBorder: withBorder
? OutlineInputBorder(
borderSide: BorderSide(color: primaryColor, width: 1.0),
)
: UnderlineInputBorder(
borderSide: BorderSide(color: primaryColor, width: 1.0)),
),
validator: validator),
);
}
}

View File

@@ -0,0 +1,120 @@
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:flutter/material.dart';
import 'local_popupmenu.dart';
typedef PopupMenuCallback = Function(LocalPopupMenu popupMenu);
class LocalPopupMenuButton extends StatefulWidget {
final PopupMenuCallback popupMenuCallback;
final List<LocalPopupMenu> popmenus;
final bool multiSelect;
const LocalPopupMenuButton(
{Key key,
this.popupMenuCallback,
this.popmenus,
this.multiSelect = false})
: super(key: key);
@override
_LocalPopupMenuButtonState createState() => _LocalPopupMenuButtonState();
}
class _LocalPopupMenuButtonState extends State<LocalPopupMenuButton> {
List<LocalPopupMenu> popmenus;
@override
void initState() {
popmenus = widget.popmenus;
super.initState();
}
@override
Widget build(BuildContext context) {
bool hightlight = _needHighlight();
return PopupMenuButton<LocalPopupMenu>(
elevation: 3.2,
onSelected: (selected) {
if (!widget.multiSelect) {
setState(() {
popmenus.forEach((e) {
if (e.id != selected.id)
e.selected = false;
else
e.selected = true;
});
});
selected.selected = true;
} else {
setState(() {
popmenus.forEach((e) {
if (e.id == selected.id) e.selected = !e.selected;
});
});
selected.selected = !selected.selected;
}
if (widget.popupMenuCallback != null)
widget.popupMenuCallback(selected);
},
icon: Container(
width: 30,
height: 30,
decoration: new BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
),
child: Stack(
fit: StackFit.expand,
children: <Widget>[
Icon(
Icons.filter_list,
color: primaryColor,
),
hightlight
? Positioned(
bottom: 0,
right: 0,
child: Container(
width: 10,
height: 10,
decoration: new BoxDecoration(
shape: BoxShape.circle,
color: secondaryColor,
),
),
)
: Container()
],
)),
itemBuilder: (BuildContext context) {
return popmenus.map((LocalPopupMenu choice) {
return PopupMenuItem<LocalPopupMenu>(
value: choice,
child: Row(
children: <Widget>[
LocalText(context, choice.textKey, color: primaryColor),
SizedBox(
width: 10,
),
choice.selected
? Icon(
Icons.check,
color: Colors.grey,
)
: Container(),
],
),
);
}).toList();
});
}
bool _needHighlight() {
popmenus.forEach((e) {
if (e.selected && e.highlight) return true;
});
return false;
}
}

View File

@@ -0,0 +1,8 @@
class LocalPopupMenu {
int id;
String textKey;
bool selected;
bool highlight;
LocalPopupMenu(
{this.id, this.textKey, this.selected = false, this.highlight = false});
}

View File

@@ -1,5 +1,3 @@
import 'package:flutter/material.dart';
class PopupMenu {
int id;
String status;

View File

@@ -0,0 +1,75 @@
import 'package:fcs/domain/constants.dart';
import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/domain/vo/shipment_status.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:intl/intl.dart';
import 'package:timeline_list/timeline.dart';
import 'package:timeline_list/timeline_model.dart';
var dateFormatter = new DateFormat('dd MMM yyyy');
class StatusTree extends StatelessWidget {
final List<ShipmentStatus> shipmentHistory;
final String currentStatus;
const StatusTree({Key key, this.shipmentHistory, this.currentStatus})
: super(key: key);
@override
Widget build(BuildContext context) {
return ExpansionTile(
initiallyExpanded: true,
title: Text(
'Status',
style: TextStyle(color: primaryColor, fontWeight: FontWeight.bold),
),
children: <Widget>[
Container(
padding: EdgeInsets.only(left: 20),
height: 400,
child: Timeline(children: _models(), position: TimelinePosition.Left),
)
],
);
}
List<TimelineModel> _models() {
if (shipmentHistory == null || currentStatus == null) return [];
bool isPacked = currentStatus != package_received_status &&
currentStatus != package_processed_status;
return 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)),
e.done || isPacked
? Text(dateFormatter.format(e.date))
: Container(),
],
),
),
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();
}
}

View File

@@ -1,3 +1,4 @@
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/app_translations.dart';
import 'package:fcs/pages/main/model/language_model.dart';
import 'package:flutter/material.dart';
@@ -22,7 +23,7 @@ class TaskButton extends StatelessWidget {
onTap: btnCallback != null ? btnCallback : () => {},
child: Container(
width: 120,
height: 170,
height: 155,
padding: EdgeInsets.only(top: 0.0, left: 5, right: 5),
decoration: new BoxDecoration(
color: Colors.transparent,
@@ -42,7 +43,7 @@ class TaskButton extends StatelessWidget {
),
),
Container(
height: 60,
height: 45,
alignment: Alignment.topCenter,
child: Text(AppTranslations.of(context).text(titleKey),
textAlign: TextAlign.center,