Skip to content

Commit 1fe8756

Browse files
committed
Remove unused libs
1 parent 2cc27fb commit 1fe8756

File tree

9 files changed

+312
-517
lines changed

9 files changed

+312
-517
lines changed

lib/main.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import 'dart:convert';
33
import 'package:connectivity_plus/connectivity_plus.dart';
44
import 'package:flutter/material.dart';
55
import 'package:flutter/services.dart';
6-
import 'package:geocoding_resolver/geocoding_resolver.dart';
7-
import 'package:geolocator/geolocator.dart';
86
import 'package:open_weather_client/open_weather.dart';
97
import 'package:watch_it/watch_it.dart';
108
import 'package:yaru/yaru.dart';
@@ -19,8 +17,7 @@ Future<void> main() async {
1917
final apiKey = await loadApiKey();
2018
if (apiKey != null && apiKey.isNotEmpty) {
2119
di.registerSingleton<OpenWeather>(OpenWeather(apiKey: apiKey));
22-
di.registerSingleton<GeoCoder>(GeoCoder());
23-
di.registerSingleton<GeolocatorPlatform>(GeolocatorPlatform.instance);
20+
2421
final locationsService = LocationsService();
2522
await locationsService.init();
2623
di.registerSingleton<LocationsService>(
@@ -35,8 +32,6 @@ Future<void> main() async {
3532
() => WeatherModel(
3633
locationsService: di<LocationsService>(),
3734
openWeather: di<OpenWeather>(),
38-
geoCoder: di<GeoCoder>(),
39-
geolocatorPlatform: di<GeolocatorPlatform>(),
4035
),
4136
dispose: (s) => s.dispose(),
4237
);

lib/src/app/app.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ class AppPage extends StatefulWidget with WatchItStatefulWidgetMixin {
5555
class _AppPageState extends State<AppPage> {
5656
@override
5757
void initState() {
58-
final lastLocation = di<WeatherModel>().lastLocation;
59-
if (lastLocation != null) {
60-
di<WeatherModel>().loadWeather(cityName: lastLocation);
61-
}
58+
di<WeatherModel>().loadWeather();
6259
super.initState();
6360
}
6461

lib/src/weather/view/forecast_chart.dart

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,48 @@ class ForeCastChart extends StatelessWidget with WatchItMixin {
1919
Widget build(BuildContext context) {
2020
final data =
2121
watchPropertyValue((WeatherModel m) => m.notTodayForecastDaily);
22-
return Center(
23-
child: Container(
24-
margin: kPagePadding,
25-
decoration: BoxDecoration(
26-
borderRadius: BorderRadius.circular(kYaruContainerRadius),
27-
color: context.theme.colorScheme.surface.withOpacity(0.3),
28-
),
29-
height:
30-
context.mq.size.height - kYaruTitleBarHeight - 3 * kYaruPagePadding,
31-
width: context.mq.size.width - kPaneWidth - 2 * kYaruPagePadding,
32-
child: Padding(
33-
padding: const EdgeInsets.symmetric(vertical: kYaruPagePadding),
34-
child: BarChart(
35-
BarChartData(
36-
baselineY: 0,
37-
titlesData: getTitlesData(context, data),
38-
borderData: borderData,
39-
barGroups: getBarGroups(data),
40-
gridData: const FlGridData(show: false),
41-
alignment: BarChartAlignment.spaceAround,
42-
maxY: data.map((e) => e.temperature.tempMax).max,
43-
minY: data.map((e) => e.temperature.tempMin).min,
44-
),
45-
),
46-
),
47-
),
48-
);
22+
final error = watchPropertyValue((WeatherModel m) => m.error);
23+
return error != null
24+
? Center(
25+
child: Text(error),
26+
)
27+
: data == null
28+
? Center(
29+
child: YaruCircularProgressIndicator(
30+
color: context.theme.colorScheme.onSurface,
31+
strokeWidth: 3,
32+
),
33+
)
34+
: Center(
35+
child: Container(
36+
margin: kPagePadding,
37+
decoration: BoxDecoration(
38+
borderRadius: BorderRadius.circular(kYaruContainerRadius),
39+
color: context.theme.colorScheme.surface.withOpacity(0.3),
40+
),
41+
height: context.mq.size.height -
42+
kYaruTitleBarHeight -
43+
3 * kYaruPagePadding,
44+
width:
45+
context.mq.size.width - kPaneWidth - 2 * kYaruPagePadding,
46+
child: Padding(
47+
padding:
48+
const EdgeInsets.symmetric(vertical: kYaruPagePadding),
49+
child: BarChart(
50+
BarChartData(
51+
baselineY: 0,
52+
titlesData: getTitlesData(context, data),
53+
borderData: borderData,
54+
barGroups: getBarGroups(data),
55+
gridData: const FlGridData(show: false),
56+
alignment: BarChartAlignment.spaceAround,
57+
maxY: data.map((e) => e.temperature.tempMax).max,
58+
minY: data.map((e) => e.temperature.tempMin).min,
59+
),
60+
),
61+
),
62+
),
63+
);
4964
}
5065

5166
FlTitlesData getTitlesData(BuildContext context, List<WeatherData> data) =>

lib/src/weather/view/today_chart.dart

Lines changed: 58 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import 'package:fl_chart/fl_chart.dart';
22
import 'package:flutter/material.dart';
33
import 'package:open_weather_client/models/weather_data.dart';
44
import '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

97
import '../../../constants.dart';
108
import '../../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(

lib/src/weather/view/today_tile.dart

Lines changed: 48 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ class TodayTile extends StatelessWidget {
1313
final String? cityName;
1414
final double fontSize;
1515
final String? position;
16-
final String? day;
1716
final String? time;
1817
final BorderRadiusGeometry? borderRadius;
1918

@@ -23,7 +22,6 @@ class TodayTile extends StatelessWidget {
2322
this.cityName,
2423
this.fontSize = 20,
2524
this.position,
26-
this.day,
2725
this.time,
2826
this.borderRadius,
2927
});
@@ -34,72 +32,6 @@ class TodayTile extends StatelessWidget {
3432

3533
final style = theme.weatherBgTextStyle;
3634

37-
final children = [
38-
Column(
39-
mainAxisSize: MainAxisSize.min,
40-
children: [
41-
Text(
42-
data.currentTemperature,
43-
style: style,
44-
),
45-
Text(
46-
'Feels like: ${data.feelsLike}',
47-
style: style,
48-
),
49-
Text(
50-
'Wind: ${data.windSpeed}',
51-
style: style,
52-
),
53-
],
54-
),
55-
if (day != null)
56-
Column(
57-
mainAxisSize: MainAxisSize.min,
58-
children: [
59-
Text(
60-
day!,
61-
style: style,
62-
),
63-
if (time != null)
64-
Text(
65-
time!,
66-
style: style,
67-
),
68-
],
69-
),
70-
Row(
71-
mainAxisSize: MainAxisSize.min,
72-
children: [
73-
Icon(
74-
data.icon,
75-
color: style?.color,
76-
shadows: style?.shadows,
77-
),
78-
const SizedBox(
79-
width: 10,
80-
),
81-
Text(
82-
data.longDescription.capitalize(),
83-
textAlign: TextAlign.center,
84-
style: style,
85-
overflow: TextOverflow.ellipsis,
86-
),
87-
],
88-
),
89-
if (cityName != null)
90-
Text(
91-
cityName!,
92-
style: style,
93-
textAlign: TextAlign.center,
94-
)
95-
else if (position != null)
96-
Text(
97-
position ?? '',
98-
style: style,
99-
textAlign: TextAlign.center,
100-
),
101-
];
102-
10335
return Center(
10436
child: Container(
10537
margin: kPagePadding,
@@ -116,7 +48,54 @@ class TodayTile extends StatelessWidget {
11648
spacing: 20,
11749
runSpacing: 20,
11850
runAlignment: WrapAlignment.center,
119-
children: children,
51+
children: [
52+
Text(
53+
'Now',
54+
style: style?.copyWith(fontWeight: FontWeight.bold),
55+
),
56+
if (cityName != null)
57+
Text(
58+
cityName!,
59+
style: style,
60+
textAlign: TextAlign.center,
61+
),
62+
Column(
63+
mainAxisSize: MainAxisSize.min,
64+
children: [
65+
Text(
66+
data.currentTemperature,
67+
style: style,
68+
),
69+
Text(
70+
'Feels like: ${data.feelsLike}',
71+
style: style,
72+
),
73+
Text(
74+
'Wind: ${data.windSpeed}',
75+
style: style,
76+
),
77+
],
78+
),
79+
Row(
80+
mainAxisSize: MainAxisSize.min,
81+
children: [
82+
Icon(
83+
data.icon,
84+
color: style?.color,
85+
shadows: style?.shadows,
86+
),
87+
const SizedBox(
88+
width: 10,
89+
),
90+
Text(
91+
data.longDescription.capitalize(),
92+
textAlign: TextAlign.center,
93+
style: style,
94+
overflow: TextOverflow.ellipsis,
95+
),
96+
],
97+
),
98+
],
12099
),
121100
],
122101
),

0 commit comments

Comments
 (0)