Remove statefull. Disting view correct equal operators
This commit is contained in:
parent
646eeb29ca
commit
de340c0664
3 changed files with 22 additions and 55 deletions
|
|
@ -37,34 +37,20 @@ class _ViewModel {
|
||||||
identical(this, other) ||
|
identical(this, other) ||
|
||||||
other is _ViewModel &&
|
other is _ViewModel &&
|
||||||
runtimeType == other.runtimeType &&
|
runtimeType == other.runtimeType &&
|
||||||
yourLocations == other.yourLocations &&
|
yourLocations == other.yourLocations ;
|
||||||
onAdd == other.onAdd &&
|
|
||||||
onDelete == other.onDelete &&
|
|
||||||
onToggleSubs == other.onToggleSubs &&
|
|
||||||
onTap == other.onTap;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode =>
|
int get hashCode =>
|
||||||
yourLocations.hashCode ^
|
yourLocations.hashCode;
|
||||||
onAdd.hashCode ^
|
|
||||||
onDelete.hashCode ^
|
|
||||||
onToggleSubs.hashCode ^
|
|
||||||
onTap.hashCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ActiveFiresPage extends StatefulWidget {
|
class ActiveFiresPage extends StatelessWidget {
|
||||||
static const String routeName = '/fires';
|
static const String routeName = '/fires';
|
||||||
|
|
||||||
ActiveFiresPage();
|
|
||||||
|
|
||||||
@override
|
|
||||||
_ActiveFiresPageState createState() => _ActiveFiresPageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ActiveFiresPageState extends State<ActiveFiresPage> {
|
|
||||||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
List<FabMiniMenuItem> _fabMiniMenuItemList(AddYourLocationFunction onAdd) {
|
List<FabMiniMenuItem> _fabMiniMenuItemList(
|
||||||
|
BuildContext context, AddYourLocationFunction onAdd) {
|
||||||
return [
|
return [
|
||||||
new FabMiniMenuItem.withText(
|
new FabMiniMenuItem.withText(
|
||||||
new Icon(Icons.location_searching),
|
new Icon(Icons.location_searching),
|
||||||
|
|
@ -85,9 +71,7 @@ class _ActiveFiresPageState extends State<ActiveFiresPage> {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
_ActiveFiresPageState();
|
Widget _buildRow(BuildContext context, YourLocation loc, onToggle, onTap) {
|
||||||
|
|
||||||
Widget _buildRow(YourLocation loc, onToggle, onTap) {
|
|
||||||
return new ListTile(
|
return new ListTile(
|
||||||
dense: true,
|
dense: true,
|
||||||
leading: const Icon(Icons.location_on),
|
leading: const Icon(Icons.location_on),
|
||||||
|
|
@ -115,16 +99,18 @@ class _ActiveFiresPageState extends State<ActiveFiresPage> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildSavedLocations(
|
Widget _buildSavedLocations(
|
||||||
List<YourLocation> yl, onDeleted, onToggle, onTap) {
|
BuildContext context, List<YourLocation> yl, onDeleted, onToggle, onTap) {
|
||||||
return new ListView.builder(
|
return new ListView.builder(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
itemCount: yl.length,
|
itemCount: yl.length,
|
||||||
itemBuilder: (BuildContext _context, int i) {
|
itemBuilder: (BuildContext _context, int i) {
|
||||||
return _buildItem(yl.elementAt(i), onDeleted, onToggle, onTap);
|
return _buildItem(
|
||||||
|
context, yl.elementAt(i), onDeleted, onToggle, onTap);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildItem(YourLocation item, onDelete, onToggle, onTap) {
|
Widget _buildItem(
|
||||||
|
BuildContext context, YourLocation item, onDelete, onToggle, onTap) {
|
||||||
final ThemeData theme = Theme.of(context);
|
final ThemeData theme = Theme.of(context);
|
||||||
return new Dismissible(
|
return new Dismissible(
|
||||||
key: new ObjectKey(item),
|
key: new ObjectKey(item),
|
||||||
|
|
@ -147,13 +133,13 @@ class _ActiveFiresPageState extends State<ActiveFiresPage> {
|
||||||
color: theme.canvasColor,
|
color: theme.canvasColor,
|
||||||
border: new Border(
|
border: new Border(
|
||||||
bottom: new BorderSide(color: theme.dividerColor))),
|
bottom: new BorderSide(color: theme.dividerColor))),
|
||||||
child: _buildRow(item, onToggle, onTap)));
|
child: _buildRow(context, item, onToggle, onTap)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return new StoreConnector<AppState, _ViewModel>(
|
return new StoreConnector<AppState, _ViewModel>(
|
||||||
distinct: false, // FIXME
|
distinct: true,
|
||||||
converter: (store) {
|
converter: (store) {
|
||||||
return new _ViewModel(
|
return new _ViewModel(
|
||||||
onAdd: (loc) {
|
onAdd: (loc) {
|
||||||
|
|
@ -211,10 +197,10 @@ class _ActiveFiresPageState extends State<ActiveFiresPage> {
|
||||||
bottomNavigationBar: new GlobalFiresBottomStats(),
|
bottomNavigationBar: new GlobalFiresBottomStats(),
|
||||||
body: hasLocations
|
body: hasLocations
|
||||||
? new Stack(children: <Widget>[
|
? new Stack(children: <Widget>[
|
||||||
_buildSavedLocations(view.yourLocations, view.onDelete,
|
_buildSavedLocations(context, view.yourLocations,
|
||||||
view.onToggleSubs, view.onTap),
|
view.onDelete, view.onToggleSubs, view.onTap),
|
||||||
new FabDialer(_fabMiniMenuItemList(view.onAdd), fires600,
|
new FabDialer(_fabMiniMenuItemList(context, view.onAdd),
|
||||||
new Icon(Icons.add))
|
fires600, new Icon(Icons.add))
|
||||||
])
|
])
|
||||||
: new Center(
|
: new Center(
|
||||||
child: new CenteredColumn(children: <Widget>[
|
child: new CenteredColumn(children: <Widget>[
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import 'package:redux/redux.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
globals.isDevelopment = true;
|
globals.isDevelopment = true;
|
||||||
var logRedux = true;
|
var logRedux = false;
|
||||||
|
|
||||||
List<Middleware> devMiddlewares = logRedux ? [
|
List<Middleware> devMiddlewares = logRedux ? [
|
||||||
LoggingMiddleware.printer(formatter: LoggingMiddleware.multiLineFormatter)
|
LoggingMiddleware.printer(formatter: LoggingMiddleware.multiLineFormatter)
|
||||||
|
|
|
||||||
|
|
@ -43,39 +43,20 @@ class _ViewModel {
|
||||||
identical(this, other) ||
|
identical(this, other) ||
|
||||||
other is _ViewModel &&
|
other is _ViewModel &&
|
||||||
runtimeType == other.runtimeType &&
|
runtimeType == other.runtimeType &&
|
||||||
mapState == other.mapState &&
|
mapState == other.mapState;
|
||||||
onSubs == other.onSubs &&
|
|
||||||
onSubsConfirmed == other.onSubsConfirmed &&
|
|
||||||
onUnSubs == other.onUnSubs &&
|
|
||||||
onSlide == other.onSlide;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode =>
|
int get hashCode => mapState.hashCode;
|
||||||
mapState.hashCode ^
|
|
||||||
onSubs.hashCode ^
|
|
||||||
onSubsConfirmed.hashCode ^
|
|
||||||
onUnSubs.hashCode ^
|
|
||||||
onSlide.hashCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class YourLocationMap extends StatefulWidget {
|
class YourLocationMap extends StatelessWidget {
|
||||||
YourLocationMap();
|
|
||||||
|
|
||||||
@override
|
|
||||||
_YourLocationMapState createState() => _YourLocationMapState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _YourLocationMapState extends State<YourLocationMap> {
|
|
||||||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||||
final FirebaseMessaging _firebaseMessaging = new FirebaseMessaging();
|
final FirebaseMessaging _firebaseMessaging = new FirebaseMessaging();
|
||||||
|
|
||||||
_YourLocationMapState();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
return new StoreConnector<AppState, _ViewModel>(
|
return new StoreConnector<AppState, _ViewModel>(
|
||||||
distinct: false, // FIXME
|
distinct: true,
|
||||||
converter: (store) {
|
converter: (store) {
|
||||||
return new _ViewModel(
|
return new _ViewModel(
|
||||||
onSubs: (loc) {
|
onSubs: (loc) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue