2021-04-10 06:28:12 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/widgets.dart';
|
|
|
|
import 'package:nc_photos/theme.dart';
|
2021-07-05 18:21:58 +02:00
|
|
|
import 'package:nc_photos/widget/selectable.dart';
|
2021-04-10 06:28:12 +02:00
|
|
|
|
|
|
|
class AlbumGridItem extends StatelessWidget {
|
|
|
|
AlbumGridItem({
|
|
|
|
Key key,
|
|
|
|
@required this.cover,
|
|
|
|
@required this.title,
|
|
|
|
this.subtitle,
|
2021-06-29 18:20:17 +02:00
|
|
|
this.subtitle2,
|
2021-06-29 07:12:48 +02:00
|
|
|
this.icon,
|
2021-04-10 06:28:12 +02:00
|
|
|
this.isSelected = false,
|
|
|
|
this.onTap,
|
|
|
|
this.onLongPress,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
build(BuildContext context) {
|
2021-07-05 18:21:58 +02:00
|
|
|
return Selectable(
|
|
|
|
isSelected: isSelected,
|
|
|
|
iconSize: 48,
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
onTap: onTap,
|
|
|
|
onLongPress: onLongPress,
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(8),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Stack(
|
2021-06-29 18:20:17 +02:00
|
|
|
children: [
|
2021-07-05 18:21:58 +02:00
|
|
|
cover,
|
|
|
|
if (icon != null)
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(8),
|
|
|
|
child: Align(
|
|
|
|
alignment: AlignmentDirectional.topEnd,
|
|
|
|
child: Icon(
|
|
|
|
icon,
|
|
|
|
size: 16,
|
|
|
|
color: Colors.white,
|
|
|
|
),
|
|
|
|
),
|
2021-06-29 18:20:17 +02:00
|
|
|
),
|
|
|
|
],
|
2021-04-10 06:28:12 +02:00
|
|
|
),
|
|
|
|
),
|
2021-07-05 18:21:58 +02:00
|
|
|
const SizedBox(height: 8),
|
|
|
|
Text(
|
|
|
|
title ?? "",
|
|
|
|
style: Theme.of(context).textTheme.bodyText1.copyWith(
|
|
|
|
color: AppTheme.getPrimaryTextColor(context),
|
|
|
|
),
|
|
|
|
textAlign: TextAlign.start,
|
|
|
|
maxLines: 1,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
2021-04-10 06:28:12 +02:00
|
|
|
),
|
2021-07-05 18:21:58 +02:00
|
|
|
const SizedBox(height: 4),
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Text(
|
|
|
|
subtitle ?? "",
|
|
|
|
style: Theme.of(context).textTheme.bodyText2.copyWith(
|
|
|
|
fontSize: 10,
|
|
|
|
color: AppTheme.getSecondaryTextColor(context),
|
|
|
|
),
|
|
|
|
textAlign: TextAlign.start,
|
|
|
|
maxLines: 1,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (subtitle2?.isNotEmpty == true)
|
|
|
|
Text(
|
|
|
|
subtitle2,
|
|
|
|
style: Theme.of(context).textTheme.bodyText2.copyWith(
|
|
|
|
fontSize: 10,
|
|
|
|
color: AppTheme.getSecondaryTextColor(context),
|
|
|
|
),
|
|
|
|
textAlign: TextAlign.end,
|
|
|
|
maxLines: 1,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2021-04-10 06:28:12 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
final Widget cover;
|
|
|
|
final String title;
|
|
|
|
final String subtitle;
|
2021-06-29 18:20:17 +02:00
|
|
|
|
|
|
|
/// Appears after [subtitle], aligned to the end side of parent
|
|
|
|
final String subtitle2;
|
2021-06-29 07:12:48 +02:00
|
|
|
final IconData icon;
|
2021-04-10 06:28:12 +02:00
|
|
|
final bool isSelected;
|
|
|
|
final VoidCallback onTap;
|
|
|
|
final VoidCallback onLongPress;
|
|
|
|
}
|