From dd579381538980f032068771da87d684997c6ae5 Mon Sep 17 00:00:00 2001 From: Yoshi Date: Mon, 29 Jul 2024 22:37:08 +0300 Subject: [PATCH] Fix anim new add form && Add feels to the top tile --- .../modules/cards/view/info_weather_card.dart | 1 + .../cards/widgets/create_card_weather.dart | 60 +++++++++++++++---- lib/app/modules/main/view/weather.dart | 1 + lib/app/widgets/daily/info_daily_card.dart | 2 + lib/app/widgets/daily/weather_daily.dart | 5 +- lib/app/widgets/now/weather_now.dart | 16 ++++- pubspec.lock | 40 ++++++------- pubspec.yaml | 6 +- 8 files changed, 89 insertions(+), 42 deletions(-) diff --git a/lib/app/modules/cards/view/info_weather_card.dart b/lib/app/modules/cards/view/info_weather_card.dart index 22def54..0f40622 100644 --- a/lib/app/modules/cards/view/info_weather_card.dart +++ b/lib/app/modules/cards/view/info_weather_card.dart @@ -91,6 +91,7 @@ class _InfoWeatherCardState extends State { time: weatherCard.time![timeNow], weather: weatherCard.weathercode![timeNow], degree: weatherCard.temperature2M![timeNow], + feels: weatherCard.apparentTemperature![timeNow]!, timeDay: weatherCard.sunrise![dayNow], timeNight: weatherCard.sunset![dayNow], tempMax: weatherCard.temperature2MMax![dayNow]!, diff --git a/lib/app/modules/cards/widgets/create_card_weather.dart b/lib/app/modules/cards/widgets/create_card_weather.dart index 49b4504..6dea2ed 100644 --- a/lib/app/modules/cards/widgets/create_card_weather.dart +++ b/lib/app/modules/cards/widgets/create_card_weather.dart @@ -15,7 +15,8 @@ class CreateWeatherCard extends StatefulWidget { State createState() => _CreateWeatherCardState(); } -class _CreateWeatherCardState extends State { +class _CreateWeatherCardState extends State + with SingleTickerProviderStateMixin { bool isLoading = false; final formKey = GlobalKey(); final _focusNode = FocusNode(); @@ -26,14 +27,41 @@ class _CreateWeatherCardState extends State { final _controllerCity = TextEditingController(); final _controllerDistrict = TextEditingController(); - textTrim(value) { + late AnimationController _animationController; + late Animation _animation; + + @override + void initState() { + super.initState(); + _animationController = AnimationController( + duration: const Duration(milliseconds: 300), + vsync: this, + ); + _animation = CurvedAnimation( + parent: _animationController, + curve: Curves.easeInOut, + ); + } + + @override + void dispose() { + _animationController.dispose(); + _controller.dispose(); + _controllerLat.dispose(); + _controllerLon.dispose(); + _controllerCity.dispose(); + _controllerDistrict.dispose(); + super.dispose(); + } + + void textTrim(TextEditingController value) { value.text = value.text.trim(); while (value.text.contains(' ')) { value.text = value.text.replaceAll(' ', ' '); } } - void fillController(selection) { + void fillController(Result selection) { _controllerLat.text = '${selection.latitude}'; _controllerLon.text = '${selection.longitude}'; _controllerCity.text = selection.name; @@ -46,6 +74,17 @@ class _CreateWeatherCardState extends State { @override Widget build(BuildContext context) { const kTextFieldElevation = 4.0; + bool showButton = _controllerLon.text.isNotEmpty && + _controllerLat.text.isNotEmpty && + _controllerCity.text.isNotEmpty && + _controllerDistrict.text.isNotEmpty; + + if (showButton) { + _animationController.forward(); + } else { + _animationController.reverse(); + } + return Padding( padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom), child: Form( @@ -62,12 +101,11 @@ class _CreateWeatherCardState extends State { mainAxisSize: MainAxisSize.min, children: [ Padding( - padding: const EdgeInsets.fromLTRB(10, 15, 10, 5), + padding: const EdgeInsets.only(top: 14, bottom: 7), child: Text( 'create'.tr, - style: context.textTheme.titleLarge?.copyWith( - fontSize: 20, - ), + style: context.textTheme.titleLarge + ?.copyWith(fontWeight: FontWeight.bold), textAlign: TextAlign.center, ), ), @@ -214,11 +252,9 @@ class _CreateWeatherCardState extends State { Padding( padding: const EdgeInsets.symmetric( horizontal: 10, vertical: 10), - child: Visibility( - visible: _controllerLon.text.isNotEmpty && - _controllerLat.text.isNotEmpty && - _controllerCity.text.isNotEmpty && - _controllerDistrict.text.isNotEmpty, + child: SizeTransition( + sizeFactor: _animation, + axisAlignment: -1.0, child: MyTextButton( buttonName: 'done'.tr, onPressed: () async { diff --git a/lib/app/modules/main/view/weather.dart b/lib/app/modules/main/view/weather.dart index efde67e..4cba272 100644 --- a/lib/app/modules/main/view/weather.dart +++ b/lib/app/modules/main/view/weather.dart @@ -73,6 +73,7 @@ class _WeatherPageState extends State { time: mainWeather.time![hourOfDay], weather: mainWeather.weathercode![hourOfDay], degree: mainWeather.temperature2M![hourOfDay], + feels: mainWeather.apparentTemperature![hourOfDay]!, timeDay: sunrise, timeNight: sunset, tempMax: tempMax!, diff --git a/lib/app/widgets/daily/info_daily_card.dart b/lib/app/widgets/daily/info_daily_card.dart index f56f19f..02d5445 100644 --- a/lib/app/widgets/daily/info_daily_card.dart +++ b/lib/app/widgets/daily/info_daily_card.dart @@ -123,6 +123,8 @@ class _InfoDailyCardState extends State { weatherData.weathercode![startIndex + hourOfDay], degree: weatherData .temperature2M![startIndex + hourOfDay], + feels: weatherData + .apparentTemperature![startIndex + hourOfDay]!, time: weatherData.time![startIndex + hourOfDay], timeDay: sunrise, timeNight: sunset, diff --git a/lib/app/widgets/daily/weather_daily.dart b/lib/app/widgets/daily/weather_daily.dart index 57d1d99..e809c4b 100644 --- a/lib/app/widgets/daily/weather_daily.dart +++ b/lib/app/widgets/daily/weather_daily.dart @@ -36,9 +36,6 @@ class _WeatherDailyState extends State { final weatherCodeDaily = weatherData.weathercodeDaily ?? []; final textTheme = context.textTheme; final labelLarge = textTheme.labelLarge; - final bodyMediumGrey = textTheme.bodyMedium?.copyWith( - color: Colors.grey, - ); return Card( margin: const EdgeInsets.only(bottom: 15), @@ -107,7 +104,7 @@ class _WeatherDailyState extends State { ), Text( ' / ', - style: bodyMediumGrey, + style: labelLarge, ), Text( statusData.getDegree( diff --git a/lib/app/widgets/now/weather_now.dart b/lib/app/widgets/now/weather_now.dart index 8d97f11..2f4e039 100644 --- a/lib/app/widgets/now/weather_now.dart +++ b/lib/app/widgets/now/weather_now.dart @@ -16,6 +16,7 @@ class WeatherNow extends StatefulWidget { required this.timeNight, required this.tempMax, required this.tempMin, + required this.feels, }); final String time; final String timeDay; @@ -24,6 +25,7 @@ class WeatherNow extends StatefulWidget { final double degree; final double tempMax; final double tempMin; + final double feels; @override State createState() => _WeatherNowState(); @@ -97,6 +99,16 @@ class _WeatherNowState extends State { style: context.textTheme.titleLarge ?.copyWith(fontSize: 20), ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('feels'.tr, + style: context.textTheme.bodyMedium), + Text(' • ', style: context.textTheme.bodyMedium), + Text(statusData.getDegree(widget.feels.round()), + style: context.textTheme.bodyMedium), + ], + ), const SizedBox(height: 30), Text( statusData.getDegree(roundDegree @@ -112,9 +124,7 @@ class _WeatherNowState extends State { children: [ Text(statusData.getDegree((widget.tempMin.round())), style: context.textTheme.labelLarge), - Text(' / ', - style: context.textTheme.labelLarge - ?.copyWith(color: Colors.grey)), + Text(' / ', style: context.textTheme.labelLarge), Text(statusData.getDegree((widget.tempMax.round())), style: context.textTheme.labelLarge), ], diff --git a/pubspec.lock b/pubspec.lock index 71c146b..c18b7b8 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -173,18 +173,18 @@ packages: dependency: "direct main" description: name: connectivity_plus - sha256: db7a4e143dc72cc3cb2044ef9b052a7ebfe729513e6a82943bc3526f784365b8 + sha256: "3e7d1d9dbae40ae82cbe6c23c518f0c4ffe32764ee9749b9a99d32cbac8734f6" url: "https://pub.dev" source: hosted - version: "6.0.3" + version: "6.0.4" connectivity_plus_platform_interface: dependency: transitive description: name: connectivity_plus_platform_interface - sha256: b6a56efe1e6675be240de39107281d4034b64ac23438026355b4234042a35adb + sha256: "42657c1715d48b167930d5f34d00222ac100475f73d10162ddf43e714932f204" url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "2.0.1" convert: dependency: transitive description: @@ -237,18 +237,18 @@ packages: dependency: "direct main" description: name: device_info_plus - sha256: eead12d1a1ed83d8283ab4c2f3fca23ac4082f29f25f29dff0f758f57d06ec91 + sha256: "93429694c9253d2871b3af80cf11b3cbb5c65660d402ed7bf69854ce4a089f82" url: "https://pub.dev" source: hosted - version: "10.1.0" + version: "10.1.1" device_info_plus_platform_interface: dependency: transitive description: name: device_info_plus_platform_interface - sha256: d3b01d5868b50ae571cd1dc6e502fc94d956b665756180f7b16ead09e836fd64 + sha256: "282d3cf731045a2feb66abfe61bbc40870ae50a3ed10a4d3d217556c35c8c2ba" url: "https://pub.dev" source: hosted - version: "7.0.0" + version: "7.0.1" dio: dependency: "direct main" description: @@ -474,10 +474,10 @@ packages: dependency: transitive description: name: geolocator_android - sha256: "00c7177a95823dd3ee35ef42fd8666cd27d219ae14cea472ac76a21dff43000b" + sha256: "7aefc530db47d90d0580b552df3242440a10fe60814496a979aa67aa98b1fd47" url: "https://pub.dev" source: hosted - version: "4.6.0" + version: "4.6.1" geolocator_apple: dependency: transitive description: @@ -770,18 +770,18 @@ packages: dependency: "direct main" description: name: package_info_plus - sha256: b93d8b4d624b4ea19b0a5a208b2d6eff06004bc3ce74c06040b120eeadd00ce0 + sha256: "4de6c36df77ffbcef0a5aefe04669d33f2d18397fea228277b852a2d4e58e860" url: "https://pub.dev" source: hosted - version: "8.0.0" + version: "8.0.1" package_info_plus_platform_interface: dependency: transitive description: name: package_info_plus_platform_interface - sha256: f49918f3433a3146047372f9d4f1f847511f2acd5cd030e1f44fe5a50036b70e + sha256: ac1f4a4847f1ade8e6a87d1f39f5d7c67490738642e2542f559ec38c37489a66 url: "https://pub.dev" source: hosted - version: "3.0.0" + version: "3.0.1" path: dependency: transitive description: @@ -802,10 +802,10 @@ packages: dependency: transitive description: name: path_provider_android - sha256: "30c5aa827a6ae95ce2853cdc5fe3971daaac00f6f081c419c013f7f57bff2f5e" + sha256: "490539678396d4c3c0b06efdaab75ae60675c3e0c66f72bc04c2e2c1e0e2abeb" url: "https://pub.dev" source: hosted - version: "2.2.7" + version: "2.2.9" path_provider_foundation: dependency: transitive description: @@ -1063,10 +1063,10 @@ packages: dependency: transitive description: name: url_launcher_android - sha256: "95d8027db36a0e52caf55680f91e33ea6aa12a3ce608c90b06f4e429a21067ac" + sha256: "678979703e10d7862c551c736fe6b9f185261bddf141b46672063b99790bc700" url: "https://pub.dev" source: hosted - version: "6.3.5" + version: "6.3.7" url_launcher_ios: dependency: transitive description: @@ -1183,10 +1183,10 @@ packages: dependency: transitive description: name: win32_registry - sha256: "10589e0d7f4e053f2c61023a31c9ce01146656a70b7b7f0828c0b46d7da2a9bb" + sha256: "723b7f851e5724c55409bb3d5a32b203b3afe8587eaf5dafb93a5fed8ecda0d6" url: "https://pub.dev" source: hosted - version: "1.1.3" + version: "1.1.4" workmanager: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 3298ded..3ebee91 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -37,9 +37,9 @@ dependencies: # quick_settings: ^1.0.1 json_annotation: ^4.9.0 flutter_timezone: ^2.1.0 - device_info_plus: ^10.1.0 - package_info_plus: ^8.0.0 - connectivity_plus: ^6.0.3 + device_info_plus: ^10.1.1 + package_info_plus: ^8.0.1 + connectivity_plus: ^6.0.4 freezed_annotation: ^2.4.4 isar_flutter_libs: version: ^3.1.7