minor changes
This commit is contained in:
parent
b488adacf6
commit
b0e5f3c178
2 changed files with 57 additions and 33 deletions
|
@ -21,7 +21,7 @@ class DaySectionHeader extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SectionHeader(title: text);
|
return TitleSectionHeader(title: text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,15 +43,15 @@ class MonthSectionHeader extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SectionHeader(title: text);
|
return TitleSectionHeader(title: text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SectionHeader extends StatelessWidget {
|
class TitleSectionHeader extends StatelessWidget {
|
||||||
final Widget leading;
|
final Widget leading;
|
||||||
final String title;
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
|
@ -94,41 +94,19 @@ class SectionSliver extends StatelessWidget {
|
||||||
|
|
||||||
const SectionSliver({
|
const SectionSliver({
|
||||||
Key key,
|
Key key,
|
||||||
this.collection,
|
@required this.collection,
|
||||||
this.sections,
|
@required this.sections,
|
||||||
this.sectionKey,
|
@required this.sectionKey,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final columnCount = 4;
|
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(
|
return SliverStickyHeader(
|
||||||
header: IgnorePointer(
|
header: SectionHeader(
|
||||||
child: header,
|
collection: collection,
|
||||||
|
sections: sections,
|
||||||
|
sectionKey: sectionKey,
|
||||||
),
|
),
|
||||||
sliver: SliverGrid(
|
sliver: SliverGrid(
|
||||||
delegate: SliverChildBuilderDelegate(
|
delegate: SliverChildBuilderDelegate(
|
||||||
|
@ -147,6 +125,8 @@ class SectionSliver extends StatelessWidget {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
childCount: sections[sectionKey].length,
|
childCount: sections[sectionKey].length,
|
||||||
|
addAutomaticKeepAlives: false,
|
||||||
|
addRepaintBoundaries: false,
|
||||||
),
|
),
|
||||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
crossAxisCount: columnCount,
|
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,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue