mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
feat: add Amoled theme #724
This commit is contained in:
parent
532248b55d
commit
5c5dbf69ec
@ -97,4 +97,5 @@ abstract class SpotubeIcons {
|
||||
static const user = FeatherIcons.user;
|
||||
static const edit = FeatherIcons.edit;
|
||||
static const web = FeatherIcons.globe;
|
||||
static const amoled = FeatherIcons.sunset;
|
||||
}
|
||||
|
@ -263,5 +263,6 @@
|
||||
"connection_restored": "Your internet connection was restored",
|
||||
"use_system_title_bar": "Use system title bar",
|
||||
"crunching_results": "Crunching results...",
|
||||
"search_to_get_results": "Search to get results"
|
||||
"search_to_get_results": "Search to get results",
|
||||
"use_amoled_dark_theme": "Use AMOLED (Pitch Black) dark theme"
|
||||
}
|
@ -163,6 +163,8 @@ class SpotubeState extends ConsumerState<Spotube> {
|
||||
ref.watch(userPreferencesProvider.select((s) => s.themeMode));
|
||||
final accentMaterialColor =
|
||||
ref.watch(userPreferencesProvider.select((s) => s.accentColorScheme));
|
||||
final isAmoledTheme =
|
||||
ref.watch(userPreferencesProvider.select((s) => s.amoledDarkTheme));
|
||||
final locale = ref.watch(userPreferencesProvider.select((s) => s.locale));
|
||||
final paletteColor =
|
||||
ref.watch(paletteProvider.select((s) => s?.dominantColor?.color));
|
||||
@ -182,12 +184,16 @@ class SpotubeState extends ConsumerState<Spotube> {
|
||||
useDisableBatteryOptimizations();
|
||||
|
||||
final lightTheme = useMemoized(
|
||||
() => theme(paletteColor ?? accentMaterialColor, Brightness.light),
|
||||
() => theme(paletteColor ?? accentMaterialColor, Brightness.light, false),
|
||||
[paletteColor, accentMaterialColor],
|
||||
);
|
||||
final darkTheme = useMemoized(
|
||||
() => theme(paletteColor ?? accentMaterialColor, Brightness.dark),
|
||||
[paletteColor, accentMaterialColor],
|
||||
() => theme(
|
||||
paletteColor ?? accentMaterialColor,
|
||||
Brightness.dark,
|
||||
isAmoledTheme,
|
||||
),
|
||||
[paletteColor, accentMaterialColor, isAmoledTheme],
|
||||
);
|
||||
|
||||
return MaterialApp.router(
|
||||
|
@ -253,6 +253,12 @@ class SettingsPage extends HookConsumerWidget {
|
||||
}
|
||||
},
|
||||
),
|
||||
SwitchListTile(
|
||||
secondary: const Icon(SpotubeIcons.amoled),
|
||||
title: Text(context.l10n.use_amoled_dark_theme),
|
||||
value: preferences.amoledDarkTheme,
|
||||
onChanged: preferences.setAmoledDarkTheme,
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(SpotubeIcons.palette),
|
||||
title: Text(context.l10n.accent_color),
|
||||
|
@ -68,6 +68,8 @@ class UserPreferences extends PersistedChangeNotifier {
|
||||
|
||||
bool systemTitleBar;
|
||||
|
||||
bool amoledDarkTheme;
|
||||
|
||||
final Ref ref;
|
||||
|
||||
UserPreferences(
|
||||
@ -89,6 +91,7 @@ class UserPreferences extends PersistedChangeNotifier {
|
||||
this.skipNonMusic = true,
|
||||
this.youtubeApiType = YoutubeApiType.youtube,
|
||||
this.systemTitleBar = false,
|
||||
this.amoledDarkTheme = false,
|
||||
}) : super() {
|
||||
if (downloadLocation.isEmpty && !kIsWeb) {
|
||||
_getDefaultDownloadDirectory().then(
|
||||
@ -210,6 +213,12 @@ class UserPreferences extends PersistedChangeNotifier {
|
||||
updatePersistence();
|
||||
}
|
||||
|
||||
void setAmoledDarkTheme(bool isAmoled) {
|
||||
amoledDarkTheme = isAmoled;
|
||||
notifyListeners();
|
||||
updatePersistence();
|
||||
}
|
||||
|
||||
Future<String> _getDefaultDownloadDirectory() async {
|
||||
if (kIsAndroid) return "/storage/emulated/0/Download/Spotube";
|
||||
|
||||
@ -274,6 +283,8 @@ class UserPreferences extends PersistedChangeNotifier {
|
||||
systemTitleBar = map["systemTitleBar"] ?? systemTitleBar;
|
||||
// updates the title bar
|
||||
setSystemTitleBar(systemTitleBar);
|
||||
|
||||
amoledDarkTheme = map["amoledDarkTheme"] ?? amoledDarkTheme;
|
||||
}
|
||||
|
||||
@override
|
||||
@ -297,6 +308,7 @@ class UserPreferences extends PersistedChangeNotifier {
|
||||
"skipNonMusic": skipNonMusic,
|
||||
"youtubeApiType": youtubeApiType.name,
|
||||
'systemTitleBar': systemTitleBar,
|
||||
"amoledDarkTheme": amoledDarkTheme,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -16,8 +16,12 @@ abstract class AudioPlayerInterface {
|
||||
final MkPlayerWithState _mkPlayer;
|
||||
// final ja.AudioPlayer? _justAudio;
|
||||
|
||||
AudioPlayerInterface() : _mkPlayer = MkPlayerWithState()
|
||||
// _mkPlayer = _mkSupportedPlatform ? MkPlayerWithState() : null,
|
||||
AudioPlayerInterface()
|
||||
: _mkPlayer = MkPlayerWithState(
|
||||
configuration: const mk.PlayerConfiguration(
|
||||
title: "Spotube",
|
||||
),
|
||||
)
|
||||
// _justAudio = !_mkSupportedPlatform ? ja.AudioPlayer() : null
|
||||
{
|
||||
_mkPlayer.stream.error.listen((event) {
|
||||
|
@ -4,7 +4,6 @@ import 'package:catcher/catcher.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:media_kit/media_kit.dart';
|
||||
// ignore: implementation_imports
|
||||
import 'package:media_kit/src/models/playable.dart';
|
||||
import 'package:spotube/services/audio_player/playback_state.dart';
|
||||
|
||||
/// MediaKit [Player] by default doesn't have a state stream.
|
||||
@ -124,7 +123,9 @@ class MkPlayerWithState extends Player {
|
||||
_loopModeStream.add(playlistMode);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> stop() async {
|
||||
await super.stop();
|
||||
await pause();
|
||||
await seek(Duration.zero);
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
ThemeData theme(Color seed, Brightness brightness) {
|
||||
ThemeData theme(Color seed, Brightness brightness, bool isAmoled) {
|
||||
final scheme = ColorScheme.fromSeed(
|
||||
seedColor: seed,
|
||||
shadow: Colors.black12,
|
||||
background: isAmoled ? Colors.black : null,
|
||||
surface: isAmoled ? Colors.black : null,
|
||||
brightness: brightness,
|
||||
);
|
||||
return ThemeData(
|
||||
|
@ -1 +1,45 @@
|
||||
{}
|
||||
{
|
||||
"bn": [
|
||||
"use_amoled_dark_theme"
|
||||
],
|
||||
|
||||
"ca": [
|
||||
"use_amoled_dark_theme"
|
||||
],
|
||||
|
||||
"de": [
|
||||
"use_amoled_dark_theme"
|
||||
],
|
||||
|
||||
"es": [
|
||||
"use_amoled_dark_theme"
|
||||
],
|
||||
|
||||
"fr": [
|
||||
"use_amoled_dark_theme"
|
||||
],
|
||||
|
||||
"hi": [
|
||||
"use_amoled_dark_theme"
|
||||
],
|
||||
|
||||
"ja": [
|
||||
"use_amoled_dark_theme"
|
||||
],
|
||||
|
||||
"pl": [
|
||||
"use_amoled_dark_theme"
|
||||
],
|
||||
|
||||
"pt": [
|
||||
"use_amoled_dark_theme"
|
||||
],
|
||||
|
||||
"ru": [
|
||||
"use_amoled_dark_theme"
|
||||
],
|
||||
|
||||
"zh": [
|
||||
"use_amoled_dark_theme"
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user