91 lines
2.6 KiB
Dart
91 lines
2.6 KiB
Dart
import 'package:fcs/helpers/theme.dart';
|
|
import 'package:fcs/localization/app_translations.dart';
|
|
import 'package:fcs/pages/discount/discount_list_row.dart';
|
|
import 'package:fcs/pages/discount/model/discount_model.dart';
|
|
import 'package:fcs/pages/main/util.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 'discount_editor.dart';
|
|
|
|
class DiscountList extends StatefulWidget {
|
|
final bool selected;
|
|
|
|
const DiscountList({Key key, this.selected}) : super(key: key);
|
|
@override
|
|
_DiscountListState createState() => _DiscountListState();
|
|
}
|
|
|
|
class _DiscountListState extends State<DiscountList> {
|
|
bool _isLoading = false;
|
|
bool _selected = false;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
if (widget.selected != null) {
|
|
_selected = widget.selected;
|
|
}
|
|
}
|
|
|
|
@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(CupertinoIcons.back),
|
|
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,
|
|
height: 1,
|
|
),
|
|
itemCount: discountModel.discounts.length,
|
|
itemBuilder: (BuildContext context, int index) {
|
|
var discount = discountModel.discounts[index];
|
|
return DiscountListRow(
|
|
key: ValueKey(discount.id),
|
|
discount: discount,
|
|
);
|
|
},
|
|
),
|
|
floatingActionButton: FloatingActionButton.extended(
|
|
onPressed: () {
|
|
Navigator.push(
|
|
context,
|
|
CupertinoPageRoute(builder: (context) => DiscountEditor()),
|
|
);
|
|
},
|
|
icon: Icon(Icons.add),
|
|
label: LocalText(
|
|
context,
|
|
'discount.new',
|
|
color: Colors.white,
|
|
),
|
|
backgroundColor: primaryColor,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|