mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-12 23:45:18 +00:00
fix(downloader): flutter downloader exception on desktop platform and too much width of TrackTile index no.
This commit is contained in:
parent
0476bf7cee
commit
d6687603d1
@ -196,7 +196,7 @@ class TrackTile extends HookConsumerWidget {
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
width: 25,
|
||||
width: 15,
|
||||
child: Text(
|
||||
(track.key + 1).toString(),
|
||||
textAlign: TextAlign.center,
|
||||
|
@ -39,6 +39,13 @@ class TracksTableView extends HookConsumerWidget {
|
||||
final selected = useState<List<String>>([]);
|
||||
final showCheck = useState<bool>(false);
|
||||
|
||||
final selectedTracks = useMemoized(
|
||||
() => tracks.where(
|
||||
(track) => selected.value.contains(track.id),
|
||||
),
|
||||
[tracks],
|
||||
);
|
||||
|
||||
return SliverList(
|
||||
delegate: SliverChildListDelegate([
|
||||
if (heading != null) heading!,
|
||||
@ -101,9 +108,11 @@ class TracksTableView extends HookConsumerWidget {
|
||||
PopupMenuItem(
|
||||
enabled: selected.value.isNotEmpty,
|
||||
child: Row(
|
||||
children: const [
|
||||
Icon(Icons.file_download_outlined),
|
||||
Text("Download"),
|
||||
children: [
|
||||
const Icon(Icons.file_download_outlined),
|
||||
Text(
|
||||
"Download ${selectedTracks.isNotEmpty ? "(${selectedTracks.length})" : ""}",
|
||||
),
|
||||
],
|
||||
),
|
||||
value: "download",
|
||||
@ -123,9 +132,6 @@ class TracksTableView extends HookConsumerWidget {
|
||||
final queue = Queue(
|
||||
delay: const Duration(seconds: 5),
|
||||
);
|
||||
final selectedTracks = tracks.where(
|
||||
(track) => selected.value.contains(track.id),
|
||||
);
|
||||
for (final selectedTrack in selectedTracks) {
|
||||
queue.add(() async {
|
||||
downloader.addToQueue(
|
||||
@ -136,6 +142,9 @@ class TracksTableView extends HookConsumerWidget {
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
selected.value = [];
|
||||
showCheck.value = false;
|
||||
await queue.onComplete;
|
||||
break;
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ class _SpotubeState extends ConsumerState<Spotube> with WidgetsBindingObserver {
|
||||
super.initState();
|
||||
SharedPreferences.getInstance().then(((value) => localStorage = value));
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
FlutterDownloader.registerCallback(downloadCallback);
|
||||
if (kIsMobile) FlutterDownloader.registerCallback(downloadCallback);
|
||||
}
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
|
@ -73,5 +73,12 @@ ThemeData darkTheme({
|
||||
cardColor: backgroundMaterialColor[800],
|
||||
canvasColor: backgroundMaterialColor[900],
|
||||
listTileTheme: const ListTileThemeData(horizontalTitleGap: 0),
|
||||
checkboxTheme: CheckboxThemeData(
|
||||
fillColor: MaterialStateProperty.resolveWith((states) {
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return accentMaterialColor[500];
|
||||
}
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -97,5 +97,12 @@ ThemeData lightTheme({
|
||||
),
|
||||
cardColor: backgroundMaterialColor[50],
|
||||
canvasColor: backgroundMaterialColor[50],
|
||||
checkboxTheme: CheckboxThemeData(
|
||||
fillColor: MaterialStateProperty.resolveWith((states) {
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return accentMaterialColor[500];
|
||||
}
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user