132 lines
4.6 KiB
Dart
132 lines
4.6 KiB
Dart
import 'package:fcs/model/discount_model.dart';
|
|
import 'package:fcs/pages/discount_editor.dart';
|
|
import 'package:fcs/fcs/common/pages/util.dart';
|
|
import 'package:fcs/widget/bottom_up_page_route.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:fcs/widget/localization/app_translations.dart';
|
|
import 'package:fcs/widget/progress.dart';
|
|
|
|
import '../fcs/common/helpers/theme.dart';
|
|
|
|
class DiscountList extends StatefulWidget {
|
|
@override
|
|
_DiscountListState createState() => _DiscountListState();
|
|
}
|
|
|
|
class _DiscountListState extends State<DiscountList> {
|
|
bool _isLoading = false;
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
var discountModel = Provider.of<DiscountModel>(context);
|
|
print('discounts => ${discountModel.discounts}');
|
|
return LocalProgress(
|
|
inAsyncCall: _isLoading,
|
|
child: Scaffold(
|
|
appBar: AppBar(
|
|
centerTitle: true,
|
|
title: Text(
|
|
AppTranslations.of(context).text("discount.title"),
|
|
),
|
|
leading: new IconButton(
|
|
icon: new Icon(Icons.close),
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
),
|
|
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: () {
|
|
Navigator.push(
|
|
context,
|
|
BottomUpPageRoute(DiscountEditor(
|
|
discount: discount,
|
|
)),
|
|
);
|
|
},
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(10.0),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: <Widget>[
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: <Widget>[
|
|
Padding(
|
|
padding: const EdgeInsets.only(bottom: 8.0),
|
|
child: Text(
|
|
discount.code,
|
|
style: TextStyle(
|
|
color: primaryColor,
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
Row(
|
|
children: <Widget>[
|
|
Text(
|
|
discount.customer,
|
|
style: TextStyle(
|
|
color: Colors.black,
|
|
fontWeight: FontWeight.normal,
|
|
fontSize: 15),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: <Widget>[
|
|
Padding(
|
|
padding:
|
|
const EdgeInsets.only(left: 10.0, bottom: 5.0),
|
|
child: Text(
|
|
'\$ ${discount.amount.toString()}',
|
|
style: TextStyle(
|
|
color: Colors.black,
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 16),
|
|
),
|
|
),
|
|
getStatus(discount.status),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
floatingActionButton: FloatingActionButton.extended(
|
|
onPressed: () {
|
|
Navigator.push(
|
|
context,
|
|
BottomUpPageRoute(DiscountEditor()),
|
|
);
|
|
},
|
|
icon: Icon(Icons.add),
|
|
label: Text(AppTranslations.of(context).text("discount.new")),
|
|
backgroundColor: primaryColor,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|