2023-06-17 20:57:57 +03:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
import 'package:rain/app/controller/controller.dart';
|
|
|
|
import 'package:rain/app/widgets/status.dart';
|
|
|
|
import 'package:rain/app/widgets/status_im_fa.dart';
|
|
|
|
import 'package:timezone/standalone.dart' as tz;
|
|
|
|
|
|
|
|
class CardDescWeather extends StatefulWidget {
|
|
|
|
const CardDescWeather({
|
|
|
|
super.key,
|
|
|
|
required this.time,
|
|
|
|
required this.weather,
|
|
|
|
required this.degree,
|
|
|
|
required this.district,
|
|
|
|
required this.city,
|
|
|
|
required this.timezone,
|
|
|
|
required this.timeDay,
|
|
|
|
required this.timeNight,
|
|
|
|
required this.timeDaily,
|
|
|
|
});
|
|
|
|
final List<String> time;
|
|
|
|
final List<String> timeDay;
|
|
|
|
final List<String> timeNight;
|
|
|
|
final List<DateTime> timeDaily;
|
|
|
|
final String district;
|
|
|
|
final String city;
|
|
|
|
final List<int> weather;
|
|
|
|
final List<double> degree;
|
|
|
|
final String timezone;
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<CardDescWeather> createState() => _CardDescWeatherState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _CardDescWeatherState extends State<CardDescWeather> {
|
|
|
|
final status = Status();
|
|
|
|
final statusImFa = StatusImFa();
|
|
|
|
final locationController = Get.put(LocationController());
|
|
|
|
|
|
|
|
@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.symmetric(horizontal: 10, vertical: 8),
|
2023-07-10 21:33:43 +03:00
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 20),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
statusImFa.getDegree(widget.degree[locationController
|
|
|
|
.getTime(widget.time, widget.timezone)]
|
|
|
|
.round()
|
|
|
|
.toInt()),
|
|
|
|
style: context.textTheme.titleLarge?.copyWith(
|
|
|
|
fontSize: 22,
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
),
|
2023-06-17 20:57:57 +03:00
|
|
|
),
|
2023-07-10 21:33:43 +03:00
|
|
|
const SizedBox(width: 7),
|
|
|
|
Text(
|
|
|
|
status.getText(widget.weather[locationController
|
|
|
|
.getTime(widget.time, widget.timezone)]),
|
|
|
|
style: context.textTheme.titleMedium?.copyWith(
|
|
|
|
color: Colors.grey,
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
),
|
2023-06-17 20:57:57 +03:00
|
|
|
),
|
2023-07-10 21:33:43 +03:00
|
|
|
],
|
|
|
|
),
|
|
|
|
const SizedBox(height: 10),
|
|
|
|
Text(
|
|
|
|
widget.district.isEmpty
|
|
|
|
? widget.city
|
|
|
|
: widget.city.isEmpty
|
|
|
|
? widget.district
|
|
|
|
: widget.city == widget.district
|
|
|
|
? widget.city
|
|
|
|
: '${widget.city}'
|
|
|
|
', ${widget.district}',
|
|
|
|
style: context.textTheme.titleMedium?.copyWith(
|
|
|
|
fontWeight: FontWeight.w500,
|
2023-06-17 20:57:57 +03:00
|
|
|
),
|
|
|
|
),
|
2023-07-10 21:33:43 +03:00
|
|
|
const SizedBox(height: 5),
|
|
|
|
StreamBuilder(
|
|
|
|
stream: Stream.periodic(const Duration(seconds: 1)),
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
return Text(
|
|
|
|
'${'time'.tr}: ${statusImFa.getTimeFormatTz(tz.TZDateTime.now(tz.getLocation(widget.timezone)))}',
|
|
|
|
style: context.textTheme.titleMedium?.copyWith(
|
|
|
|
color: Colors.grey,
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(width: 5),
|
|
|
|
Image.asset(
|
|
|
|
status.getImageNow(
|
|
|
|
widget.weather[
|
|
|
|
locationController.getTime(widget.time, widget.timezone)],
|
|
|
|
widget.time[
|
|
|
|
locationController.getTime(widget.time, widget.timezone)],
|
|
|
|
widget.timeDay[locationController.getDay(
|
|
|
|
widget.timeDaily, widget.timezone)],
|
|
|
|
widget.timeNight[locationController.getDay(
|
|
|
|
widget.timeDaily, widget.timezone)]),
|
|
|
|
scale: 6.5,
|
2023-06-17 20:57:57 +03:00
|
|
|
),
|
2023-07-10 21:33:43 +03:00
|
|
|
],
|
|
|
|
),
|
2023-06-17 20:57:57 +03:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|