fix: track_table_view table headers

This commit is contained in:
Kingkor Roy Tirtho 2023-06-12 09:39:54 +06:00
parent c8b7de0879
commit d88d287fc5
2 changed files with 161 additions and 155 deletions

View File

@ -121,7 +121,8 @@ class TrackTile extends HookConsumerWidget {
Positioned.fill( Positioned.fill(
child: Center( child: Center(
child: IconTheme( child: IconTheme(
data: theme.iconTheme.copyWith(size: 26), data: theme.iconTheme
.copyWith(size: 26, color: Colors.white),
child: AnimatedSwitcher( child: AnimatedSwitcher(
duration: const Duration(milliseconds: 300), duration: const Duration(milliseconds: 300),
child: !isHovering child: !isHovering

View File

@ -49,8 +49,6 @@ class TracksTableView extends HookConsumerWidget {
TextStyle tableHeadStyle = TextStyle tableHeadStyle =
const TextStyle(fontWeight: FontWeight.bold, fontSize: 16); const TextStyle(fontWeight: FontWeight.bold, fontSize: 16);
final mediaQuery = MediaQuery.of(context);
final selected = useState<List<String>>([]); final selected = useState<List<String>>([]);
final showCheck = useState<bool>(false); final showCheck = useState<bool>(false);
final sortBy = ref.watch(trackCollectionSortState(playlistId ?? '')); final sortBy = ref.watch(trackCollectionSortState(playlistId ?? ''));
@ -73,29 +71,40 @@ class TracksTableView extends HookConsumerWidget {
? [const NotFound(vertical: true)] ? [const NotFound(vertical: true)]
: [ : [
if (heading != null) heading!, if (heading != null) heading!,
Row( LayoutBuilder(builder: (context, constrains) {
return Row(
children: [ children: [
Checkbox.adaptive( AnimatedSwitcher(
duration: const Duration(milliseconds: 200),
transitionBuilder: (child, animation) {
return FadeTransition(
opacity: animation,
child: ScaleTransition(
scale: animation,
child: child,
),
);
},
child: showCheck.value
? Checkbox.adaptive(
value: selected.value.length == sortedTracks.length, value: selected.value.length == sortedTracks.length,
onChanged: (checked) { onChanged: (checked) {
if (!showCheck.value) showCheck.value = true; if (!showCheck.value) showCheck.value = true;
if (checked == true) { if (checked == true) {
selected.value = sortedTracks.map((s) => s.id!).toList(); selected.value =
sortedTracks.map((s) => s.id!).toList();
} else { } else {
selected.value = []; selected.value = [];
showCheck.value = false; showCheck.value = false;
} }
}, },
), )
Padding( : constrains.mdAndUp
padding: const EdgeInsets.all(8.0), ? const SizedBox(width: 32)
child: Text( : const SizedBox(width: 16),
"#",
textAlign: TextAlign.center,
style: tableHeadStyle,
),
), ),
Expanded( Expanded(
flex: 5,
child: Row( child: Row(
children: [ children: [
Text( Text(
@ -107,9 +116,9 @@ class TracksTableView extends HookConsumerWidget {
), ),
), ),
// used alignment of this table-head // used alignment of this table-head
if (mediaQuery.lgAndUp) ...[ if (constrains.mdAndUp)
const SizedBox(width: 100),
Expanded( Expanded(
flex: 3,
child: Row( child: Row(
children: [ children: [
Text( Text(
@ -119,19 +128,13 @@ class TracksTableView extends HookConsumerWidget {
), ),
], ],
), ),
) ),
],
if (!mediaQuery.isSm) ...[
const SizedBox(width: 10),
Text(context.l10n.time, style: tableHeadStyle),
const SizedBox(width: 10),
],
SortTracksDropdown( SortTracksDropdown(
value: sortBy, value: sortBy,
onChanged: (value) { onChanged: (value) {
ref ref
.read( .read(trackCollectionSortState(playlistId ?? '')
trackCollectionSortState(playlistId ?? '').notifier) .notifier)
.state = value; .state = value;
}, },
), ),
@ -210,7 +213,8 @@ class TracksTableView extends HookConsumerWidget {
}, },
); );
if (confirmed != true) return; if (confirmed != true) return;
await downloader.enqueueAll(selectedTracks.toList()); await downloader
.enqueueAll(selectedTracks.toList());
if (context.mounted) { if (context.mounted) {
selected.value = []; selected.value = [];
showCheck.value = false; showCheck.value = false;
@ -250,7 +254,8 @@ class TracksTableView extends HookConsumerWidget {
), ),
const SizedBox(width: 10), const SizedBox(width: 10),
], ],
), );
}),
...sortedTracks.mapIndexed((i, track) { ...sortedTracks.mapIndexed((i, track) {
return TrackTile( return TrackTile(
index: i, index: i,