add pagination for invoice and update ui for material 3
This commit is contained in:
@@ -14,8 +14,8 @@ class CustomDuty {
|
||||
factory CustomDuty.fromMap(Map<String, dynamic> map, String id) {
|
||||
return CustomDuty(
|
||||
id: id,
|
||||
productType: map['product_type'],
|
||||
desc: map['desc'],
|
||||
productType: map['product_type'] ?? "",
|
||||
desc: map['desc'] ?? "",
|
||||
fee: (map['fee'] ?? 0).toDouble(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -133,8 +133,9 @@ class Invoice {
|
||||
cargoTypesMaps.map((e) => CargoType.fromMap(e, e["id"])).toList();
|
||||
var customDutiesMap =
|
||||
List<Map<String, dynamic>>.from(map['custom_duties'] ?? []);
|
||||
var customDuties =
|
||||
customDutiesMap.map((e) => CustomDuty.fromMap(e, e["id"])).toList();
|
||||
var customDuties = customDutiesMap
|
||||
.map((e) => CustomDuty.fromMap(e, e["id"] ?? ""))
|
||||
.toList();
|
||||
var handlingShipmentsMap =
|
||||
List<Map<String, dynamic>>.from(map['handling_fee_shipments'] ?? []);
|
||||
var handingShipments =
|
||||
@@ -149,22 +150,23 @@ class Invoice {
|
||||
var discount = Discount.fromMap(discountMap, discountMap['id']);
|
||||
var paymentMaps = List<Map<String, dynamic>>.from(map['payments'] ?? []);
|
||||
var payments = paymentMaps.map((e) => Payment.fromMap(e, e["id"])).toList();
|
||||
|
||||
return Invoice(
|
||||
id: docID,
|
||||
invoiceNumber: map['invoice_number'],
|
||||
invoiceNumber: map['invoice_number'] ?? "",
|
||||
invoiceDate: invd.toDate(),
|
||||
userName: map['user_name'],
|
||||
fcsID: map['fcs_id'],
|
||||
phoneNumber: map['phone_number'],
|
||||
amount: map['amount'],
|
||||
userName: map['user_name'] ?? "",
|
||||
fcsID: map['fcs_id'] ?? "",
|
||||
phoneNumber: map['phone_number'] ?? "",
|
||||
amount: map['amount'] ?? 0,
|
||||
paidAmount: double.tryParse(map['paid_amount'].toString()) ?? 0,
|
||||
status: map['status'],
|
||||
status: map['status'] ?? "",
|
||||
cartons: cartons,
|
||||
cargoTypes: cargoTypes,
|
||||
shipments: handingShipments,
|
||||
customDuties: customDuties,
|
||||
deliveryFee: map['delivery_fee'],
|
||||
invoiceURL: map['invoice_url'],
|
||||
deliveryFee: map['delivery_fee'] ?? 0,
|
||||
invoiceURL: map['invoice_url'] ?? "",
|
||||
paymentMethod: paymentMethod,
|
||||
discount: discount,
|
||||
payments: payments,
|
||||
|
||||
@@ -109,8 +109,8 @@ class User {
|
||||
fcsID: map['fcs_id'],
|
||||
privileges: _privileges,
|
||||
lastMessage: map['last_message'],
|
||||
userUnseenCount: map['user_unseen_count'],
|
||||
fcsUnseenCount: map['fcs_unseen_count'],
|
||||
userUnseenCount: map['user_unseen_count'] ?? 0,
|
||||
fcsUnseenCount: map['fcs_unseen_count'] ?? 0,
|
||||
preferCurrency: map['preferred_currency'],
|
||||
lastMessageTime: _date == null ? null : _date.toDate());
|
||||
}
|
||||
|
||||
@@ -2,10 +2,9 @@ import 'package:fcs/domain/entities/cargo_type.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
||||
import 'package:fcs/pages/widgets/local_title.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
@@ -99,21 +98,11 @@ class _CargoTypeAdditionState extends State<CargoTypeAddition> {
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon:
|
||||
new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
shadowColor: Colors.transparent,
|
||||
appBar: LocalAppBar(
|
||||
labelKey: 'cargo.form.title',
|
||||
backgroundColor: Colors.white,
|
||||
title: LocalText(
|
||||
context,
|
||||
"cargo.form.title",
|
||||
fontSize: 20,
|
||||
color: primaryColor,
|
||||
)),
|
||||
labelColor: primaryColor,
|
||||
arrowColor: primaryColor),
|
||||
body: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: ListView(
|
||||
|
||||
@@ -3,9 +3,8 @@ import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/widgets/input_text.dart';
|
||||
import 'package:fcs/pages/widgets/length_picker.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -135,29 +134,21 @@ class _CartonSizeEditorState extends State<CartonSizeEditor> {
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon:
|
||||
new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
|
||||
onPressed: () {
|
||||
if (isDataChanged()) {
|
||||
showConfirmDialog(context, "back.button_confirm", () {
|
||||
Navigator.of(context).pop();
|
||||
});
|
||||
} else {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
),
|
||||
shadowColor: Colors.transparent,
|
||||
backgroundColor: Colors.white,
|
||||
title: LocalText(
|
||||
context,
|
||||
"box.carton_size",
|
||||
fontSize: 20,
|
||||
color: primaryColor,
|
||||
)),
|
||||
appBar: LocalAppBar(
|
||||
labelKey: "box.carton_size",
|
||||
backgroundColor: Colors.white,
|
||||
labelColor: primaryColor,
|
||||
arrowColor: primaryColor,
|
||||
onBack: () {
|
||||
if (isDataChanged()) {
|
||||
showConfirmDialog(context, "back.button_confirm", () {
|
||||
Navigator.of(context).pop();
|
||||
});
|
||||
} else {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
),
|
||||
body: Container(
|
||||
padding: EdgeInsets.all(18),
|
||||
child: ListView(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:fcs/domain/entities/carton_size.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -72,22 +72,11 @@ class _CartonSizeListState extends State<CartonSizeList> {
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon:
|
||||
new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
shadowColor: Colors.transparent,
|
||||
backgroundColor: Colors.white,
|
||||
title: LocalText(
|
||||
context,
|
||||
"box.carton_size.title",
|
||||
fontSize: 20,
|
||||
color: primaryColor,
|
||||
),
|
||||
),
|
||||
appBar: LocalAppBar(
|
||||
labelKey: 'box.carton_size.title',
|
||||
backgroundColor: Colors.white,
|
||||
labelColor: primaryColor,
|
||||
arrowColor: primaryColor),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.only(left: 12.0, right: 12),
|
||||
child: ListView(
|
||||
|
||||
@@ -72,27 +72,18 @@ class Bubble extends StatelessWidget {
|
||||
getMsg(context, icon),
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor:Colors.blue[50],
|
||||
backgroundColor: Colors.blue[50],
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
)),
|
||||
onPressed: () {},
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
)),
|
||||
onPressed: () {
|
||||
_viewDetail();
|
||||
},
|
||||
child: Text(
|
||||
getLocalString(context, "message.view.detail"),
|
||||
style: TextStyle(
|
||||
color: primaryColor,
|
||||
fontWeight: FontWeight.bold)))
|
||||
// FlatButton(
|
||||
// shape: RoundedRectangleBorder(
|
||||
// borderRadius: BorderRadius.circular(10.0),
|
||||
// ),
|
||||
// color: Colors.blue[50],
|
||||
// onPressed: () => _viewDetail(),
|
||||
// child: Text(
|
||||
// getLocalString(context, "message.view.detail"),
|
||||
// style: TextStyle(
|
||||
// color: primaryColor,
|
||||
// fontWeight: FontWeight.bold)))
|
||||
]
|
||||
: [
|
||||
Text(isCustomer ? "FCS Team" : sender ?? "",
|
||||
|
||||
@@ -82,7 +82,7 @@ class DiscountModel extends BaseModel {
|
||||
var snaps = await q.get(const GetOptions(source: Source.server));
|
||||
var discounts = snaps.docs.map((snap) {
|
||||
if (snap.exists) {
|
||||
var s = Discount.fromMap(snap.data as Map<String, dynamic>, snap.id);
|
||||
var s = Discount.fromMap(snap.data(), snap.id);
|
||||
return s;
|
||||
}
|
||||
}).toList();
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'package:fcs/domain/entities/rate.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/local_title.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
typedef OnSelect = Function(Carton carton, bool checked);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:fcs/domain/entities/discount.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class InvoiceDiscountList extends StatelessWidget {
|
||||
@@ -15,24 +15,9 @@ class InvoiceDiscountList extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(CupertinoIcons.back),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
title: LocalText(
|
||||
context,
|
||||
"invoice.shipment.discount.title",
|
||||
fontSize: 20,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: table(context),
|
||||
));
|
||||
appBar: LocalAppBar(labelKey: 'invoice.shipment.discount.title'),
|
||||
body:
|
||||
Padding(padding: const EdgeInsets.all(8.0), child: table(context)));
|
||||
}
|
||||
|
||||
Widget table(BuildContext context) {
|
||||
|
||||
@@ -25,11 +25,11 @@ import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
||||
import 'package:fcs/pages/shipment/model/shipment_model.dart';
|
||||
import 'package:fcs/pages/widgets/display_text.dart';
|
||||
import 'package:fcs/pages/widgets/fcs_icons.dart';
|
||||
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
||||
import 'package:fcs/pages/widgets/local_button.dart';
|
||||
import 'package:fcs/pages/widgets/local_dropdown.dart';
|
||||
import 'package:fcs/pages/widgets/local_popup_menu_button.dart';
|
||||
import 'package:fcs/pages/widgets/local_popupmenu.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';
|
||||
@@ -249,22 +249,23 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
],
|
||||
popupMenuCallback: (p) async {
|
||||
if (p.id == 1) {
|
||||
CustomDuty customDuty = await Navigator.of(context).push(
|
||||
CargoType? customDuty = await Navigator.of(context).push(
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => CustomList(selected: true)));
|
||||
_addCustom(customDuty);
|
||||
if (customDuty == null) return;
|
||||
// _addCustom(customDuty);
|
||||
} else if (p.id == 2) {
|
||||
Shipment shipment = await Navigator.of(context).push(
|
||||
Shipment? shipment = await Navigator.of(context).push(
|
||||
CupertinoPageRoute(
|
||||
builder: (context) =>
|
||||
InvoiceHandlingFeeList(shipments: _invoice!.shipments)));
|
||||
if (shipment == null) return;
|
||||
_addShipment(shipment);
|
||||
} else if (p.id == 3) {
|
||||
Discount? discount =
|
||||
await Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => InvoiceDiscountList(
|
||||
discounts: discounts,
|
||||
)));
|
||||
Discount? discount = await Navigator.of(context).push(
|
||||
CupertinoPageRoute(
|
||||
builder: (context) =>
|
||||
InvoiceDiscountList(discounts: discounts)));
|
||||
if (discount != null) {
|
||||
setState(() {
|
||||
_invoice!.discount = discount;
|
||||
@@ -314,19 +315,11 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(CupertinoIcons.back, color: primaryColor),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
backgroundColor: Colors.white,
|
||||
shadowColor: Colors.transparent,
|
||||
title: LocalText(context, 'invoice.form.title',
|
||||
color: primaryColor, fontSize: 20),
|
||||
),
|
||||
appBar: LocalAppBar(
|
||||
labelKey: 'invoice.form.title',
|
||||
backgroundColor: Colors.white,
|
||||
labelColor: primaryColor,
|
||||
arrowColor: primaryColor),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: ListView(
|
||||
@@ -336,10 +329,7 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
_isNew ? Container() : statusBox,
|
||||
_showCartons ? cartonTable : Container(),
|
||||
_showCartons
|
||||
? Divider(
|
||||
color: primaryColor,
|
||||
thickness: 2,
|
||||
)
|
||||
? Divider(color: primaryColor, thickness: 2)
|
||||
: Container(),
|
||||
invoiceTableBox,
|
||||
SizedBox(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:fcs/domain/entities/shipment.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -19,20 +20,7 @@ class InvoiceHandlingFeeList extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(CupertinoIcons.back),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
title: LocalText(
|
||||
context,
|
||||
"invoice.shipment.handling.fee.title",
|
||||
fontSize: 20,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
appBar: LocalAppBar(labelKey: 'invoice.shipment.handling.fee.title'),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: table(context),
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:fcs/domain/entities/user.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/customer/model/customer_model.dart';
|
||||
import 'package:fcs/pages/invoice/editor/invoice_editor.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -44,20 +44,7 @@ class _InvoiceCustomerListState extends State<InvoiceCustomerList> {
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(CupertinoIcons.back),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
title: LocalText(
|
||||
context,
|
||||
"customer.list.title",
|
||||
fontSize: 20,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
appBar: LocalAppBar(labelKey: 'customer.list.title'),
|
||||
body: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
@@ -83,12 +70,10 @@ class _InvoiceCustomerListState extends State<InvoiceCustomerList> {
|
||||
Widget _item(User customer) {
|
||||
return InkWell(
|
||||
onTap: () async {
|
||||
bool created = await Navigator.of(context).push(CupertinoPageRoute(
|
||||
bool? created = await Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => InvoiceEditor(
|
||||
customer: customer,
|
||||
fcsShipment: widget.fcsShipment,
|
||||
)));
|
||||
if (created) {
|
||||
customer: customer, fcsShipment: widget.fcsShipment)));
|
||||
if (created ?? false) {
|
||||
_load();
|
||||
}
|
||||
},
|
||||
|
||||
@@ -11,10 +11,9 @@ import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
||||
import 'package:fcs/pages/widgets/display_text.dart';
|
||||
import 'package:fcs/pages/widgets/fcs_icons.dart';
|
||||
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
||||
import 'package:fcs/pages/widgets/local_button.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:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -151,17 +150,11 @@ class _InvoiceInfoState extends State<InvoiceInfo> {
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(CupertinoIcons.back, color: primaryColor),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
backgroundColor: Colors.white,
|
||||
shadowColor: Colors.transparent,
|
||||
title: LocalText(context, 'invoice.form.title',
|
||||
color: primaryColor, fontSize: 20),
|
||||
),
|
||||
appBar: LocalAppBar(
|
||||
labelKey: 'invoice.form.title',
|
||||
backgroundColor: Colors.white,
|
||||
labelColor: primaryColor,
|
||||
arrowColor: primaryColor),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: ListView(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/invoice/invoice_shipment_list.dart';
|
||||
import 'package:fcs/pages/invoice/model/invoice_model.dart';
|
||||
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
||||
import 'package:fcs/pages/widgets/local_popup_menu_button.dart';
|
||||
import 'package:fcs/pages/widgets/local_popupmenu.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
@@ -9,38 +10,35 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../domain/entities/invoice.dart';
|
||||
import '../../pagination/paginator_listview.dart';
|
||||
import 'invoice_list_row.dart';
|
||||
|
||||
class InvoiceList extends StatefulWidget {
|
||||
final bool? forCustomer;
|
||||
final bool forCustomer;
|
||||
|
||||
const InvoiceList({Key? key, this.forCustomer}) : super(key: key);
|
||||
const InvoiceList({Key? key, required this.forCustomer}) : super(key: key);
|
||||
@override
|
||||
_InvoiceListState createState() => _InvoiceListState();
|
||||
}
|
||||
|
||||
class _InvoiceListState extends State<InvoiceList> {
|
||||
bool _isLoading = false;
|
||||
var _controller = ScrollController();
|
||||
int _selectedIndex = 1;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller.addListener(() async {
|
||||
if (_controller.position.pixels == _controller.position.maxScrollExtent) {
|
||||
Provider.of<InvoiceModel>(context, listen: false)
|
||||
.loadMore(isCustomer: widget.forCustomer!);
|
||||
}
|
||||
});
|
||||
|
||||
InvoiceModel invoiceModel =
|
||||
Provider.of<InvoiceModel>(context, listen: false);
|
||||
invoiceModel.initData(widget.forCustomer!, true, false);
|
||||
_init();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
_init() {
|
||||
var model = context.read<InvoiceModel>();
|
||||
_selectedIndex = model.selectedIndex;
|
||||
model.loadPaginationInvoices(_selectedIndex, widget.forCustomer);
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -48,102 +46,50 @@ class _InvoiceListState extends State<InvoiceList> {
|
||||
var invoiceModel = Provider.of<InvoiceModel>(context);
|
||||
|
||||
final popupMenu = LocalPopupMenuButton(
|
||||
popmenus: [
|
||||
LocalPopupMenu(
|
||||
id: 1,
|
||||
textKey: "invoice.popupmenu.issused",
|
||||
selected: invoiceModel.selectedIndex == 1),
|
||||
LocalPopupMenu(
|
||||
id: 2,
|
||||
textKey: "invoice.popupmenu.paid",
|
||||
selected: invoiceModel.selectedIndex == 2),
|
||||
LocalPopupMenu(
|
||||
id: 3,
|
||||
textKey: "invoice.popupmenu.cancel",
|
||||
selected: invoiceModel.selectedIndex == 3)
|
||||
],
|
||||
popupMenuCallback: (p) => this.setState(() {
|
||||
invoiceModel.selectedIndex = p.id;
|
||||
if (p.id == 2) {
|
||||
Provider.of<InvoiceModel>(context, listen: false)
|
||||
.initData(widget.forCustomer!, false, true);
|
||||
} else if (p.id == 3) {
|
||||
Provider.of<InvoiceModel>(context, listen: false)
|
||||
.initData(widget.forCustomer!, true, false);
|
||||
} else {
|
||||
Provider.of<InvoiceModel>(context, listen: false)
|
||||
.initData(widget.forCustomer!, true, false);
|
||||
}
|
||||
}),
|
||||
);
|
||||
popmenus: [
|
||||
LocalPopupMenu(
|
||||
id: 1,
|
||||
textKey: "invoice.popupmenu.issused",
|
||||
selected: invoiceModel.selectedIndex == 1),
|
||||
LocalPopupMenu(
|
||||
id: 2,
|
||||
textKey: "invoice.popupmenu.paid",
|
||||
selected: invoiceModel.selectedIndex == 2),
|
||||
LocalPopupMenu(
|
||||
id: 3,
|
||||
textKey: "invoice.popupmenu.cancel",
|
||||
selected: invoiceModel.selectedIndex == 3)
|
||||
],
|
||||
popupMenuCallback: (p) {
|
||||
this.setState(() {
|
||||
_selectedIndex = p.id;
|
||||
});
|
||||
context
|
||||
.read<InvoiceModel>()
|
||||
.onChanged(_selectedIndex, widget.forCustomer);
|
||||
});
|
||||
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: DefaultTabController(
|
||||
length: 2,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(CupertinoIcons.back),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
title: LocalText(context, 'invoices.title',
|
||||
color: Colors.white, fontSize: 20),
|
||||
actions: <Widget>[popupMenu],
|
||||
),
|
||||
floatingActionButton: widget.forCustomer!
|
||||
? null
|
||||
: FloatingActionButton.extended(
|
||||
onPressed: () {
|
||||
_newInvoice();
|
||||
},
|
||||
icon: Icon(Icons.add),
|
||||
label:
|
||||
LocalText(context, 'invoices.add', color: Colors.white),
|
||||
backgroundColor: primaryColor,
|
||||
),
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: RefreshIndicator(
|
||||
child: ListView.separated(
|
||||
physics: AlwaysScrollableScrollPhysics(),
|
||||
controller: _controller,
|
||||
separatorBuilder: (context, index) => Divider(
|
||||
color: Colors.black,
|
||||
height: 1,
|
||||
),
|
||||
scrollDirection: Axis.vertical,
|
||||
shrinkWrap: true,
|
||||
itemCount: invoiceModel.invoices.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return InvoiceListRow(
|
||||
key: ValueKey(invoiceModel.invoices[index].id),
|
||||
invoice: invoiceModel.invoices[index],
|
||||
forCustomer: widget.forCustomer,
|
||||
);
|
||||
}),
|
||||
onRefresh: () => invoiceModel.refresh(),
|
||||
),
|
||||
child: Scaffold(
|
||||
appBar: LocalAppBar(
|
||||
labelKey: 'invoices.title', actions: <Widget>[popupMenu]),
|
||||
floatingActionButton: (widget.forCustomer)
|
||||
? null
|
||||
: FloatingActionButton.extended(
|
||||
onPressed: () {
|
||||
_newInvoice();
|
||||
},
|
||||
icon: Icon(Icons.add),
|
||||
label:
|
||||
LocalText(context, 'invoices.add', color: Colors.white),
|
||||
backgroundColor: primaryColor,
|
||||
),
|
||||
invoiceModel.isLoading
|
||||
? Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
color: primaryColor,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text("Loading...",
|
||||
style: TextStyle(color: Colors.white)),
|
||||
],
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
],
|
||||
)),
|
||||
),
|
||||
body: PaginatorListView<Invoice>(
|
||||
paginatorListener: invoiceModel.getInvoices!,
|
||||
rowBuilder: (p) =>
|
||||
InvoiceListRow(invoice: p, isCustomer: widget.forCustomer),
|
||||
color: primaryColor)),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,9 @@ import '../widgets/pdf_screen.dart';
|
||||
class InvoiceListRow extends StatelessWidget {
|
||||
final dateFormatter = new DateFormat('dd MMM yyyy');
|
||||
final Invoice? invoice;
|
||||
final bool? forCustomer;
|
||||
InvoiceListRow({Key? key, this.invoice, this.forCustomer}) : super(key: key);
|
||||
final bool isCustomer;
|
||||
InvoiceListRow({Key? key, this.invoice, required this.isCustomer})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -22,9 +23,7 @@ class InvoiceListRow extends StatelessWidget {
|
||||
onTap: () {
|
||||
Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => PDFScreen(
|
||||
title: invoice!.invoiceNumber,
|
||||
url: invoice!.invoiceURL,
|
||||
)));
|
||||
title: invoice!.invoiceNumber, url: invoice!.invoiceURL)));
|
||||
},
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
@@ -55,7 +54,7 @@ class InvoiceListRow extends StatelessWidget {
|
||||
new Text(
|
||||
invoice!.status ?? "",
|
||||
style: new TextStyle(
|
||||
fontSize: 13.0, color: primaryColor),
|
||||
fontSize: 15.0, color: primaryColor),
|
||||
),
|
||||
new Text(
|
||||
invoice!.invoiceDate != null
|
||||
@@ -76,28 +75,25 @@ class InvoiceListRow extends StatelessWidget {
|
||||
? Padding(
|
||||
padding: const EdgeInsets.only(left: 10.0),
|
||||
child: InkWell(
|
||||
child: ElevatedButton(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Icon(
|
||||
Icons.payment,
|
||||
color: primaryColor,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 3.0),
|
||||
child: Text(
|
||||
"Payment",
|
||||
style: TextStyle(fontSize: 12, color: Colors.black),
|
||||
),
|
||||
)
|
||||
],
|
||||
child: ElevatedButton.icon(
|
||||
style: ElevatedButton.styleFrom(
|
||||
// shape: RoundedRectangleBorder(
|
||||
// borderRadius: BorderRadius.all(Radius.circular(5))),
|
||||
elevation: 0,
|
||||
backgroundColor: Colors.grey.shade300),
|
||||
icon: Icon(
|
||||
Icons.payment,
|
||||
color: primaryColor,
|
||||
),
|
||||
label: Padding(
|
||||
padding: const EdgeInsets.only(left: 3.0),
|
||||
child: Text("Payment",
|
||||
style:
|
||||
TextStyle(fontSize: 12, color: Colors.black))),
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => PaymentPage(
|
||||
invoice: invoice,
|
||||
forCustomer: forCustomer,
|
||||
)));
|
||||
invoice: invoice, forCustomer: isCustomer)));
|
||||
},
|
||||
)),
|
||||
)
|
||||
@@ -141,7 +137,7 @@ class InvoiceListRow extends StatelessWidget {
|
||||
Navigator.pop(context);
|
||||
Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) =>
|
||||
InvoiceInfo(invoice: invoice, forCustomer: forCustomer)));
|
||||
InvoiceInfo(invoice: invoice, forCustomer: isCustomer)));
|
||||
},
|
||||
),
|
||||
CupertinoActionSheetAction(
|
||||
@@ -162,7 +158,7 @@ class InvoiceListRow extends StatelessWidget {
|
||||
Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => PaymentPage(
|
||||
invoice: invoice,
|
||||
forCustomer: forCustomer,
|
||||
forCustomer: isCustomer,
|
||||
)));
|
||||
},
|
||||
)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:fcs/domain/entities/fcs_shipment.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/fcs_shipment/model/fcs_shipment_model.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -42,39 +41,26 @@ class _InvoiceShipmentListState extends State<InvoiceShipmentList> {
|
||||
Widget build(BuildContext context) {
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: DefaultTabController(
|
||||
length: 3,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(CupertinoIcons.back),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
title: LocalText(context, "invoice.shipment.title",
|
||||
fontSize: 18, color: Colors.white),
|
||||
),
|
||||
body: new ListView.separated(
|
||||
separatorBuilder: (context, index) => Divider(
|
||||
color: Colors.black,
|
||||
),
|
||||
scrollDirection: Axis.vertical,
|
||||
padding: EdgeInsets.only(top: 15),
|
||||
shrinkWrap: true,
|
||||
itemCount: _fcsShipments.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return InvoiceShipmentListRow(
|
||||
fcsShipment: _fcsShipments[index],
|
||||
onSelect: (f) {
|
||||
Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => InvoiceCustomerList(
|
||||
fcsShipment: f,
|
||||
)));
|
||||
},
|
||||
);
|
||||
}),
|
||||
),
|
||||
child: Scaffold(
|
||||
appBar: LocalAppBar(labelKey: "invoice.shipment.title"),
|
||||
body: new ListView.separated(
|
||||
separatorBuilder: (context, index) => Divider(
|
||||
color: Colors.black,
|
||||
),
|
||||
scrollDirection: Axis.vertical,
|
||||
padding: EdgeInsets.only(top: 15),
|
||||
shrinkWrap: true,
|
||||
itemCount: _fcsShipments.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return InvoiceShipmentListRow(
|
||||
fcsShipment: _fcsShipments[index],
|
||||
onSelect: (f) {
|
||||
Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) =>
|
||||
InvoiceCustomerList(fcsShipment: f)));
|
||||
},
|
||||
);
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ class InvoiceTable extends StatelessWidget {
|
||||
List<Widget> dataRow = tableRows.map((r) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(bottom: BorderSide(color: Colors.grey))),
|
||||
border: Border(bottom: BorderSide(color: Colors.grey.shade300))),
|
||||
padding: const EdgeInsets.only(
|
||||
left: 5.0, right: 5.0, top: 10.0, bottom: 10.0),
|
||||
child: Row(
|
||||
@@ -164,7 +164,7 @@ class InvoiceTable extends StatelessWidget {
|
||||
padding: const EdgeInsets.only(
|
||||
left: 5.0, right: 5.0, top: 15.0, bottom: 15.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(bottom: BorderSide(color: Colors.grey))),
|
||||
border: Border(bottom: BorderSide(color: Colors.grey.shade300))),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
|
||||
@@ -7,131 +7,65 @@ import 'package:fcs/domain/constants.dart';
|
||||
import 'package:fcs/domain/entities/invoice.dart';
|
||||
import 'package:fcs/domain/entities/payment.dart';
|
||||
import 'package:fcs/helpers/firebase_helper.dart';
|
||||
import 'package:fcs/helpers/paginator.dart';
|
||||
import 'package:fcs/pages/main/model/base_model.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:path/path.dart' as Path;
|
||||
|
||||
import '../../../pagination/paginator_listener.dart';
|
||||
|
||||
class InvoiceModel extends BaseModel {
|
||||
final log = Logger('InvoiceModel');
|
||||
|
||||
StreamSubscription<QuerySnapshot<Map<String, dynamic>>>? listener;
|
||||
|
||||
List<Invoice> _invoices = [];
|
||||
|
||||
List<Invoice> get invoices =>
|
||||
_selectedIndex == 1 ? _invoices : List<Invoice>.from(_paginator!.values);
|
||||
|
||||
Paginator? _paginator;
|
||||
|
||||
bool endOfPaidInvoices = false;
|
||||
bool isLoading = false;
|
||||
int _selectedIndex = 1;
|
||||
|
||||
set selectedIndex(int index) {
|
||||
_selectedIndex = index;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
int get selectedIndex => _selectedIndex;
|
||||
|
||||
@override
|
||||
void privilegeChanged() {
|
||||
super.privilegeChanged();
|
||||
}
|
||||
|
||||
initData(bool forCustomer, bool isCanceled, bool isPaid) {
|
||||
_loadInvoices(forCustomer);
|
||||
|
||||
if (_paginator != null) _paginator!.close();
|
||||
_paginator = _getPaginator(forCustomer, isCanceled, isPaid);
|
||||
_paginator!.load(onFinished: () {
|
||||
notifyListeners();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _loadInvoices(bool forCustomer) async {
|
||||
if (user == null) return;
|
||||
if (!forCustomer && !user!.hasInvoices()) return;
|
||||
String path = "/$invoices_collection";
|
||||
if (listener != null) listener!.cancel();
|
||||
_invoices = [];
|
||||
|
||||
try {
|
||||
var q = FirebaseFirestore.instance
|
||||
.collection("$path")
|
||||
.where("status", isEqualTo: invoice_issued_status)
|
||||
.where("is_deleted", isEqualTo: false);
|
||||
|
||||
if (forCustomer) {
|
||||
q = q.where("user_id", isEqualTo: user!.id);
|
||||
}
|
||||
|
||||
listener = q.snapshots().listen((QuerySnapshot snapshot) {
|
||||
_invoices.clear();
|
||||
_invoices = snapshot.docs.map((documentSnapshot) {
|
||||
var s = Invoice.fromMap(
|
||||
documentSnapshot.data() as Map<String, dynamic>,
|
||||
documentSnapshot.id);
|
||||
return s;
|
||||
}).toList();
|
||||
notifyListeners();
|
||||
});
|
||||
} catch (e) {
|
||||
log.warning("Error!! $e");
|
||||
}
|
||||
}
|
||||
|
||||
Paginator _getPaginator(bool isCustomer, bool isCanceled, bool isPaid) {
|
||||
if (!isCustomer) {
|
||||
if (user == null || !(user!.hasInvoices())) throw "No privilege";
|
||||
}
|
||||
var pageQuery = FirebaseFirestore.instance
|
||||
.collection("/$invoices_collection")
|
||||
.where("is_deleted", isEqualTo: false);
|
||||
if (isCustomer) {
|
||||
pageQuery = pageQuery.where("user_id", isEqualTo: user!.id);
|
||||
}
|
||||
if (isCanceled) {
|
||||
pageQuery = pageQuery.where("status", isEqualTo: invoice_cancel_status);
|
||||
}
|
||||
if (isPaid) {
|
||||
pageQuery = pageQuery.where("status", isEqualTo: invoice_paid_status);
|
||||
}
|
||||
|
||||
pageQuery = pageQuery.orderBy("created_at", descending: true);
|
||||
var paginator = new Paginator(pageQuery, rowPerLoad: 20, toObj: (data, id) {
|
||||
return Invoice.fromMap(data, id);
|
||||
});
|
||||
return paginator;
|
||||
}
|
||||
|
||||
Future<void> loadMore({bool? isCustomer}) async {
|
||||
if (_paginator!.ended || _selectedIndex == 1)
|
||||
return; // when paid menu is not selected return
|
||||
isLoading = true;
|
||||
notifyListeners();
|
||||
await _paginator!.load(onFinished: () {
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> refresh({bool? isCustomer}) async {
|
||||
if (_selectedIndex == 1) return; // when paid menu is not selected return
|
||||
await _paginator!.refresh(onFinished: () {
|
||||
notifyListeners();
|
||||
});
|
||||
}
|
||||
PaginatorListener<Invoice>? getInvoices;
|
||||
int selectedIndex = 1;
|
||||
|
||||
void initUser(user) {
|
||||
super.initUser(user);
|
||||
}
|
||||
|
||||
logout() async {
|
||||
if (_paginator != null) _paginator!.close();
|
||||
if (listener != null) await listener!.cancel();
|
||||
_invoices = [];
|
||||
getInvoices?.close();
|
||||
}
|
||||
|
||||
onChanged(int index, bool isCustomer) {
|
||||
selectedIndex = index;
|
||||
loadPaginationInvoices(index, isCustomer);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> loadPaginationInvoices(int index, bool isCustomer) async {
|
||||
if (user == null) return;
|
||||
if (!isCustomer && !user!.hasInvoices()) return;
|
||||
|
||||
String path = "/$invoices_collection";
|
||||
Query col = FirebaseFirestore.instance.collection(path);
|
||||
Query pageQuery = FirebaseFirestore.instance.collection(path);
|
||||
|
||||
if (isCustomer) {
|
||||
col = col.where("user_id", isEqualTo: user!.id);
|
||||
pageQuery = pageQuery.where("user_id", isEqualTo: user!.id);
|
||||
}
|
||||
|
||||
if (index == 1) {
|
||||
col = col.where("status", isEqualTo: invoice_issued_status);
|
||||
pageQuery = pageQuery.where("status", isEqualTo: invoice_issued_status);
|
||||
}
|
||||
|
||||
if (index == 2) {
|
||||
col = col.where("status", isEqualTo: invoice_paid_status);
|
||||
pageQuery = pageQuery.where("status", isEqualTo: invoice_paid_status);
|
||||
}
|
||||
|
||||
if (index == 3) {
|
||||
col = col.where("status", isEqualTo: invoice_cancel_status);
|
||||
pageQuery = pageQuery.where("status", isEqualTo: invoice_cancel_status);
|
||||
}
|
||||
|
||||
pageQuery = pageQuery.orderBy("created_at", descending: true);
|
||||
|
||||
getInvoices?.close();
|
||||
getInvoices = PaginatorListener<Invoice>(
|
||||
col, pageQuery, (data, id) => Invoice.fromMap(data, id),
|
||||
rowPerLoad: 30);
|
||||
}
|
||||
|
||||
Future<Invoice?> getInvoice(String id) async {
|
||||
@@ -140,7 +74,7 @@ class InvoiceModel extends BaseModel {
|
||||
var ref = FirebaseFirestore.instance.collection("$path").doc(id);
|
||||
var snap = await ref.get(const GetOptions(source: Source.server));
|
||||
if (snap.exists) {
|
||||
var s = Invoice.fromMap(snap.data as Map<String, dynamic>, snap.id);
|
||||
var s = Invoice.fromMap(snap.data() as Map<String, dynamic>, snap.id);
|
||||
return s;
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
@@ -4,16 +4,15 @@ import 'package:fcs/domain/constants.dart';
|
||||
import 'package:fcs/domain/entities/invoice.dart';
|
||||
import 'package:fcs/domain/entities/payment.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/localization/app_translations.dart';
|
||||
import 'package:fcs/pages/invoice/model/invoice_model.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/widgets/img_picker.dart';
|
||||
import 'package:fcs/pages/widgets/input_text.dart';
|
||||
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
||||
import 'package:fcs/pages/widgets/local_button.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/local_title.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
@@ -51,8 +50,9 @@ class _PaymentPageState extends State<PaymentPage> {
|
||||
InvoiceModel invoiceModel =
|
||||
Provider.of<InvoiceModel>(context, listen: false);
|
||||
Invoice? i = await invoiceModel.getInvoice(_invoice.id!);
|
||||
if (i == null) return;
|
||||
setState(() {
|
||||
_invoice = i!;
|
||||
_invoice = i;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -90,15 +90,11 @@ class _PaymentPageState extends State<PaymentPage> {
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(CupertinoIcons.back),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
title: Text(AppTranslations.of(context)!.text("pm_.title")),
|
||||
),
|
||||
appBar: LocalAppBar(
|
||||
labelKey: 'pm_.title',
|
||||
backgroundColor: Colors.white,
|
||||
labelColor: primaryColor,
|
||||
arrowColor: primaryColor),
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
children: <Widget>[
|
||||
|
||||
@@ -17,7 +17,11 @@ Widget getInvoiceStatus(BuildContext context, Invoice invoice) {
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: Chip(label: Text(invoice.status ?? "")),
|
||||
child: Chip(
|
||||
shape: const StadiumBorder(
|
||||
side: BorderSide(color: Colors.transparent)),
|
||||
backgroundColor: Colors.grey.withOpacity(0.3),
|
||||
label: Text(invoice.status ?? "")),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -344,32 +344,29 @@ Widget fcsButton(BuildContext context, String text,
|
||||
|
||||
return Container(
|
||||
padding: EdgeInsets.only(left: 10, right: 10, top: 10),
|
||||
child: Container(
|
||||
child: SizedBox(
|
||||
height: 45.0,
|
||||
decoration: BoxDecoration(
|
||||
color: primaryColor,
|
||||
shape: BoxShape.rectangle,
|
||||
),
|
||||
child: ButtonTheme(
|
||||
minWidth: 900.0,
|
||||
height: 100.0,
|
||||
child: TextButton(
|
||||
onPressed: callack == null ? null : () => callack(),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
iconData == null
|
||||
? Container()
|
||||
: Icon(
|
||||
iconData,
|
||||
color: Colors.white,
|
||||
),
|
||||
SizedBox(
|
||||
width: 15,
|
||||
),
|
||||
Text(text, style: style),
|
||||
],
|
||||
),
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
elevation: 0,
|
||||
backgroundColor: primaryColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(3)))),
|
||||
onPressed: callack == null ? null : () => callack(),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
iconData == null
|
||||
? Container()
|
||||
: Icon(
|
||||
iconData,
|
||||
color: Colors.white,
|
||||
),
|
||||
SizedBox(
|
||||
width: 15,
|
||||
),
|
||||
Text(text, style: style),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -6,7 +6,6 @@ import 'package:fcs/pages/widgets/input_text.dart';
|
||||
import 'package:fcs/pages/widgets/local_app_bar.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';
|
||||
|
||||
|
||||
@@ -21,30 +21,21 @@ class PackageModel extends BaseModel {
|
||||
PaginatorListener<Package>? activePackages;
|
||||
|
||||
bool isLoading = false;
|
||||
int _menuSelectedIndex = 1;
|
||||
int selectedIndex = 1;
|
||||
|
||||
set menuSelectedIndex(int index) {
|
||||
_menuSelectedIndex = index;
|
||||
|
||||
_loadPaginationPackages(_menuSelectedIndex == 2);
|
||||
_loadPaginationCustomerPackages(_menuSelectedIndex == 2);
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
int get menuSelectedIndex => _menuSelectedIndex;
|
||||
|
||||
void privilegeChanged() {
|
||||
if (user != null) {
|
||||
_initData();
|
||||
initData(int index, bool isCustomer) {
|
||||
selectedIndex = index;
|
||||
if (isCustomer) {
|
||||
_loadPaginationCustomerPackages(selectedIndex == 2);
|
||||
} else {
|
||||
_loadPaginationPackages(selectedIndex == 2);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _initData() async {
|
||||
_menuSelectedIndex = 1;
|
||||
_loadPaginationPackages(_menuSelectedIndex == 2);
|
||||
_loadPaginationCustomerPackages(_menuSelectedIndex == 2);
|
||||
_loadPaginationActivePackages();
|
||||
void privilegeChanged() {
|
||||
if (user != null) {
|
||||
_loadPaginationActivePackages();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -54,6 +45,16 @@ class PackageModel extends BaseModel {
|
||||
if (activePackages != null) activePackages!.close();
|
||||
}
|
||||
|
||||
onChanged(int index, bool isCustomer) {
|
||||
selectedIndex = index;
|
||||
if (isCustomer) {
|
||||
_loadPaginationCustomerPackages(selectedIndex == 2);
|
||||
} else {
|
||||
_loadPaginationPackages(selectedIndex == 2);
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
_loadPaginationPackages(bool isDelivered) {
|
||||
if (user == null) return;
|
||||
if (!((user!.hasPackages() ||
|
||||
@@ -78,7 +79,6 @@ class PackageModel extends BaseModel {
|
||||
_loadPaginationCustomerPackages(bool isDelivered) {
|
||||
if (user == null) return;
|
||||
String path = "/$packages_collection";
|
||||
|
||||
Query col = FirebaseFirestore.instance
|
||||
.collection(path)
|
||||
.where("is_delivered", isEqualTo: isDelivered)
|
||||
|
||||
@@ -23,12 +23,24 @@ class PackageList extends StatefulWidget {
|
||||
|
||||
class _PackageListState extends State<PackageList> {
|
||||
bool _isLoading = false;
|
||||
int _selectedIndex = 1;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_init();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
_init() {
|
||||
var model = context.read<PackageModel>();
|
||||
_selectedIndex = model.selectedIndex;
|
||||
model.initData(_selectedIndex, widget.forCustomer);
|
||||
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var packageModel = Provider.of<PackageModel>(context);
|
||||
@@ -37,20 +49,24 @@ class _PackageListState extends State<PackageList> {
|
||||
: packageModel.packages;
|
||||
|
||||
final popupMenu = LocalPopupMenuButton(
|
||||
popmenus: [
|
||||
LocalPopupMenu(
|
||||
id: 1,
|
||||
textKey: "package.popupmenu.active",
|
||||
selected: packageModel.menuSelectedIndex == 1),
|
||||
LocalPopupMenu(
|
||||
id: 2,
|
||||
textKey: "package.popupmenu.delivered",
|
||||
selected: packageModel.menuSelectedIndex == 2)
|
||||
],
|
||||
popupMenuCallback: (p) => this.setState(() {
|
||||
packageModel.menuSelectedIndex = p.id;
|
||||
}),
|
||||
);
|
||||
popmenus: [
|
||||
LocalPopupMenu(
|
||||
id: 1,
|
||||
textKey: "package.popupmenu.active",
|
||||
selected: packageModel.selectedIndex == 1),
|
||||
LocalPopupMenu(
|
||||
id: 2,
|
||||
textKey: "package.popupmenu.delivered",
|
||||
selected: packageModel.selectedIndex == 2)
|
||||
],
|
||||
popupMenuCallback: (p) {
|
||||
this.setState(() {
|
||||
_selectedIndex = p.id;
|
||||
});
|
||||
context
|
||||
.read<PackageModel>()
|
||||
.onChanged(_selectedIndex, widget.forCustomer);
|
||||
});
|
||||
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:fcs/domain/entities/custom_duty.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_icons_null_safety/flutter_icons_null_safety.dart';
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import 'package:fcs/pages/main/model/main_model.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/widgets/local_app_bar.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:flutter/services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../helpers/theme.dart';
|
||||
@@ -29,14 +28,7 @@ class _RequestInvitationPageState extends State<RequestInvitationPage> {
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: new Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(CupertinoIcons.back),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
),
|
||||
appBar: LocalAppBar(),
|
||||
body: _buildBody(context),
|
||||
),
|
||||
);
|
||||
@@ -91,6 +83,11 @@ class _RequestInvitationPageState extends State<RequestInvitationPage> {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(3))),
|
||||
backgroundColor: primaryColor),
|
||||
onPressed: _request,
|
||||
child: Text(getLocalString(context, "invite.request")),
|
||||
)
|
||||
|
||||
@@ -4,7 +4,6 @@ import 'package:fcs/pages/main/model/main_model.dart';
|
||||
import 'package:fcs/pages/signin/invitation_request_page.dart';
|
||||
import 'package:fcs/pages/signin/signup_page.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
navigateAfterAuthVerified(BuildContext context) async {
|
||||
|
||||
@@ -3,11 +3,11 @@ import 'package:fcs/domain/entities/auth_result.dart';
|
||||
import 'package:fcs/domain/entities/auth_status.dart';
|
||||
import 'package:fcs/pages/main/model/main_model.dart';
|
||||
import 'package:fcs/pages/signin/signin_logic.dart';
|
||||
import 'package:fcs/pages/widgets/local_app_bar.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:flutter/services.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
@@ -40,17 +40,7 @@ class _SigninPageState extends State<SigninPage> {
|
||||
Widget build(BuildContext context) {
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: new Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(CupertinoIcons.back),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
),
|
||||
body: _buildLogin(context),
|
||||
),
|
||||
child: new Scaffold(appBar: LocalAppBar(), body: _buildLogin(context)),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import 'package:fcs/pages/main/model/main_model.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/widgets/local_app_bar.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:flutter/services.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
@@ -30,16 +29,7 @@ class _SignupPageState extends State<SignupPage> {
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: new Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(
|
||||
CupertinoIcons.back,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
),
|
||||
appBar: LocalAppBar(),
|
||||
body: _buildBody(context),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -5,9 +5,9 @@ import 'package:fcs/domain/entities/auth_status.dart';
|
||||
import 'package:fcs/pages/main/model/main_model.dart';
|
||||
import 'package:fcs/pages/signin/signin_logic.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/widgets/local_app_bar.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:pin_input_text_field/pin_input_text_field.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -67,14 +67,7 @@ class _SmsCodePageState extends State<SmsCodePage> {
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(CupertinoIcons.back),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
),
|
||||
appBar: LocalAppBar(),
|
||||
body: ListView(
|
||||
padding: EdgeInsets.only(top: 5, left: 5, right: 5),
|
||||
children: <Widget>[
|
||||
@@ -129,29 +122,21 @@ class _SmsCodePageState extends State<SmsCodePage> {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
canResend ? Colors.white : Colors.grey,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
side: BorderSide(
|
||||
color: canResend
|
||||
? primaryColor
|
||||
: Colors.grey.shade400))),
|
||||
onPressed: canResend ? _resend : null,
|
||||
// color: canResend ? Colors.white : Colors.grey,
|
||||
child: LocalText(context, 'sms.resend',
|
||||
fontSize: 16,
|
||||
color: canResend
|
||||
? primaryColor
|
||||
: Colors.grey.shade400),
|
||||
// shape: RoundedRectangleBorder(
|
||||
// borderRadius: BorderRadius.circular(10.0),
|
||||
// side: BorderSide(
|
||||
// color: canResend
|
||||
// ? primaryColor
|
||||
// : Colors.grey.shade400)),
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
canResend ? Colors.white : Colors.grey,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
side: BorderSide(
|
||||
color: canResend
|
||||
? primaryColor
|
||||
: Colors.grey.shade400))),
|
||||
onPressed: canResend ? _resend : null,
|
||||
child: LocalText(context, 'sms.resend',
|
||||
fontSize: 16,
|
||||
color: canResend
|
||||
? primaryColor
|
||||
: Colors.grey.shade400)),
|
||||
InkWell(
|
||||
onTap: allNumberEntered ? _verify : null,
|
||||
child: CircleAvatar(
|
||||
@@ -220,19 +205,4 @@ class _SmsCodePageState extends State<SmsCodePage> {
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
_completeResend() {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
_start = resend_count_sec;
|
||||
canResend = false;
|
||||
startTimer();
|
||||
});
|
||||
}
|
||||
|
||||
_completeVerify() {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import 'dart:io';
|
||||
import 'package:fcs/helpers/cache_mgr.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_pdfview/flutter_pdfview.dart';
|
||||
import 'package:share/share.dart';
|
||||
@@ -54,17 +54,12 @@ class _PDFScreenState extends State<PDFScreen> with WidgetsBindingObserver {
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
appBar: LocalAppBar(
|
||||
backgroundColor: Colors.white,
|
||||
shadowColor: Colors.transparent,
|
||||
title:
|
||||
Text(widget.title ?? "", style: TextStyle(color: primaryColor)),
|
||||
leading: new IconButton(
|
||||
icon: new Icon(CupertinoIcons.back, color: primaryColor),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
actions: <Widget>[
|
||||
arrowColor: primaryColor,
|
||||
titleWidget: Text(widget.title ?? "",
|
||||
style: TextStyle(color: primaryColor, fontSize: 20)),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
Icons.share,
|
||||
@@ -89,7 +84,7 @@ class _PDFScreenState extends State<PDFScreen> with WidgetsBindingObserver {
|
||||
fitPolicy: FitPolicy.BOTH,
|
||||
preventLinkNavigation:
|
||||
false, // if set to true the link is handled in flutter
|
||||
onRender: (int?_pages) {
|
||||
onRender: (int? _pages) {
|
||||
print(('pages => $pages'));
|
||||
setState(() {
|
||||
pages = _pages!;
|
||||
|
||||
Reference in New Issue
Block a user