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

170 lines
5.6 KiB
Dart
Raw Normal View History

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_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 Now extends StatefulWidget {
const Now({
2023-06-17 20:57:57 +03:00
super.key,
required this.weather,
required this.degree,
required this.time,
required this.timeDay,
required this.timeNight,
2024-06-23 23:23:43 +03:00
required this.tempMax,
required this.tempMin,
required this.feels,
2023-06-17 20:57:57 +03:00
});
final String time;
final String timeDay;
final String timeNight;
final int weather;
final double degree;
2024-06-23 23:23:43 +03:00
final double tempMax;
final double tempMin;
final double feels;
2023-06-17 20:57:57 +03:00
@override
2024-09-06 22:07:50 +03:00
State<Now> createState() => _NowState();
2023-06-17 20:57:57 +03:00
}
2024-09-06 22:07:50 +03:00
class _NowState extends State<Now> {
2023-07-15 21:51:32 +03:00
final statusWeather = StatusWeather();
2024-06-23 23:23:43 +03:00
final statusData = StatusData();
2023-06-17 20:57:57 +03:00
@override
Widget build(BuildContext context) {
2024-07-10 21:59:36 +03:00
return largeElement
? Padding(
2025-03-15 23:40:48 +03:00
padding: const EdgeInsets.only(bottom: 15),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Gap(15),
Image(
image: AssetImage(
statusWeather.getImageNow(
widget.weather,
widget.time,
widget.timeDay,
widget.timeNight,
),
2024-07-10 21:59:36 +03:00
),
2025-03-15 23:40:48 +03:00
fit: BoxFit.fill,
height: 200,
),
Text(
'${roundDegree ? widget.degree.round() : widget.degree}',
style: context.textTheme.displayLarge?.copyWith(
fontSize: 90,
fontWeight: FontWeight.w800,
shadows: const [Shadow(blurRadius: 15, offset: Offset(5, 5))],
2024-07-10 21:59:36 +03:00
),
2025-03-15 23:40:48 +03:00
),
Text(
statusWeather.getText(widget.weather),
style: context.textTheme.titleLarge,
),
const Gap(5),
Text(
DateFormat.MMMMEEEEd(
locale.languageCode,
).format(DateTime.parse(widget.time)),
style: context.textTheme.labelLarge?.copyWith(
color: Colors.grey,
2024-07-10 21:59:36 +03:00
),
2025-03-15 23:40:48 +03:00
),
],
),
)
2024-07-10 21:59:36 +03:00
: Card(
2025-03-15 23:40:48 +03:00
margin: const EdgeInsets.only(bottom: 15),
child: Padding(
padding: const EdgeInsets.only(
top: 18,
bottom: 18,
left: 25,
right: 15,
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
DateFormat.MMMMEEEEd(
locale.languageCode,
).format(DateTime.parse(widget.time)),
style: context.textTheme.labelLarge?.copyWith(
color: Colors.grey,
2024-07-10 21:59:36 +03:00
),
2025-03-15 23:40:48 +03:00
),
const Gap(5),
Text(
statusWeather.getText(widget.weather),
style: context.textTheme.titleLarge?.copyWith(
fontSize: 20,
),
2025-03-15 23:40:48 +03:00
),
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,
2024-07-10 21:59:36 +03:00
),
2025-03-15 23:40:48 +03:00
],
),
const Gap(30),
Text(
statusData.getDegree(
roundDegree ? widget.degree.round() : widget.degree,
2024-07-10 21:59:36 +03:00
),
2025-03-15 23:40:48 +03:00
style: context.textTheme.displayMedium?.copyWith(
fontWeight: FontWeight.w800,
2024-07-10 21:59:36 +03:00
),
2025-03-15 23:40:48 +03:00
),
const Gap(5),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
statusData.getDegree((widget.tempMin.round())),
style: context.textTheme.labelLarge,
),
Text(' / ', style: context.textTheme.labelLarge),
Text(
statusData.getDegree((widget.tempMax.round())),
style: context.textTheme.labelLarge,
),
],
),
],
2024-06-23 23:23:43 +03:00
),
2025-03-15 23:40:48 +03:00
),
Image(
image: AssetImage(
statusWeather.getImageNow(
widget.weather,
widget.time,
widget.timeDay,
widget.timeNight,
),
2024-06-23 23:23:43 +03:00
),
2025-03-15 23:40:48 +03:00
fit: BoxFit.fill,
height: 140,
),
],
2024-06-23 23:23:43 +03:00
),
2025-03-15 23:40:48 +03:00
),
);
2023-06-17 20:57:57 +03:00
}
}