@@ -2,9 +2,7 @@ import 'package:fl_chart/fl_chart.dart';
22import 'package:flutter/material.dart' ;
33import 'package:open_weather_client/models/weather_data.dart' ;
44import 'package:watch_it/watch_it.dart' ;
5- import 'package:yaru/constants.dart' ;
6- import 'package:yaru/icons.dart' ;
7- import 'package:yaru/theme.dart' ;
5+ import 'package:yaru/yaru.dart' ;
86
97import '../../../constants.dart' ;
108import '../../build_context_x.dart' ;
@@ -29,64 +27,69 @@ class _TodayChartState extends State<TodayChart> {
2927
3028 @override
3129 Widget build (BuildContext context) {
32- final forecast = watchPropertyValue ((WeatherModel m) => m.forecast );
30+ final forecast = watchPropertyValue ((WeatherModel m) => m.fiveDaysForCast );
3331 final mq = context.mq;
34- final cityFromPosition =
35- watchPropertyValue ((WeatherModel m) => m.cityFromPosition);
36- final cityName = watchPropertyValue ((WeatherModel m) => m.cityName);
32+
33+ final cityName = watchPropertyValue ((WeatherModel m) => m.lastLocation);
3734 final data = watchPropertyValue ((WeatherModel m) => m.data);
3835 final error = watchPropertyValue ((WeatherModel m) => m.error);
3936
40- return data == null
41- ? Center (
42- child: error != null ? Text (error) : const SizedBox .shrink (),
43- )
44- : Container (
45- width: mq.size.width - kPaneWidth,
46- margin: kPagePadding,
47- decoration: BoxDecoration (
48- borderRadius: BorderRadius .circular (kYaruContainerRadius),
49- color: context.theme.colorScheme.surface.withOpacity (0.3 ),
50- ),
51- child: Stack (
52- alignment: Alignment .center,
53- children: [
54- TodayTile (
55- day: 'Now' ,
56- position: cityFromPosition,
57- data: data,
58- fontSize: 20 ,
59- cityName: cityName,
60- ),
61- Positioned (
62- bottom: 0 ,
63- child: SizedBox (
64- height: 400 ,
65- width: mq.size.width - kPaneWidth,
66- child: LineChart (
67- showAvg ? avgData (forecast) : mainData (forecast),
68- ),
69- ),
70- ),
71- Positioned (
72- right: 25 ,
73- bottom: 55 ,
74- child: FloatingActionButton (
75- backgroundColor: Colors .white,
76- onPressed: () {
77- setState (() {
78- showAvg = ! showAvg;
79- });
80- },
81- child: Icon (
82- showAvg ? YaruIcons .weather : YaruIcons .minus,
83- color: Colors .black,
37+ return Stack (
38+ children: [
39+ Container (
40+ margin: kPagePadding,
41+ height: mq.size.height,
42+ decoration: BoxDecoration (
43+ borderRadius: BorderRadius .circular (kYaruContainerRadius),
44+ color: context.theme.colorScheme.surface.withOpacity (0.3 ),
45+ ),
46+ child: error != null
47+ ? Center (
48+ child: Text (error),
49+ )
50+ : forecast == null || data == null
51+ ? Center (
52+ child: YaruCircularProgressIndicator (
53+ color: context.theme.colorScheme.onSurface,
54+ strokeWidth: 3 ,
55+ ),
56+ )
57+ : SingleChildScrollView (
58+ padding: EdgeInsets .only (top: mq.size.height / 3 ),
59+ scrollDirection: Axis .horizontal,
60+ child: SizedBox (
61+ width: forecast.length * 50 ,
62+ height: 400 ,
63+ child: LineChart (
64+ showAvg ? avgData (forecast) : mainData (forecast),
65+ ),
66+ ),
8467 ),
85- ),
86- ),
87- ],
68+ ),
69+ Positioned (
70+ right: 65 ,
71+ bottom: 100 ,
72+ child: FloatingActionButton (
73+ backgroundColor: Colors .white,
74+ onPressed: () {
75+ setState (() {
76+ showAvg = ! showAvg;
77+ });
78+ },
79+ child: Icon (
80+ showAvg ? YaruIcons .weather : YaruIcons .minus,
81+ color: Colors .black,
8882 ),
89- );
83+ ),
84+ ),
85+ if (data != null )
86+ TodayTile (
87+ data: data,
88+ fontSize: 20 ,
89+ cityName: cityName,
90+ ),
91+ ],
92+ );
9093 }
9194
9295 Widget bottomTitleWidgets (
0 commit comments