Workaround upstream grid scrolling bug when there are multiple sliver grids

This commit is contained in:
Ming Ming 2023-08-09 01:30:47 +08:00
parent 85a9157a9d
commit f8882de9d7

View file

@ -396,53 +396,62 @@ class _ButtonGrid extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SliverStaggeredGrid.extent( // needed to workaround a scrolling bug when there are more than one
maxCrossAxisExtent: 256, // SliverStaggeredGrids in a CustomScrollView
staggeredTiles: List.filled(5, const StaggeredTile.fit(1)), // see: https://github.com/letsar/flutter_staggered_grid_view/issues/98 and
children: [ // https://github.com/letsar/flutter_staggered_grid_view/issues/265
_ButtonGridItemView( return SliverToBoxAdapter(
icon: Icons.share_outlined, child: StaggeredGridView.extent(
label: L10n.global().collectionSharingLabel, shrinkWrap: true,
isShowIndicator: AccountPref.of(account).hasNewSharedAlbumOr(), physics: const NeverScrollableScrollPhysics(),
isEnabled: isEnabled, padding: const EdgeInsets.all(0),
onTap: () { maxCrossAxisExtent: 256,
onSharingPressed?.call(); staggeredTiles: List.filled(5, const StaggeredTile.fit(1)),
}, children: [
),
if (features.isSupportEnhancement)
_ButtonGridItemView( _ButtonGridItemView(
icon: Icons.auto_fix_high_outlined, icon: Icons.share_outlined,
label: L10n.global().collectionEditedPhotosLabel, label: L10n.global().collectionSharingLabel,
isShowIndicator: AccountPref.of(account).hasNewSharedAlbumOr(),
isEnabled: isEnabled, isEnabled: isEnabled,
onTap: () { onTap: () {
onEnhancedPhotosPressed?.call(); onSharingPressed?.call();
}, },
), ),
_ButtonGridItemView( if (features.isSupportEnhancement)
icon: Icons.archive_outlined, _ButtonGridItemView(
label: L10n.global().albumArchiveLabel, icon: Icons.auto_fix_high_outlined,
isEnabled: isEnabled, label: L10n.global().collectionEditedPhotosLabel,
onTap: () { isEnabled: isEnabled,
onArchivePressed?.call(); onTap: () {
}, onEnhancedPhotosPressed?.call();
), },
_ButtonGridItemView( ),
icon: Icons.delete_outlined, _ButtonGridItemView(
label: L10n.global().albumTrashLabel, icon: Icons.archive_outlined,
isEnabled: isEnabled, label: L10n.global().albumArchiveLabel,
onTap: () { isEnabled: isEnabled,
onTrashbinPressed?.call(); onTap: () {
}, onArchivePressed?.call();
), },
_ButtonGridItemView( ),
icon: Icons.add, _ButtonGridItemView(
label: L10n.global().createCollectionTooltip, icon: Icons.delete_outlined,
isEnabled: isEnabled, label: L10n.global().albumTrashLabel,
onTap: () { isEnabled: isEnabled,
onNewCollectionPressed?.call(); onTap: () {
}, onTrashbinPressed?.call();
), },
], ),
_ButtonGridItemView(
icon: Icons.add,
label: L10n.global().createCollectionTooltip,
isEnabled: isEnabled,
onTap: () {
onNewCollectionPressed?.call();
},
),
],
),
); );
} }