mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 16:05:18 +00:00
fix: navigation to settings not working
This commit is contained in:
parent
6d836bdb65
commit
ce10aa1fe2
@ -5,19 +5,29 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|||||||
class SideBarTiles {
|
class SideBarTiles {
|
||||||
final IconData icon;
|
final IconData icon;
|
||||||
final String title;
|
final String title;
|
||||||
SideBarTiles({required this.icon, required this.title});
|
final String id;
|
||||||
|
SideBarTiles({required this.icon, required this.title, required this.id});
|
||||||
}
|
}
|
||||||
|
|
||||||
List<SideBarTiles> getSidebarTileList(AppLocalizations l10n) => [
|
List<SideBarTiles> getSidebarTileList(AppLocalizations l10n) => [
|
||||||
SideBarTiles(icon: SpotubeIcons.home, title: l10n.browse),
|
SideBarTiles(id: "browse", icon: SpotubeIcons.home, title: l10n.browse),
|
||||||
SideBarTiles(icon: SpotubeIcons.search, title: l10n.search),
|
SideBarTiles(id: "search", icon: SpotubeIcons.search, title: l10n.search),
|
||||||
SideBarTiles(icon: SpotubeIcons.library, title: l10n.library),
|
SideBarTiles(
|
||||||
SideBarTiles(icon: SpotubeIcons.music, title: l10n.lyrics),
|
id: "library", icon: SpotubeIcons.library, title: l10n.library),
|
||||||
|
SideBarTiles(id: "lyrics", icon: SpotubeIcons.music, title: l10n.lyrics),
|
||||||
];
|
];
|
||||||
|
|
||||||
List<SideBarTiles> getNavbarTileList(AppLocalizations l10n) => [
|
List<SideBarTiles> getNavbarTileList(AppLocalizations l10n) => [
|
||||||
SideBarTiles(icon: SpotubeIcons.home, title: l10n.browse),
|
SideBarTiles(id: "browse", icon: SpotubeIcons.home, title: l10n.browse),
|
||||||
SideBarTiles(icon: SpotubeIcons.search, title: l10n.search),
|
SideBarTiles(id: "search", icon: SpotubeIcons.search, title: l10n.search),
|
||||||
SideBarTiles(icon: SpotubeIcons.library, title: l10n.library),
|
SideBarTiles(
|
||||||
SideBarTiles(icon: SpotubeIcons.settings, title: l10n.settings)
|
id: "library",
|
||||||
|
icon: SpotubeIcons.library,
|
||||||
|
title: l10n.library,
|
||||||
|
),
|
||||||
|
SideBarTiles(
|
||||||
|
id: "settings",
|
||||||
|
icon: SpotubeIcons.settings,
|
||||||
|
title: l10n.settings,
|
||||||
|
)
|
||||||
];
|
];
|
||||||
|
@ -70,7 +70,7 @@ class SpotubeNavigationBar extends HookConsumerWidget {
|
|||||||
return MouseRegion(
|
return MouseRegion(
|
||||||
cursor: SystemMouseCursors.click,
|
cursor: SystemMouseCursors.click,
|
||||||
child: Badge(
|
child: Badge(
|
||||||
isLabelVisible: e.title == "Library" && downloadCount > 0,
|
isLabelVisible: e.id == "library" && downloadCount > 0,
|
||||||
label: Text(downloadCount.toString()),
|
label: Text(downloadCount.toString()),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
e.icon,
|
e.icon,
|
||||||
@ -84,7 +84,7 @@ class SpotubeNavigationBar extends HookConsumerWidget {
|
|||||||
index: insideSelectedIndex.value,
|
index: insideSelectedIndex.value,
|
||||||
onTap: (i) {
|
onTap: (i) {
|
||||||
insideSelectedIndex.value = i;
|
insideSelectedIndex.value = i;
|
||||||
if (navbarTileList[i].title == "Settings") {
|
if (navbarTileList[i].id == "settings") {
|
||||||
Sidebar.goToSettings(context);
|
Sidebar.goToSettings(context);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ class PlaylistQueue {
|
|||||||
class PlaylistQueueNotifier extends PersistedStateNotifier<PlaylistQueue?> {
|
class PlaylistQueueNotifier extends PersistedStateNotifier<PlaylistQueue?> {
|
||||||
final Ref ref;
|
final Ref ref;
|
||||||
|
|
||||||
AudioServices? audioServices;
|
late AudioServices audioServices;
|
||||||
|
|
||||||
static final provider =
|
static final provider =
|
||||||
StateNotifierProvider<PlaylistQueueNotifier, PlaylistQueue?>(
|
StateNotifierProvider<PlaylistQueueNotifier, PlaylistQueue?>(
|
||||||
@ -150,7 +150,7 @@ class PlaylistQueueNotifier extends PersistedStateNotifier<PlaylistQueue?> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void configure() async {
|
void configure() async {
|
||||||
audioServices = await AudioServices.create(ref, this);
|
audioServices = AudioServices(ref, this);
|
||||||
|
|
||||||
audioPlayer.onPlayerComplete.listen((event) async {
|
audioPlayer.onPlayerComplete.listen((event) async {
|
||||||
if (!isLoaded) return;
|
if (!isLoaded) return;
|
||||||
@ -337,8 +337,7 @@ class PlaylistQueueNotifier extends PersistedStateNotifier<PlaylistQueue?> {
|
|||||||
Future<void> play() async {
|
Future<void> play() async {
|
||||||
if (!isLoaded) return;
|
if (!isLoaded) return;
|
||||||
await pause();
|
await pause();
|
||||||
audioServices?.activateSession();
|
await audioServices.addTrack(state!.activeTrack);
|
||||||
await audioServices?.addTrack(state!.activeTrack);
|
|
||||||
if (state!.activeTrack is LocalTrack) {
|
if (state!.activeTrack is LocalTrack) {
|
||||||
await audioPlayer.play(
|
await audioPlayer.play(
|
||||||
DeviceFileSource((state!.activeTrack as LocalTrack).path),
|
DeviceFileSource((state!.activeTrack as LocalTrack).path),
|
||||||
@ -363,7 +362,7 @@ class PlaylistQueueNotifier extends PersistedStateNotifier<PlaylistQueue?> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
audioServices?.addTrack(state!.activeTrack);
|
audioServices.addTrack(state!.activeTrack);
|
||||||
|
|
||||||
final cached =
|
final cached =
|
||||||
await DefaultCacheManager().getFileFromCache(state!.activeTrack.id!);
|
await DefaultCacheManager().getFileFromCache(state!.activeTrack.id!);
|
||||||
@ -415,7 +414,7 @@ class PlaylistQueueNotifier extends PersistedStateNotifier<PlaylistQueue?> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> stop() async {
|
Future<void> stop() async {
|
||||||
audioServices?.deactivateSession();
|
audioServices.deactivateSession();
|
||||||
state = null;
|
state = null;
|
||||||
|
|
||||||
return audioPlayer.stop();
|
return audioPlayer.stop();
|
||||||
@ -528,7 +527,7 @@ class PlaylistQueueNotifier extends PersistedStateNotifier<PlaylistQueue?> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
audioServices?.dispose();
|
audioServices.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,25 @@
|
|||||||
import 'package:audioplayers/audioplayers.dart';
|
import 'package:audioplayers/audioplayers.dart';
|
||||||
|
|
||||||
final audioPlayer = AudioPlayer();
|
final audioPlayer = (() {
|
||||||
|
AudioPlayer.global.setAudioContext(
|
||||||
|
const AudioContext(
|
||||||
|
android: AudioContextAndroid(
|
||||||
|
audioFocus: AndroidAudioFocus.gain,
|
||||||
|
audioMode: AndroidAudioMode.inCall,
|
||||||
|
contentType: AndroidContentType.music,
|
||||||
|
stayAwake: true,
|
||||||
|
usageType: AndroidUsageType.media,
|
||||||
|
),
|
||||||
|
iOS: AudioContextIOS(
|
||||||
|
category: AVAudioSessionCategory.playback,
|
||||||
|
options: [
|
||||||
|
AVAudioSessionOptions.allowBluetooth,
|
||||||
|
AVAudioSessionOptions.allowBluetoothA2DP,
|
||||||
|
AVAudioSessionOptions.defaultToSpeaker,
|
||||||
|
AVAudioSessionOptions.mixWithOthers,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return AudioPlayer();
|
||||||
|
})();
|
||||||
|
@ -14,25 +14,24 @@ class AudioServices {
|
|||||||
final WindowsAudioService? smtc;
|
final WindowsAudioService? smtc;
|
||||||
final LinuxAudioService? mpris;
|
final LinuxAudioService? mpris;
|
||||||
|
|
||||||
AudioServices(this.mobile, this.smtc, this.mpris);
|
AudioServices._(this.mobile, this.smtc, this.mpris);
|
||||||
|
|
||||||
static Future<AudioServices> create(
|
factory AudioServices(Ref ref, PlaylistQueueNotifier playlistQueueNotifier) {
|
||||||
Ref ref, PlaylistQueueNotifier playlistQueueNotifier) async {
|
|
||||||
final mobile =
|
final mobile =
|
||||||
!DesktopTools.platform.isMobile && !!DesktopTools.platform.isMacOS
|
DesktopTools.platform.isMobile || DesktopTools.platform.isMacOS
|
||||||
? null
|
? MobileAudioService(
|
||||||
: MobileAudioService(
|
|
||||||
playlistQueueNotifier,
|
playlistQueueNotifier,
|
||||||
ref.read(VolumeProvider.provider.notifier),
|
ref.read(VolumeProvider.provider.notifier),
|
||||||
);
|
)
|
||||||
final smtc = !DesktopTools.platform.isWindows
|
: null;
|
||||||
? null
|
final smtc = DesktopTools.platform.isWindows
|
||||||
: WindowsAudioService(ref, playlistQueueNotifier);
|
? WindowsAudioService(ref, playlistQueueNotifier)
|
||||||
final mpris = !DesktopTools.platform.isLinux
|
: null;
|
||||||
? null
|
final mpris = DesktopTools.platform.isLinux
|
||||||
: LinuxAudioService(ref, playlistQueueNotifier);
|
? LinuxAudioService(ref, playlistQueueNotifier)
|
||||||
|
: null;
|
||||||
|
|
||||||
return AudioServices(mobile, smtc, mpris);
|
return AudioServices._(mobile, smtc, mpris);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> addTrack(Track track) async {
|
Future<void> addTrack(Track track) async {
|
||||||
|
28
pubspec.lock
28
pubspec.lock
@ -141,58 +141,58 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: audioplayers
|
name: audioplayers
|
||||||
sha256: "16451eab798b23ad9307aef6f9ca62bb8fb06542af8810eead0d236d3fd40a42"
|
sha256: "6063c05f987596ba7a3dad9bb9a5d8adfa5e7c07b9bae5301b27c11d0b3a239f"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.1"
|
version: "4.0.1"
|
||||||
audioplayers_android:
|
audioplayers_android:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: audioplayers_android
|
name: audioplayers_android
|
||||||
sha256: b2c833e6f718b6b030454e329931229afafe9327fdb002874dd544dc8bf2484d
|
sha256: fb6bca878ad175d8f6ddc0e0a2d4226d81fa7c10747c12db420e96c7a096b2cc
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "3.0.1"
|
||||||
audioplayers_darwin:
|
audioplayers_darwin:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: audioplayers_darwin
|
name: audioplayers_darwin
|
||||||
sha256: e7a3c8759bf11ecfe4b20df338bf9f3d37c7719a5761c46a3833aba0ceeaacff
|
sha256: c4a56c49347b2e85ac4e1efea218948ca0fba87f04d2a3d3de07ce2410037038
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.1"
|
version: "4.0.1"
|
||||||
audioplayers_linux:
|
audioplayers_linux:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: audioplayers_linux
|
name: audioplayers_linux
|
||||||
sha256: e95b65e1f4d4764601dac5e65f8d8186fc29401043ab020f1dacec483d708707
|
sha256: "897e24f190232a3fbb88134b062aa83a9240f55789b5e8d17c114283284ef56b"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.4"
|
version: "2.0.1"
|
||||||
audioplayers_platform_interface:
|
audioplayers_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: audioplayers_platform_interface
|
name: audioplayers_platform_interface
|
||||||
sha256: "178581a44cb685fd798d2108111d2e98cca3400e30b9c3a05546f124fb37f600"
|
sha256: "3a90a46198d375fc7d47bc1d3070c8fd8863b6469b7d87ca80f953efb090f976"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.0.0"
|
version: "5.0.0"
|
||||||
audioplayers_web:
|
audioplayers_web:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: audioplayers_web
|
name: audioplayers_web
|
||||||
sha256: "859ba09be2a57e57a787273f18c8cf0d9b61383870c5ee4b5632fe9adbc37edf"
|
sha256: "4f5dcbfec0bf98ea09e243d5f5b64ea43a4e6710a2f292724bed16cdba3c691e"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.0"
|
version: "3.0.1"
|
||||||
audioplayers_windows:
|
audioplayers_windows:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: audioplayers_windows
|
name: audioplayers_windows
|
||||||
sha256: "622e01c4c357c2aaf1b956c3a0f89d97c3cb40315c03f16e3b6c2a31ff9c38bc"
|
sha256: "010f575653c01ccbe9756050b18df83d89426740e04b684f6438aa26c775a965"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.3"
|
version: "2.0.1"
|
||||||
auto_size_text:
|
auto_size_text:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -13,7 +13,7 @@ dependencies:
|
|||||||
async: ^2.9.0
|
async: ^2.9.0
|
||||||
audio_service: ^0.18.9
|
audio_service: ^0.18.9
|
||||||
audio_session: ^0.1.13
|
audio_session: ^0.1.13
|
||||||
audioplayers: ^3.0.1
|
audioplayers: ^4.0.1
|
||||||
auto_size_text: ^3.0.0
|
auto_size_text: ^3.0.0
|
||||||
badges: ^2.0.3
|
badges: ^2.0.3
|
||||||
buttons_tabbar: ^1.3.6
|
buttons_tabbar: ^1.3.6
|
||||||
|
Loading…
Reference in New Issue
Block a user