mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-12-06 07:29:42 +00:00
chore: fix replace material widgets with shadcn widgets
This commit is contained in:
parent
0b1f4876d4
commit
bafa117aae
@ -2,7 +2,6 @@ import 'package:auto_size_text/auto_size_text.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:flutter/material.dart' show showModalBottomSheet, ListTile, SafeArea, Column, Navigator;
|
||||
import 'package:fuzzywuzzy/fuzzywuzzy.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
|
||||
@ -10,14 +9,16 @@ import 'package:scroll_to_index/scroll_to_index.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||
import 'package:spotube/collections/spotube_icons.dart';
|
||||
import 'package:spotube/components/button/back_button.dart';
|
||||
import 'package:spotube/components/dialogs/playlist_add_track_dialog.dart';
|
||||
import 'package:spotube/components/fallbacks/not_found.dart';
|
||||
import 'package:spotube/components/inter_scrollbar/inter_scrollbar.dart';
|
||||
import 'package:spotube/components/track_tile/track_tile.dart';
|
||||
import 'package:spotube/components/dialogs/playlist_add_track_dialog.dart';
|
||||
import 'package:spotube/components/ui/button_tile.dart';
|
||||
import 'package:spotube/extensions/constrains.dart';
|
||||
import 'package:spotube/extensions/context.dart';
|
||||
import 'package:spotube/hooks/controllers/use_auto_scroll_controller.dart';
|
||||
import 'package:spotube/models/metadata/metadata.dart';
|
||||
import 'package:spotube/modules/player/player_queue_actions.dart';
|
||||
import 'package:spotube/provider/audio_player/audio_player.dart';
|
||||
import 'package:spotube/provider/audio_player/state.dart';
|
||||
|
||||
@ -136,9 +137,8 @@ class PlayerQueue extends HookConsumerWidget {
|
||||
surfaceOpacity: 0,
|
||||
child: searchBar,
|
||||
)
|
||||
else
|
||||
selectionMode.value
|
||||
? AppBar(
|
||||
else if (selectionMode.value)
|
||||
AppBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
surfaceBlur: 0,
|
||||
surfaceOpacity: 0,
|
||||
@ -159,44 +159,34 @@ class PlayerQueue extends HookConsumerWidget {
|
||||
),
|
||||
),
|
||||
trailing: [
|
||||
IconButton.ghost(
|
||||
icon: const Icon(SpotubeIcons.moreHorizontal),
|
||||
onPressed: () async {
|
||||
await showModalBottomSheet<void>(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return SafeArea(
|
||||
child: Column(
|
||||
PlayerQueueActionButton(
|
||||
builder: (context, close) => Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(
|
||||
SpotubeIcons.selectionCheck),
|
||||
title: Text(
|
||||
context.l10n.select_all),
|
||||
onTap: () {
|
||||
const Gap(12),
|
||||
ButtonTile(
|
||||
style: const ButtonStyle.ghost(),
|
||||
leading:
|
||||
const Icon(SpotubeIcons.selectionCheck),
|
||||
title: Text(context.l10n.select_all),
|
||||
onPressed: () {
|
||||
selectedTrackIds.value =
|
||||
filteredTracks
|
||||
.map((t) => t.id)
|
||||
.toSet();
|
||||
filteredTracks.map((t) => t.id).toSet();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(
|
||||
SpotubeIcons.playlistAdd),
|
||||
title: Text(
|
||||
context.l10n.add_to_playlist),
|
||||
onTap: () async {
|
||||
ButtonTile(
|
||||
style: const ButtonStyle.ghost(),
|
||||
leading: const Icon(SpotubeIcons.playlistAdd),
|
||||
title: Text(context.l10n.add_to_playlist),
|
||||
onPressed: () async {
|
||||
final selected = filteredTracks
|
||||
.where((t) => selectedTrackIds
|
||||
.value
|
||||
.contains(t.id))
|
||||
.where((t) =>
|
||||
selectedTrackIds.value.contains(t.id))
|
||||
.toList();
|
||||
Navigator.pop(context);
|
||||
close();
|
||||
if (selected.isEmpty) return;
|
||||
final res = await showDialog<
|
||||
bool?>(
|
||||
final res = await showDialog<bool?>(
|
||||
context: context,
|
||||
builder: (context) =>
|
||||
PlaylistAddTrackDialog(
|
||||
@ -210,41 +200,30 @@ class PlayerQueue extends HookConsumerWidget {
|
||||
}
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading:
|
||||
const Icon(SpotubeIcons.trash),
|
||||
title: Text(
|
||||
context.l10n.remove_from_queue),
|
||||
onTap: () async {
|
||||
final ids = selectedTrackIds
|
||||
.value
|
||||
.toList();
|
||||
Navigator.pop(context);
|
||||
ButtonTile(
|
||||
style: const ButtonStyle.ghost(),
|
||||
leading: const Icon(SpotubeIcons.trash),
|
||||
title: Text(context.l10n.remove_from_queue),
|
||||
onPressed: () async {
|
||||
final ids = selectedTrackIds.value.toList();
|
||||
close();
|
||||
if (ids.isEmpty) return;
|
||||
await Future.wait(ids
|
||||
.map((id) => onRemove(id)));
|
||||
await Future.wait(
|
||||
ids.map((id) => onRemove(id)));
|
||||
if (context.mounted) {
|
||||
selectedTrackIds.value = {};
|
||||
selectionMode.value = false;
|
||||
}
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(
|
||||
SpotubeIcons.close),
|
||||
title: Text(context.l10n.cancel),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
const Gap(12),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
: AppBar(
|
||||
else
|
||||
AppBar(
|
||||
trailingGap: 0,
|
||||
backgroundColor: Colors.transparent,
|
||||
surfaceBlur: 0,
|
||||
@ -259,7 +238,8 @@ class PlayerQueue extends HookConsumerWidget {
|
||||
)
|
||||
: null,
|
||||
trailing: [
|
||||
if (mediaQuery.mdAndUp) searchBar
|
||||
if (mediaQuery.mdAndUp)
|
||||
searchBar
|
||||
else
|
||||
IconButton.ghost(
|
||||
icon: const Icon(SpotubeIcons.filter),
|
||||
|
||||
44
lib/modules/player/player_queue_actions.dart
Normal file
44
lib/modules/player/player_queue_actions.dart
Normal file
@ -0,0 +1,44 @@
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter_extension.dart';
|
||||
import 'package:spotube/collections/spotube_icons.dart';
|
||||
import 'package:spotube/extensions/constrains.dart';
|
||||
|
||||
class PlayerQueueActionButton extends StatelessWidget {
|
||||
final Widget Function(BuildContext context, VoidCallback close) builder;
|
||||
|
||||
const PlayerQueueActionButton({
|
||||
super.key,
|
||||
required this.builder,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return IconButton.ghost(
|
||||
onPressed: () {
|
||||
final mediaQuery = MediaQuery.sizeOf(context);
|
||||
|
||||
if (mediaQuery.lgAndUp) {
|
||||
showDropdown(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return SizedBox(
|
||||
width: 220 * context.theme.scaling,
|
||||
child: Card(
|
||||
padding: EdgeInsets.zero,
|
||||
child: builder(context, () => closeOverlay(context)),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
openSheet(
|
||||
context: context,
|
||||
builder: (context) => builder(context, () => closeSheet(context)),
|
||||
position: OverlayPosition.bottom,
|
||||
);
|
||||
}
|
||||
},
|
||||
icon: const Icon(SpotubeIcons.moreHorizontal),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -50,7 +50,6 @@ class MetadataPlugin {
|
||||
sharedPreferences,
|
||||
config.slug,
|
||||
),
|
||||
createYoutubeEngine: () => throw UnimplementedError(),
|
||||
onNavigatorPush: (route) {
|
||||
return rootNavigatorKey.currentContext?.router
|
||||
.pushWidget(Builder(builder: (context) {
|
||||
|
||||
@ -12,11 +12,13 @@
|
||||
#include <flutter_secure_storage_linux/flutter_secure_storage_linux_plugin.h>
|
||||
#include <flutter_timezone/flutter_timezone_plugin.h>
|
||||
#include <gtk/gtk_plugin.h>
|
||||
#include <irondash_engine_context/irondash_engine_context_plugin.h>
|
||||
#include <local_notifier/local_notifier_plugin.h>
|
||||
#include <media_kit_libs_linux/media_kit_libs_linux_plugin.h>
|
||||
#include <open_file_linux/open_file_linux_plugin.h>
|
||||
#include <screen_retriever_linux/screen_retriever_linux_plugin.h>
|
||||
#include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>
|
||||
#include <super_native_extensions/super_native_extensions_plugin.h>
|
||||
#include <system_theme/system_theme_plugin.h>
|
||||
#include <tray_manager/tray_manager_plugin.h>
|
||||
#include <url_launcher_linux/url_launcher_plugin.h>
|
||||
@ -41,6 +43,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) gtk_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "GtkPlugin");
|
||||
gtk_plugin_register_with_registrar(gtk_registrar);
|
||||
g_autoptr(FlPluginRegistrar) irondash_engine_context_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "IrondashEngineContextPlugin");
|
||||
irondash_engine_context_plugin_register_with_registrar(irondash_engine_context_registrar);
|
||||
g_autoptr(FlPluginRegistrar) local_notifier_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "LocalNotifierPlugin");
|
||||
local_notifier_plugin_register_with_registrar(local_notifier_registrar);
|
||||
@ -56,6 +61,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) sqlite3_flutter_libs_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "Sqlite3FlutterLibsPlugin");
|
||||
sqlite3_flutter_libs_plugin_register_with_registrar(sqlite3_flutter_libs_registrar);
|
||||
g_autoptr(FlPluginRegistrar) super_native_extensions_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "SuperNativeExtensionsPlugin");
|
||||
super_native_extensions_plugin_register_with_registrar(super_native_extensions_registrar);
|
||||
g_autoptr(FlPluginRegistrar) system_theme_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "SystemThemePlugin");
|
||||
system_theme_plugin_register_with_registrar(system_theme_registrar);
|
||||
|
||||
@ -9,11 +9,13 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
||||
flutter_secure_storage_linux
|
||||
flutter_timezone
|
||||
gtk
|
||||
irondash_engine_context
|
||||
local_notifier
|
||||
media_kit_libs_linux
|
||||
open_file_linux
|
||||
screen_retriever_linux
|
||||
sqlite3_flutter_libs
|
||||
super_native_extensions
|
||||
system_theme
|
||||
tray_manager
|
||||
url_launcher_linux
|
||||
|
||||
@ -18,6 +18,7 @@ import flutter_inappwebview_macos
|
||||
import flutter_new_pipe_extractor
|
||||
import flutter_secure_storage_macos
|
||||
import flutter_timezone
|
||||
import irondash_engine_context
|
||||
import local_notifier
|
||||
import media_kit_libs_macos_audio
|
||||
import open_file_mac
|
||||
@ -27,6 +28,7 @@ import screen_retriever_macos
|
||||
import shared_preferences_foundation
|
||||
import sqflite_darwin
|
||||
import sqlite3_flutter_libs
|
||||
import super_native_extensions
|
||||
import system_theme
|
||||
import tray_manager
|
||||
import url_launcher_macos
|
||||
@ -46,6 +48,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
FlutterNewPipeExtractorPlugin.register(with: registry.registrar(forPlugin: "FlutterNewPipeExtractorPlugin"))
|
||||
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
|
||||
FlutterTimezonePlugin.register(with: registry.registrar(forPlugin: "FlutterTimezonePlugin"))
|
||||
IrondashEngineContextPlugin.register(with: registry.registrar(forPlugin: "IrondashEngineContextPlugin"))
|
||||
LocalNotifierPlugin.register(with: registry.registrar(forPlugin: "LocalNotifierPlugin"))
|
||||
MediaKitLibsMacosAudioPlugin.register(with: registry.registrar(forPlugin: "MediaKitLibsMacosAudioPlugin"))
|
||||
OpenFilePlugin.register(with: registry.registrar(forPlugin: "OpenFilePlugin"))
|
||||
@ -55,6 +58,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
|
||||
Sqlite3FlutterLibsPlugin.register(with: registry.registrar(forPlugin: "Sqlite3FlutterLibsPlugin"))
|
||||
SuperNativeExtensionsPlugin.register(with: registry.registrar(forPlugin: "SuperNativeExtensionsPlugin"))
|
||||
SystemThemePlugin.register(with: registry.registrar(forPlugin: "SystemThemePlugin"))
|
||||
TrayManagerPlugin.register(with: registry.registrar(forPlugin: "TrayManagerPlugin"))
|
||||
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
||||
|
||||
@ -15,11 +15,13 @@
|
||||
#include <flutter_new_pipe_extractor/flutter_new_pipe_extractor_plugin_c_api.h>
|
||||
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
|
||||
#include <flutter_timezone/flutter_timezone_plugin_c_api.h>
|
||||
#include <irondash_engine_context/irondash_engine_context_plugin_c_api.h>
|
||||
#include <local_notifier/local_notifier_plugin.h>
|
||||
#include <media_kit_libs_windows_audio/media_kit_libs_windows_audio_plugin_c_api.h>
|
||||
#include <permission_handler_windows/permission_handler_windows_plugin.h>
|
||||
#include <screen_retriever_windows/screen_retriever_windows_plugin_c_api.h>
|
||||
#include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>
|
||||
#include <super_native_extensions/super_native_extensions_plugin_c_api.h>
|
||||
#include <system_theme/system_theme_plugin.h>
|
||||
#include <tray_manager/tray_manager_plugin.h>
|
||||
#include <url_launcher_windows/url_launcher_windows.h>
|
||||
@ -44,6 +46,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
|
||||
FlutterTimezonePluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("FlutterTimezonePluginCApi"));
|
||||
IrondashEngineContextPluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("IrondashEngineContextPluginCApi"));
|
||||
LocalNotifierPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("LocalNotifierPlugin"));
|
||||
MediaKitLibsWindowsAudioPluginCApiRegisterWithRegistrar(
|
||||
@ -54,6 +58,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
registry->GetRegistrarForPlugin("ScreenRetrieverWindowsPluginCApi"));
|
||||
Sqlite3FlutterLibsPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("Sqlite3FlutterLibsPlugin"));
|
||||
SuperNativeExtensionsPluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("SuperNativeExtensionsPluginCApi"));
|
||||
SystemThemePluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("SystemThemePlugin"));
|
||||
TrayManagerPluginRegisterWithRegistrar(
|
||||
|
||||
@ -12,11 +12,13 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
||||
flutter_new_pipe_extractor
|
||||
flutter_secure_storage_windows
|
||||
flutter_timezone
|
||||
irondash_engine_context
|
||||
local_notifier
|
||||
media_kit_libs_windows_audio
|
||||
permission_handler_windows
|
||||
screen_retriever_windows
|
||||
sqlite3_flutter_libs
|
||||
super_native_extensions
|
||||
system_theme
|
||||
tray_manager
|
||||
url_launcher_windows
|
||||
|
||||
Loading…
Reference in New Issue
Block a user