@@ -7,19 +7,20 @@ import 'package:yaru/yaru.dart';
77
88import '../../../constants.dart' ;
99import '../../build_context_x.dart' ;
10+ import '../../l10n/l10n.dart' ;
1011import '../weather_data_x.dart' ;
1112import '../weather_model.dart' ;
1213import 'error_view.dart' ;
13- import 'today_tile .dart' ;
14+ import 'now_tile .dart' ;
1415
15- class TodayChart extends StatefulWidget with WatchItStatefulWidgetMixin {
16- const TodayChart ({super .key});
16+ class HourlyLineChart extends StatefulWidget with WatchItStatefulWidgetMixin {
17+ const HourlyLineChart ({super .key});
1718
1819 @override
19- State <TodayChart > createState () => _TodayChartState ();
20+ State <HourlyLineChart > createState () => _HourlyLineChartState ();
2021}
2122
22- class _TodayChartState extends State <TodayChart > {
23+ class _HourlyLineChartState extends State <HourlyLineChart > {
2324 late ScrollController _scrollController;
2425
2526 List <Color > gradientColors = [
@@ -42,7 +43,7 @@ class _TodayChartState extends State<TodayChart> {
4243 @override
4344 Widget build (BuildContext context) {
4445 final forecast =
45- watchPropertyValue ((WeatherModel m) => m.notTodayFullForecast );
46+ watchPropertyValue ((WeatherModel m) => m.fiveDaysForCast ?? [] );
4647 final mq = context.mq;
4748
4849 final cityName = watchPropertyValue ((WeatherModel m) => m.lastLocation);
@@ -76,7 +77,7 @@ class _TodayChartState extends State<TodayChart> {
7677 width: forecast.length * 100 ,
7778 height: 400 ,
7879 child: LineChart (
79- mainData (forecast),
80+ mainData (forecast: forecast, data : data ),
8081 ),
8182 ),
8283 ),
@@ -114,7 +115,7 @@ class _TodayChartState extends State<TodayChart> {
114115 ),
115116 ),
116117 if (data != null )
117- TodayTile (
118+ NowTile (
118119 data: data,
119120 fontSize: 20 ,
120121 cityName: cityName,
@@ -123,29 +124,41 @@ class _TodayChartState extends State<TodayChart> {
123124 );
124125 }
125126
126- Widget bottomTitleWidgets (
127- double value,
128- TitleMeta meta,
129- List <WeatherData > data,
130- ) {
131- const style = TextStyle (
132- fontWeight: FontWeight .bold,
133- fontSize: 16 ,
134- );
135- Widget text;
136- text = Text (
137- data[value.toInt ()].getTime (context),
138- style: style,
139- );
140-
127+ Widget bottomTitleWidgets ({
128+ required double value,
129+ required TitleMeta meta,
130+ required List <WeatherData > forecast,
131+ required WeatherData data,
132+ }) {
133+ final weekday = forecast[value.toInt ()].getWeekDay (context);
141134 return SideTitleWidget (
142135 fitInside: SideTitleFitInsideData .fromTitleMeta (meta),
143136 axisSide: meta.axisSide,
144- child: text,
137+ child: Column (
138+ children: [
139+ Text (
140+ forecast[value.toInt ()].getTime (context),
141+ style: const TextStyle (
142+ fontWeight: FontWeight .bold,
143+ fontSize: 16 ,
144+ ),
145+ ),
146+ Text (
147+ weekday == data.getWeekDay (context) ? context.l10n.today : weekday,
148+ style: const TextStyle (
149+ fontWeight: FontWeight .w400,
150+ fontSize: 10 ,
151+ ),
152+ ),
153+ ],
154+ ),
145155 );
146156 }
147157
148- LineChartData mainData (List <WeatherData > forecast) {
158+ LineChartData mainData ({
159+ required List <WeatherData > forecast,
160+ required WeatherData data,
161+ }) {
149162 final outlineColor = context.theme.colorScheme.onSurface.withOpacity (0.2 );
150163
151164 return LineChartData (
@@ -181,10 +194,14 @@ class _TodayChartState extends State<TodayChart> {
181194 bottomTitles: AxisTitles (
182195 sideTitles: SideTitles (
183196 showTitles: true ,
184- reservedSize: 35 ,
197+ reservedSize: 55 ,
185198 interval: 1 ,
186- getTitlesWidget: (value, meta) =>
187- bottomTitleWidgets (value, meta, forecast),
199+ getTitlesWidget: (value, meta) => bottomTitleWidgets (
200+ value: value,
201+ meta: meta,
202+ forecast: forecast,
203+ data: data,
204+ ),
188205 ),
189206 ),
190207 leftTitles: const AxisTitles (
0 commit comments