show daily weather at different times, use weather icons, get prevalent weather icon for the day
This commit is contained in:
@@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:weather_icons/weather_icons.dart';
|
||||
import 'package:wetter/models/daily_weather_model.dart';
|
||||
import 'package:wetter/models/hourly_weather_model.dart';
|
||||
import 'package:wetter/services/utils.dart';
|
||||
|
||||
class CompactWeatherData extends StatefulWidget {
|
||||
final DailyWeatherModel dwm;
|
||||
@@ -18,29 +20,51 @@ class _CompactWeatherDataState extends State<CompactWeatherData> {
|
||||
return Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
children: [
|
||||
child: Column(children: [
|
||||
Text(
|
||||
"${DateFormat('EEEE').format(widget.dwm.dateOfDay())}, ${widget.dwm.dateOfDay().day}.${widget.dwm.dateOfDay().month}.",
|
||||
style: Theme.of(context).textTheme.headline5,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Icon(weatherIcon(widget.dwm.prevalentWeatherIcon())),
|
||||
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||
const Icon(WeatherIcons.thermometer),
|
||||
Text(
|
||||
"${DateFormat('EEEE').format(widget.dwm.dateOfDay())}, ${widget.dwm.dateOfDay().day}.${widget.dwm.dateOfDay().month}.",
|
||||
style: Theme.of(context).textTheme.headline4,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||
const Icon(WeatherIcons.thermometer),
|
||||
Text(
|
||||
"${widget.dwm.dailyMaxTemp()} °C",
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
)
|
||||
]),
|
||||
const SizedBox(height: 20),
|
||||
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||
const Icon(WeatherIcons.thermometer_exterior),
|
||||
Text(
|
||||
"${widget.dwm.dailyMinTemp()} °C",
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
)
|
||||
]),
|
||||
],
|
||||
)));
|
||||
"${widget.dwm.dailyMaxTemp()} °C",
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
)
|
||||
]),
|
||||
const SizedBox(height: 20),
|
||||
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||
const Icon(WeatherIcons.thermometer_exterior),
|
||||
Text(
|
||||
"${widget.dwm.dailyMinTemp()} °C",
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
)
|
||||
]),
|
||||
const SizedBox(height: 20),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
_hourlyInfo(widget.dwm.hourlyWeatherModelAtTimeOfDay(4)),
|
||||
_hourlyInfo(widget.dwm.hourlyWeatherModelAtTimeOfDay(8)),
|
||||
_hourlyInfo(widget.dwm.hourlyWeatherModelAtTimeOfDay(12)),
|
||||
_hourlyInfo(widget.dwm.hourlyWeatherModelAtTimeOfDay(16)),
|
||||
_hourlyInfo(widget.dwm.hourlyWeatherModelAtTimeOfDay(20))
|
||||
],
|
||||
),
|
||||
])));
|
||||
}
|
||||
|
||||
Widget _hourlyInfo(HourlyWeatherModel hwm) {
|
||||
return Column(
|
||||
children: [
|
||||
Text(DateFormat.Hm().format(hwm.timestamp)),
|
||||
const SizedBox(height: 8),
|
||||
Icon(weatherIcon(hwm.icon ?? "not defined")),
|
||||
const SizedBox(height: 14),
|
||||
Text("${hwm.temperature.round()} °C")
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user