mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55: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(
|
SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
width: 25,
|
width: 15,
|
||||||
child: Text(
|
child: Text(
|
||||||
(track.key + 1).toString(),
|
(track.key + 1).toString(),
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
|
@ -39,6 +39,13 @@ class TracksTableView extends HookConsumerWidget {
|
|||||||
final selected = useState<List<String>>([]);
|
final selected = useState<List<String>>([]);
|
||||||
final showCheck = useState<bool>(false);
|
final showCheck = useState<bool>(false);
|
||||||
|
|
||||||
|
final selectedTracks = useMemoized(
|
||||||
|
() => tracks.where(
|
||||||
|
(track) => selected.value.contains(track.id),
|
||||||
|
),
|
||||||
|
[tracks],
|
||||||
|
);
|
||||||
|
|
||||||
return SliverList(
|
return SliverList(
|
||||||
delegate: SliverChildListDelegate([
|
delegate: SliverChildListDelegate([
|
||||||
if (heading != null) heading!,
|
if (heading != null) heading!,
|
||||||
@ -101,9 +108,11 @@ class TracksTableView extends HookConsumerWidget {
|
|||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
enabled: selected.value.isNotEmpty,
|
enabled: selected.value.isNotEmpty,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: const [
|
children: [
|
||||||
Icon(Icons.file_download_outlined),
|
const Icon(Icons.file_download_outlined),
|
||||||
Text("Download"),
|
Text(
|
||||||
|
"Download ${selectedTracks.isNotEmpty ? "(${selectedTracks.length})" : ""}",
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
value: "download",
|
value: "download",
|
||||||
@ -123,9 +132,6 @@ class TracksTableView extends HookConsumerWidget {
|
|||||||
final queue = Queue(
|
final queue = Queue(
|
||||||
delay: const Duration(seconds: 5),
|
delay: const Duration(seconds: 5),
|
||||||
);
|
);
|
||||||
final selectedTracks = tracks.where(
|
|
||||||
(track) => selected.value.contains(track.id),
|
|
||||||
);
|
|
||||||
for (final selectedTrack in selectedTracks) {
|
for (final selectedTrack in selectedTracks) {
|
||||||
queue.add(() async {
|
queue.add(() async {
|
||||||
downloader.addToQueue(
|
downloader.addToQueue(
|
||||||
@ -136,6 +142,9 @@ class TracksTableView extends HookConsumerWidget {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
selected.value = [];
|
||||||
|
showCheck.value = false;
|
||||||
await queue.onComplete;
|
await queue.onComplete;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ class _SpotubeState extends ConsumerState<Spotube> with WidgetsBindingObserver {
|
|||||||
super.initState();
|
super.initState();
|
||||||
SharedPreferences.getInstance().then(((value) => localStorage = value));
|
SharedPreferences.getInstance().then(((value) => localStorage = value));
|
||||||
WidgetsBinding.instance.addObserver(this);
|
WidgetsBinding.instance.addObserver(this);
|
||||||
FlutterDownloader.registerCallback(downloadCallback);
|
if (kIsMobile) FlutterDownloader.registerCallback(downloadCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
|
@ -73,5 +73,12 @@ ThemeData darkTheme({
|
|||||||
cardColor: backgroundMaterialColor[800],
|
cardColor: backgroundMaterialColor[800],
|
||||||
canvasColor: backgroundMaterialColor[900],
|
canvasColor: backgroundMaterialColor[900],
|
||||||
listTileTheme: const ListTileThemeData(horizontalTitleGap: 0),
|
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],
|
cardColor: backgroundMaterialColor[50],
|
||||||
canvasColor: 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