95 lines
2.9 KiB
Dart
95 lines
2.9 KiB
Dart
import 'package:aves/model/collection_lens.dart';
|
|
import 'package:aves/model/image_entry.dart';
|
|
import 'package:aves/utils/constants.dart';
|
|
import 'package:aves/widgets/album/grid/header_album.dart';
|
|
import 'package:aves/widgets/album/grid/header_date.dart';
|
|
import 'package:aves/widgets/common/fx/outlined_text.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class SectionHeader extends StatelessWidget {
|
|
final CollectionLens 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;
|
|
switch (collection.sortFactor) {
|
|
case SortFactor.date:
|
|
if (collection.sortFactor == SortFactor.date) {
|
|
switch (collection.groupFactor) {
|
|
case GroupFactor.album:
|
|
header = _buildAlbumSectionHeader();
|
|
break;
|
|
case GroupFactor.month:
|
|
header = MonthSectionHeader(key: ValueKey(sectionKey), date: sectionKey as DateTime);
|
|
break;
|
|
case GroupFactor.day:
|
|
header = DaySectionHeader(key: ValueKey(sectionKey), date: sectionKey as DateTime);
|
|
break;
|
|
}
|
|
}
|
|
break;
|
|
case SortFactor.size:
|
|
break;
|
|
case SortFactor.name:
|
|
header = _buildAlbumSectionHeader();
|
|
break;
|
|
}
|
|
return header != null
|
|
? IgnorePointer(
|
|
child: header,
|
|
)
|
|
: const SizedBox.shrink();
|
|
}
|
|
|
|
Widget _buildAlbumSectionHeader() {
|
|
final folderPath = sectionKey as String;
|
|
return AlbumSectionHeader(
|
|
key: ValueKey(folderPath),
|
|
folderPath: folderPath,
|
|
albumName: collection.source.getUniqueAlbumName(folderPath),
|
|
);
|
|
}
|
|
}
|
|
|
|
class TitleSectionHeader extends StatelessWidget {
|
|
final Widget leading;
|
|
final String title;
|
|
|
|
const TitleSectionHeader({Key key, this.leading, this.title}) : super(key: key);
|
|
|
|
static const leadingDimension = 32.0;
|
|
static const leadingPadding = EdgeInsets.only(right: 8, bottom: 4);
|
|
static const padding = EdgeInsets.all(16);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
alignment: AlignmentDirectional.centerStart,
|
|
padding: padding,
|
|
constraints: const BoxConstraints(minHeight: leadingDimension),
|
|
child: OutlinedText(
|
|
leadingBuilder: leading != null
|
|
? (context, isShadow) => Container(
|
|
padding: leadingPadding,
|
|
width: leadingDimension,
|
|
height: leadingDimension,
|
|
child: isShadow ? null : leading,
|
|
)
|
|
: null,
|
|
text: title,
|
|
style: Constants.titleTextStyle,
|
|
outlineWidth: 2,
|
|
),
|
|
);
|
|
}
|
|
}
|