@@ -7,19 +7,20 @@ import 'package:yaru/yaru.dart';
7
7
8
8
import '../../../constants.dart' ;
9
9
import '../../build_context_x.dart' ;
10
+ import '../../l10n/l10n.dart' ;
10
11
import '../weather_data_x.dart' ;
11
12
import '../weather_model.dart' ;
12
13
import 'error_view.dart' ;
13
- import 'today_tile .dart' ;
14
+ import 'now_tile .dart' ;
14
15
15
- class TodayChart extends StatefulWidget with WatchItStatefulWidgetMixin {
16
- const TodayChart ({super .key});
16
+ class HourlyLineChart extends StatefulWidget with WatchItStatefulWidgetMixin {
17
+ const HourlyLineChart ({super .key});
17
18
18
19
@override
19
- State <TodayChart > createState () => _TodayChartState ();
20
+ State <HourlyLineChart > createState () => _HourlyLineChartState ();
20
21
}
21
22
22
- class _TodayChartState extends State <TodayChart > {
23
+ class _HourlyLineChartState extends State <HourlyLineChart > {
23
24
late ScrollController _scrollController;
24
25
25
26
List <Color > gradientColors = [
@@ -42,7 +43,7 @@ class _TodayChartState extends State<TodayChart> {
42
43
@override
43
44
Widget build (BuildContext context) {
44
45
final forecast =
45
- watchPropertyValue ((WeatherModel m) => m.notTodayFullForecast );
46
+ watchPropertyValue ((WeatherModel m) => m.fiveDaysForCast ?? [] );
46
47
final mq = context.mq;
47
48
48
49
final cityName = watchPropertyValue ((WeatherModel m) => m.lastLocation);
@@ -76,7 +77,7 @@ class _TodayChartState extends State<TodayChart> {
76
77
width: forecast.length * 100 ,
77
78
height: 400 ,
78
79
child: LineChart (
79
- mainData (forecast),
80
+ mainData (forecast: forecast, data : data ),
80
81
),
81
82
),
82
83
),
@@ -114,7 +115,7 @@ class _TodayChartState extends State<TodayChart> {
114
115
),
115
116
),
116
117
if (data != null )
117
- TodayTile (
118
+ NowTile (
118
119
data: data,
119
120
fontSize: 20 ,
120
121
cityName: cityName,
@@ -123,29 +124,41 @@ class _TodayChartState extends State<TodayChart> {
123
124
);
124
125
}
125
126
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);
141
134
return SideTitleWidget (
142
135
fitInside: SideTitleFitInsideData .fromTitleMeta (meta),
143
136
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
+ ),
145
155
);
146
156
}
147
157
148
- LineChartData mainData (List <WeatherData > forecast) {
158
+ LineChartData mainData ({
159
+ required List <WeatherData > forecast,
160
+ required WeatherData data,
161
+ }) {
149
162
final outlineColor = context.theme.colorScheme.onSurface.withOpacity (0.2 );
150
163
151
164
return LineChartData (
@@ -181,10 +194,14 @@ class _TodayChartState extends State<TodayChart> {
181
194
bottomTitles: AxisTitles (
182
195
sideTitles: SideTitles (
183
196
showTitles: true ,
184
- reservedSize: 35 ,
197
+ reservedSize: 55 ,
185
198
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
+ ),
188
205
),
189
206
),
190
207
leftTitles: const AxisTitles (
0 commit comments