diff --git a/lib/ui/screens/map_screen.dart b/lib/ui/screens/map_screen.dart index 11f4bcfa6f2d6c8f8817e5abeb2f1458e7ab68c1..4a81eac35eab13574e0a87027045d7d0525321e0 100644 --- a/lib/ui/screens/map_screen.dart +++ b/lib/ui/screens/map_screen.dart @@ -2,6 +2,7 @@ import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_marker_cluster/flutter_map_marker_cluster.dart'; import 'package:kunstforum_tu_darmstadt/api/artwork_service.dart'; import 'package:provider/provider.dart'; import 'package:latlong2/latlong.dart'; @@ -89,9 +90,9 @@ class _MapScreenState extends State { child: FlutterMap( mapController: _mapController, options: MapOptions( - center: _currentPosition, - zoom: 15.0, - ), + center: _currentPosition, + zoom: 15.0, + plugins: [MarkerClusterPlugin()]), layers: [ TileLayerOptions( urlTemplate: @@ -100,6 +101,29 @@ class _MapScreenState extends State { MarkerLayerOptions( markers: _markers, ), + MarkerClusterLayerOptions( + maxClusterRadius: 30, + size: Size(40, 40), + anchor: AnchorPos.align(AnchorAlign.center), + fitBoundsOptions: FitBoundsOptions( + padding: EdgeInsets.all(50), + ), + showPolygon: false, + markers: _markers, + builder: (context, markers) { + return Container( + child: Center( + child: Text( + markers.length.toString(), + style: TextStyle( + color: appSetting!.primaryColor.computeLuminance() < 0.6 + ? Colors.white + : Colors.black), + )), + decoration: BoxDecoration( + color: appSetting!.primaryColor, shape: BoxShape.circle)); + }, + ), ], )), floatingActionButton: FloatingActionButton( @@ -109,6 +133,9 @@ class _MapScreenState extends State { child: Icon( Kunstforum.location, size: appSetting!.iconSize, + color: appSetting!.primaryColor.computeLuminance() < 0.6 + ? Colors.white + : Colors.black, ), backgroundColor: appSetting!.primaryColor, ), @@ -127,8 +154,8 @@ class _MapScreenState extends State { /// based on the position and artwork name Marker createMarker(LatLng position, Artwork artwork) { return Marker( - width: 80.0, - height: 80.0, + width: 50.0, + height: 50.0, point: position, builder: (ctx) => Container( child: IconButton( diff --git a/lib/ui/screens/search_screen.dart b/lib/ui/screens/search_screen.dart index b9f53b8dbcbbb2660e4c596c679b7bf43d564bff..f0c565d77c4abfd2784bc9f284904b45116fa026 100644 --- a/lib/ui/screens/search_screen.dart +++ b/lib/ui/screens/search_screen.dart @@ -85,6 +85,12 @@ class SearchScreen extends SearchDelegate { artworkService = Provider.of(context); List filteredList = getFilteredList(artworkService); + Color textColorActive = appSetting.primaryColor.computeLuminance() < 0.6 + ? Colors.white + : Colors.black; + + Color textColorInActive = Colors.black; + return Scaffold( backgroundColor: appSetting.scaffoldBackgroundColor, appBar: AppBar( @@ -109,7 +115,7 @@ class SearchScreen extends SearchDelegate { .textTheme .bodyText1! .copyWith(fontSize: appSetting.cardFontSize), - primary: searchViaNr ? Colors.white : Colors.black, + primary: searchViaNr ? textColorActive : textColorInActive, backgroundColor: searchViaNr ? appSetting.primaryColor : Colors.grey[300], ), @@ -118,7 +124,7 @@ class SearchScreen extends SearchDelegate { //maxLines: 1, style: Theme.of(context).textTheme.caption!.copyWith( fontSize: appSetting.captionTextFontSize, - color: searchViaNr ? Colors.white : Colors.black), + color: searchViaNr ? textColorActive : textColorInActive), )), ), Expanded( @@ -139,14 +145,14 @@ class SearchScreen extends SearchDelegate { .textTheme .bodyText1! .copyWith(fontSize: appSetting.cardFontSize), - primary: searchViaNr ? Colors.black : Colors.white, + primary: searchViaNr ? textColorInActive : textColorActive, backgroundColor: searchViaNr ? Colors.grey[300] : appSetting.primaryColor, ), child: AutoSizeText(AppLocalizations.of(context)!.exhibitInfo, style: Theme.of(context).textTheme.caption!.copyWith( fontSize: appSetting.captionTextFontSize, - color: searchViaNr ? Colors.black : Colors.white))), + color: searchViaNr ? textColorInActive : textColorActive))), ), Expanded( flex: 1, diff --git a/pubspec.lock b/pubspec.lock index edb6b68ed5d12f35613fcb6a649709930dd502ff..3b29a4427ffd47b8caa4494ff6c5e118a62c2e2f 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,6 +1,13 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + animated_stack_widget: + dependency: transitive + description: + name: animated_stack_widget + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.2+1" async: dependency: transitive description: @@ -165,6 +172,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.13.1" + flutter_map_marker_cluster: + dependency: "direct main" + description: + name: flutter_map_marker_cluster + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.0" + flutter_map_marker_popup: + dependency: transitive + description: + name: flutter_map_marker_popup + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0+2" flutter_offline: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 42d00d594df2951da77f8bfff39eb17ff9b1b975..bfe80720d0d5ebabbaf51310559590a82e4b21ce 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -40,6 +40,7 @@ dependencies: latlong2: ^0.8.0 location: ^4.3.0 map_launcher: ^2.1.1 + flutter_map_marker_cluster: ^0.4.0 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons.