Rain/lib/app/ui/widgets/weather/hourly.dart

67 lines
1.7 KiB
Dart
Raw Normal View History

2023-06-17 20:57:57 +03:00
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
2024-09-06 22:07:50 +03:00
import 'package:rain/app/ui/widgets/weather/status/status_data.dart';
import 'package:rain/app/ui/widgets/weather/status/status_weather.dart';
2023-08-03 20:52:20 +03:00
import 'package:rain/main.dart';
2023-06-17 20:57:57 +03:00
2024-09-06 22:07:50 +03:00
class Hourly extends StatefulWidget {
const Hourly({
2023-06-17 20:57:57 +03:00
super.key,
required this.time,
required this.weather,
required this.degree,
required this.timeDay,
required this.timeNight,
});
final String time;
final String timeDay;
final String timeNight;
final int weather;
final double degree;
@override
2024-09-06 22:07:50 +03:00
State<Hourly> createState() => _HourlyState();
2023-06-17 20:57:57 +03:00
}
2024-09-06 22:07:50 +03:00
class _HourlyState extends State<Hourly> {
2023-07-15 21:51:32 +03:00
final statusWeather = StatusWeather();
final statusData = StatusData();
2023-06-17 20:57:57 +03:00
@override
Widget build(BuildContext context) {
final textTheme = context.textTheme;
final time = widget.time;
2023-06-17 20:57:57 +03:00
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Column(
children: [
2025-03-15 23:40:48 +03:00
Text(statusData.getTimeFormat(time), style: textTheme.labelLarge),
2023-06-17 20:57:57 +03:00
Text(
2025-03-15 23:40:48 +03:00
DateFormat(
'E',
locale.languageCode,
).format(DateTime.tryParse(time)!),
style: textTheme.labelLarge?.copyWith(color: Colors.grey),
2023-06-17 20:57:57 +03:00
),
],
),
Image.asset(
2023-07-15 21:51:32 +03:00
statusWeather.getImageToday(
widget.weather,
time,
widget.timeDay,
widget.timeNight,
),
2023-06-17 20:57:57 +03:00
scale: 3,
),
Text(
2023-07-15 21:51:32 +03:00
statusData.getDegree(widget.degree.round()),
2025-03-15 23:40:48 +03:00
style: textTheme.titleMedium?.copyWith(fontWeight: FontWeight.w600),
2023-06-17 20:57:57 +03:00
),
],
);
}
}