From 1d7cbbd1bf05e5cc7ecf77cf56a4f7dfec6b3738 Mon Sep 17 00:00:00 2001 From: Yoshi Date: Wed, 28 Aug 2024 21:52:42 +0300 Subject: [PATCH] Fix map and add new button --- lib/app/modules/geolocation.dart | 5 +++++ lib/app/modules/map/view/map.dart | 34 +++++++++++++++++++++++++------ pubspec.yaml | 4 ++-- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/lib/app/modules/geolocation.dart b/lib/app/modules/geolocation.dart index 6e3dc67..1af8ca4 100644 --- a/lib/app/modules/geolocation.dart +++ b/lib/app/modules/geolocation.dart @@ -148,6 +148,11 @@ class _SelectGeolocationState extends State { 37.6156, ), initialZoom: 3, + interactionOptions: + const InteractionOptions( + flags: InteractiveFlag.all & + ~InteractiveFlag.rotate, + ), cameraConstraint: CameraConstraint.contain( bounds: LatLngBounds( diff --git a/lib/app/modules/map/view/map.dart b/lib/app/modules/map/view/map.dart index 619c8a4..1c6a792 100644 --- a/lib/app/modules/map/view/map.dart +++ b/lib/app/modules/map/view/map.dart @@ -38,11 +38,15 @@ class _MapWeatherState extends State with TickerProviderStateMixin { final statusData = StatusData(); final Future _cacheStoreFuture = _getCacheStore(); + final GlobalKey _fabKey = GlobalKey(); + final bool _isDarkMode = Get.theme.brightness == Brightness.dark; WeatherCard? _selectedWeatherCard; bool _isCardVisible = false; late final AnimationController _animationController; late final Animation _offsetAnimation; + static const _useTransformerId = 'useTransformerId'; + final bool _useTransformer = true; final _focusNode = FocusNode(); late final TextEditingController _controllerSearch = TextEditingController(); @@ -79,6 +83,7 @@ class _MapWeatherState extends State with TickerProviderStateMixin { void _resetMapOrientation({LatLng? center, double? zoom}) { _animatedMapController.animateTo( + customId: _useTransformer ? _useTransformerId : null, dest: center, zoom: zoom, rotation: 0, @@ -93,6 +98,10 @@ class _MapWeatherState extends State with TickerProviderStateMixin { }); _animationController.forward(); _isCardVisible = true; + + if (_fabKey.currentState?.isOpen == true) { + _fabKey.currentState?.toggle(); + } } void _hideCard() { @@ -241,7 +250,10 @@ class _MapWeatherState extends State with TickerProviderStateMixin { options: MapOptions( backgroundColor: context.theme.colorScheme.surface, initialCenter: LatLng(mainLocation.lat!, mainLocation.lon!), - initialZoom: 12, + initialZoom: 8, + interactionOptions: const InteractionOptions( + flags: InteractiveFlag.all & ~InteractiveFlag.rotate, + ), cameraConstraint: CameraConstraint.contain( bounds: LatLngBounds( const LatLng(-90, -180), @@ -303,8 +315,9 @@ class _MapWeatherState extends State with TickerProviderStateMixin { ); }), ExpandableFab( + key: _fabKey, pos: ExpandableFabPos.right, - type: ExpandableFabType.fan, + type: ExpandableFabType.up, distance: 70, openButtonBuilder: RotateFloatingActionButtonBuilder( child: const Icon(IconsaxPlusLinear.menu), @@ -317,16 +330,25 @@ class _MapWeatherState extends State with TickerProviderStateMixin { children: [ FloatingActionButton( heroTag: null, - child: const Icon(IconsaxPlusLinear.gps), + child: const Icon(IconsaxPlusLinear.home_2), onPressed: () => _resetMapOrientation( center: LatLng(mainLocation.lat!, mainLocation.lon!), - zoom: 12), + zoom: 8), ), FloatingActionButton( heroTag: null, - child: const Icon(IconsaxPlusLinear.refresh_2), - onPressed: () => _resetMapOrientation(), + child: const Icon(IconsaxPlusLinear.search_zoom_out_1), + onPressed: () => _animatedMapController.animatedZoomOut( + customId: _useTransformer ? _useTransformerId : null, + ), + ), + FloatingActionButton( + heroTag: null, + child: const Icon(IconsaxPlusLinear.search_zoom_in), + onPressed: () => _animatedMapController.animatedZoomIn( + customId: _useTransformer ? _useTransformerId : null, + ), ), ], ), diff --git a/pubspec.yaml b/pubspec.yaml index 6c9d2f4..7a74f30 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -50,7 +50,7 @@ dependencies: flutter_local_notifications: ^17.2.2 internet_connection_checker_plus: ^2.5.1 dio_cache_interceptor_file_store: ^1.2.2 - isar: + isar: version: ^3.1.8 hosted: https://pub.isar-community.dev/ isar_flutter_libs: @@ -74,7 +74,7 @@ dev_dependencies: json_serializable: ^6.8.0 flutter_native_splash: ^2.4.1 flutter_launcher_icons: ^0.13.1 - isar_generator: + isar_generator: version: ^3.1.8 hosted: https://pub.isar-community.dev/