125 lines
4.0 KiB
Dart
125 lines
4.0 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 'custom_row.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.toString()),
|
|
),
|
|
);
|
|
}),
|
|
)),
|
|
);
|
|
}
|
|
|
|
_row(String desc, String price) {
|
|
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),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
SizedBox(
|
|
width: 50,
|
|
),
|
|
],
|
|
));
|
|
}
|
|
}
|