More work with map location operations
This commit is contained in:
parent
b22ee50f89
commit
521eef5aa8
5 changed files with 134 additions and 89 deletions
|
|
@ -35,21 +35,16 @@ class _ActiveFiresPageState extends State<ActiveFiresPage> {
|
|||
onAddYourLocation();
|
||||
},
|
||||
"Add your current position",
|
||||
fires300,
|
||||
Colors.black38,
|
||||
Colors.white,
|
||||
),
|
||||
new FabMiniMenuItem.withText(
|
||||
new Icon(Icons.edit_location),
|
||||
fires600,
|
||||
8.0,
|
||||
"Add some other place",
|
||||
new Icon(Icons.edit_location), fires600, 8.0, "Add some other place",
|
||||
() {
|
||||
onAddOtherLocation(context);
|
||||
},
|
||||
"Add some other place",
|
||||
fires300,
|
||||
Colors.white)
|
||||
];}
|
||||
}, "Add some other place", Colors.black38, Colors.white)
|
||||
];
|
||||
}
|
||||
|
||||
_ActiveFiresPageState();
|
||||
|
||||
|
|
@ -83,7 +78,7 @@ class _ActiveFiresPageState extends State<ActiveFiresPage> {
|
|||
builder: (context) => new GenericMap(
|
||||
title: loc.description,
|
||||
location: loc,
|
||||
)));
|
||||
operation: MapOperation.view)));
|
||||
}
|
||||
|
||||
void showSnackMsg(String msg) {
|
||||
|
|
@ -162,7 +157,9 @@ class _ActiveFiresPageState extends State<ActiveFiresPage> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var hasLocations = globals.yourLocations.length > 0;
|
||||
final title = hasLocations ? 'Active fires in your places': 'Active fires in the world';
|
||||
final title = hasLocations
|
||||
? 'Active fires in your places'
|
||||
: 'Active fires in the world';
|
||||
print('Building Active Fires');
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
|
|
@ -182,7 +179,8 @@ class _ActiveFiresPageState extends State<ActiveFiresPage> {
|
|||
body: hasLocations
|
||||
? new Stack(children: <Widget>[
|
||||
_buildSavedLocations(),
|
||||
new FabDialer(_fabMiniMenuItemList(context), fires600, new Icon(Icons.add))
|
||||
new FabDialer(
|
||||
_fabMiniMenuItemList(context), fires600, new Icon(Icons.add))
|
||||
])
|
||||
: new Center(
|
||||
child: new CenteredColumn(children: <Widget>[
|
||||
|
|
|
|||
|
|
@ -13,7 +13,10 @@ class FireMarker extends Marker {
|
|||
height: 80.0,
|
||||
point: new LatLng(location.lat, location.lon),
|
||||
builder: (ctx) => new Container(
|
||||
child: new FireMarkerIcon(type),
|
||||
child: new GestureDetector(
|
||||
child: new FireMarkerIcon(type), onTap: () {
|
||||
print('marker pressed');
|
||||
})
|
||||
),
|
||||
anchor: anchor,
|
||||
anchorOverride: anchorOverride ?? type == FireMarkType.position
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import 'fireMarkType.dart';
|
|||
import 'colors.dart';
|
||||
|
||||
class FireMarkerIcon extends StatelessWidget {
|
||||
|
||||
final FireMarkType type;
|
||||
|
||||
FireMarkerIcon(this.type);
|
||||
|
|
|
|||
|
|
@ -10,24 +10,29 @@ import 'dart:core';
|
|||
import 'globals.dart' as globals;
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:convert' show json;
|
||||
import 'slider.dart';
|
||||
import 'fireMarker.dart';
|
||||
import 'zoomMapPlugin.dart';
|
||||
import 'dummyMapPlugin.dart';
|
||||
import 'package:just_debounce_it/just_debounce_it.dart';
|
||||
import 'fireMarkType.dart';
|
||||
import 'slider.dart';
|
||||
import 'package:just_debounce_it/just_debounce_it.dart';
|
||||
import 'package:padder/padding.dart';
|
||||
|
||||
enum MapOperation { view }
|
||||
enum MapOperation { view, subscriptionConfirm, unsubscribe }
|
||||
|
||||
class GenericMap extends StatefulWidget {
|
||||
final BasicLocation location;
|
||||
final String title;
|
||||
final MapOperation operation;
|
||||
|
||||
GenericMap({@required this.title, @required this.location});
|
||||
GenericMap(
|
||||
{@required this.title,
|
||||
@required this.location,
|
||||
@required this.operation});
|
||||
|
||||
@override
|
||||
_GenericMapState createState() =>
|
||||
_GenericMapState(title: title, location: location);
|
||||
_GenericMapState(title: title, location: location, operation: operation);
|
||||
}
|
||||
|
||||
class _GenericMapState extends State<GenericMap> {
|
||||
|
|
@ -40,6 +45,7 @@ class _GenericMapState extends State<GenericMap> {
|
|||
List<dynamic> fires = [];
|
||||
List<dynamic> falsePos = [];
|
||||
List<dynamic> industries = [];
|
||||
MapOperation operation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
|
@ -63,16 +69,21 @@ class _GenericMapState extends State<GenericMap> {
|
|||
var firesCount = fires.length;
|
||||
var industriesCount = industries.length;
|
||||
var falsePosCount = falsePos.length;
|
||||
print('real: $numFires, fire: $firesCount falsePos: $falsePosCount industries: $industriesCount');
|
||||
print(
|
||||
'real: $numFires, fire: $firesCount falsePos: $falsePosCount industries: $industriesCount');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
_GenericMapState({@required this.title, @required this.location});
|
||||
_GenericMapState(
|
||||
{@required this.title,
|
||||
@required this.location,
|
||||
@required this.operation});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print('Build map with operation: $operation');
|
||||
MapOptions mapOptions = new MapOptions(
|
||||
center: new LatLng(this.location.lat, this.location.lon),
|
||||
plugins: globals.isDevelopment
|
||||
|
|
@ -90,14 +101,17 @@ class _GenericMapState extends State<GenericMap> {
|
|||
var mapController = new MapController();
|
||||
// mapController.fitBounds(bounds);
|
||||
// mapController.center
|
||||
var fmap = new FlutterMap(
|
||||
var fmap = new Opacity(
|
||||
opacity: operation == MapOperation.subscriptionConfirm ? 0.5 : 1.0,
|
||||
child: new FlutterMap(
|
||||
options: mapOptions,
|
||||
mapController: mapController,
|
||||
layers: [
|
||||
new TileLayerOptions(
|
||||
maxZoom: 6.0,
|
||||
subdomains: ['a', 'b', 'c'],
|
||||
urlTemplate: 'https://tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png',
|
||||
urlTemplate:
|
||||
'https://tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png',
|
||||
additionalOptions: {
|
||||
// 'opacity': '0.1',
|
||||
'attribution':
|
||||
|
|
@ -112,7 +126,7 @@ class _GenericMapState extends State<GenericMap> {
|
|||
this.location, this.fires, this.industries, this.falsePos),
|
||||
),
|
||||
],
|
||||
);
|
||||
));
|
||||
|
||||
return new Scaffold(
|
||||
key: _scaffoldKey,
|
||||
|
|
@ -120,15 +134,43 @@ class _GenericMapState extends State<GenericMap> {
|
|||
appBar: new AppBar(
|
||||
title: new Text(title),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton.extended(
|
||||
onPressed: () {},
|
||||
icon: const Icon(Icons.notifications_none, color: fires600),
|
||||
floatingActionButton: Column(mainAxisAlignment: MainAxisAlignment.end,
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
FloatingActionButton.extended(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
switch (operation) {
|
||||
case MapOperation.view:
|
||||
operation = MapOperation.subscriptionConfirm;
|
||||
break;
|
||||
case MapOperation.subscriptionConfirm:
|
||||
operation = MapOperation.unsubscribe;
|
||||
break;
|
||||
case MapOperation.unsubscribe:
|
||||
operation = MapOperation.view;
|
||||
break;
|
||||
}
|
||||
});
|
||||
},
|
||||
icon: new Icon(
|
||||
operation == MapOperation.view
|
||||
? Icons.notifications_active
|
||||
: operation == MapOperation.subscriptionConfirm
|
||||
? Icons.check
|
||||
: Icons.notifications_off,
|
||||
color: fires600),
|
||||
label: new Text(
|
||||
'Subscribe',
|
||||
operation == MapOperation.view
|
||||
? 'Subscribe to fires notifications'
|
||||
: operation == MapOperation.subscriptionConfirm
|
||||
? 'Confirm'
|
||||
: 'Unsubscribe',
|
||||
style: const TextStyle(color: fires600),
|
||||
),
|
||||
backgroundColor: Colors.white,
|
||||
),
|
||||
)
|
||||
]),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
|
||||
bottomNavigationBar: new CustomBottomAppBar(
|
||||
fabLocation: FloatingActionButtonLocation.centerFloat,
|
||||
|
|
@ -137,7 +179,7 @@ class _GenericMapState extends State<GenericMap> {
|
|||
// height: 170.0,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
actions: listWithoutNulls(<Widget>[
|
||||
numFires == null
|
||||
operation == MapOperation.subscriptionConfirm|| numFires == null
|
||||
? null
|
||||
: numFires > 0
|
||||
? new Text('${numFires.toString()} fires at ${kmAround
|
||||
|
|
@ -152,13 +194,14 @@ class _GenericMapState extends State<GenericMap> {
|
|||
// Material(color: Colors.yellowAccent),
|
||||
fmap,
|
||||
Positioned(
|
||||
top: constraints.maxHeight - 160,
|
||||
top: constraints.maxHeight - 200,
|
||||
right: 10.0,
|
||||
left: 10.0,
|
||||
child: new CenteredRow(
|
||||
// Fit sample:
|
||||
// https://github.com/apptreesoftware/flutter_map/blob/master/flutter_map_example/lib/pages/map_controller.dart
|
||||
children: <Widget>[
|
||||
children: operation == MapOperation.subscriptionConfirm
|
||||
? <Widget>[
|
||||
new FireDistanceSlider(
|
||||
initialValue: kmAround,
|
||||
onSlide: (distance) {
|
||||
|
|
@ -167,7 +210,8 @@ class _GenericMapState extends State<GenericMap> {
|
|||
Debounce.seconds(1, updateFireStats);
|
||||
});
|
||||
})
|
||||
],
|
||||
]
|
||||
: [],
|
||||
),
|
||||
)
|
||||
]),
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||
import 'colors.dart';
|
||||
import 'package:comunes_flutter/comunes_flutter.dart';
|
||||
import 'package:padder/padding.dart';
|
||||
import 'package:fluttery/framing.dart';
|
||||
|
||||
typedef void SlideCallback(int distance);
|
||||
|
||||
|
|
@ -25,7 +26,8 @@ class _FireDistanceSliderState extends State<FireDistanceSlider> {
|
|||
}
|
||||
|
||||
sizeText(_sliderValue) =>
|
||||
new Text('Subscribe to $_sliderValue км around this area');
|
||||
new Text('Subscribe to $_sliderValue км around this area',
|
||||
style: new TextStyle(color: Colors.black87));
|
||||
|
||||
warningText(_sliderValue) => _sliderValue >= 50
|
||||
? new Text('Warning: this is a very large area',
|
||||
|
|
@ -38,7 +40,6 @@ class _FireDistanceSliderState extends State<FireDistanceSlider> {
|
|||
value: _sliderValue + 0.0,
|
||||
activeColor: fires900,
|
||||
inactiveColor: Colors.black45,
|
||||
|
||||
min: 1.0,
|
||||
max: 100.0,
|
||||
divisions: 99,
|
||||
|
|
@ -54,14 +55,14 @@ class _FireDistanceSliderState extends State<FireDistanceSlider> {
|
|||
return new Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: listWithoutNulls(<Widget>[
|
||||
slider,
|
||||
new Card(
|
||||
color: const Color(0x60FFFFFF),
|
||||
child: PaddingAll(10.0,
|
||||
child: new Column(children: <Widget>[
|
||||
new SizedBox(height: 50.0),
|
||||
new Row(mainAxisSize: MainAxisSize.max, children: <Widget>[slider]),
|
||||
// new SizedBox(height: 5.0),
|
||||
new Column(children: <Widget>[
|
||||
sizeText(_sliderValue),
|
||||
new SizedBox(height: 5.0),
|
||||
warningText(_sliderValue)
|
||||
])))
|
||||
])
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue