Skip to content

Commit 2bb2bdf

Browse files
authored
fix: dont default to thunder weather and fix tab label color (#20)
1 parent d3a3893 commit 2bb2bdf

File tree

5 files changed

+28
-18
lines changed

5 files changed

+28
-18
lines changed

lib/app/app.dart

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,10 @@ class App extends StatelessWidget {
2020
Widget build(BuildContext context) => MaterialApp(
2121
localizationsDelegates: AppLocalizations.localizationsDelegates,
2222
supportedLocales: supportedLocales,
23-
onGenerateTitle: (context) => 'MusicPod',
23+
onGenerateTitle: (context) => 'Pulse',
2424
debugShowCheckedModeBanner: false,
2525
theme: yaruLight,
26-
darkTheme: yaruDark.copyWith(
27-
tabBarTheme: TabBarTheme.of(context).copyWith(
28-
labelColor: Colors.white,
29-
unselectedLabelColor: Colors.white.withValues(
30-
alpha: 0.8,
31-
),
32-
),
33-
),
26+
darkTheme: yaruDark,
3427
home: const _StartPage(),
3528
scrollBehavior: const MaterialScrollBehavior().copyWith(
3629
dragDevices: {

lib/weather/view/weather_page.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import 'dart:io';
22

33
import 'package:flutter/material.dart';
4+
import 'package:flutter_weather_bg_null_safety/utils/weather_type.dart';
45
import 'package:watch_it/watch_it.dart';
56
import 'package:yaru/yaru.dart';
67

7-
import '../../constants.dart';
88
import '../../app/app_model.dart';
99
import '../../app/side_bar.dart';
10+
import '../../constants.dart';
1011
import '../../l10n/l10n.dart';
12+
import '../weather_data_x.dart';
13+
import '../weather_model.dart';
1114
import 'daily_bar_chart.dart';
1215
import 'hourly_line_chart.dart';
1316

@@ -20,7 +23,12 @@ class WeatherPage extends StatelessWidget with WatchItMixin {
2023
Widget build(BuildContext context) {
2124
final appModel = watchIt<AppModel>();
2225
final showToday = appModel.tabIndex == 0;
26+
final weatherType =
27+
watchPropertyValue((WeatherModel m) => m.data?.weatherType);
2328

29+
final labelColor = weatherType == null
30+
? null
31+
: contrastColor(WeatherUtil.getColor(weatherType).first);
2432
return DefaultTabController(
2533
initialIndex: appModel.tabIndex,
2634
length: 2,
@@ -46,6 +54,8 @@ class WeatherPage extends StatelessWidget with WatchItMixin {
4654
title: SizedBox(
4755
width: kPaneWidth,
4856
child: YaruTabBar(
57+
labelColor: labelColor,
58+
unselectedLabelColor: labelColor?.withValues(alpha: 0.8),
4959
onTap: (v) => appModel.tabIndex = v,
5060
tabs: [
5161
Tab(text: context.l10n.hourly),

lib/weather/weather_data_x.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@ extension WeatherDataX on WeatherData {
2828
'Drizzle' => WeatherType.lightRainy,
2929
'Rain' => WeatherType.middleRainy,
3030
'Snow' => WeatherType.heavySnow,
31-
'Clear' => night ? WeatherType.sunnyNight : WeatherType.sunny,
32-
'Sunny' => night ? WeatherType.sunnyNight : WeatherType.sunny,
31+
'Clear' ||
32+
'Sunny' =>
33+
night ? WeatherType.sunnyNight : WeatherType.sunny,
3334
'Wind' => night ? WeatherType.dusty : WeatherType.dusty,
3435
'Mist' => WeatherType.foggy,
35-
_ => WeatherType.thunder
36+
'Fog' => WeatherType.foggy,
37+
'Thunderstorm' || 'Thunder' || 'Lightning' => WeatherType.thunder,
38+
_ => WeatherType.sunny
3639
}
3740
};
3841
}

pubspec.lock

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,10 +1038,11 @@ packages:
10381038
yaru:
10391039
dependency: "direct main"
10401040
description:
1041-
name: yaru
1042-
sha256: f149399d81ecd3d20bfcc79afd5ddd9bcd7e4c901d5e602a8577fe59c71c8617
1043-
url: "https://pub.dev"
1044-
source: hosted
1041+
path: "."
1042+
ref: e4be44ca80d4535eacb85a8c7fb422fa9c15d43c
1043+
resolved-ref: e4be44ca80d4535eacb85a8c7fb422fa9c15d43c
1044+
url: "https://github.com/ubuntu/yaru.dart"
1045+
source: git
10451046
version: "7.0.0"
10461047
yaru_window:
10471048
dependency: transitive

pubspec.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ dependencies:
3434
shared_preferences: ^2.5.1
3535
watch_it: ^1.6.2
3636
xdg_directories: ^1.0.4
37-
yaru: ^7.0.0
37+
yaru:
38+
git:
39+
url: https://github.com/ubuntu/yaru.dart
40+
ref: e4be44ca80d4535eacb85a8c7fb422fa9c15d43c
3841

3942
dev_dependencies:
4043
build_runner: ^2.4.8

0 commit comments

Comments
 (0)