diff --git a/lib/widgets/album/sections.dart b/lib/widgets/album/sections.dart index 7c4b662b5..2af26582d 100644 --- a/lib/widgets/album/sections.dart +++ b/lib/widgets/album/sections.dart @@ -21,7 +21,7 @@ class DaySectionHeader extends StatelessWidget { @override Widget build(BuildContext context) { - return SectionHeader(title: text); + return TitleSectionHeader(title: text); } } @@ -43,15 +43,15 @@ class MonthSectionHeader extends StatelessWidget { @override Widget build(BuildContext context) { - return SectionHeader(title: text); + return TitleSectionHeader(title: text); } } -class SectionHeader extends StatelessWidget { +class TitleSectionHeader extends StatelessWidget { final Widget leading; final String title; - const SectionHeader({Key key, this.leading, this.title}) : super(key: key); + const TitleSectionHeader({Key key, this.leading, this.title}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/widgets/album/thumbnail_collection.dart b/lib/widgets/album/thumbnail_collection.dart index 896f48fb1..79af19e07 100644 --- a/lib/widgets/album/thumbnail_collection.dart +++ b/lib/widgets/album/thumbnail_collection.dart @@ -94,41 +94,19 @@ class SectionSliver extends StatelessWidget { const SectionSliver({ Key key, - this.collection, - this.sections, - this.sectionKey, + @required this.collection, + @required this.sections, + @required this.sectionKey, }) : super(key: key); @override Widget build(BuildContext context) { final columnCount = 4; - Widget header = SizedBox.shrink(); - if (collection.sortFactor == SortFactor.date) { - switch (collection.groupFactor) { - case GroupFactor.album: - Widget albumIcon = IconUtils.getAlbumIcon(context, sectionKey); - if (albumIcon != null) { - albumIcon = Material( - type: MaterialType.circle, - elevation: 3, - color: Colors.transparent, - shadowColor: Colors.black, - child: albumIcon, - ); - } - header = SectionHeader( - leading: albumIcon, - title: collection.getUniqueAlbumName(sectionKey, sections.keys.cast()), - ); - break; - case GroupFactor.date: - header = MonthSectionHeader(date: sectionKey); - break; - } - } return SliverStickyHeader( - header: IgnorePointer( - child: header, + header: SectionHeader( + collection: collection, + sections: sections, + sectionKey: sectionKey, ), sliver: SliverGrid( delegate: SliverChildBuilderDelegate( @@ -147,6 +125,8 @@ class SectionSliver extends StatelessWidget { ); }, childCount: sections[sectionKey].length, + addAutomaticKeepAlives: false, + addRepaintBoundaries: false, ), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: columnCount, @@ -167,3 +147,47 @@ class SectionSliver extends StatelessWidget { ); } } + +class SectionHeader extends StatelessWidget { + final ImageCollection collection; + final Map> sections; + final dynamic sectionKey; + + const SectionHeader({ + Key key, + @required this.collection, + @required this.sections, + @required this.sectionKey, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + Widget header = SizedBox.shrink(); + if (collection.sortFactor == SortFactor.date) { + switch (collection.groupFactor) { + case GroupFactor.album: + Widget albumIcon = IconUtils.getAlbumIcon(context, sectionKey); + if (albumIcon != null) { + albumIcon = Material( + type: MaterialType.circle, + elevation: 3, + color: Colors.transparent, + shadowColor: Colors.black, + child: albumIcon, + ); + } + header = TitleSectionHeader( + leading: albumIcon, + title: collection.getUniqueAlbumName(sectionKey, sections.keys.cast()), + ); + break; + case GroupFactor.date: + header = MonthSectionHeader(date: sectionKey); + break; + } + } + return IgnorePointer( + child: header, + ); + } +}