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,
|
|
|
|
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,
|
|
|
|
});
|
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-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-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-08-03 20:52:20 +03:00
|
|
|
widget.humidity == null
|
2023-07-20 10:35:31 +03:00
|
|
|
? Container()
|
|
|
|
: DescWeather(
|
|
|
|
imageName: 'assets/images/humidity.png',
|
2023-08-03 20:52:20 +03:00
|
|
|
value: '${widget.humidity}%',
|
2023-07-20 10:35:31 +03:00
|
|
|
desc: 'humidity'.tr,
|
|
|
|
),
|
2023-08-03 20:52:20 +03:00
|
|
|
widget.feels == null
|
2023-07-20 10:35:31 +03:00
|
|
|
? Container()
|
|
|
|
: DescWeather(
|
|
|
|
imageName: 'assets/images/temperature.png',
|
2023-08-03 20:52:20 +03:00
|
|
|
value: statusData.getDegree(widget.feels?.round()),
|
2023-07-20 10:35:31 +03:00
|
|
|
desc: 'feels'.tr,
|
|
|
|
),
|
2023-08-03 20:52:20 +03:00
|
|
|
widget.visibility == null
|
2023-07-20 10:35:31 +03:00
|
|
|
? Container()
|
|
|
|
: DescWeather(
|
|
|
|
imageName: 'assets/images/fog.png',
|
2023-08-03 20:52:20 +03:00
|
|
|
value: statusData.getVisibility(widget.visibility),
|
2023-07-20 10:35:31 +03:00
|
|
|
desc: 'visibility'.tr,
|
|
|
|
),
|
2023-08-03 20:52:20 +03:00
|
|
|
widget.direction == null
|
2023-07-20 10:35:31 +03:00
|
|
|
? Container()
|
|
|
|
: DescWeather(
|
|
|
|
imageName: 'assets/images/windsock.png',
|
2023-08-03 20:52:20 +03:00
|
|
|
value: '${widget.direction}°',
|
2023-07-20 10:35:31 +03:00
|
|
|
desc: 'direction'.tr,
|
2023-08-03 20:52:20 +03:00
|
|
|
message: message.getDirection(widget.direction),
|
2023-07-20 10:35:31 +03:00
|
|
|
),
|
2023-08-03 20:52:20 +03:00
|
|
|
widget.wind == null
|
2023-07-20 10:35:31 +03:00
|
|
|
? Container()
|
|
|
|
: DescWeather(
|
|
|
|
imageName: 'assets/images/wind.png',
|
2023-08-03 20:52:20 +03:00
|
|
|
value: statusData.getSpeed(widget.wind?.round()),
|
2023-07-20 10:35:31 +03:00
|
|
|
desc: 'wind'.tr,
|
|
|
|
),
|
2023-08-03 20:52:20 +03:00
|
|
|
widget.windgusts == null
|
2023-07-20 10:35:31 +03:00
|
|
|
? Container()
|
|
|
|
: DescWeather(
|
|
|
|
imageName: 'assets/images/windgusts.png',
|
2023-08-03 20:52:20 +03:00
|
|
|
value: statusData.getSpeed(widget.windgusts?.round()),
|
2023-07-20 10:35:31 +03:00
|
|
|
desc: 'windgusts'.tr,
|
|
|
|
),
|
2023-08-03 20:52:20 +03:00
|
|
|
widget.evaporation == null
|
2023-07-20 10:35:31 +03:00
|
|
|
? Container()
|
|
|
|
: DescWeather(
|
|
|
|
imageName: 'assets/images/evaporation.png',
|
2023-08-03 20:52:20 +03:00
|
|
|
value:
|
|
|
|
statusData.getPrecipitation(widget.evaporation?.abs()),
|
2023-07-20 10:35:31 +03:00
|
|
|
desc: 'evaporation'.tr,
|
|
|
|
),
|
2023-08-03 20:52:20 +03:00
|
|
|
widget.precipitation == null
|
2023-07-20 10:35:31 +03:00
|
|
|
? Container()
|
|
|
|
: DescWeather(
|
|
|
|
imageName: 'assets/images/rainfall.png',
|
2023-08-03 20:52:20 +03:00
|
|
|
value: statusData.getPrecipitation(widget.precipitation),
|
2023-07-20 10:35:31 +03:00
|
|
|
desc: 'precipitation'.tr,
|
|
|
|
),
|
2023-08-03 20:52:20 +03:00
|
|
|
widget.rain == null
|
2023-07-20 10:35:31 +03:00
|
|
|
? Container()
|
|
|
|
: DescWeather(
|
|
|
|
imageName: 'assets/images/water.png',
|
2023-08-03 20:52:20 +03:00
|
|
|
value: statusData.getPrecipitation(widget.rain),
|
2023-07-20 10:35:31 +03:00
|
|
|
desc: 'rain'.tr,
|
|
|
|
),
|
2023-08-03 20:52:20 +03:00
|
|
|
widget.cloudcover == null
|
2023-07-20 10:35:31 +03:00
|
|
|
? Container()
|
|
|
|
: DescWeather(
|
|
|
|
imageName: 'assets/images/cloudy.png',
|
2023-08-03 20:52:20 +03:00
|
|
|
value: '${widget.cloudcover}%',
|
2023-07-20 10:35:31 +03:00
|
|
|
desc: 'cloudcover'.tr,
|
|
|
|
),
|
2023-08-03 20:52:20 +03:00
|
|
|
widget.pressure == null
|
2023-07-20 10:35:31 +03:00
|
|
|
? Container()
|
|
|
|
: DescWeather(
|
|
|
|
imageName: 'assets/images/atmospheric.png',
|
2023-08-03 20:52:20 +03:00
|
|
|
value: '${widget.pressure?.round()} ${'hPa'.tr}',
|
2023-07-20 10:35:31 +03:00
|
|
|
desc: 'pressure'.tr,
|
2023-08-03 20:52:20 +03:00
|
|
|
message: message.getPressure(widget.pressure?.round()),
|
2023-07-20 10:35:31 +03:00
|
|
|
),
|
2023-08-03 20:52:20 +03:00
|
|
|
widget.uvIndex == null
|
2023-07-20 10:35:31 +03:00
|
|
|
? Container()
|
|
|
|
: DescWeather(
|
|
|
|
imageName: 'assets/images/uv.png',
|
2023-08-03 20:52:20 +03:00
|
|
|
value: '${widget.uvIndex?.round()}',
|
2023-07-20 10:35:31 +03:00
|
|
|
desc: 'uvIndex'.tr,
|
2023-08-03 20:52:20 +03:00
|
|
|
message: message.getUvIndex(widget.uvIndex?.round()),
|
2023-07-20 10:35:31 +03:00
|
|
|
),
|
2023-07-10 21:33:43 +03:00
|
|
|
],
|
2023-06-17 20:57:57 +03:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|