Files
fcs/lib/pages/rates/custom_list.dart
2020-12-10 20:06:15 +06:30

136 lines
4.5 KiB
Dart

import 'package:fcs/domain/entities/custom_duty.dart';
import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/delivery_address/delivery_address_editor.dart';
import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/rates/custom_editor.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';
import 'model/shipment_rate_model.dart';
class CustomList extends StatefulWidget {
final bool selected;
const CustomList({Key key, this.selected}) : super(key: key);
@override
_CustomListState createState() => _CustomListState();
}
class _CustomListState extends State<CustomList> {
bool _isLoading = false;
bool _selected = false;
@override
void initState() {
super.initState();
if (widget.selected != null) {
_selected = widget.selected;
}
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
var shipmentRateModel = Provider.of<ShipmentRateModel>(context);
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(CupertinoIcons.back),
onPressed: () => Navigator.pop(context),
),
backgroundColor: primaryColor,
title: LocalText(
context,
"rate.custom_duty.title",
fontSize: 20,
color: Colors.white,
),
),
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)),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: ListView.separated(
separatorBuilder: (c, i) => Divider(
color: primaryColor,
),
itemCount: shipmentRateModel.rate.customDuties.length,
itemBuilder: (context, index) {
CustomDuty custom =
shipmentRateModel.rate.customDuties[index];
return InkWell(
onTap: () {
_selected
? Navigator.pop(context, custom)
: Navigator.of(context).push(CupertinoPageRoute(
builder: (context) =>
CustomEditor(custom: custom)));
},
child: Container(
child: _row(
custom.productType,
"\$ " + custom.fee.toStringAsFixed(2),
custom.shipmentRate == null
? ""
: "\$ " + custom.shipmentRate.toStringAsFixed(2)),
),
);
}),
)),
);
}
_row(String desc, String fee, String shipmentRate) {
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(
'$fee',
style: TextStyle(color: primaryColor, fontSize: 14),
),
),
shipmentRate == ""
? Container()
: Padding(
padding: const EdgeInsets.only(top: 3.0),
child: Text(
"\$ " + "$shipmentRate",
style: TextStyle(color: Colors.grey, fontSize: 14),
),
)
],
),
SizedBox(
width: 50,
),
],
));
}
}