2023-06-17 20:57:57 +03:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:get/get.dart';
|
2023-09-03 09:08:43 +03:00
|
|
|
import 'package:rain/app/widgets/desc/desc.dart';
|
|
|
|
import 'package:rain/app/widgets/desc/message.dart';
|
|
|
|
import 'package:rain/app/widgets/status/status_data.dart';
|
2023-06-17 20:57:57 +03:00
|
|
|
|
2023-08-03 20:52:20 +03:00
|
|
|
class DescContainer extends StatefulWidget {
|
2023-06-17 20:57:57 +03:00
|
|
|
const DescContainer({
|
|
|
|
super.key,
|
2023-10-15 12:38:03 +03:00
|
|
|
required this.humidity,
|
|
|
|
required this.wind,
|
|
|
|
required this.visibility,
|
|
|
|
required this.feels,
|
|
|
|
required this.evaporation,
|
|
|
|
required this.precipitation,
|
|
|
|
required this.direction,
|
|
|
|
required this.pressure,
|
|
|
|
required this.rain,
|
|
|
|
required this.cloudcover,
|
|
|
|
required this.windgusts,
|
|
|
|
required this.uvIndex,
|
|
|
|
required this.dewpoint2M,
|
|
|
|
required this.precipitationProbability,
|
|
|
|
required this.shortwaveRadiation,
|
2023-06-17 20:57:57 +03:00
|
|
|
});
|
2023-07-20 10:35:31 +03:00
|
|
|
final int? humidity;
|
|
|
|
final double? wind;
|
|
|
|
final double? visibility;
|
|
|
|
final double? feels;
|
|
|
|
final double? evaporation;
|
|
|
|
final double? precipitation;
|
|
|
|
final int? direction;
|
|
|
|
final double? pressure;
|
|
|
|
final double? rain;
|
|
|
|
final int? cloudcover;
|
|
|
|
final double? windgusts;
|
|
|
|
final double? uvIndex;
|
2023-10-15 12:04:16 +03:00
|
|
|
final double? dewpoint2M;
|
|
|
|
final int? precipitationProbability;
|
|
|
|
final double? shortwaveRadiation;
|
2023-06-17 20:57:57 +03:00
|
|
|
|
2023-08-03 20:52:20 +03:00
|
|
|
@override
|
|
|
|
State<DescContainer> createState() => _DescContainerState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _DescContainerState extends State<DescContainer> {
|
|
|
|
final statusData = StatusData();
|
|
|
|
final message = Message();
|
|
|
|
|
2023-06-17 20:57:57 +03:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-10-30 23:04:14 +05:30
|
|
|
final dewpoint2M = widget.dewpoint2M?.round();
|
|
|
|
final feels = widget.feels;
|
|
|
|
final visibility = widget.visibility;
|
|
|
|
final direction = widget.direction;
|
|
|
|
final wind = widget.wind;
|
|
|
|
final windgusts = widget.windgusts;
|
|
|
|
final evaporation = widget.evaporation;
|
|
|
|
final precipitation = widget.precipitation;
|
|
|
|
final rain = widget.rain;
|
|
|
|
final precipitationProbability = widget.precipitationProbability;
|
|
|
|
final humidity = widget.humidity;
|
|
|
|
final cloudcover = widget.cloudcover;
|
|
|
|
final pressure = widget.pressure;
|
|
|
|
final uvIndex = widget.uvIndex;
|
|
|
|
final shortwaveRadiation = widget.shortwaveRadiation;
|
|
|
|
|
2023-07-10 21:33:43 +03:00
|
|
|
return Card(
|
2023-06-17 20:57:57 +03:00
|
|
|
margin: const EdgeInsets.only(bottom: 15),
|
2023-07-10 21:33:43 +03:00
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.only(top: 22, bottom: 5),
|
2023-07-17 20:53:23 +03:00
|
|
|
child: Wrap(
|
2023-07-19 18:59:53 +03:00
|
|
|
alignment: WrapAlignment.spaceEvenly,
|
2023-07-17 20:53:23 +03:00
|
|
|
spacing: 5,
|
2023-07-10 21:33:43 +03:00
|
|
|
children: [
|
2023-10-30 23:04:14 +05:30
|
|
|
dewpoint2M == null
|
2023-10-15 12:04:16 +03:00
|
|
|
? const Offstage()
|
2023-07-20 10:35:31 +03:00
|
|
|
: DescWeather(
|
2023-10-15 12:04:16 +03:00
|
|
|
imageName: 'assets/images/dew.png',
|
2023-10-30 23:04:14 +05:30
|
|
|
value: statusData.getDegree(dewpoint2M.round()),
|
2023-10-15 12:04:16 +03:00
|
|
|
desc: 'dewpoint'.tr,
|
2023-07-20 10:35:31 +03:00
|
|
|
),
|
2023-10-30 23:04:14 +05:30
|
|
|
feels == null
|
2023-10-15 12:04:16 +03:00
|
|
|
? const Offstage()
|
2023-07-20 10:35:31 +03:00
|
|
|
: DescWeather(
|
|
|
|
imageName: 'assets/images/temperature.png',
|
2023-10-30 23:04:14 +05:30
|
|
|
value: statusData.getDegree(feels.round()),
|
2023-07-20 10:35:31 +03:00
|
|
|
desc: 'feels'.tr,
|
|
|
|
),
|
2023-10-30 23:04:14 +05:30
|
|
|
visibility == null
|
2023-10-15 12:04:16 +03:00
|
|
|
? const Offstage()
|
2023-07-20 10:35:31 +03:00
|
|
|
: DescWeather(
|
|
|
|
imageName: 'assets/images/fog.png',
|
2023-10-30 23:04:14 +05:30
|
|
|
value: statusData.getVisibility(visibility),
|
2023-07-20 10:35:31 +03:00
|
|
|
desc: 'visibility'.tr,
|
|
|
|
),
|
2023-10-30 23:04:14 +05:30
|
|
|
direction == null
|
2023-10-15 12:04:16 +03:00
|
|
|
? const Offstage()
|
2023-07-20 10:35:31 +03:00
|
|
|
: DescWeather(
|
|
|
|
imageName: 'assets/images/windsock.png',
|
2023-10-30 23:04:14 +05:30
|
|
|
value: '$direction°',
|
2023-07-20 10:35:31 +03:00
|
|
|
desc: 'direction'.tr,
|
2023-10-30 23:04:14 +05:30
|
|
|
message: message.getDirection(direction),
|
2023-07-20 10:35:31 +03:00
|
|
|
),
|
2023-10-30 23:04:14 +05:30
|
|
|
wind == null
|
2023-10-15 12:04:16 +03:00
|
|
|
? const Offstage()
|
2023-07-20 10:35:31 +03:00
|
|
|
: DescWeather(
|
|
|
|
imageName: 'assets/images/wind.png',
|
2023-10-30 23:04:14 +05:30
|
|
|
value: statusData.getSpeed(wind.round()),
|
2023-07-20 10:35:31 +03:00
|
|
|
desc: 'wind'.tr,
|
|
|
|
),
|
2023-10-30 23:04:14 +05:30
|
|
|
windgusts == null
|
2023-10-15 12:04:16 +03:00
|
|
|
? const Offstage()
|
2023-07-20 10:35:31 +03:00
|
|
|
: DescWeather(
|
|
|
|
imageName: 'assets/images/windgusts.png',
|
2023-10-30 23:04:14 +05:30
|
|
|
value: statusData.getSpeed(windgusts.round()),
|
2023-07-20 10:35:31 +03:00
|
|
|
desc: 'windgusts'.tr,
|
|
|
|
),
|
2023-10-30 23:04:14 +05:30
|
|
|
evaporation == null
|
2023-10-15 12:04:16 +03:00
|
|
|
? const Offstage()
|
2023-07-20 10:35:31 +03:00
|
|
|
: DescWeather(
|
|
|
|
imageName: 'assets/images/evaporation.png',
|
2023-10-30 23:04:14 +05:30
|
|
|
value: statusData.getPrecipitation(evaporation.abs()),
|
2023-07-20 10:35:31 +03:00
|
|
|
desc: 'evaporation'.tr,
|
|
|
|
),
|
2023-10-30 23:04:14 +05:30
|
|
|
precipitation == null
|
2023-10-15 12:04:16 +03:00
|
|
|
? const Offstage()
|
2023-07-20 10:35:31 +03:00
|
|
|
: DescWeather(
|
|
|
|
imageName: 'assets/images/rainfall.png',
|
2023-10-30 23:04:14 +05:30
|
|
|
value: statusData.getPrecipitation(precipitation),
|
2023-07-20 10:35:31 +03:00
|
|
|
desc: 'precipitation'.tr,
|
|
|
|
),
|
2023-10-30 23:04:14 +05:30
|
|
|
rain == null
|
2023-10-15 12:04:16 +03:00
|
|
|
? const Offstage()
|
2023-07-20 10:35:31 +03:00
|
|
|
: DescWeather(
|
|
|
|
imageName: 'assets/images/water.png',
|
2023-10-30 23:04:14 +05:30
|
|
|
value: statusData.getPrecipitation(rain),
|
2023-07-20 10:35:31 +03:00
|
|
|
desc: 'rain'.tr,
|
|
|
|
),
|
2023-10-30 23:04:14 +05:30
|
|
|
precipitationProbability == null
|
2023-10-15 12:04:16 +03:00
|
|
|
? const Offstage()
|
|
|
|
: DescWeather(
|
|
|
|
imageName: 'assets/images/precipitation_probability.png',
|
2023-10-30 23:04:14 +05:30
|
|
|
value: '$precipitationProbability%',
|
2023-10-15 12:20:56 +03:00
|
|
|
desc: 'precipitationProbability'.tr,
|
2023-10-15 12:04:16 +03:00
|
|
|
),
|
2023-10-30 23:04:14 +05:30
|
|
|
humidity == null
|
2023-10-15 12:04:16 +03:00
|
|
|
? const Offstage()
|
|
|
|
: DescWeather(
|
|
|
|
imageName: 'assets/images/humidity.png',
|
2023-10-30 23:04:14 +05:30
|
|
|
value: '$humidity%',
|
2023-10-15 12:04:16 +03:00
|
|
|
desc: 'humidity'.tr,
|
|
|
|
),
|
2023-10-30 23:04:14 +05:30
|
|
|
cloudcover == null
|
2023-10-15 12:04:16 +03:00
|
|
|
? const Offstage()
|
2023-07-20 10:35:31 +03:00
|
|
|
: DescWeather(
|
|
|
|
imageName: 'assets/images/cloudy.png',
|
2023-10-30 23:04:14 +05:30
|
|
|
value: '$cloudcover%',
|
2023-07-20 10:35:31 +03:00
|
|
|
desc: 'cloudcover'.tr,
|
|
|
|
),
|
2023-10-30 23:04:14 +05:30
|
|
|
pressure == null
|
2023-10-15 12:04:16 +03:00
|
|
|
? const Offstage()
|
2023-07-20 10:35:31 +03:00
|
|
|
: DescWeather(
|
|
|
|
imageName: 'assets/images/atmospheric.png',
|
2023-10-30 23:04:14 +05:30
|
|
|
value: '${pressure.round()} ${'hPa'.tr}',
|
2023-07-20 10:35:31 +03:00
|
|
|
desc: 'pressure'.tr,
|
2023-10-30 23:04:14 +05:30
|
|
|
message: message.getPressure(pressure.round()),
|
2023-07-20 10:35:31 +03:00
|
|
|
),
|
2023-10-30 23:04:14 +05:30
|
|
|
uvIndex == null
|
2023-10-15 12:04:16 +03:00
|
|
|
? const Offstage()
|
2023-07-20 10:35:31 +03:00
|
|
|
: DescWeather(
|
|
|
|
imageName: 'assets/images/uv.png',
|
2023-10-30 23:04:14 +05:30
|
|
|
value: '${uvIndex.round()}',
|
2023-07-20 10:35:31 +03:00
|
|
|
desc: 'uvIndex'.tr,
|
2023-10-30 23:04:14 +05:30
|
|
|
message: message.getUvIndex(uvIndex.round()),
|
2023-07-20 10:35:31 +03:00
|
|
|
),
|
2023-10-30 23:04:14 +05:30
|
|
|
shortwaveRadiation == null
|
2023-10-15 12:04:16 +03:00
|
|
|
? const Offstage()
|
|
|
|
: DescWeather(
|
|
|
|
imageName: 'assets/images/shortwave_radiation.png',
|
2023-10-30 23:04:14 +05:30
|
|
|
value: '${shortwaveRadiation.round()} ${'W/m2'.tr}',
|
2023-10-15 12:04:16 +03:00
|
|
|
desc: 'shortwaveRadiation'.tr,
|
|
|
|
),
|
2023-07-10 21:33:43 +03:00
|
|
|
],
|
2023-06-17 20:57:57 +03:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|