Files
fcs/lib/pages/rates/shipment_rates_calculate.dart

229 lines
7.4 KiB
Dart
Raw Normal View History

2020-10-07 02:33:06 +06:30
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/app_translations.dart';
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
2020-10-15 18:48:32 +06:30
import 'package:fcs/pages/widgets/display_text.dart';
import 'package:fcs/pages/widgets/length_picker.dart';
2020-10-15 03:06:13 +06:30
import 'package:fcs/pages/widgets/local_text.dart';
2020-10-15 18:48:32 +06:30
import 'package:fcs/pages/widgets/local_title.dart';
2020-10-07 02:33:06 +06:30
import 'package:fcs/pages/widgets/progress.dart';
2020-10-14 13:54:42 +06:30
import 'package:flutter/cupertino.dart';
2020-10-15 18:48:32 +06:30
import 'package:flutter_icons/flutter_icons.dart';
2020-05-31 15:00:11 +06:30
import 'package:provider/provider.dart';
import 'package:flutter/material.dart';
class ShipmentRatesCal extends StatefulWidget {
2020-10-07 02:33:06 +06:30
ShipmentRatesCal();
2020-05-31 15:00:11 +06:30
@override
_ShipmentRatesCalState createState() => _ShipmentRatesCalState();
}
class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
bool _isLoading = false;
2020-06-25 16:19:23 +06:30
String cargoType;
2020-10-15 18:48:32 +06:30
TextEditingController _widthController = new TextEditingController();
TextEditingController _heightController = new TextEditingController();
TextEditingController _lengthController = new TextEditingController();
double shipmentWeight = 0;
double volumetricRatio = 0;
2020-05-31 15:00:11 +06:30
@override
void initState() {
super.initState();
2020-10-15 18:48:32 +06:30
//for shipment weight
volumetricRatio = Provider.of<ShipmentRateModel>(context, listen: false)
.rate
.volumetricRatio;
// _lengthController.addListener(_calShipmentWeight);
// _widthController.addListener(_calShipmentWeight);
// _heightController.addListener(_calShipmentWeight);
_lengthController.text = '10';
_widthController.text = '10';
_heightController.text = '10';
2020-05-31 15:00:11 +06:30
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
var shipmentRateModel = Provider.of<ShipmentRateModel>(context);
2020-06-25 16:19:23 +06:30
2020-10-15 18:48:32 +06:30
final lengthBox = LengthPicker(
controller: _lengthController,
lableKey: "box.length",
);
final widthBox = LengthPicker(
controller: _widthController,
lableKey: "box.width",
);
final heightBox = LengthPicker(
controller: _heightController,
lableKey: "box.height",
);
final dimBox = Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: Icon(FontAwesome.arrow_circle_right, color: primaryColor),
),
SizedBox(child: lengthBox, width: 80),
SizedBox(child: widthBox, width: 80),
SizedBox(child: heightBox, width: 80),
],
);
final shipmentWeightBox = DisplayText(
text: shipmentWeight != null ? shipmentWeight.toStringAsFixed(0) : "6",
labelTextKey: "box.shipment_weight",
iconData: MaterialCommunityIcons.weight,
);
final actualWeightBox = DisplayText(
text: shipmentWeight != null ? shipmentWeight.toStringAsFixed(0) : "",
labelTextKey: "box.actual_weight",
iconData: MaterialCommunityIcons.weight,
);
2020-05-31 15:00:11 +06:30
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
2020-06-02 15:21:26 +06:30
leading: new IconButton(
2020-10-15 03:06:13 +06:30
icon: new Icon(CupertinoIcons.back, color: primaryColor),
2020-06-02 15:21:26 +06:30
onPressed: () => Navigator.of(context).pop(),
),
2020-10-15 03:06:13 +06:30
backgroundColor: Colors.white,
shadowColor: Colors.transparent,
title: LocalText(context, 'rate.cal.title',
color: primaryColor, fontSize: 20),
2020-05-31 15:00:11 +06:30
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: ListView(
children: <Widget>[
Container(
2020-06-25 16:19:23 +06:30
padding: EdgeInsets.only(top: 5, left: 25),
child: Row(
children: <Widget>[
Expanded(
2020-10-15 18:48:32 +06:30
child: LocalText(context, 'rate.cargo.type',
color: Colors.grey, fontSize: 15)),
2020-06-25 16:19:23 +06:30
Container(
width: 150.0,
child: DropdownButtonFormField(
decoration: InputDecoration(
fillColor: Colors.white,
2020-10-15 03:06:13 +06:30
hintText: shipmentRateModel.rate.cargoTypes[0].name,
2020-06-25 16:19:23 +06:30
hintStyle: TextStyle(color: Colors.black87)),
2020-10-15 03:06:13 +06:30
items: shipmentRateModel.rate.cargoTypes
2020-06-25 16:19:23 +06:30
.map((e) => DropdownMenuItem(
2020-10-15 03:06:13 +06:30
child: Text(e.name), value: e.name))
2020-06-25 16:19:23 +06:30
.toList(),
onChanged: (selected) => {
setState(() {
cargoType = selected;
})
},
),
),
],
),
2020-05-31 15:00:11 +06:30
),
2020-10-15 18:48:32 +06:30
// LocalTitle(textKey: "box.dimension"),
dimBox,
shipmentWeightBox,
actualWeightBox,
2020-05-31 15:00:11 +06:30
SizedBox(height: 50),
2020-06-02 15:21:26 +06:30
Center(
2020-10-15 18:48:32 +06:30
child: Container(
alignment: Alignment.center,
width: 150,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
LocalText(context, "rate.delivery_fee",
color: primaryColor, fontSize: 16),
Text(
':\$ 5',
style: TextStyle(
color: primaryColor,
fontSize: 16,
),
)
],
),
2020-06-02 15:21:26 +06:30
)),
2020-05-31 15:00:11 +06:30
SizedBox(height: 20),
2020-06-02 15:21:26 +06:30
Center(
2020-10-15 18:48:32 +06:30
child: Container(
width: 220,
alignment: Alignment.center,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
LocalText(context, "rate.total_estimated_amount",
color: primaryColor, fontSize: 16),
Text(
':\$ 41',
style: TextStyle(
color: primaryColor,
fontSize: 16,
),
)
],
),
2020-06-02 15:21:26 +06:30
))
2020-05-31 15:00:11 +06:30
],
),
),
),
);
}
2020-06-25 16:19:23 +06:30
_row(String desc, String price, String unit, String value, {bool input}) {
2020-05-31 15:00:11 +06:30
return Container(
padding: EdgeInsets.only(left: 25, top: 5, bottom: 5),
child: Row(
children: <Widget>[
Text('$desc ', style: TextStyle(fontSize: 15)),
Spacer(),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
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),
),
// TextFormField(),
],
),
SizedBox(
width: 50,
),
Container(
2020-07-02 16:16:21 +06:30
width: 50,
2020-06-25 16:19:23 +06:30
child: TextFormField(
initialValue: value,
2020-06-02 15:21:26 +06:30
textAlign: TextAlign.end,
)),
2020-05-31 15:00:11 +06:30
],
));
}
}