chore: fix adaptive select tile scrolling not working

This commit is contained in:
Kingkor Roy Tirtho 2025-02-23 11:33:44 +06:00
parent 47edb8bf96
commit edc9636940
10 changed files with 58 additions and 65 deletions

View File

@ -26,8 +26,8 @@
android:usesCleartextTraffic="true"> android:usesCleartextTraffic="true">
<!-- Enable Impeller --> <!-- Enable Impeller -->
<!-- <meta-data <!-- <meta-data
android:name="io.flutter.embedding.android.EnableImpeller" android:name="io.flutter.embedding.android.EnableImpeller"
android:value="true" /> --> android:value="false" /> -->
<activity <activity
android:name="com.ryanheise.audioservice.AudioServiceActivity" android:name="com.ryanheise.audioservice.AudioServiceActivity"

View File

@ -44,7 +44,7 @@ class AdaptiveSelectTile<T> extends HookWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = Theme.of(context); final theme = Theme.of(context);
final mediaQuery = MediaQuery.of(context); final mediaQuery = MediaQuery.sizeOf(context);
Widget? control = Select<T>( Widget? control = Select<T>(
itemBuilder: (context, item) { itemBuilder: (context, item) {
@ -83,24 +83,26 @@ class AdaptiveSelectTile<T> extends HookWidget {
context: context, context: context,
builder: (context) { builder: (context) {
return AlertDialog( return AlertDialog(
content: ListView.builder( content: Flexible(
shrinkWrap: true, child: ListView.builder(
itemCount: options.length, shrinkWrap: true,
itemBuilder: (context, index) { itemCount: options.length,
final item = options[index]; itemBuilder: (context, index) {
final item = options[index];
return ListTile( return ListTile(
iconColor: theme.colorScheme.primary, iconColor: theme.colorScheme.primary,
leading: item.value == value leading: item.value == value
? const Icon(SpotubeIcons.radioChecked) ? const Icon(SpotubeIcons.radioChecked)
: const Icon(SpotubeIcons.radioUnchecked), : const Icon(SpotubeIcons.radioUnchecked),
title: item.child, title: item.child,
onTap: () { onTap: () {
onChanged?.call(item.value); onChanged?.call(item.value);
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
); );
}, },
),
), ),
); );
}, },

View File

@ -71,10 +71,8 @@ class Sidebar extends HookConsumerWidget {
tooltip: TooltipContainer(child: Text(tile.title)), tooltip: TooltipContainer(child: Text(tile.title)),
child: Icon(tile.icon), child: Icon(tile.icon),
), ),
onChanged: (value) { onPressed: () {
if (value) { context.navigateTo(tile.route);
context.navigateTo(tile.route);
}
}, },
), ),
const NavigationDivider(), const NavigationDivider(),
@ -83,10 +81,8 @@ class Sidebar extends HookConsumerWidget {
for (final tile in sidebarLibraryTileList) for (final tile in sidebarLibraryTileList)
NavigationButton( NavigationButton(
label: mediaQuery.lgAndUp ? Text(tile.title) : null, label: mediaQuery.lgAndUp ? Text(tile.title) : null,
onChanged: (value) { onPressed: () {
if (value) { context.navigateTo(tile.route);
context.navigateTo(tile.route);
}
}, },
child: Tooltip( child: Tooltip(
tooltip: TooltipContainer(child: Text(tile.title)), tooltip: TooltipContainer(child: Text(tile.title)),

View File

@ -61,20 +61,20 @@ class SpotubeNavigationBar extends HookConsumerWidget {
index: selectedIndex, index: selectedIndex,
surfaceBlur: context.theme.surfaceBlur, surfaceBlur: context.theme.surfaceBlur,
surfaceOpacity: context.theme.surfaceOpacity, surfaceOpacity: context.theme.surfaceOpacity,
onSelected: (i) {
context.navigateTo(navbarTileList[i].route);
},
children: [ children: [
for (final tile in navbarTileList) for (final tile in navbarTileList)
NavigationButton( NavigationButton(
style: const ButtonStyle.muted(density: ButtonDensity.icon), style: navbarTileList[selectedIndex] == tile
selectedStyle: ? const ButtonStyle.fixed(density: ButtonDensity.icon)
const ButtonStyle.fixed(density: ButtonDensity.icon), : const ButtonStyle.muted(density: ButtonDensity.icon),
child: Badge( child: Badge(
isLabelVisible: tile.id == "library" && downloadCount > 0, isLabelVisible: tile.id == "library" && downloadCount > 0,
label: Text(downloadCount.toString()), label: Text(downloadCount.toString()),
child: Icon(tile.icon), child: Icon(tile.icon),
), ),
onPressed: () {
context.navigateTo(tile.route);
},
) )
], ],
), ),

View File

@ -63,18 +63,18 @@ class StatsPageTopSection extends HookConsumerWidget {
children: [ children: [
TabList( TabList(
index: selectedIndex.value, index: selectedIndex.value,
onChanged: (value) {
selectedIndex.value = value;
},
children: [ children: [
TabButton( TabItem(
child: Text(context.l10n.top_tracks), child: Text(context.l10n.top_tracks),
onPressed: () => selectedIndex.value = 0,
), ),
TabButton( TabItem(
child: Text(context.l10n.top_artists), child: Text(context.l10n.top_artists),
onPressed: () => selectedIndex.value = 1,
), ),
TabButton( TabItem(
child: Text(context.l10n.top_albums), child: Text(context.l10n.top_albums),
onPressed: () => selectedIndex.value = 2,
), ),
], ],
), ),

View File

@ -53,18 +53,18 @@ class LibraryPage extends HookConsumerWidget {
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
child: TabList( child: TabList(
index: index, index: index,
onChanged: (index) {
context.navigateTo(sidebarLibraryTileList[index].route);
},
children: [ children: [
for (final tile in sidebarLibraryTileList) for (final tile in sidebarLibraryTileList)
TabButton( TabItem(
child: Badge( child: Badge(
isLabelVisible: tile.id == 'downloads' && isLabelVisible: tile.id == 'downloads' &&
downloadingCount > 0, downloadingCount > 0,
label: Text(downloadingCount.toString()), label: Text(downloadingCount.toString()),
child: Text(tile.title), child: Text(tile.title),
), ),
onPressed: () {
context.navigateTo(tile.route);
},
), ),
], ],
), ),

View File

@ -41,13 +41,12 @@ class LyricsPage extends HookConsumerWidget {
child: isModal child: isModal
? TabList( ? TabList(
index: selectedIndex.value, index: selectedIndex.value,
onChanged: (index) => selectedIndex.value = index,
children: [ children: [
TabButton( TabItem(
onPressed: () => selectedIndex.value = 0,
child: Text(context.l10n.synced), child: Text(context.l10n.synced),
), ),
TabButton( TabItem(
onPressed: () => selectedIndex.value = 1,
child: Text(context.l10n.plain), child: Text(context.l10n.plain),
), ),
], ],
@ -55,9 +54,9 @@ class LyricsPage extends HookConsumerWidget {
: Tabs( : Tabs(
index: selectedIndex.value, index: selectedIndex.value,
onChanged: (index) => selectedIndex.value = index, onChanged: (index) => selectedIndex.value = index,
tabs: [ children: [
Text(context.l10n.synced), TabItem(child: Text(context.l10n.synced)),
Text(context.l10n.plain), TabItem(child: Text(context.l10n.plain)),
], ],
), ),
); );

View File

@ -81,9 +81,9 @@ class MiniLyricsPage extends HookConsumerWidget {
onChanged: (i) { onChanged: (i) {
index.value = i; index.value = i;
}, },
tabs: [ children: [
Text(context.l10n.synced), TabItem(child: Text(context.l10n.synced)),
Text(context.l10n.plain), TabItem(child: Text(context.l10n.plain)),
], ],
), ),
const Spacer(), const Spacer(),

View File

@ -2011,12 +2011,11 @@ packages:
shadcn_flutter: shadcn_flutter:
dependency: "direct main" dependency: "direct main"
description: description:
path: "." name: shadcn_flutter
ref: d928e73cd734582046c63a3bed99cc42aeab6085 sha256: a04b6ce51ff8486fe9c0c3b373605ab30b823507a79a4458fc74b056edc883d8
resolved-ref: d928e73cd734582046c63a3bed99cc42aeab6085 url: "https://pub.dev"
url: "https://github.com/KRTirtho/shadcn_flutter.git" source: hosted
source: git version: "0.0.25"
version: "0.0.24"
shared_preferences: shared_preferences:
dependency: "direct main" dependency: "direct main"
description: description:
@ -2754,4 +2753,4 @@ packages:
version: "1.0.0" version: "1.0.0"
sdks: sdks:
dart: ">=3.7.0-0 <4.0.0" dart: ">=3.7.0-0 <4.0.0"
flutter: ">=3.27.0" flutter: ">=3.29.0"

View File

@ -104,10 +104,7 @@ dependencies:
ref: dart-3-support ref: dart-3-support
url: https://github.com/KRTirtho/scrobblenaut.git url: https://github.com/KRTirtho/scrobblenaut.git
scroll_to_index: ^3.0.1 scroll_to_index: ^3.0.1
shadcn_flutter: shadcn_flutter: ^0.0.25
git:
url: https://github.com/KRTirtho/shadcn_flutter.git
ref: d928e73cd734582046c63a3bed99cc42aeab6085
shared_preferences: ^2.2.3 shared_preferences: ^2.2.3
shelf: ^1.4.1 shelf: ^1.4.1
shelf_router: ^1.1.4 shelf_router: ^1.1.4