Fix anim new add form && Add feels to the top tile

This commit is contained in:
Yoshi 2024-07-29 22:37:08 +03:00
parent fc246ac5a2
commit dd57938153
8 changed files with 89 additions and 42 deletions

View file

@ -91,6 +91,7 @@ class _InfoWeatherCardState extends State<InfoWeatherCard> {
time: weatherCard.time![timeNow], time: weatherCard.time![timeNow],
weather: weatherCard.weathercode![timeNow], weather: weatherCard.weathercode![timeNow],
degree: weatherCard.temperature2M![timeNow], degree: weatherCard.temperature2M![timeNow],
feels: weatherCard.apparentTemperature![timeNow]!,
timeDay: weatherCard.sunrise![dayNow], timeDay: weatherCard.sunrise![dayNow],
timeNight: weatherCard.sunset![dayNow], timeNight: weatherCard.sunset![dayNow],
tempMax: weatherCard.temperature2MMax![dayNow]!, tempMax: weatherCard.temperature2MMax![dayNow]!,

View file

@ -15,7 +15,8 @@ class CreateWeatherCard extends StatefulWidget {
State<CreateWeatherCard> createState() => _CreateWeatherCardState(); State<CreateWeatherCard> createState() => _CreateWeatherCardState();
} }
class _CreateWeatherCardState extends State<CreateWeatherCard> { class _CreateWeatherCardState extends State<CreateWeatherCard>
with SingleTickerProviderStateMixin {
bool isLoading = false; bool isLoading = false;
final formKey = GlobalKey<FormState>(); final formKey = GlobalKey<FormState>();
final _focusNode = FocusNode(); final _focusNode = FocusNode();
@ -26,14 +27,41 @@ class _CreateWeatherCardState extends State<CreateWeatherCard> {
final _controllerCity = TextEditingController(); final _controllerCity = TextEditingController();
final _controllerDistrict = TextEditingController(); final _controllerDistrict = TextEditingController();
textTrim(value) { late AnimationController _animationController;
late Animation<double> _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(); value.text = value.text.trim();
while (value.text.contains(' ')) { while (value.text.contains(' ')) {
value.text = value.text.replaceAll(' ', ' '); value.text = value.text.replaceAll(' ', ' ');
} }
} }
void fillController(selection) { void fillController(Result selection) {
_controllerLat.text = '${selection.latitude}'; _controllerLat.text = '${selection.latitude}';
_controllerLon.text = '${selection.longitude}'; _controllerLon.text = '${selection.longitude}';
_controllerCity.text = selection.name; _controllerCity.text = selection.name;
@ -46,6 +74,17 @@ class _CreateWeatherCardState extends State<CreateWeatherCard> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
const kTextFieldElevation = 4.0; 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( return Padding(
padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom), padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
child: Form( child: Form(
@ -62,12 +101,11 @@ class _CreateWeatherCardState extends State<CreateWeatherCard> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.fromLTRB(10, 15, 10, 5), padding: const EdgeInsets.only(top: 14, bottom: 7),
child: Text( child: Text(
'create'.tr, 'create'.tr,
style: context.textTheme.titleLarge?.copyWith( style: context.textTheme.titleLarge
fontSize: 20, ?.copyWith(fontWeight: FontWeight.bold),
),
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
), ),
@ -214,11 +252,9 @@ class _CreateWeatherCardState extends State<CreateWeatherCard> {
Padding( Padding(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 10, vertical: 10), horizontal: 10, vertical: 10),
child: Visibility( child: SizeTransition(
visible: _controllerLon.text.isNotEmpty && sizeFactor: _animation,
_controllerLat.text.isNotEmpty && axisAlignment: -1.0,
_controllerCity.text.isNotEmpty &&
_controllerDistrict.text.isNotEmpty,
child: MyTextButton( child: MyTextButton(
buttonName: 'done'.tr, buttonName: 'done'.tr,
onPressed: () async { onPressed: () async {

View file

@ -73,6 +73,7 @@ class _WeatherPageState extends State<WeatherPage> {
time: mainWeather.time![hourOfDay], time: mainWeather.time![hourOfDay],
weather: mainWeather.weathercode![hourOfDay], weather: mainWeather.weathercode![hourOfDay],
degree: mainWeather.temperature2M![hourOfDay], degree: mainWeather.temperature2M![hourOfDay],
feels: mainWeather.apparentTemperature![hourOfDay]!,
timeDay: sunrise, timeDay: sunrise,
timeNight: sunset, timeNight: sunset,
tempMax: tempMax!, tempMax: tempMax!,

View file

@ -123,6 +123,8 @@ class _InfoDailyCardState extends State<InfoDailyCard> {
weatherData.weathercode![startIndex + hourOfDay], weatherData.weathercode![startIndex + hourOfDay],
degree: weatherData degree: weatherData
.temperature2M![startIndex + hourOfDay], .temperature2M![startIndex + hourOfDay],
feels: weatherData
.apparentTemperature![startIndex + hourOfDay]!,
time: weatherData.time![startIndex + hourOfDay], time: weatherData.time![startIndex + hourOfDay],
timeDay: sunrise, timeDay: sunrise,
timeNight: sunset, timeNight: sunset,

View file

@ -36,9 +36,6 @@ class _WeatherDailyState extends State<WeatherDaily> {
final weatherCodeDaily = weatherData.weathercodeDaily ?? []; final weatherCodeDaily = weatherData.weathercodeDaily ?? [];
final textTheme = context.textTheme; final textTheme = context.textTheme;
final labelLarge = textTheme.labelLarge; final labelLarge = textTheme.labelLarge;
final bodyMediumGrey = textTheme.bodyMedium?.copyWith(
color: Colors.grey,
);
return Card( return Card(
margin: const EdgeInsets.only(bottom: 15), margin: const EdgeInsets.only(bottom: 15),
@ -107,7 +104,7 @@ class _WeatherDailyState extends State<WeatherDaily> {
), ),
Text( Text(
' / ', ' / ',
style: bodyMediumGrey, style: labelLarge,
), ),
Text( Text(
statusData.getDegree( statusData.getDegree(

View file

@ -16,6 +16,7 @@ class WeatherNow extends StatefulWidget {
required this.timeNight, required this.timeNight,
required this.tempMax, required this.tempMax,
required this.tempMin, required this.tempMin,
required this.feels,
}); });
final String time; final String time;
final String timeDay; final String timeDay;
@ -24,6 +25,7 @@ class WeatherNow extends StatefulWidget {
final double degree; final double degree;
final double tempMax; final double tempMax;
final double tempMin; final double tempMin;
final double feels;
@override @override
State<WeatherNow> createState() => _WeatherNowState(); State<WeatherNow> createState() => _WeatherNowState();
@ -97,6 +99,16 @@ class _WeatherNowState extends State<WeatherNow> {
style: context.textTheme.titleLarge style: context.textTheme.titleLarge
?.copyWith(fontSize: 20), ?.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), const SizedBox(height: 30),
Text( Text(
statusData.getDegree(roundDegree statusData.getDegree(roundDegree
@ -112,9 +124,7 @@ class _WeatherNowState extends State<WeatherNow> {
children: [ children: [
Text(statusData.getDegree((widget.tempMin.round())), Text(statusData.getDegree((widget.tempMin.round())),
style: context.textTheme.labelLarge), style: context.textTheme.labelLarge),
Text(' / ', Text(' / ', style: context.textTheme.labelLarge),
style: context.textTheme.labelLarge
?.copyWith(color: Colors.grey)),
Text(statusData.getDegree((widget.tempMax.round())), Text(statusData.getDegree((widget.tempMax.round())),
style: context.textTheme.labelLarge), style: context.textTheme.labelLarge),
], ],

View file

@ -173,18 +173,18 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: connectivity_plus name: connectivity_plus
sha256: db7a4e143dc72cc3cb2044ef9b052a7ebfe729513e6a82943bc3526f784365b8 sha256: "3e7d1d9dbae40ae82cbe6c23c518f0c4ffe32764ee9749b9a99d32cbac8734f6"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "6.0.3" version: "6.0.4"
connectivity_plus_platform_interface: connectivity_plus_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: connectivity_plus_platform_interface name: connectivity_plus_platform_interface
sha256: b6a56efe1e6675be240de39107281d4034b64ac23438026355b4234042a35adb sha256: "42657c1715d48b167930d5f34d00222ac100475f73d10162ddf43e714932f204"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.0" version: "2.0.1"
convert: convert:
dependency: transitive dependency: transitive
description: description:
@ -237,18 +237,18 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: device_info_plus name: device_info_plus
sha256: eead12d1a1ed83d8283ab4c2f3fca23ac4082f29f25f29dff0f758f57d06ec91 sha256: "93429694c9253d2871b3af80cf11b3cbb5c65660d402ed7bf69854ce4a089f82"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "10.1.0" version: "10.1.1"
device_info_plus_platform_interface: device_info_plus_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: device_info_plus_platform_interface name: device_info_plus_platform_interface
sha256: d3b01d5868b50ae571cd1dc6e502fc94d956b665756180f7b16ead09e836fd64 sha256: "282d3cf731045a2feb66abfe61bbc40870ae50a3ed10a4d3d217556c35c8c2ba"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "7.0.0" version: "7.0.1"
dio: dio:
dependency: "direct main" dependency: "direct main"
description: description:
@ -474,10 +474,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: geolocator_android name: geolocator_android
sha256: "00c7177a95823dd3ee35ef42fd8666cd27d219ae14cea472ac76a21dff43000b" sha256: "7aefc530db47d90d0580b552df3242440a10fe60814496a979aa67aa98b1fd47"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.6.0" version: "4.6.1"
geolocator_apple: geolocator_apple:
dependency: transitive dependency: transitive
description: description:
@ -770,18 +770,18 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: package_info_plus name: package_info_plus
sha256: b93d8b4d624b4ea19b0a5a208b2d6eff06004bc3ce74c06040b120eeadd00ce0 sha256: "4de6c36df77ffbcef0a5aefe04669d33f2d18397fea228277b852a2d4e58e860"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "8.0.0" version: "8.0.1"
package_info_plus_platform_interface: package_info_plus_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: package_info_plus_platform_interface name: package_info_plus_platform_interface
sha256: f49918f3433a3146047372f9d4f1f847511f2acd5cd030e1f44fe5a50036b70e sha256: ac1f4a4847f1ade8e6a87d1f39f5d7c67490738642e2542f559ec38c37489a66
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.0" version: "3.0.1"
path: path:
dependency: transitive dependency: transitive
description: description:
@ -802,10 +802,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: path_provider_android name: path_provider_android
sha256: "30c5aa827a6ae95ce2853cdc5fe3971daaac00f6f081c419c013f7f57bff2f5e" sha256: "490539678396d4c3c0b06efdaab75ae60675c3e0c66f72bc04c2e2c1e0e2abeb"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.2.7" version: "2.2.9"
path_provider_foundation: path_provider_foundation:
dependency: transitive dependency: transitive
description: description:
@ -1063,10 +1063,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_android name: url_launcher_android
sha256: "95d8027db36a0e52caf55680f91e33ea6aa12a3ce608c90b06f4e429a21067ac" sha256: "678979703e10d7862c551c736fe6b9f185261bddf141b46672063b99790bc700"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "6.3.5" version: "6.3.7"
url_launcher_ios: url_launcher_ios:
dependency: transitive dependency: transitive
description: description:
@ -1183,10 +1183,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: win32_registry name: win32_registry
sha256: "10589e0d7f4e053f2c61023a31c9ce01146656a70b7b7f0828c0b46d7da2a9bb" sha256: "723b7f851e5724c55409bb3d5a32b203b3afe8587eaf5dafb93a5fed8ecda0d6"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.3" version: "1.1.4"
workmanager: workmanager:
dependency: "direct main" dependency: "direct main"
description: description:

View file

@ -37,9 +37,9 @@ dependencies:
# quick_settings: ^1.0.1 # quick_settings: ^1.0.1
json_annotation: ^4.9.0 json_annotation: ^4.9.0
flutter_timezone: ^2.1.0 flutter_timezone: ^2.1.0
device_info_plus: ^10.1.0 device_info_plus: ^10.1.1
package_info_plus: ^8.0.0 package_info_plus: ^8.0.1
connectivity_plus: ^6.0.3 connectivity_plus: ^6.0.4
freezed_annotation: ^2.4.4 freezed_annotation: ^2.4.4
isar_flutter_libs: isar_flutter_libs:
version: ^3.1.7 version: ^3.1.7