nc-photos/app/lib/widget/album_grid_item.dart

81 lines
2.1 KiB
Dart
Raw Normal View History

2021-04-10 06:28:12 +02:00
import 'package:flutter/material.dart';
class AlbumGridItem extends StatelessWidget {
2021-09-15 08:58:06 +02:00
const AlbumGridItem({
2021-07-23 22:05:57 +02:00
Key? key,
required this.cover,
required this.title,
2021-04-10 06:28:12 +02:00
this.subtitle,
this.subtitle2,
2021-06-29 07:12:48 +02:00
this.icon,
2021-04-10 06:28:12 +02:00
}) : super(key: key);
@override
build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Stack(
children: [
cover,
if (icon != null)
Padding(
padding: const EdgeInsets.all(8),
child: Align(
alignment: AlignmentDirectional.topEnd,
child: Icon(
icon,
size: 16,
color: Colors.white,
2021-07-05 18:21:58 +02:00
),
),
2021-07-05 18:21:58 +02:00
),
],
2021-04-10 06:28:12 +02:00
),
),
const SizedBox(height: 8),
Text(
title,
2022-11-12 10:55:33 +01:00
style: Theme.of(context).textTheme.bodyMedium,
textAlign: TextAlign.start,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
2022-11-12 10:55:33 +01:00
const SizedBox(height: 2),
Row(
children: [
Expanded(
child: Text(
subtitle ?? "",
2022-11-12 10:55:33 +01:00
style: Theme.of(context).textTheme.bodySmall,
textAlign: TextAlign.start,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
if (subtitle2?.isNotEmpty == true)
Text(
subtitle2!,
2022-11-12 10:55:33 +01:00
style: Theme.of(context).textTheme.bodySmall,
textAlign: TextAlign.end,
maxLines: 1,
),
],
)
],
2021-07-05 18:21:58 +02:00
),
2021-04-10 06:28:12 +02:00
);
}
final Widget cover;
final String title;
2021-07-23 22:05:57 +02:00
final String? subtitle;
/// Appears after [subtitle], aligned to the end side of parent
2021-07-23 22:05:57 +02:00
final String? subtitle2;
final IconData? icon;
2021-04-10 06:28:12 +02:00
}