Fix loading spinners

This commit is contained in:
Hillel Coren 2019-09-23 20:57:42 +03:00
parent 00334fa91d
commit afde837684
11 changed files with 19 additions and 15 deletions

View File

@ -278,8 +278,8 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
@override @override
String toString() { String toString() {
//return 'Settings: ${selectedCompanyState.company.settings}'; //return 'Settings: ${selectedCompanyState.company.settings}';
return 'URL: ${authState.url}, ${selectedCompany.plan}'; //return 'URL: ${authState.url}, ${selectedCompany.plan}';
//return 'Is Testing: ${uiState.isTesting}'; return 'Is Loading: $isLoading';
//return 'Route: ${uiState.currentRoute}, Previous: ${uiState.previousRoute}, Layout: ${uiState.layout}, Menu: ${uiState.isMenuVisible}, History: ${uiState.isHistoryVisible}'; //return 'Route: ${uiState.currentRoute}, Previous: ${uiState.previousRoute}, Layout: ${uiState.layout}, Menu: ${uiState.isMenuVisible}, History: ${uiState.isHistoryVisible}';
} }
} }

View File

@ -20,7 +20,7 @@ class ClientList extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (!viewModel.isLoaded) { if (!viewModel.isLoaded) {
return LoadingIndicator(); return viewModel.isLoading ? LoadingIndicator() : SizedBox();
} else if (viewModel.clientList.isEmpty) { } else if (viewModel.clientList.isEmpty) {
return HelpText(AppLocalization.of(context).noRecordsFound); return HelpText(AppLocalization.of(context).noRecordsFound);
} }

View File

@ -121,14 +121,18 @@ class DashboardPanels extends StatelessWidget {
List<ChartDataGroup> currentData, List<ChartDataGroup> currentData,
List<ChartDataGroup> previousData, List<ChartDataGroup> previousData,
bool isLoaded}) { bool isLoaded}) {
if (!isLoaded) {
return LoadingIndicator(useCard: true);
}
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final settings = viewModel.dashboardUIState; final settings = viewModel.dashboardUIState;
final state = viewModel.state; final state = viewModel.state;
if (!isLoaded) {
if (state.isLoading) {
return LoadingIndicator(useCard: true);
} else {
return SizedBox();
}
}
currentData.forEach((dataGroup) { currentData.forEach((dataGroup) {
final index = currentData.indexOf(dataGroup); final index = currentData.indexOf(dataGroup);
dataGroup.chartSeries = <Series<dynamic, DateTime>>[ dataGroup.chartSeries = <Series<dynamic, DateTime>>[

View File

@ -68,7 +68,7 @@ class ExpenseList extends StatelessWidget {
widgets.add(Expanded( widgets.add(Expanded(
child: !viewModel.isLoaded child: !viewModel.isLoaded
? LoadingIndicator() ? (viewModel.isLoading ? LoadingIndicator() : SizedBox())
: RefreshIndicator( : RefreshIndicator(
onRefresh: () => viewModel.onRefreshed(context), onRefresh: () => viewModel.onRefreshed(context),
child: viewModel.expenseList.isEmpty child: viewModel.expenseList.isEmpty

View File

@ -64,7 +64,7 @@ class InvoiceList extends StatelessWidget {
: Container(), : Container(),
Expanded( Expanded(
child: !viewModel.isLoaded child: !viewModel.isLoaded
? LoadingIndicator() ? (viewModel.isLoading ? LoadingIndicator() : SizedBox())
: RefreshIndicator( : RefreshIndicator(
onRefresh: () => viewModel.onRefreshed(context), onRefresh: () => viewModel.onRefreshed(context),
child: viewModel.invoiceList.isEmpty child: viewModel.invoiceList.isEmpty

View File

@ -76,7 +76,7 @@ class PaymentList extends StatelessWidget {
: Container(), : Container(),
Expanded( Expanded(
child: !viewModel.isLoaded child: !viewModel.isLoaded
? LoadingIndicator() ? (viewModel.isLoading ? LoadingIndicator() : SizedBox())
: RefreshIndicator( : RefreshIndicator(
onRefresh: () => viewModel.onRefreshed(context), onRefresh: () => viewModel.onRefreshed(context),
child: viewModel.paymentList.isEmpty child: viewModel.paymentList.isEmpty

View File

@ -20,7 +20,7 @@ class ProductList extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (!viewModel.isLoaded) { if (!viewModel.isLoaded) {
return LoadingIndicator(); return viewModel.isLoading ? LoadingIndicator() : SizedBox();
} else if (viewModel.productList.isEmpty) { } else if (viewModel.productList.isEmpty) {
return HelpText(AppLocalization.of(context).noRecordsFound); return HelpText(AppLocalization.of(context).noRecordsFound);
} }

View File

@ -59,7 +59,7 @@ class ProjectList extends StatelessWidget {
: Container(), : Container(),
Expanded( Expanded(
child: !viewModel.isLoaded child: !viewModel.isLoaded
? LoadingIndicator() ? (viewModel.isLoading ? LoadingIndicator() : SizedBox())
: RefreshIndicator( : RefreshIndicator(
onRefresh: () => viewModel.onRefreshed(context), onRefresh: () => viewModel.onRefreshed(context),
child: viewModel.projectList.isEmpty child: viewModel.projectList.isEmpty

View File

@ -71,7 +71,7 @@ class TaskList extends StatelessWidget {
: Container(), : Container(),
Expanded( Expanded(
child: !viewModel.isLoaded child: !viewModel.isLoaded
? LoadingIndicator() ? (viewModel.isLoading ? LoadingIndicator() : SizedBox())
: RefreshIndicator( : RefreshIndicator(
onRefresh: () => viewModel.onRefreshed(context), onRefresh: () => viewModel.onRefreshed(context),
child: viewModel.taskList.isEmpty child: viewModel.taskList.isEmpty

View File

@ -23,7 +23,7 @@ class VendorList extends StatelessWidget {
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
child: !viewModel.isLoaded child: !viewModel.isLoaded
? LoadingIndicator() ? (viewModel.isLoading ? LoadingIndicator() : SizedBox())
: RefreshIndicator( : RefreshIndicator(
onRefresh: () => viewModel.onRefreshed(context), onRefresh: () => viewModel.onRefreshed(context),
child: viewModel.vendorList.isEmpty child: viewModel.vendorList.isEmpty

View File

@ -33,7 +33,7 @@ class StubList extends StatelessWidget {
Expanded( Expanded(
child: !viewModel.isLoaded child: !viewModel.isLoaded
? LoadingIndicator() ? (viewModel.isLoading ? LoadingIndicator() : SizedBox())
: RefreshIndicator( : RefreshIndicator(
onRefresh: () => viewModel.onRefreshed(context), onRefresh: () => viewModel.onRefreshed(context),
child: viewModel.stubList.isEmpty child: viewModel.stubList.isEmpty