Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Remove wallpaper color source, always use book cover colors

Nathan Poulson8788ffaba933
diff --git a/lib/main.dart b/lib/main.dart
index ce9b327d..6f06ed6a 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -3,7 +3,6 @@ import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
-import 'package:dynamic_color/dynamic_color.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:flutter_native_splash/flutter_native_splash.dart';
import 'l10n/app_localizations.dart';
@@ -38,8 +37,6 @@ final ValueNotifier<bool> oledNotifier = ValueNotifier(false);
/// Whether to disable the fade animation when switching bottom nav tabs.
final ValueNotifier<bool> snappyTransitionsNotifier = ValueNotifier(false);
-/// Color source: 'wallpaper' (system dynamic) or 'cover' (playing book art).
-final ValueNotifier<String> colorSourceNotifier = ValueNotifier('wallpaper');
/// Cover-art-derived ColorScheme for the currently playing item.
/// null when nothing is playing or cover hasn't loaded yet.
@@ -112,9 +109,8 @@ void main() async {
final savedTheme = await PlayerSettings.getThemeMode();
applyThemeMode(savedTheme);
snappyTransitionsNotifier.value = await PlayerSettings.getSnappyTransitions();
- colorSourceNotifier.value = await PlayerSettings.getColorSource();
- // Restore last cover seed color so the theme doesn't flash wallpaper colors
- if (colorSourceNotifier.value == 'cover') {
+ // Restore last cover seed color so the theme doesn't flash on startup
+ {
final seedInt = await PlayerSettings.getCoverSeedColor();
if (seedInt != null) {
final seedColor = Color(seedInt);
@@ -174,9 +170,6 @@ class AbsorbApp extends StatelessWidget {
return ValueListenableBuilder<bool>(
valueListenable: oledNotifier,
builder: (context, isOled, _) {
- return ValueListenableBuilder<String>(
- valueListenable: colorSourceNotifier,
- builder: (context, colorSource, _) {
return ValueListenableBuilder<ColorScheme?>(
valueListenable: coverSchemeNotifier,
builder: (context, coverScheme, _) {
@@ -192,53 +185,30 @@ class AbsorbApp extends StatelessWidget {
systemNavigationBarIconBrightness: isDark ? Brightness.light : Brightness.dark,
));
- final useCover = colorSource == 'cover' && coverScheme != null;
-
- return DynamicColorBuilder(
- builder: (ColorScheme? lightDynamic, ColorScheme? darkDynamic) {
- // Absorb is dark-first — use dynamic dark colors or our custom palette
- ColorScheme darkScheme;
- if (useCover) {
- darkScheme = ColorScheme.fromSeed(
- seedColor: coverScheme.primary,
- brightness: Brightness.dark,
- );
- } else if (darkDynamic != null) {
- darkScheme = darkDynamic.harmonized();
- } else {
- darkScheme = ColorScheme.fromSeed(
- seedColor: const Color(0xFF7C6FBF), // deep muted purple
- brightness: Brightness.dark,
- );
- }
-
- // OLED: pure black surfaces so OLED pixels turn fully off
- if (isOled) {
- darkScheme = darkScheme.copyWith(
- surface: Colors.black,
- surfaceContainerLowest: Colors.black,
- surfaceContainerLow: Colors.black,
- surfaceContainer: const Color(0xFF050505),
- surfaceContainerHigh: const Color(0xFF0A0A0A),
- surfaceContainerHighest: const Color(0xFF0F0F0F),
- );
- }
-
- // Light scheme for users who prefer it
- ColorScheme lightScheme;
- if (useCover) {
- lightScheme = ColorScheme.fromSeed(
- seedColor: coverScheme.primary,
- brightness: Brightness.light,
- );
- } else if (lightDynamic != null) {
- lightScheme = lightDynamic.harmonized();
- } else {
- lightScheme = ColorScheme.fromSeed(
- seedColor: const Color(0xFF7C6FBF),
- brightness: Brightness.light,
- );
- }
+ const defaultSeed = Color(0xFF7C6FBF); // deep muted purple
+ final seedColor = coverScheme?.primary ?? defaultSeed;
+
+ ColorScheme darkScheme = ColorScheme.fromSeed(
+ seedColor: seedColor,
+ brightness: Brightness.dark,
+ );
+
+ // OLED: pure black surfaces so OLED pixels turn fully off
+ if (isOled) {
+ darkScheme = darkScheme.copyWith(
+ surface: Colors.black,
+ surfaceContainerLowest: Colors.black,
+ surfaceContainerLow: Colors.black,
+ surfaceContainer: const Color(0xFF050505),
+ surfaceContainerHigh: const Color(0xFF0A0A0A),
+ surfaceContainerHighest: const Color(0xFF0F0F0F),
+ );
+ }
+
+ final lightScheme = ColorScheme.fromSeed(
+ seedColor: seedColor,
+ brightness: Brightness.light,
+ );
const pageTransition = PageTransitionsTheme(builders: {
TargetPlatform.android: CupertinoPageTransitionsBuilder(),
@@ -364,10 +334,6 @@ class AbsorbApp extends StatelessWidget {
),
home: const AuthGate(),
);
- },
- );
- },
- );
},
);
},
@@ -415,8 +381,8 @@ class _AuthGateState extends State<AuthGate> {
final scopedTheme = await PlayerSettings.getThemeMode();
applyThemeMode(scopedTheme);
snappyTransitionsNotifier.value = await PlayerSettings.getSnappyTransitions();
- colorSourceNotifier.value = await PlayerSettings.getColorSource();
- if (colorSourceNotifier.value == 'cover') {
+ // Restore cover seed color
+ {
final seedInt = await PlayerSettings.getCoverSeedColor();
if (seedInt != null) {
coverSchemeNotifier.value = ColorScheme.fromSeed(
diff --git a/lib/screens/app_shell.dart b/lib/screens/app_shell.dart
index 466567c8..d3955eef 100644
--- a/lib/screens/app_shell.dart
+++ b/lib/screens/app_shell.dart
@@ -9,7 +9,7 @@ import '../services/chromecast_service.dart';
import '../services/sleep_timer_service.dart';
import 'dart:io';
import 'package:cached_network_image/cached_network_image.dart';
-import '../main.dart' show snappyTransitionsNotifier, colorSourceNotifier, coverSchemeNotifier;
+import '../main.dart' show snappyTransitionsNotifier, coverSchemeNotifier;
import '../l10n/app_localizations.dart';
import '../services/android_auto_service.dart';
import '../widgets/expanded_card.dart';
@@ -146,7 +146,6 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver, Ticker
_player.addListener(_onPlayerChanged);
_wasCasting = _cast.isCasting;
_cast.addListener(_onCastChanged);
- colorSourceNotifier.addListener(_onColorSourceChanged);
// Try immediately; _onLibraryChanged picks it up once data loads.
_deriveCoverScheme();
context.read<LibraryProvider>().addListener(_onLibraryChanged);
@@ -158,32 +157,21 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver, Ticker
_fadeController.dispose();
_player.removeListener(_onPlayerChanged);
_cast.removeListener(_onCastChanged);
- colorSourceNotifier.removeListener(_onColorSourceChanged);
try { context.read<LibraryProvider>().removeListener(_onLibraryChanged); } catch (_) {}
if (_instance == this) _instance = null;
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
- void _onColorSourceChanged() {
- if (colorSourceNotifier.value == 'cover') {
- _lastCoverItemId = null; // force re-derive
- _deriveCoverScheme();
- } else {
- coverSchemeNotifier.value = null;
- }
- }
-
void _onLibraryChanged() {
// Once absorbing list loads, derive cover scheme if we haven't yet
- if (colorSourceNotifier.value == 'cover' && coverSchemeNotifier.value == null) {
+ if (coverSchemeNotifier.value == null) {
_deriveCoverScheme();
}
}
/// Attempt to derive cover scheme. Returns true if successful.
bool _deriveCoverScheme() {
- if (colorSourceNotifier.value != 'cover') return false;
// Use player's current item, or fall back to absorbing list's first item
var itemId = _player.currentItemId;
if (itemId == null) {
diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart
index 0607fb44..1e908ac9 100644
--- a/lib/screens/settings_screen.dart
+++ b/lib/screens/settings_screen.dart
@@ -21,7 +21,7 @@ import '../screens/app_shell.dart';
import '../screens/admin_screen.dart';
import '../screens/downloads_screen.dart';
import '../screens/bookmarks_screen.dart';
-import '../main.dart' show applyThemeMode, applyTrustAllCerts, oledNotifier, snappyTransitionsNotifier, colorSourceNotifier;
+import '../main.dart' show applyThemeMode, applyTrustAllCerts, oledNotifier, snappyTransitionsNotifier;
import '../widgets/absorb_page_header.dart';
import '../widgets/absorb_slider.dart';
@@ -70,7 +70,6 @@ class _SettingsScreenState extends State<SettingsScreen> {
bool _rectangleCovers = false;
bool _coverPlayButton = false;
String _themeMode = 'dark';
- String _colorSource = 'wallpaper';
int _startScreen = 2;
int _streamingCacheSizeMb = 0;
bool _localServerEnabled = false;
@@ -160,7 +159,6 @@ class _SettingsScreenState extends State<SettingsScreen> {
PlayerSettings.getLocalServerUrl(), // 32
PlayerSettings.getDisableAudioFocus(), // 33
PlayerSettings.getAutoDownloadOnStream(), // 34
- PlayerSettings.getColorSource(), // 35
PlayerSettings.getStartScreen(), // 36
PlayerSettings.getPodcastQueueMode(), // 37
PlayerSettings.getCardButtonLayout(), // 38
@@ -202,13 +200,12 @@ class _SettingsScreenState extends State<SettingsScreen> {
final localUrl = results[31] as String;
final audioFocusOff = results[32] as bool;
final autoDlStream = results[33] as bool;
- final colorSource = results[34] as String;
- final startScreen = results[35] as int;
- final podcastQueueMode = results[36] as String;
- final cardBtnLayout = results[37] as String;
- final rectCovers = results[38] as bool;
- final trustCerts = results[39] as bool;
- final coverPlay = results[40] as bool;
+ final startScreen = results[34] as int;
+ final podcastQueueMode = results[35] as String;
+ final cardBtnLayout = results[36] as String;
+ final rectCovers = results[37] as bool;
+ final trustCerts = results[38] as bool;
+ final coverPlay = results[39] as bool;
if (mounted) setState(() {
_rewindSettings = s;
_defaultSpeed = speed;
@@ -236,7 +233,6 @@ class _SettingsScreenState extends State<SettingsScreen> {
_fullScreenPlayer = fullScreen;
_snappyTransitions = snappyTrans;
_themeMode = theme;
- _colorSource = colorSource;
_downloadLocationLabel = dlLabel;
_totalDownloadSizeBytes = dlSize;
if (deviceStorage != null) {
@@ -616,36 +612,6 @@ class _SettingsScreenState extends State<SettingsScreen> {
),
),
),
- const SizedBox(height: 16),
- Text('Color source', style: tt.titleSmall),
- const SizedBox(height: 4),
- Text(
- _colorSource == 'cover'
- ? 'App colors follow the currently playing book cover'
- : 'App colors follow your system wallpaper',
- style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant),
- ),
- const SizedBox(height: 12),
- SizedBox(
- width: double.infinity,
- child: SegmentedButton<String>(
- showSelectedIcon: false,
- segments: const [
- ButtonSegment(value: 'wallpaper', label: Text('Wallpaper')),
- ButtonSegment(value: 'cover', label: Text('Now Playing')),
- ],
- selected: {_colorSource},
- onSelectionChanged: _loaded ? (selected) {
- final source = selected.first;
- setState(() => _colorSource = source);
- PlayerSettings.setColorSource(source);
- colorSourceNotifier.value = source;
- } : null,
- style: const ButtonStyle(
- visualDensity: VisualDensity.compact,
- ),
- ),
- ),
],
),
),
diff --git a/lib/services/audio_player_service.dart b/lib/services/audio_player_service.dart
index a1e25270..82e2f138 100644
--- a/lib/services/audio_player_service.dart
+++ b/lib/services/audio_player_service.dart
@@ -355,7 +355,7 @@ class PlayerSettings {
static Future<String> getThemeMode() => _get('themeMode', 'dark');
static Future<void> setThemeMode(String value) => _set('themeMode', value);
- static Future<String> getColorSource() => _get('colorSource', 'wallpaper');
+ static Future<String> getColorSource() => _get('colorSource', 'default');
static Future<void> setColorSource(String value) => _set('colorSource', value);
/// Default start screen tab index: 0=Home, 1=Library, 2=Absorbing, 3=Stats, 4=Settings