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

122 lines
4.1 KiB
Dart
Raw Normal View History

2021-01-08 17:13:51 +06:30
import 'package:fcs/domain/entities/cargo_type.dart';
2020-10-14 20:56:46 +06:30
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/rates/custom_editor.dart';
2024-01-25 17:40:35 +06:30
import 'package:fcs/pages/widgets/local_app_bar.dart';
2020-10-14 20:56:46 +06:30
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 'model/shipment_rate_model.dart';
class CustomList extends StatefulWidget {
2021-09-10 12:02:08 +06:30
final bool? selected;
const CustomList({Key? key, this.selected}) : super(key: key);
2020-10-14 20:56:46 +06:30
@override
_CustomListState createState() => _CustomListState();
}
class _CustomListState extends State<CustomList> {
bool _isLoading = false;
2020-10-16 21:38:39 +06:30
bool _selected = false;
2020-10-14 20:56:46 +06:30
@override
void initState() {
super.initState();
2020-10-16 21:38:39 +06:30
if (widget.selected != null) {
2021-09-10 12:02:08 +06:30
_selected = widget.selected!;
2020-10-16 21:38:39 +06:30
}
2020-10-14 20:56:46 +06:30
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
var shipmentRateModel = Provider.of<ShipmentRateModel>(context);
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
2024-01-25 17:40:35 +06:30
appBar: LocalAppBar(labelKey: 'rate.custom_duty.title'),
2020-10-15 15:49:02 +06:30
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
Navigator.of(context).push(
CupertinoPageRoute(builder: (context) => CustomEditor()));
},
icon: Icon(Icons.add, color: Colors.white),
backgroundColor: primaryColor,
label:
LocalText(context, 'rate.custom_duty', color: Colors.white)),
2020-10-14 20:56:46 +06:30
body: Padding(
padding: const EdgeInsets.all(8.0),
child: ListView.separated(
separatorBuilder: (c, i) => Divider(
color: primaryColor,
),
2020-10-15 03:06:13 +06:30
itemCount: shipmentRateModel.rate.customDuties.length,
2020-10-14 20:56:46 +06:30
itemBuilder: (context, index) {
2021-01-08 17:13:51 +06:30
CargoType custom = shipmentRateModel.rate.customDuties[index];
2020-10-15 15:49:02 +06:30
return InkWell(
onTap: () {
2020-10-16 21:38:39 +06:30
_selected
? Navigator.pop(context, custom)
: Navigator.of(context).push(CupertinoPageRoute(
builder: (context) =>
CustomEditor(custom: custom)));
2020-10-15 15:49:02 +06:30
},
child: Container(
child: _row(
2024-01-25 17:40:35 +06:30
custom.name ?? "",
"Custom Fee \$ " +
custom.customDutyFee.toStringAsFixed(2),
2024-01-23 16:28:08 +06:30
// ignore: unnecessary_null_comparison
2021-01-08 17:13:51 +06:30
custom.rate == null
2020-12-10 20:06:15 +06:30
? ""
2021-09-10 14:29:55 +06:30
: "Shipment rate \$ " +
2021-09-10 17:14:59 +06:30
custom.rate.toStringAsFixed(2)),
2020-10-15 15:49:02 +06:30
),
);
2020-10-14 20:56:46 +06:30
}),
)),
);
}
2020-12-10 20:06:15 +06:30
_row(String desc, String fee, String shipmentRate) {
2020-10-15 15:49:02 +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(
2020-12-10 20:06:15 +06:30
'$fee',
2020-10-15 15:49:02 +06:30
style: TextStyle(color: primaryColor, fontSize: 14),
),
),
2020-12-10 20:06:15 +06:30
shipmentRate == ""
? Container()
: Padding(
padding: const EdgeInsets.only(top: 3.0),
child: Text(
2021-01-08 17:13:51 +06:30
"$shipmentRate",
2020-12-10 20:06:15 +06:30
style: TextStyle(color: Colors.grey, fontSize: 14),
),
)
2020-10-15 15:49:02 +06:30
],
2020-10-14 20:56:46 +06:30
),
2020-10-15 15:49:02 +06:30
SizedBox(
width: 50,
),
],
));
2020-10-14 20:56:46 +06:30
}
}