Dashboard
This commit is contained in:
parent
0820d09eab
commit
c2cd649c38
|
|
@ -35,8 +35,24 @@ class BaseItemResponse extends Object with _$BaseItemResponseSerializerMixin {
|
|||
class DashboardEntity extends Object with _$DashboardEntitySerializerMixin {
|
||||
|
||||
double paidToDate;
|
||||
int paidToDateCurrency;
|
||||
double balances;
|
||||
int balancesCurrency;
|
||||
double averageInvoice;
|
||||
int averageInvoiceCurrency;
|
||||
int invoicesSent;
|
||||
int activeClients;
|
||||
|
||||
DashboardEntity([this.paidToDate]);
|
||||
DashboardEntity([
|
||||
this.paidToDate,
|
||||
this.paidToDateCurrency,
|
||||
this.balances,
|
||||
this.balancesCurrency,
|
||||
this.averageInvoice,
|
||||
this.averageInvoiceCurrency,
|
||||
this.invoicesSent,
|
||||
this.activeClients,
|
||||
]);
|
||||
|
||||
factory DashboardEntity.fromJson(Map<String, dynamic> json) => _$DashboardEntityFromJson(json);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,11 +23,35 @@ abstract class _$BaseItemResponseSerializerMixin {
|
|||
}
|
||||
|
||||
DashboardEntity _$DashboardEntityFromJson(Map<String, dynamic> json) =>
|
||||
new DashboardEntity((json['paidToDate'] as num)?.toDouble());
|
||||
new DashboardEntity(
|
||||
(json['paidToDate'] as num)?.toDouble(),
|
||||
json['paidToDateCurrency'] as int,
|
||||
(json['balances'] as num)?.toDouble(),
|
||||
json['balancesCurrency'] as int,
|
||||
(json['averageInvoice'] as num)?.toDouble(),
|
||||
json['averageInvoiceCurrency'] as int,
|
||||
json['invoicesSent'] as int,
|
||||
json['activeClients'] as int);
|
||||
|
||||
abstract class _$DashboardEntitySerializerMixin {
|
||||
double get paidToDate;
|
||||
Map<String, dynamic> toJson() => <String, dynamic>{'paidToDate': paidToDate};
|
||||
int get paidToDateCurrency;
|
||||
double get balances;
|
||||
int get balancesCurrency;
|
||||
double get averageInvoice;
|
||||
int get averageInvoiceCurrency;
|
||||
int get invoicesSent;
|
||||
int get activeClients;
|
||||
Map<String, dynamic> toJson() => <String, dynamic>{
|
||||
'paidToDate': paidToDate,
|
||||
'paidToDateCurrency': paidToDateCurrency,
|
||||
'balances': balances,
|
||||
'balancesCurrency': balancesCurrency,
|
||||
'averageInvoice': averageInvoice,
|
||||
'averageInvoiceCurrency': averageInvoiceCurrency,
|
||||
'invoicesSent': invoicesSent,
|
||||
'activeClients': activeClients
|
||||
};
|
||||
}
|
||||
|
||||
ProductEntity _$ProductEntityFromJson(Map<String, dynamic> json) =>
|
||||
|
|
|
|||
|
|
@ -15,15 +15,45 @@ class DashboardPanels extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print('building...');
|
||||
return AppLoading(builder: (context, loading) {
|
||||
return loading
|
||||
? LoadingIndicator(key: NinjaKeys.productsLoading)
|
||||
: _buildPanels();
|
||||
});
|
||||
return ListView(
|
||||
padding: EdgeInsets.only(left: 12.0, right: 12.0, top: 20.0),
|
||||
children: <Widget>[
|
||||
DashboardPanel(
|
||||
'Total Revenue', Icons.credit_card, this.dashboard.paidToDate),
|
||||
DashboardPanel(
|
||||
'Average Invoice', Icons.email, this.dashboard.averageInvoice),
|
||||
DashboardPanel(
|
||||
'Outstanding', Icons.schedule, this.dashboard.balances),
|
||||
DashboardPanel(
|
||||
'Invoices Sent', Icons.send, this.dashboard.invoicesSent, false),
|
||||
DashboardPanel(
|
||||
'Active Clients', Icons.people, this.dashboard.activeClients, false),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Text _buildPanels() {
|
||||
return Text('Paid to Date: ' + dashboard.paidToDate.toString());
|
||||
class DashboardPanel extends StatelessWidget {
|
||||
DashboardPanel(this.title, this.icon, this.amount, [this.isMoney = true]);
|
||||
|
||||
final String title;
|
||||
final IconData icon;
|
||||
final num amount;
|
||||
final bool isMoney;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
ListTile(
|
||||
leading: Icon(this.icon),
|
||||
title: Text(this.title),
|
||||
trailing: Text(this.amount.toStringAsFixed(this.isMoney ? 2 : 0)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue