mirror of
https://github.com/darkmoonight/Rain.git
synced 2025-06-28 20:19:58 +00:00
Fix animation markers
This commit is contained in:
parent
88a7bafffb
commit
d0791279a2
2 changed files with 55 additions and 41 deletions
|
@ -40,7 +40,8 @@ class _MapWeatherState extends State<MapWeather> with TickerProviderStateMixin {
|
|||
final bool _isDarkMode = Get.theme.brightness == Brightness.dark;
|
||||
WeatherCard? _selectedWeatherCard;
|
||||
bool _isCardVisible = false;
|
||||
double _cardBottomPosition = -200;
|
||||
late final AnimationController _animationController;
|
||||
late final Animation<Offset> _offsetAnimation;
|
||||
|
||||
final _focusNode = FocusNode();
|
||||
late final TextEditingController _controllerSearch = TextEditingController();
|
||||
|
@ -50,28 +51,44 @@ class _MapWeatherState extends State<MapWeather> with TickerProviderStateMixin {
|
|||
return FileCacheStore('${dir.path}${Platform.pathSeparator}MapTiles');
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_animationController = AnimationController(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
vsync: this,
|
||||
);
|
||||
|
||||
_offsetAnimation = Tween<Offset>(
|
||||
begin: const Offset(0.0, 1.0),
|
||||
end: Offset.zero,
|
||||
).animate(CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: Curves.easeInOut,
|
||||
));
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_animatedMapController.dispose();
|
||||
_controllerSearch.dispose();
|
||||
_animationController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _onMarkerTap(WeatherCard weatherCard) {
|
||||
setState(() {
|
||||
_selectedWeatherCard = weatherCard;
|
||||
_cardBottomPosition = 0;
|
||||
_isCardVisible = true;
|
||||
});
|
||||
_animationController.forward();
|
||||
_isCardVisible = true;
|
||||
}
|
||||
|
||||
void _hideCard() {
|
||||
setState(() {
|
||||
_cardBottomPosition = -200;
|
||||
});
|
||||
Future.delayed(const Duration(milliseconds: 300), () {
|
||||
_animationController.reverse().then((_) {
|
||||
setState(() {
|
||||
_isCardVisible = false;
|
||||
_selectedWeatherCard = null;
|
||||
});
|
||||
});
|
||||
_focusNode.unfocus();
|
||||
|
@ -160,17 +177,10 @@ class _MapWeatherState extends State<MapWeather> with TickerProviderStateMixin {
|
|||
}
|
||||
|
||||
Widget _buildWeatherCard() {
|
||||
return AnimatedPositioned(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeInOut,
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: _cardBottomPosition,
|
||||
child: AnimatedOpacity(
|
||||
opacity: _isCardVisible ? 1.0 : 0.0,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
child: _isCardVisible
|
||||
? GestureDetector(
|
||||
return _isCardVisible && _selectedWeatherCard != null
|
||||
? SlideTransition(
|
||||
position: _offsetAnimation,
|
||||
child: GestureDetector(
|
||||
onTap: () => Get.to(
|
||||
() => InfoWeatherCard(weatherCard: _selectedWeatherCard!),
|
||||
transition: Transition.downToUp,
|
||||
|
@ -186,10 +196,9 @@ class _MapWeatherState extends State<MapWeather> with TickerProviderStateMixin {
|
|||
city: _selectedWeatherCard!.city!,
|
||||
timezone: _selectedWeatherCard!.timezone!,
|
||||
),
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
),
|
||||
);
|
||||
)
|
||||
: const SizedBox.shrink();
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -280,7 +289,12 @@ class _MapWeatherState extends State<MapWeather> with TickerProviderStateMixin {
|
|||
markers: [mainMarker, ...cardMarkers],
|
||||
);
|
||||
}),
|
||||
_buildWeatherCard(),
|
||||
Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
child: _buildWeatherCard(),
|
||||
),
|
||||
],
|
||||
),
|
||||
RawAutocomplete<Result>(
|
||||
|
|
|
@ -1195,10 +1195,10 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_android
|
||||
sha256: f0c73347dfcfa5b3db8bc06e1502668265d39c08f310c29bff4e28eea9699f79
|
||||
sha256: e35a698ac302dd68e41f73250bd9517fe3ab5fa4f18fe4647a0872db61bacbab
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.3.9"
|
||||
version: "6.3.10"
|
||||
url_launcher_ios:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -1369,4 +1369,4 @@ packages:
|
|||
version: "3.1.2"
|
||||
sdks:
|
||||
dart: ">=3.5.0 <4.0.0"
|
||||
flutter: ">=3.22.0"
|
||||
flutter: ">=3.24.0"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue