Fix map and add new button

This commit is contained in:
Yoshi 2024-08-28 21:52:42 +03:00
parent 1ea344c69a
commit 1d7cbbd1bf
3 changed files with 35 additions and 8 deletions

View file

@ -148,6 +148,11 @@ class _SelectGeolocationState extends State<SelectGeolocation> {
37.6156, 37.6156,
), ),
initialZoom: 3, initialZoom: 3,
interactionOptions:
const InteractionOptions(
flags: InteractiveFlag.all &
~InteractiveFlag.rotate,
),
cameraConstraint: cameraConstraint:
CameraConstraint.contain( CameraConstraint.contain(
bounds: LatLngBounds( bounds: LatLngBounds(

View file

@ -38,11 +38,15 @@ class _MapWeatherState extends State<MapWeather> with TickerProviderStateMixin {
final statusData = StatusData(); final statusData = StatusData();
final Future<CacheStore> _cacheStoreFuture = _getCacheStore(); final Future<CacheStore> _cacheStoreFuture = _getCacheStore();
final GlobalKey<ExpandableFabState> _fabKey = GlobalKey<ExpandableFabState>();
final bool _isDarkMode = Get.theme.brightness == Brightness.dark; final bool _isDarkMode = Get.theme.brightness == Brightness.dark;
WeatherCard? _selectedWeatherCard; WeatherCard? _selectedWeatherCard;
bool _isCardVisible = false; bool _isCardVisible = false;
late final AnimationController _animationController; late final AnimationController _animationController;
late final Animation<Offset> _offsetAnimation; late final Animation<Offset> _offsetAnimation;
static const _useTransformerId = 'useTransformerId';
final bool _useTransformer = true;
final _focusNode = FocusNode(); final _focusNode = FocusNode();
late final TextEditingController _controllerSearch = TextEditingController(); late final TextEditingController _controllerSearch = TextEditingController();
@ -79,6 +83,7 @@ class _MapWeatherState extends State<MapWeather> with TickerProviderStateMixin {
void _resetMapOrientation({LatLng? center, double? zoom}) { void _resetMapOrientation({LatLng? center, double? zoom}) {
_animatedMapController.animateTo( _animatedMapController.animateTo(
customId: _useTransformer ? _useTransformerId : null,
dest: center, dest: center,
zoom: zoom, zoom: zoom,
rotation: 0, rotation: 0,
@ -93,6 +98,10 @@ class _MapWeatherState extends State<MapWeather> with TickerProviderStateMixin {
}); });
_animationController.forward(); _animationController.forward();
_isCardVisible = true; _isCardVisible = true;
if (_fabKey.currentState?.isOpen == true) {
_fabKey.currentState?.toggle();
}
} }
void _hideCard() { void _hideCard() {
@ -241,7 +250,10 @@ class _MapWeatherState extends State<MapWeather> with TickerProviderStateMixin {
options: MapOptions( options: MapOptions(
backgroundColor: context.theme.colorScheme.surface, backgroundColor: context.theme.colorScheme.surface,
initialCenter: LatLng(mainLocation.lat!, mainLocation.lon!), initialCenter: LatLng(mainLocation.lat!, mainLocation.lon!),
initialZoom: 12, initialZoom: 8,
interactionOptions: const InteractionOptions(
flags: InteractiveFlag.all & ~InteractiveFlag.rotate,
),
cameraConstraint: CameraConstraint.contain( cameraConstraint: CameraConstraint.contain(
bounds: LatLngBounds( bounds: LatLngBounds(
const LatLng(-90, -180), const LatLng(-90, -180),
@ -303,8 +315,9 @@ class _MapWeatherState extends State<MapWeather> with TickerProviderStateMixin {
); );
}), }),
ExpandableFab( ExpandableFab(
key: _fabKey,
pos: ExpandableFabPos.right, pos: ExpandableFabPos.right,
type: ExpandableFabType.fan, type: ExpandableFabType.up,
distance: 70, distance: 70,
openButtonBuilder: RotateFloatingActionButtonBuilder( openButtonBuilder: RotateFloatingActionButtonBuilder(
child: const Icon(IconsaxPlusLinear.menu), child: const Icon(IconsaxPlusLinear.menu),
@ -317,16 +330,25 @@ class _MapWeatherState extends State<MapWeather> with TickerProviderStateMixin {
children: [ children: [
FloatingActionButton( FloatingActionButton(
heroTag: null, heroTag: null,
child: const Icon(IconsaxPlusLinear.gps), child: const Icon(IconsaxPlusLinear.home_2),
onPressed: () => _resetMapOrientation( onPressed: () => _resetMapOrientation(
center: center:
LatLng(mainLocation.lat!, mainLocation.lon!), LatLng(mainLocation.lat!, mainLocation.lon!),
zoom: 12), zoom: 8),
), ),
FloatingActionButton( FloatingActionButton(
heroTag: null, heroTag: null,
child: const Icon(IconsaxPlusLinear.refresh_2), child: const Icon(IconsaxPlusLinear.search_zoom_out_1),
onPressed: () => _resetMapOrientation(), onPressed: () => _animatedMapController.animatedZoomOut(
customId: _useTransformer ? _useTransformerId : null,
),
),
FloatingActionButton(
heroTag: null,
child: const Icon(IconsaxPlusLinear.search_zoom_in),
onPressed: () => _animatedMapController.animatedZoomIn(
customId: _useTransformer ? _useTransformerId : null,
),
), ),
], ],
), ),

View file

@ -50,7 +50,7 @@ dependencies:
flutter_local_notifications: ^17.2.2 flutter_local_notifications: ^17.2.2
internet_connection_checker_plus: ^2.5.1 internet_connection_checker_plus: ^2.5.1
dio_cache_interceptor_file_store: ^1.2.2 dio_cache_interceptor_file_store: ^1.2.2
isar: isar:
version: ^3.1.8 version: ^3.1.8
hosted: https://pub.isar-community.dev/ hosted: https://pub.isar-community.dev/
isar_flutter_libs: isar_flutter_libs:
@ -74,7 +74,7 @@ dev_dependencies:
json_serializable: ^6.8.0 json_serializable: ^6.8.0
flutter_native_splash: ^2.4.1 flutter_native_splash: ^2.4.1
flutter_launcher_icons: ^0.13.1 flutter_launcher_icons: ^0.13.1
isar_generator: isar_generator:
version: ^3.1.8 version: ^3.1.8
hosted: https://pub.isar-community.dev/ hosted: https://pub.isar-community.dev/