commit 66c0919a91c7d567b8f7a71f14140c981831db7d
parent 30210f4447b1417aec5425beec34badd91640bff
Author: Marcel <mtrnord1@gmail.com>
Date: Sun, 23 Feb 2020 14:12:28 +0100
Use Mapbox
Update README.md
Minor performance optimizing
Took 1 hour 0 minutes
Diffstat:
4 files changed, 58 insertions(+), 26 deletions(-)
diff --git a/README.md b/README.md
@@ -1,16 +1,5 @@
-# rs_flutter_app
+
-Bahnhofsfoto-App for Android and iOS using Flutter
+# Bahnhofsfotos
-## Getting Started
-
-This project is a starting point for a Flutter application.
-
-A few resources to get you started if this is your first Flutter project:
-
-- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
-- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
-
-For help getting started with Flutter, view our
-[online documentation](https://flutter.dev/docs), which offers tutorials,
-samples, guidance on mobile development, and a full API reference.
+Bahnhofsfoto-App for Android and iOS using Flutter (focused on iOS)
+\ No newline at end of file
diff --git a/android/app/build.gradle b/android/app/build.gradle
@@ -50,6 +50,7 @@ android {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
+ applicationIdSuffix '.release'
}
debug {
applicationIdSuffix '.debug'
diff --git a/lib/views/tabs/MapTab.dart b/lib/views/tabs/MapTab.dart
@@ -4,9 +4,9 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_map_marker_cluster/flutter_map_marker_cluster.dart';
import 'package:latlong/latlong.dart';
-import 'package:rs_flutter_app/events/MapEvent.dart';
import '../../blocs/MapBloc.dart';
+import '../../events/MapEvent.dart';
import '../../models/models.dart';
import '../../states/MapState.dart';
@@ -15,7 +15,8 @@ class MapTab extends StatefulWidget {
MapTabState createState() => MapTabState();
}
-class MapTabState extends State<MapTab> {
+class MapTabState extends State<MapTab>
+ with AutomaticKeepAliveClientMixin<MapTab> {
MapTabState();
List<Station> stations;
@@ -25,19 +26,24 @@ class MapTabState extends State<MapTab> {
List<Marker> _makeStationMarkers(List<Station> stations) {
List<Marker> stationMarkers = List();
stations.forEach((element) {
- stationMarkers.add(Marker(
- anchorPos: AnchorPos.align(AnchorAlign.center),
- height: 30,
- width: 30,
- point: LatLng(element.lat, element.lon),
- builder: (BuildContext context) => Icon(Icons.pin_drop),
- ));
+ if (element.active) {
+ stationMarkers.add(Marker(
+ anchorPos: AnchorPos.align(AnchorAlign.center),
+ height: 30,
+ width: 30,
+ point: LatLng(element.lat, element.lon),
+ builder: (BuildContext context) => Icon(Icons.pin_drop),
+ ));
+ }
+ // Todo calculate an extra layer for deactivated stations
});
return stationMarkers;
}
@override
Widget build(BuildContext context) {
+ super.build(context);
+
// Fetch map data on opening
if (stations == null) {
BlocProvider.of<MapBloc>(context).add(FetchStations());
@@ -57,10 +63,35 @@ class MapTabState extends State<MapTab> {
],
),
layers: [
+ // Mapbox
TileLayerOptions(
- urlTemplate: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
- subdomains: ['a', 'b', 'c'],
+ //tileSize: 1024,
+ zoomOffset: -1,
+ urlTemplate:
+ "https://api.mapbox.com/styles/v1/mapbox/{id}/tiles/256/{z}/{x}/{y}@2x?access_token={accessToken}",
+ additionalOptions: {
+ 'accessToken':
+ 'pk.eyJ1IjoibXRybm9yZCIsImEiOiJjaXIyZTRhNDcwMDhwaTJtZzBseTNkancxIn0.09m6ZCFvkKL6Ppss7XAnfA',
+ 'id': 'streets-v11',
+ },
),
+ // Openstreetmap
+ /*TileLayerOptions(
+ urlTemplate: "https://{s}.tile.openstreetmap.de/{z}/{x}/{y}.png",
+ subdomains: ['a', 'b', 'c'],
+ ),*/
+ // Transport Map
+ /*TileLayerOptions(
+ urlTemplate: "http://tile.memomaps.de/tilegen/{z}/{x}/{y}.png",
+ subdomains: [],
+ ),*/
+ // Railway overlay
+ /*TileLayerOptions(
+ urlTemplate:
+ "https://{s}.tiles.openrailwaymap.org/standard/{z}/{x}/{y}.png",
+ subdomains: ['a', 'b', 'c'],
+ opacity: 0.2,
+ ),*/
MarkerClusterLayerOptions(
maxClusterRadius: 120,
size: Size(50, 50),
@@ -98,6 +129,7 @@ class MapTabState extends State<MapTab> {
},
);
}
+ // Todo show reload button on error
if (state is MapError) {
return Text(
'Something went wrong!',
@@ -117,4 +149,7 @@ class MapTabState extends State<MapTab> {
BlocProvider.of<MapBloc>(context).add(RenderMap());
});
}
+
+ @override
+ bool get wantKeepAlive => true;
}
diff --git a/lib/views/tabs/SettingsTab.dart b/lib/views/tabs/SettingsTab.dart
@@ -7,9 +7,12 @@ class SettingsTab extends StatefulWidget {
SettingsTabState createState() => SettingsTabState();
}
-class SettingsTabState extends State<SettingsTab> {
+class SettingsTabState extends State<SettingsTab>
+ with AutomaticKeepAliveClientMixin<SettingsTab> {
@override
Widget build(BuildContext context) {
+ super.build(context);
+
return Material(
child: SettingsList(sections: [
SettingsSection(
@@ -33,4 +36,7 @@ class SettingsTabState extends State<SettingsTab> {
]),
);
}
+
+ @override
+ bool get wantKeepAlive => true;
}