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;
|
final bool _isDarkMode = Get.theme.brightness == Brightness.dark;
|
||||||
WeatherCard? _selectedWeatherCard;
|
WeatherCard? _selectedWeatherCard;
|
||||||
bool _isCardVisible = false;
|
bool _isCardVisible = false;
|
||||||
double _cardBottomPosition = -200;
|
late final AnimationController _animationController;
|
||||||
|
late final Animation<Offset> _offsetAnimation;
|
||||||
|
|
||||||
final _focusNode = FocusNode();
|
final _focusNode = FocusNode();
|
||||||
late final TextEditingController _controllerSearch = TextEditingController();
|
late final TextEditingController _controllerSearch = TextEditingController();
|
||||||
|
@ -50,28 +51,44 @@ class _MapWeatherState extends State<MapWeather> with TickerProviderStateMixin {
|
||||||
return FileCacheStore('${dir.path}${Platform.pathSeparator}MapTiles');
|
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
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_animatedMapController.dispose();
|
_animatedMapController.dispose();
|
||||||
_controllerSearch.dispose();
|
_controllerSearch.dispose();
|
||||||
|
_animationController.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onMarkerTap(WeatherCard weatherCard) {
|
void _onMarkerTap(WeatherCard weatherCard) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_selectedWeatherCard = weatherCard;
|
_selectedWeatherCard = weatherCard;
|
||||||
_cardBottomPosition = 0;
|
|
||||||
_isCardVisible = true;
|
|
||||||
});
|
});
|
||||||
|
_animationController.forward();
|
||||||
|
_isCardVisible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _hideCard() {
|
void _hideCard() {
|
||||||
setState(() {
|
_animationController.reverse().then((_) {
|
||||||
_cardBottomPosition = -200;
|
|
||||||
});
|
|
||||||
Future.delayed(const Duration(milliseconds: 300), () {
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_isCardVisible = false;
|
_isCardVisible = false;
|
||||||
|
_selectedWeatherCard = null;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
_focusNode.unfocus();
|
_focusNode.unfocus();
|
||||||
|
@ -160,36 +177,28 @@ class _MapWeatherState extends State<MapWeather> with TickerProviderStateMixin {
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildWeatherCard() {
|
Widget _buildWeatherCard() {
|
||||||
return AnimatedPositioned(
|
return _isCardVisible && _selectedWeatherCard != null
|
||||||
duration: const Duration(milliseconds: 300),
|
? SlideTransition(
|
||||||
curve: Curves.easeInOut,
|
position: _offsetAnimation,
|
||||||
left: 0,
|
child: GestureDetector(
|
||||||
right: 0,
|
onTap: () => Get.to(
|
||||||
bottom: _cardBottomPosition,
|
() => InfoWeatherCard(weatherCard: _selectedWeatherCard!),
|
||||||
child: AnimatedOpacity(
|
transition: Transition.downToUp,
|
||||||
opacity: _isCardVisible ? 1.0 : 0.0,
|
),
|
||||||
duration: const Duration(milliseconds: 300),
|
child: WeatherCardContainer(
|
||||||
child: _isCardVisible
|
time: _selectedWeatherCard!.time!,
|
||||||
? GestureDetector(
|
timeDaily: _selectedWeatherCard!.timeDaily!,
|
||||||
onTap: () => Get.to(
|
timeDay: _selectedWeatherCard!.sunrise!,
|
||||||
() => InfoWeatherCard(weatherCard: _selectedWeatherCard!),
|
timeNight: _selectedWeatherCard!.sunset!,
|
||||||
transition: Transition.downToUp,
|
weather: _selectedWeatherCard!.weathercode!,
|
||||||
),
|
degree: _selectedWeatherCard!.temperature2M!,
|
||||||
child: WeatherCardContainer(
|
district: _selectedWeatherCard!.district!,
|
||||||
time: _selectedWeatherCard!.time!,
|
city: _selectedWeatherCard!.city!,
|
||||||
timeDaily: _selectedWeatherCard!.timeDaily!,
|
timezone: _selectedWeatherCard!.timezone!,
|
||||||
timeDay: _selectedWeatherCard!.sunrise!,
|
),
|
||||||
timeNight: _selectedWeatherCard!.sunset!,
|
),
|
||||||
weather: _selectedWeatherCard!.weathercode!,
|
)
|
||||||
degree: _selectedWeatherCard!.temperature2M!,
|
: const SizedBox.shrink();
|
||||||
district: _selectedWeatherCard!.district!,
|
|
||||||
city: _selectedWeatherCard!.city!,
|
|
||||||
timezone: _selectedWeatherCard!.timezone!,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: const SizedBox.shrink(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -280,7 +289,12 @@ class _MapWeatherState extends State<MapWeather> with TickerProviderStateMixin {
|
||||||
markers: [mainMarker, ...cardMarkers],
|
markers: [mainMarker, ...cardMarkers],
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
_buildWeatherCard(),
|
Positioned(
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: 0,
|
||||||
|
child: _buildWeatherCard(),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
RawAutocomplete<Result>(
|
RawAutocomplete<Result>(
|
||||||
|
|
|
@ -1195,10 +1195,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: url_launcher_android
|
name: url_launcher_android
|
||||||
sha256: f0c73347dfcfa5b3db8bc06e1502668265d39c08f310c29bff4e28eea9699f79
|
sha256: e35a698ac302dd68e41f73250bd9517fe3ab5fa4f18fe4647a0872db61bacbab
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.3.9"
|
version: "6.3.10"
|
||||||
url_launcher_ios:
|
url_launcher_ios:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -1369,4 +1369,4 @@ packages:
|
||||||
version: "3.1.2"
|
version: "3.1.2"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.5.0 <4.0.0"
|
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