Skip to content

Commit

Permalink
fix: UI glitch when loading more user artists and albums
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Oct 17, 2024
1 parent 6e1cd96 commit 3c45732
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 105 deletions.
64 changes: 32 additions & 32 deletions lib/modules/library/user_albums.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,41 +73,41 @@ class UserAlbums extends HookConsumerWidget {
),
),
const SliverGap(10),
Skeletonizer.sliver(
enabled: albumsQuery.isLoading,
child: SliverLayoutBuilder(builder: (context, constrains) {
return SliverGrid.builder(
itemCount: albums.isEmpty ? 6 : albums.length + 1,
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: 200,
mainAxisExtent: constrains.smAndDown ? 225 : 250,
crossAxisSpacing: 8,
mainAxisSpacing: 8,
),
itemBuilder: (context, index) {
if (albums.isNotEmpty && index == albums.length) {
if (albumsQuery.asData?.value.hasMore != true) {
return const SizedBox.shrink();
}

return Waypoint(
controller: controller,
isGrid: true,
onTouchEdge: albumsQueryNotifier.fetchMore,
child: Skeletonizer(
enabled: true,
child: AlbumCard(FakeData.albumSimple),
),
);
SliverLayoutBuilder(builder: (context, constrains) {
return SliverGrid.builder(
itemCount: albums.isEmpty ? 6 : albums.length + 1,
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: 200,
mainAxisExtent: constrains.smAndDown ? 225 : 250,
crossAxisSpacing: 8,
mainAxisSpacing: 8,
),
itemBuilder: (context, index) {
if (albums.isNotEmpty && index == albums.length) {
if (albumsQuery.asData?.value.hasMore != true) {
return const SizedBox.shrink();
}

return AlbumCard(
albums.elementAtOrNull(index) ?? FakeData.albumSimple,
return Waypoint(
controller: controller,
isGrid: true,
onTouchEdge: albumsQueryNotifier.fetchMore,
child: Skeletonizer(
enabled: true,
child: AlbumCard(FakeData.albumSimple),
),
);
},
);
}),
),
}

return Skeletonizer(
enabled: albumsQuery.isLoading,
child: AlbumCard(
albums.elementAtOrNull(index) ?? FakeData.albumSimple,
),
);
},
);
}),
],
),
),
Expand Down
70 changes: 35 additions & 35 deletions lib/modules/library/user_artists.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,45 +74,45 @@ class UserArtists extends HookConsumerWidget {
),
),
const SliverGap(10),
Skeletonizer.sliver(
enabled: artistQuery.isLoading,
child: SliverLayoutBuilder(builder: (context, constrains) {
return SliverGrid.builder(
itemCount: filteredArtists.isEmpty
? 6
: filteredArtists.length + 1,
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: 200,
mainAxisExtent: constrains.smAndDown ? 225 : 250,
crossAxisSpacing: 8,
mainAxisSpacing: 8,
),
itemBuilder: (context, index) {
if (filteredArtists.isNotEmpty &&
index == filteredArtists.length) {
if (artistQuery.asData?.value.hasMore != true) {
return const SizedBox.shrink();
}

return Waypoint(
controller: controller,
isGrid: true,
onTouchEdge: artistQueryNotifier.fetchMore,
child: Skeletonizer(
enabled: true,
child: ArtistCard(FakeData.artist),
),
);
SliverLayoutBuilder(builder: (context, constrains) {
return SliverGrid.builder(
itemCount: filteredArtists.isEmpty
? 6
: filteredArtists.length + 1,
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: 200,
mainAxisExtent: constrains.smAndDown ? 225 : 250,
crossAxisSpacing: 8,
mainAxisSpacing: 8,
),
itemBuilder: (context, index) {
if (filteredArtists.isNotEmpty &&
index == filteredArtists.length) {
if (artistQuery.asData?.value.hasMore != true) {
return const SizedBox.shrink();
}

return ArtistCard(
return Waypoint(
controller: controller,
isGrid: true,
onTouchEdge: artistQueryNotifier.fetchMore,
child: Skeletonizer(
enabled: true,
child: ArtistCard(FakeData.artist),
),
);
}

return Skeletonizer(
enabled: artistQuery.isLoading,
child: ArtistCard(
filteredArtists.elementAtOrNull(index) ??
FakeData.artist,
);
},
);
}),
),
),
);
},
);
}),
],
),
),
Expand Down
57 changes: 35 additions & 22 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -731,12 +731,11 @@ packages:
flutter_discord_rpc:
dependency: "direct main"
description:
path: "packages/flutter_discord_rpc"
ref: cargokit
resolved-ref: "331636d8e378e3ac9ad30a4b0d3eed17d5a85fe9"
url: "https://github.com/KRTirtho/frb_plugins.git"
source: git
version: "0.1.0+1"
name: flutter_discord_rpc
sha256: "9363a803863d56fd89c0a21639c70b126245fcbafaeb0a3d091e7ac06951d03f"
url: "https://pub.dev"
source: hosted
version: "1.0.0"
flutter_displaymode:
dependency: "direct main"
description:
Expand Down Expand Up @@ -895,10 +894,10 @@ packages:
dependency: transitive
description:
name: flutter_rust_bridge
sha256: fac14d2dd67eeba29a20e5d99fac0d4d9fcd552cdf6bf4f8945f7679c6b07b1d
sha256: "0ad5079de35d317650fec59b26cb4d0c116ebc2ce703a29f9367513b8a91c287"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
version: "2.5.0"
flutter_secure_storage:
dependency: "direct main"
description:
Expand Down Expand Up @@ -1319,6 +1318,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.0.0"
lists:
dependency: transitive
description:
name: lists
sha256: "4ca5c19ae4350de036a7e996cdd1ee39c93ac0a2b840f4915459b7d0a7d4ab27"
url: "https://pub.dev"
source: hosted
version: "1.0.1"
local_notifier:
dependency: "direct main"
description:
Expand Down Expand Up @@ -1450,12 +1457,11 @@ packages:
metadata_god:
dependency: "direct main"
description:
path: "packages/metadata_god"
ref: cargokit
resolved-ref: "331636d8e378e3ac9ad30a4b0d3eed17d5a85fe9"
url: "https://github.com/KRTirtho/frb_plugins.git"
source: git
version: "0.5.3"
name: metadata_god
sha256: "025d8149059f62f44108ab9d74ebd77aa8f0af98b238f3f25121a4711ee3e5d0"
url: "https://pub.dev"
source: hosted
version: "1.0.0"
mime:
dependency: "direct main"
description:
Expand Down Expand Up @@ -1945,12 +1951,11 @@ packages:
smtc_windows:
dependency: "direct main"
description:
path: "packages/smtc_windows"
ref: cargokit
resolved-ref: "331636d8e378e3ac9ad30a4b0d3eed17d5a85fe9"
url: "https://github.com/KRTirtho/frb_plugins.git"
source: git
version: "0.1.3"
name: smtc_windows
sha256: "80f7c10867da485ffdf87f842bf27e6763589933c18c11af5dc1cd1e158c3154"
url: "https://pub.dev"
source: hosted
version: "1.0.0"
source_gen:
dependency: transitive
description:
Expand Down Expand Up @@ -2183,6 +2188,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.2"
unicode:
dependency: transitive
description:
name: unicode
sha256: "0f69e46593d65245774d4f17125c6084d2c20b4e473a983f6e21b7d7762218f1"
url: "https://pub.dev"
source: hosted
version: "0.3.1"
universal_io:
dependency: transitive
description:
Expand Down Expand Up @@ -2427,10 +2440,10 @@ packages:
dependency: "direct main"
description:
name: youtube_explode_dart
sha256: "28dca07fefb4b6518beab95f0c1ef81031f921ed0fe87ebcd9c51378546edfee"
sha256: "523a01ef948607d3e8fdcdcdcef1ce805c7d26480f609e3b209d1c73520a6c3c"
url: "https://pub.dev"
source: hosted
version: "2.2.3"
version: "2.3.1"
sdks:
dart: ">=3.5.0 <4.0.0"
flutter: ">=3.24.0"
20 changes: 4 additions & 16 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ dependencies:
logger: ^2.0.2
media_kit: ^1.1.10+1
media_kit_libs_audio: ^1.0.4
metadata_god:
git:
url: https://github.com/KRTirtho/frb_plugins.git
path: packages/metadata_god
ref: cargokit
metadata_god: ^1.0.0
mime: ^1.0.2
package_info_plus: ^6.0.0
palette_generator: ^0.3.3
Expand All @@ -82,11 +78,7 @@ dependencies:
scroll_to_index: ^3.0.1
sidebarx: ^0.17.1
shared_preferences: ^2.2.3
smtc_windows:
git:
url: https://github.com/KRTirtho/frb_plugins.git
path: packages/smtc_windows
ref: cargokit
smtc_windows: ^1.0.0
stroke_text: ^0.0.2
system_theme: ^2.1.0
titlebar_buttons: ^1.0.0
Expand All @@ -95,7 +87,7 @@ dependencies:
version: ^3.0.2
visibility_detector: ^0.4.0+2
window_manager: ^0.3.9
youtube_explode_dart: ^2.2.3
youtube_explode_dart: ^2.3.1
simple_icons: ^10.1.3
jiosaavn: ^0.1.0
draggable_scrollbar:
Expand All @@ -105,11 +97,7 @@ dependencies:
very_good_infinite_list: ^0.7.1
gap: ^3.0.1
sliver_tools: ^0.2.12
flutter_discord_rpc:
git:
url: https://github.com/KRTirtho/frb_plugins.git
path: packages/flutter_discord_rpc
ref: cargokit
flutter_discord_rpc: ^1.0.0
html_unescape: ^2.0.0
wikipedia_api: ^0.1.0
skeletonizer: ^1.1.1
Expand Down

0 comments on commit 3c45732

Please sign in to comment.