Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#608 fix #609

Merged
merged 1 commit into from
Jul 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
251 changes: 124 additions & 127 deletions example/lib/widgets/drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@ import '../pages/polyline.dart';
import '../pages/tap_to_add.dart';
import '../pages/wms_tile_layer.dart';

Widget _buildMenuItem(
BuildContext context, Widget title, String routeName, String currentRoute) {
var isSelected = routeName == currentRoute;

return ListTile(
title: title,
selected: isSelected,
onTap: () {
if (isSelected) {
Navigator.pop(context);
} else {
Navigator.pushReplacementNamed(context, routeName);
}
},
);
}

Drawer buildDrawer(BuildContext context, String currentRoute) {
return Drawer(
child: ListView(
Expand All @@ -28,133 +45,113 @@ Drawer buildDrawer(BuildContext context, String currentRoute) {
child: Text('Flutter Map Examples'),
),
),
ListTile(
title: const Text('OpenStreetMap'),
selected: currentRoute == HomePage.route,
onTap: () {
Navigator.pushReplacementNamed(context, HomePage.route);
},
),
ListTile(
title: const Text('WMS Layer'),
selected: currentRoute == WMSLayerPage.route,
onTap: () {
Navigator.pushReplacementNamed(context, WMSLayerPage.route);
},
),
ListTile(
title: const Text('Custom CRS'),
selected: currentRoute == CustomCrsPage.route,
onTap: () {
Navigator.pushReplacementNamed(context, CustomCrsPage.route);
},
),
ListTile(
title: const Text('Add Pins'),
selected: currentRoute == TapToAddPage.route,
onTap: () {
Navigator.pushReplacementNamed(context, TapToAddPage.route);
},
),
ListTile(
title: const Text('Esri'),
selected: currentRoute == EsriPage.route,
onTap: () {
Navigator.pushReplacementNamed(context, EsriPage.route);
},
),
ListTile(
title: const Text('Polylines'),
selected: currentRoute == PolylinePage.route,
onTap: () {
Navigator.pushReplacementNamed(context, PolylinePage.route);
},
),
ListTile(
title: const Text('MapController'),
selected: currentRoute == MapControllerPage.route,
onTap: () {
Navigator.pushReplacementNamed(context, MapControllerPage.route);
},
),
ListTile(
title: const Text('Animated MapController'),
selected: currentRoute == AnimatedMapControllerPage.route,
onTap: () {
Navigator.pushReplacementNamed(
context, AnimatedMapControllerPage.route);
},
),
ListTile(
title: const Text('Marker Anchors'),
selected: currentRoute == MarkerAnchorPage.route,
onTap: () {
Navigator.pushReplacementNamed(context, MarkerAnchorPage.route);
},
),
ListTile(
title: const Text('Plugins'),
selected: currentRoute == PluginPage.route,
onTap: () {
Navigator.pushReplacementNamed(context, PluginPage.route);
},
),
ListTile(
title: const Text('ScaleBar Plugins'),
selected: currentRoute == PluginScaleBar.route,
onTap: () {
Navigator.pushReplacementNamed(context, PluginScaleBar.route);
},
),
ListTile(
title: const Text('ZoomButtons Plugins'),
selected: currentRoute == PluginZoomButtons.route,
onTap: () {
Navigator.pushReplacementNamed(context, PluginZoomButtons.route);
},
),
ListTile(
title: const Text('Offline Map'),
selected: currentRoute == OfflineMapPage.route,
onTap: () {
Navigator.pushReplacementNamed(context, OfflineMapPage.route);
},
),
ListTile(
title: const Text('Offline Map (using MBTiles)'),
selected: currentRoute == OfflineMBTilesMapPage.route,
onTap: () {
Navigator.pushReplacementNamed(
context, OfflineMBTilesMapPage.route);
},
),
ListTile(
title: const Text('OnTap'),
selected: currentRoute == OnTapPage.route,
onTap: () {
Navigator.pushReplacementNamed(context, OnTapPage.route);
},
),
ListTile(
title: const Text('Moving Markers'),
selected: currentRoute == MovingMarkersPage.route,
onTap: () {
Navigator.pushReplacementNamed(context, MovingMarkersPage.route);
},
),
ListTile(
title: const Text('Circle'),
selected: currentRoute == CirclePage.route,
onTap: () {
Navigator.pushReplacementNamed(context, CirclePage.route);
},
),
ListTile(
title: const Text('Overlay Image'),
selected: currentRoute == OverlayImagePage.route,
onTap: () {
Navigator.pushReplacementNamed(context, OverlayImagePage.route);
},
_buildMenuItem(
context,
const Text('OpenStreetMap'),
HomePage.route,
currentRoute,
),
_buildMenuItem(
context,
const Text('WMS Layer'),
WMSLayerPage.route,
currentRoute,
),
_buildMenuItem(
context,
const Text('Custom CRS'),
CustomCrsPage.route,
currentRoute,
),
_buildMenuItem(
context,
const Text('Add Pins'),
TapToAddPage.route,
currentRoute,
),
_buildMenuItem(
context,
const Text('Esri'),
EsriPage.route,
currentRoute,
),
_buildMenuItem(
context,
const Text('Polylines'),
PolylinePage.route,
currentRoute,
),
_buildMenuItem(
context,
const Text('MapController'),
MapControllerPage.route,
currentRoute,
),
_buildMenuItem(
context,
const Text('Animated MapController'),
AnimatedMapControllerPage.route,
currentRoute,
),
_buildMenuItem(
context,
const Text('Marker Anchors'),
MarkerAnchorPage.route,
currentRoute,
),
_buildMenuItem(
context,
const Text('Plugins'),
PluginPage.route,
currentRoute,
),
_buildMenuItem(
context,
const Text('ScaleBar Plugins'),
PluginScaleBar.route,
currentRoute,
),
_buildMenuItem(
context,
const Text('ZoomButtons Plugins'),
PluginZoomButtons.route,
currentRoute,
),
_buildMenuItem(
context,
const Text('Offline Map'),
OfflineMapPage.route,
currentRoute,
),
_buildMenuItem(
context,
const Text('Offline Map (using MBTiles)'),
OfflineMBTilesMapPage.route,
currentRoute,
),
_buildMenuItem(
context,
const Text('OnTap'),
OnTapPage.route,
currentRoute,
),
_buildMenuItem(
context,
const Text('Moving Markers'),
MovingMarkersPage.route,
currentRoute,
),
_buildMenuItem(
context,
const Text('Circle'),
CirclePage.route,
currentRoute,
),
_buildMenuItem(
context,
const Text('Overlay Image'),
OverlayImagePage.route,
currentRoute,
),
],
),
Expand Down