From 4a2ebf841901c730381bc7d8434b497835a95238 Mon Sep 17 00:00:00 2001 From: Feichtmeier Date: Tue, 11 Mar 2025 18:49:33 +0100 Subject: [PATCH] fix: dont default to thunder weather and fix tab label color --- lib/app/app.dart | 11 ++--------- lib/weather/view/weather_page.dart | 12 +++++++++++- lib/weather/weather_data_x.dart | 9 ++++++--- pubspec.lock | 9 +++++---- pubspec.yaml | 5 ++++- 5 files changed, 28 insertions(+), 18 deletions(-) diff --git a/lib/app/app.dart b/lib/app/app.dart index 4de2044..e442299 100644 --- a/lib/app/app.dart +++ b/lib/app/app.dart @@ -20,17 +20,10 @@ class App extends StatelessWidget { Widget build(BuildContext context) => MaterialApp( localizationsDelegates: AppLocalizations.localizationsDelegates, supportedLocales: supportedLocales, - onGenerateTitle: (context) => 'MusicPod', + onGenerateTitle: (context) => 'Pulse', debugShowCheckedModeBanner: false, theme: yaruLight, - darkTheme: yaruDark.copyWith( - tabBarTheme: TabBarTheme.of(context).copyWith( - labelColor: Colors.white, - unselectedLabelColor: Colors.white.withValues( - alpha: 0.8, - ), - ), - ), + darkTheme: yaruDark, home: const _StartPage(), scrollBehavior: const MaterialScrollBehavior().copyWith( dragDevices: { diff --git a/lib/weather/view/weather_page.dart b/lib/weather/view/weather_page.dart index 1ffefbf..d65cba3 100644 --- a/lib/weather/view/weather_page.dart +++ b/lib/weather/view/weather_page.dart @@ -1,13 +1,16 @@ import 'dart:io'; import 'package:flutter/material.dart'; +import 'package:flutter_weather_bg_null_safety/utils/weather_type.dart'; import 'package:watch_it/watch_it.dart'; import 'package:yaru/yaru.dart'; -import '../../constants.dart'; import '../../app/app_model.dart'; import '../../app/side_bar.dart'; +import '../../constants.dart'; import '../../l10n/l10n.dart'; +import '../weather_data_x.dart'; +import '../weather_model.dart'; import 'daily_bar_chart.dart'; import 'hourly_line_chart.dart'; @@ -20,7 +23,12 @@ class WeatherPage extends StatelessWidget with WatchItMixin { Widget build(BuildContext context) { final appModel = watchIt(); final showToday = appModel.tabIndex == 0; + final weatherType = + watchPropertyValue((WeatherModel m) => m.data?.weatherType); + final labelColor = weatherType == null + ? null + : contrastColor(WeatherUtil.getColor(weatherType).first); return DefaultTabController( initialIndex: appModel.tabIndex, length: 2, @@ -46,6 +54,8 @@ class WeatherPage extends StatelessWidget with WatchItMixin { title: SizedBox( width: kPaneWidth, child: YaruTabBar( + labelColor: labelColor, + unselectedLabelColor: labelColor?.withValues(alpha: 0.8), onTap: (v) => appModel.tabIndex = v, tabs: [ Tab(text: context.l10n.hourly), diff --git a/lib/weather/weather_data_x.dart b/lib/weather/weather_data_x.dart index aabdf08..266b054 100644 --- a/lib/weather/weather_data_x.dart +++ b/lib/weather/weather_data_x.dart @@ -28,11 +28,14 @@ extension WeatherDataX on WeatherData { 'Drizzle' => WeatherType.lightRainy, 'Rain' => WeatherType.middleRainy, 'Snow' => WeatherType.heavySnow, - 'Clear' => night ? WeatherType.sunnyNight : WeatherType.sunny, - 'Sunny' => night ? WeatherType.sunnyNight : WeatherType.sunny, + 'Clear' || + 'Sunny' => + night ? WeatherType.sunnyNight : WeatherType.sunny, 'Wind' => night ? WeatherType.dusty : WeatherType.dusty, 'Mist' => WeatherType.foggy, - _ => WeatherType.thunder + 'Fog' => WeatherType.foggy, + 'Thunderstorm' || 'Thunder' || 'Lightning' => WeatherType.thunder, + _ => WeatherType.sunny } }; } diff --git a/pubspec.lock b/pubspec.lock index ed97011..e245cd0 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1038,10 +1038,11 @@ packages: yaru: dependency: "direct main" description: - name: yaru - sha256: f149399d81ecd3d20bfcc79afd5ddd9bcd7e4c901d5e602a8577fe59c71c8617 - url: "https://pub.dev" - source: hosted + path: "." + ref: e4be44ca80d4535eacb85a8c7fb422fa9c15d43c + resolved-ref: e4be44ca80d4535eacb85a8c7fb422fa9c15d43c + url: "https://github.com/ubuntu/yaru.dart" + source: git version: "7.0.0" yaru_window: dependency: transitive diff --git a/pubspec.yaml b/pubspec.yaml index 8c813f7..a83b3eb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -34,7 +34,10 @@ dependencies: shared_preferences: ^2.5.1 watch_it: ^1.6.2 xdg_directories: ^1.0.4 - yaru: ^7.0.0 + yaru: + git: + url: https://github.com/ubuntu/yaru.dart + ref: e4be44ca80d4535eacb85a8c7fb422fa9c15d43c dev_dependencies: build_runner: ^2.4.8