Dashboard..
This commit is contained in:
parent
8232aed318
commit
0820d09eab
|
|
@ -29,8 +29,6 @@ class DashboardRepositoryFlutter implements BaseRepository {
|
|||
auth.url + '/dashboard', auth.token);
|
||||
|
||||
//fileStorage.saveDashboard(products);
|
||||
print('== LOAD DASHBOARD ==');
|
||||
print(data);
|
||||
|
||||
return DashboardEntity.fromJson(data);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
import 'package:redux/redux.dart';
|
||||
import 'package:invoiceninja/redux/dashboard/dashboard_actions.dart';
|
||||
import 'package:invoiceninja/redux/product/product_actions.dart';
|
||||
|
||||
final loadingReducer = combineReducers<bool>([
|
||||
TypedReducer<bool, DashboardLoadedAction>(_setLoaded),
|
||||
TypedReducer<bool, DashboardNotLoadedAction>(_setLoaded),
|
||||
TypedReducer<bool, ProductsLoadedAction>(_setLoaded),
|
||||
TypedReducer<bool, ProductsNotLoadedAction>(_setLoaded),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:invoiceninja/keys.dart';
|
||||
import 'package:invoiceninja/ui/app/sidebar.dart';
|
||||
import 'package:invoiceninja/ui/dashboard/dashboard_vm.dart';
|
||||
|
||||
class Dashboard extends StatelessWidget {
|
||||
Dashboard() : super(key: NinjaKeys.dashboard);
|
||||
|
|
@ -12,6 +13,8 @@ class Dashboard extends StatelessWidget {
|
|||
title: Text('Dashboard'),
|
||||
),
|
||||
drawer: Sidebar(),
|
||||
body: DashboardVM(),
|
||||
/*
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
Card(
|
||||
|
|
@ -29,6 +32,7 @@ class Dashboard extends StatelessWidget {
|
|||
),
|
||||
],
|
||||
),
|
||||
*/
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:invoiceninja/ui/app/app_loading.dart';
|
||||
import 'package:invoiceninja/data/models/models.dart';
|
||||
import 'package:invoiceninja/ui/app/loading_indicator.dart';
|
||||
import 'package:invoiceninja/keys.dart';
|
||||
|
||||
class DashboardPanels extends StatelessWidget {
|
||||
final DashboardEntity dashboard;
|
||||
|
||||
DashboardPanels({
|
||||
Key key,
|
||||
@required this.dashboard,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print('building...');
|
||||
return AppLoading(builder: (context, loading) {
|
||||
return loading
|
||||
? LoadingIndicator(key: NinjaKeys.productsLoading)
|
||||
: _buildPanels();
|
||||
});
|
||||
}
|
||||
|
||||
Text _buildPanels() {
|
||||
return Text('Paid to Date: ' + dashboard.paidToDate.toString());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
import 'package:invoiceninja/redux/dashboard/dashboard_actions.dart';
|
||||
import 'package:invoiceninja/data/models/models.dart';
|
||||
import 'package:invoiceninja/ui/dashboard/dashboard_panels.dart';
|
||||
import 'package:invoiceninja/redux/app/app_state.dart';
|
||||
|
||||
class DashboardVM extends StatelessWidget {
|
||||
DashboardVM({Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return StoreConnector<AppState, _ViewModel>(
|
||||
converter: _ViewModel.fromStore,
|
||||
builder: (context, vm) {
|
||||
return DashboardPanels(
|
||||
dashboard: vm.dashboard,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ViewModel {
|
||||
final DashboardEntity dashboard;
|
||||
final bool loading;
|
||||
|
||||
_ViewModel({
|
||||
@required this.dashboard,
|
||||
@required this.loading,
|
||||
});
|
||||
|
||||
static _ViewModel fromStore(Store<AppState> store) {
|
||||
return _ViewModel(
|
||||
dashboard: store.state.dashboard,
|
||||
loading: store.state.isLoading,
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue