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/discount/model/discount_model.dart';
|
|
|
|
|
import 'package:fcs/pages/main/util.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/progress.dart';
|
2020-10-12 03:34:05 +06:30
|
|
|
import 'package:flutter/cupertino.dart';
|
2020-06-26 16:04:40 +06:30
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'discount_editor.dart';
|
2020-06-26 16:04:40 +06:30
|
|
|
|
|
|
|
|
class DiscountList extends StatefulWidget {
|
2020-10-14 20:56:46 +06:30
|
|
|
final bool selected;
|
|
|
|
|
|
|
|
|
|
const DiscountList({Key key, this.selected}) : super(key: key);
|
2020-06-26 16:04:40 +06:30
|
|
|
@override
|
|
|
|
|
_DiscountListState createState() => _DiscountListState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _DiscountListState extends State<DiscountList> {
|
|
|
|
|
bool _isLoading = false;
|
2020-10-15 15:49:02 +06:30
|
|
|
bool _selected = false;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
if (widget.selected != null) {
|
|
|
|
|
_selected = widget.selected;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-26 16:04:40 +06:30
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
var discountModel = Provider.of<DiscountModel>(context);
|
|
|
|
|
print('discounts => ${discountModel.discounts}');
|
|
|
|
|
return LocalProgress(
|
|
|
|
|
inAsyncCall: _isLoading,
|
|
|
|
|
child: Scaffold(
|
|
|
|
|
appBar: AppBar(
|
2020-06-30 16:11:58 +06:30
|
|
|
centerTitle: true,
|
2020-06-26 16:04:40 +06:30
|
|
|
title: Text(
|
|
|
|
|
AppTranslations.of(context).text("discount.title"),
|
|
|
|
|
),
|
2020-06-30 16:11:58 +06:30
|
|
|
leading: new IconButton(
|
2020-10-12 03:34:05 +06:30
|
|
|
icon: new Icon(CupertinoIcons.back),
|
2020-06-30 16:11:58 +06:30
|
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
|
|
|
),
|
2020-06-26 16:04:40 +06:30
|
|
|
backgroundColor: primaryColor,
|
|
|
|
|
actions: <Widget>[
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: Icon(Icons.search),
|
|
|
|
|
onPressed: () {},
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
body: ListView.separated(
|
|
|
|
|
separatorBuilder: (context, index) => Divider(
|
|
|
|
|
color: Colors.black,
|
|
|
|
|
),
|
|
|
|
|
itemCount: discountModel.discounts.length,
|
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
|
var discount = discountModel.discounts[index];
|
|
|
|
|
return InkWell(
|
|
|
|
|
onTap: () {
|
2020-10-15 15:49:02 +06:30
|
|
|
_selected
|
2020-10-14 20:56:46 +06:30
|
|
|
? Navigator.pop(context, discount)
|
|
|
|
|
: Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
CupertinoPageRoute(
|
|
|
|
|
builder: (context) => DiscountEditor(
|
|
|
|
|
discount: discount,
|
|
|
|
|
)),
|
|
|
|
|
);
|
2020-06-26 16:04:40 +06:30
|
|
|
},
|
|
|
|
|
child: Padding(
|
2020-06-30 16:11:58 +06:30
|
|
|
padding: const EdgeInsets.all(10.0),
|
2020-06-26 16:04:40 +06:30
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: <Widget>[
|
2020-06-30 16:11:58 +06:30
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(bottom: 8.0),
|
|
|
|
|
child: Text(
|
|
|
|
|
discount.code,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
),
|
2020-06-26 16:04:40 +06:30
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Text(
|
|
|
|
|
discount.customer,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: Colors.black,
|
|
|
|
|
fontWeight: FontWeight.normal,
|
|
|
|
|
fontSize: 15),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Padding(
|
2020-08-30 21:26:37 +06:30
|
|
|
padding:
|
|
|
|
|
const EdgeInsets.only(left: 10.0, bottom: 5.0),
|
2020-06-26 16:04:40 +06:30
|
|
|
child: Text(
|
2020-06-30 16:11:58 +06:30
|
|
|
'\$ ${discount.amount.toString()}',
|
2020-06-26 16:04:40 +06:30
|
|
|
style: TextStyle(
|
|
|
|
|
color: Colors.black,
|
2020-06-30 16:11:58 +06:30
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
fontSize: 16),
|
2020-06-26 16:04:40 +06:30
|
|
|
),
|
|
|
|
|
),
|
2020-08-30 21:26:37 +06:30
|
|
|
getStatus(discount.status),
|
2020-06-26 16:04:40 +06:30
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
floatingActionButton: FloatingActionButton.extended(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
2020-10-14 13:54:42 +06:30
|
|
|
CupertinoPageRoute(builder: (context) => DiscountEditor()),
|
2020-06-26 16:04:40 +06:30
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
icon: Icon(Icons.add),
|
|
|
|
|
label: Text(AppTranslations.of(context).text("discount.new")),
|
|
|
|
|
backgroundColor: primaryColor,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|