Spinner class. Fire notifications loading

This commit is contained in:
Vicente J. Ruiz Jurado 2018-08-13 07:23:18 +02:00
parent fa63734ff2
commit 4ff9d995e7
4 changed files with 25 additions and 8 deletions

View file

@ -17,6 +17,7 @@ import 'mainDrawer.dart';
import 'models/appState.dart';
import 'placesAutocompleteUtils.dart';
import 'redux/actions.dart';
import 'firesSpinner.dart';
@immutable
class _ViewModel {
@ -217,7 +218,7 @@ class _ActiveFiresPageState extends State<ActiveFiresPage> {
FloatingActionButtonLocation.centerFloat,
bottomNavigationBar: new GlobalFiresBottomStats(),
body: view.isLoading
? new SpinKitPulse(color: fires600)
? new FiresSpinner()
: hasLocations
? new Stack(children: <Widget>[
new RefreshIndicator(

View file

@ -13,9 +13,11 @@ import 'genericMap.dart';
import 'mainDrawer.dart';
import 'models/appState.dart';
import 'redux/actions.dart';
import 'firesSpinner.dart';
@immutable
class _ViewModel {
final bool isLoaded;
final List<FireNotification> fireNotifications;
final int fireNotificationsUnread;
final List<YourLocation> yourLocations;
@ -24,7 +26,8 @@ class _ViewModel {
final DeleteAllFireNotificationFunction onDeleteAll;
_ViewModel(
{@required this.onTap,
{@required this.isLoaded,
@required this.onTap,
@required this.onDelete,
@required this.onDeleteAll,
@required this.fireNotifications,
@ -36,12 +39,14 @@ class _ViewModel {
identical(this, other) ||
other is _ViewModel &&
runtimeType == other.runtimeType &&
isLoaded == other.isLoaded &&
fireNotifications == other.fireNotifications &&
fireNotificationsUnread == other.fireNotificationsUnread &&
yourLocations == other.yourLocations;
@override
int get hashCode =>
isLoaded.hashCode ^
fireNotifications.hashCode ^
fireNotificationsUnread.hashCode ^
yourLocations.hashCode;
@ -144,8 +149,10 @@ class _FireNotificationListState extends State<FireNotificationList> {
return new StoreConnector<AppState, _ViewModel>(
distinct: true,
converter: (store) {
print('New ViewModel of Fires Notifications (unread: ${store.state.fireNotificationsUnread})');
print('New ViewModel of Fires Notifications (unread: ${store.state
.fireNotificationsUnread})');
return new _ViewModel(
isLoaded: store.state.isLoaded,
onDeleteAll: () {
store.dispatch(new DeleteAllFireNotificationAction());
},
@ -179,8 +186,7 @@ class _FireNotificationListState extends State<FireNotificationList> {
return Scaffold(
key: _scaffoldKey,
drawer: new MainDrawer(context, FireNotificationList.routeName),
drawer: new MainDrawer(context, FireNotificationList.routeName),
appBar: new AppBar(
title: Text(title),
leading: IconButton(
@ -196,7 +202,7 @@ class _FireNotificationListState extends State<FireNotificationList> {
onPressed: () => _showConfirmDialog(view))
: null
])),
body: !hasFireNotifications
body: !view.isLoaded ? new FiresSpinner() : !hasFireNotifications
? Padding(
padding: const EdgeInsets.all(20.0),
child: new Card(

10
lib/firesSpinner.dart Normal file
View file

@ -0,0 +1,10 @@
import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'colors.dart';
class FiresSpinner extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new SpinKitPulse(color: fires600);
}
}

View file

@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:latlong/latlong.dart';
import 'colors.dart';
@ -9,6 +8,7 @@ import 'customBottomAppBar.dart';
import 'generated/i18n.dart';
import 'mainDrawer.dart';
import 'models/appState.dart';
import 'firesSpinner.dart';
class _ViewModel {
List<Polyline> monitoredAreas;
@ -61,7 +61,7 @@ class MonitoredAreasPage extends StatelessWidget {
])))
]),
body: !(view.monitoredAreas is List)
? new SpinKitPulse(color: fires600)
? new FiresSpinner()
: new Padding(
padding: new EdgeInsets.all(10.0),
child: new Column(