113 lines
3.7 KiB
Dart
113 lines
3.7 KiB
Dart
import 'package:fcs/domain/entities/discount_by_weight.dart';
|
|
import 'package:fcs/helpers/theme.dart';
|
|
import 'package:fcs/pages/rates/discount_by_weight_editor.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 DiscountByWeightList extends StatefulWidget {
|
|
const DiscountByWeightList({Key? key}) : super(key: key);
|
|
@override
|
|
_DiscountByWeightListState createState() => _DiscountByWeightListState();
|
|
}
|
|
|
|
class _DiscountByWeightListState extends State<DiscountByWeightList> {
|
|
bool _isLoading = false;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
@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.discount_by_weight",
|
|
fontSize: 20,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
floatingActionButton: FloatingActionButton.extended(
|
|
onPressed: () {
|
|
Navigator.of(context).push(CupertinoPageRoute(
|
|
builder: (context) => DiscountByWeightEditor()));
|
|
},
|
|
icon: Icon(Icons.add, color: Colors.white),
|
|
backgroundColor: primaryColor,
|
|
label: LocalText(context, 'discount.new', color: Colors.white)),
|
|
body: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: ListView.separated(
|
|
separatorBuilder: (c, i) => Divider(
|
|
color: primaryColor,
|
|
),
|
|
itemCount: shipmentRateModel.rate.discountByWeights.length,
|
|
itemBuilder: (context, index) {
|
|
DiscountByWeight discountByWeight =
|
|
shipmentRateModel.rate.discountByWeights[index];
|
|
return InkWell(
|
|
onTap: () {
|
|
Navigator.of(context).push(CupertinoPageRoute(
|
|
builder: (context) => DiscountByWeightEditor(
|
|
discountByWeight: discountByWeight)));
|
|
},
|
|
child: Container(
|
|
child: _row(
|
|
"${discountByWeight.weight.toStringAsFixed(2)} lb",
|
|
"\$ " + discountByWeight.discount.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,
|
|
),
|
|
],
|
|
));
|
|
}
|
|
}
|