2023-06-17 20:57:57 +03:00
|
|
|
import 'package:flutter/material.dart';
|
2024-08-04 11:48:25 +03:00
|
|
|
import 'package:gap/gap.dart';
|
2023-06-17 20:57:57 +03:00
|
|
|
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_weather.dart';
|
|
|
|
import 'package:rain/app/ui/widgets/weather/status/status_data.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 DailyCard extends StatefulWidget {
|
|
|
|
const DailyCard({
|
2023-06-17 20:57:57 +03:00
|
|
|
super.key,
|
|
|
|
required this.timeDaily,
|
|
|
|
required this.weathercodeDaily,
|
|
|
|
required this.temperature2MMax,
|
|
|
|
required this.temperature2MMin,
|
|
|
|
});
|
|
|
|
final DateTime timeDaily;
|
2023-07-20 22:30:01 +03:00
|
|
|
final int? weathercodeDaily;
|
|
|
|
final double? temperature2MMax;
|
|
|
|
final double? temperature2MMin;
|
2023-06-17 20:57:57 +03:00
|
|
|
|
|
|
|
@override
|
2024-09-06 22:07:50 +03:00
|
|
|
State<DailyCard> createState() => _DailyCardState();
|
2023-08-03 20:52:20 +03:00
|
|
|
}
|
2023-06-17 20:57:57 +03:00
|
|
|
|
2024-09-06 22:07:50 +03:00
|
|
|
class _DailyCardState extends State<DailyCard> {
|
2023-08-03 20:52:20 +03:00
|
|
|
final statusWeather = StatusWeather();
|
|
|
|
final statusData = StatusData();
|
2023-09-03 09:08:43 +03:00
|
|
|
|
2023-08-03 20:52:20 +03:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return widget.weathercodeDaily == null
|
2023-07-20 22:30:01 +03:00
|
|
|
? Container()
|
|
|
|
: Card(
|
2025-03-15 23:40:48 +03:00
|
|
|
margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 8),
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 20),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
'${statusData.getDegree(widget.temperature2MMin?.round())} / ${statusData.getDegree(widget.temperature2MMax?.round())}',
|
|
|
|
style: context.textTheme.titleLarge?.copyWith(
|
|
|
|
fontSize: 22,
|
|
|
|
fontWeight: FontWeight.w600,
|
2023-07-20 22:30:01 +03:00
|
|
|
),
|
2025-03-15 23:40:48 +03:00
|
|
|
),
|
|
|
|
const Gap(5),
|
|
|
|
Text(
|
|
|
|
DateFormat.MMMMEEEEd(
|
|
|
|
locale.languageCode,
|
|
|
|
).format(widget.timeDaily),
|
|
|
|
style: context.textTheme.titleMedium?.copyWith(
|
|
|
|
color: Colors.grey,
|
|
|
|
fontWeight: FontWeight.w400,
|
2023-07-20 22:30:01 +03:00
|
|
|
),
|
2025-03-15 23:40:48 +03:00
|
|
|
),
|
|
|
|
const Gap(5),
|
|
|
|
Text(
|
|
|
|
statusWeather.getText(widget.weathercodeDaily),
|
|
|
|
style: context.textTheme.titleMedium?.copyWith(
|
|
|
|
color: Colors.grey,
|
|
|
|
fontWeight: FontWeight.w400,
|
2023-07-20 22:30:01 +03:00
|
|
|
),
|
2025-03-15 23:40:48 +03:00
|
|
|
),
|
|
|
|
],
|
2023-06-17 20:57:57 +03:00
|
|
|
),
|
2025-03-15 23:40:48 +03:00
|
|
|
),
|
|
|
|
const Gap(5),
|
|
|
|
Image.asset(
|
|
|
|
statusWeather.getImageNowDaily(widget.weathercodeDaily),
|
|
|
|
scale: 6.5,
|
|
|
|
),
|
|
|
|
],
|
2023-07-10 21:33:43 +03:00
|
|
|
),
|
2025-03-15 23:40:48 +03:00
|
|
|
),
|
|
|
|
);
|
2023-06-17 20:57:57 +03:00
|
|
|
}
|
|
|
|
}
|