minor changes

This commit is contained in:
Thibault Deckers 2019-10-09 20:35:28 +09:00
parent b488adacf6
commit b0e5f3c178
2 changed files with 57 additions and 33 deletions

View file

@ -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) {

View file

@ -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<String>()),
);
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<dynamic, List<ImageEntry>> 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<String>()),
);
break;
case GroupFactor.date:
header = MonthSectionHeader(date: sectionKey);
break;
}
}
return IgnorePointer(
child: header,
);
}
}