249 lines
8.3 KiB
Dart
249 lines
8.3 KiB
Dart
import 'package:fcs/domain/constants.dart';
|
|
import 'package:fcs/domain/entities/box.dart';
|
|
import 'package:fcs/domain/entities/shipment.dart';
|
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
|
import 'package:fcs/helpers/theme.dart';
|
|
import 'package:fcs/pages/box/model/box_model.dart';
|
|
import 'package:fcs/pages/main/model/main_model.dart';
|
|
import 'package:fcs/pages/shipment/model/shipment_model.dart';
|
|
import 'package:fcs/pages/widgets/defalut_delivery_address.dart';
|
|
import 'package:fcs/pages/widgets/delivery_address_selection.dart';
|
|
import 'package:fcs/pages/widgets/display_text.dart';
|
|
import 'package:fcs/pages/widgets/input_date.dart';
|
|
import 'package:fcs/pages/widgets/input_time.dart';
|
|
import 'package:fcs/pages/widgets/local_dropdown.dart';
|
|
import 'package:fcs/pages/widgets/local_radio_buttons.dart';
|
|
import 'package:fcs/pages/widgets/local_text.dart';
|
|
import 'package:fcs/pages/widgets/local_title.dart';
|
|
import 'package:fcs/pages/widgets/multi_img_controller.dart';
|
|
import 'package:fcs/pages/widgets/progress.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_icons/flutter_icons.dart';
|
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'box_row.dart';
|
|
|
|
class ShipmentInfo extends StatefulWidget {
|
|
final Shipment shipment;
|
|
ShipmentInfo({this.shipment});
|
|
|
|
@override
|
|
_ShipmentInfoState createState() => _ShipmentInfoState();
|
|
}
|
|
|
|
class _ShipmentInfoState extends State<ShipmentInfo> {
|
|
var dateFormatter = new DateFormat('dd MMM yyyy');
|
|
final numberFormatter = new NumberFormat("#,###");
|
|
MultiImgController multiImgController = MultiImgController();
|
|
|
|
TextEditingController _addressEditingController = new TextEditingController();
|
|
TextEditingController _fromTimeEditingController =
|
|
new TextEditingController();
|
|
TextEditingController _toTimeEditingController = new TextEditingController();
|
|
TextEditingController _noOfPackageEditingController =
|
|
new TextEditingController();
|
|
TextEditingController _weightEditingController = new TextEditingController();
|
|
TextEditingController _recipientNameEditingController =
|
|
new TextEditingController();
|
|
TextEditingController _recipientPhoneEditingController =
|
|
new TextEditingController();
|
|
TextEditingController _recipientAddressEditingController =
|
|
new TextEditingController();
|
|
TextEditingController _pickupDate = new TextEditingController();
|
|
TextEditingController _handlingFeeController = new TextEditingController();
|
|
|
|
Shipment _shipment;
|
|
bool _isLoading = false;
|
|
var now = new DateTime.now();
|
|
|
|
int _currVal = 1;
|
|
String _selectedShipmentType;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_selectedShipmentType = shipment_local_pickup;
|
|
_shipment = widget.shipment;
|
|
|
|
if (widget.shipment != null) {
|
|
_addressEditingController.text = _shipment.address;
|
|
_fromTimeEditingController.text = _shipment.pickupTimeStart;
|
|
_toTimeEditingController.text = _shipment.pickupTimeEnd;
|
|
_noOfPackageEditingController.text = _shipment.numberOfPackage.toString();
|
|
_weightEditingController.text = _shipment.weight.toString();
|
|
_pickupDate.text = dateFormatter.format(_shipment.pickupDate ?? now);
|
|
// _handlingFeeController.text =
|
|
// numberFormatter.format(_shipment.handlingFee);
|
|
_currVal = _shipment.radioIndex;
|
|
}
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
MainModel mainModel = Provider.of<MainModel>(context);
|
|
ShipmentModel pickupModel = Provider.of<ShipmentModel>(context);
|
|
|
|
final fromTimeBox = InputTime(
|
|
labelTextKey: 'shipment.from',
|
|
iconData: Icons.timer,
|
|
controller: _fromTimeEditingController);
|
|
|
|
final toTimeBox = Container(
|
|
width: 150,
|
|
child: InputTime(
|
|
iconData: Icons.timer_off,
|
|
labelTextKey: 'shipment.to',
|
|
controller: _toTimeEditingController));
|
|
|
|
final pickupDateBox = InputDate(
|
|
labelTextKey: "shipment.date",
|
|
iconData: Icons.date_range,
|
|
controller: _pickupDate,
|
|
);
|
|
final localDropoffAddress = DisplayText(
|
|
iconData: Icons.location_on,
|
|
labelTextKey: "Local Dropoff Address",
|
|
text: mainModel.setting.usaAddress);
|
|
final curierDropoffAddress = FloatingActionButton.extended(
|
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
onPressed: () {},
|
|
icon: Icon(Icons.arrow_right),
|
|
label: Text(
|
|
'Visit courier websie for nearest drop-off',
|
|
style: TextStyle(fontSize: 12),
|
|
),
|
|
backgroundColor: primaryColor,
|
|
);
|
|
final pickupAddressBox = DefaultDeliveryAddress(
|
|
deliveryAddress: _shipment.pickupAddress,
|
|
iconData: Icons.location_on,
|
|
labelKey: "shipment.location",
|
|
onTap: () async {
|
|
DeliveryAddress address = await Navigator.push<DeliveryAddress>(
|
|
context,
|
|
CupertinoPageRoute(
|
|
builder: (context) => DeliveryAddressSelection(
|
|
deliveryAddress: _shipment.pickupAddress,
|
|
)),
|
|
);
|
|
if (address == null) return;
|
|
setState(() {
|
|
_shipment.pickupAddress = address;
|
|
});
|
|
},
|
|
);
|
|
var boxModel = Provider.of<BoxModel>(context);
|
|
var handlingFeeBox = DisplayText(
|
|
labelTextKey: "shipment.handling.fee",
|
|
text: "10",
|
|
iconData: FontAwesomeIcons.moneyBill);
|
|
var shipmentTypeBox = LocalDropdown<String>(
|
|
callback: (v) {
|
|
setState(() {
|
|
_selectedShipmentType = v;
|
|
});
|
|
},
|
|
iconData: SimpleLineIcons.direction,
|
|
selectedValue: _selectedShipmentType,
|
|
values: pickupModel.shipmentTypes,
|
|
);
|
|
|
|
return LocalProgress(
|
|
inAsyncCall: _isLoading,
|
|
child: Scaffold(
|
|
appBar: AppBar(
|
|
centerTitle: true,
|
|
leading: new IconButton(
|
|
icon: new Icon(
|
|
CupertinoIcons.back,
|
|
color: primaryColor,
|
|
),
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
),
|
|
shadowColor: Colors.transparent,
|
|
backgroundColor: Colors.white,
|
|
title: LocalText(
|
|
context,
|
|
"shipment.info",
|
|
fontSize: 20,
|
|
color: primaryColor,
|
|
),
|
|
actions: <Widget>[
|
|
IconButton(
|
|
icon: Icon(Icons.edit, color: primaryColor),
|
|
onPressed: _edit,
|
|
)
|
|
]),
|
|
body: Padding(
|
|
padding: const EdgeInsets.all(10.0),
|
|
child: ListView(
|
|
children: <Widget>[
|
|
LocalTitle(textKey: "shipment.type"),
|
|
LocalRadioButtons(
|
|
values: pickupModel.shipmentTypes,
|
|
selectedValue: _selectedShipmentType,
|
|
callback: (v) {
|
|
setState(() {
|
|
_selectedShipmentType = v;
|
|
});
|
|
}),
|
|
// handlingFeeBox,
|
|
// shipmentTypeBox,
|
|
LocalTitle(textKey: "shipment.location"),
|
|
pickupAddressBox,
|
|
LocalTitle(textKey: "shipment.date.time"),
|
|
pickupDateBox,
|
|
fromTimeBox,
|
|
toTimeBox,
|
|
// localDropoffAddress,
|
|
// curierDropoffAddress,
|
|
LocalTitle(
|
|
textKey: "boxes.name",
|
|
trailing: IconButton(
|
|
icon: Icon(
|
|
Icons.add_circle,
|
|
color: primaryColor,
|
|
),
|
|
onPressed: () async {},
|
|
),
|
|
),
|
|
// Column(
|
|
// children: getBoxList(context, _shipment.boxes),
|
|
// ),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
List<Widget> getBoxList(BuildContext context, List<Box> boxes) {
|
|
return boxes.asMap().entries.map((_box) {
|
|
return InkWell(
|
|
onTap: () async {},
|
|
child: Row(
|
|
children: [
|
|
Expanded(child: BoxRow(box: _box.value)),
|
|
InkWell(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Icon(Icons.remove, color: primaryColor),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}).toList();
|
|
}
|
|
|
|
_edit() {}
|
|
}
|