import 'package:fcs/model/pickup_model.dart'; import 'package:fcs/model/shipment_rate_model.dart'; import 'package:fcs/vo/pickup.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; import 'package:fcs/widget/localization/app_translations.dart'; import 'package:flutter/material.dart'; import 'package:fcs/widget/progress.dart'; import '../theme/theme.dart'; import 'util.dart'; class ShipmentRatesEdit extends StatefulWidget { final PickUp pickUp; ShipmentRatesEdit({this.pickUp}); @override _ShipmentRatesEditState createState() => _ShipmentRatesEditState(); } class _ShipmentRatesEditState extends State { TextEditingController _addressEditingController = new TextEditingController(); TextEditingController _fromTimeEditingController = new TextEditingController(); TextEditingController _toTimeEditingController = new TextEditingController(); TextEditingController _noOfPackageEditingController = new TextEditingController(); TextEditingController _weightEditingController = new TextEditingController(); PickUp _pickUp; bool _isLoading = false; List texts = [ "Minimum shipping weight is 1lbs.", "Oversized goods, Light weight/Large volume items, laptops, phones, tablets may incur extra charges based on specifications. Please contact us for pricing.", "Goods with lithium battary needs extra packaging and declaration. Please inform us ahead of time so that we can process your package accordingly.", "Loose Batteries, Drones, and Prescription medicines are not allowed on aircraft.", "Payment: We accept money orders, any US bank transfers via Zelle, AYA, KBZ and CB. No COD except for pick-ups.", "Payments made in Myanmar will incur 2% tranfer fee" ]; @override void initState() { super.initState(); if (widget.pickUp != null) { _pickUp = widget.pickUp; _addressEditingController.text = _pickUp.address; _fromTimeEditingController.text = _pickUp.fromTime; _toTimeEditingController.text = _pickUp.toTime; _noOfPackageEditingController.text = _pickUp.numberOfPackage.toString(); _weightEditingController.text = _pickUp.weight.toString(); } } @override void dispose() { super.dispose(); } @override Widget build(BuildContext context) { var shipmentRateModel = Provider.of(context); var textList = texts .map( (e) => TextSpan( text: "\n * " + e + "\n", style: TextStyle(fontWeight: FontWeight.normal, fontSize: 13)), ) .toList(); return LocalProgress( inAsyncCall: _isLoading, child: Scaffold( appBar: AppBar( centerTitle: true, leading: new IconButton( icon: new Icon( Icons.close, ), onPressed: () => Navigator.of(context).pop(), ), backgroundColor: primaryColor, title: Text(AppTranslations.of(context).text("rate.edit.title")), ), body: Container( padding: EdgeInsets.all(18), child: ListView( children: [ Container( height: 145, child: ListView.builder( itemCount: shipmentRateModel.rates.length, itemBuilder: (context, index) { return fcsInput( shipmentRateModel.rates[index].description, Icons.attach_money, value: shipmentRateModel.rates[index].price.toString()); }), ), fcsInput("Min Weight for Free delivery within Yangon", FontAwesomeIcons.weightHanging, value: "10"), fcsInput("Delivery fees", Icons.attach_money, value: "5"), Padding( padding: const EdgeInsets.only(left: 8.0, right: 8), child: RichText( // overflow: TextOverflow.fade, text: TextSpan( style: TextStyle(color: primaryColor), children: textList, ), ), ), fcsButton(context, "Save", callack: () {}), SizedBox(height: 10) ], ), ), ), ); } _row(String desc, String price, String unit) { return Container( padding: EdgeInsets.only(left: 25, top: 5, bottom: 5), child: Row( children: [ Text('$desc ', style: TextStyle(fontSize: 15)), Spacer(), Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ Padding( padding: const EdgeInsets.only(bottom: 3.0), child: Text( '$price', style: TextStyle(color: primaryColor, fontSize: 14), ), ), Text( '$unit', style: TextStyle(color: Colors.grey, fontSize: 14), ), ], ), SizedBox( width: 50, ), ], )); } }