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

83 lines
2.2 KiB
Dart
Raw Normal View History

2022-08-28 16:10:28 +02:00
import 'package:flutter/material.dart';
import 'package:nc_photos/theme.dart';
class CollectionListSmall extends StatelessWidget {
const CollectionListSmall({
2023-07-22 20:57:01 +02:00
super.key,
2022-08-28 16:10:28 +02:00
required this.label,
2023-07-22 20:57:01 +02:00
required this.child,
2022-08-28 16:10:28 +02:00
this.onTap,
2023-07-22 20:57:01 +02:00
});
2022-08-28 16:10:28 +02:00
@override
2023-07-22 20:57:01 +02:00
Widget build(BuildContext context) {
2022-08-28 16:10:28 +02:00
Widget content = Stack(
children: [
2023-07-22 20:57:01 +02:00
SizedBox.expand(child: child),
2022-08-28 16:10:28 +02:00
Positioned(
bottom: 0,
left: 0,
right: 0,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
height: 24,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.black.withOpacity(0),
2022-11-12 10:55:33 +01:00
Colors.black.withOpacity(.5),
2022-08-28 16:10:28 +02:00
],
),
),
),
Container(
2022-11-12 10:55:33 +01:00
color: Colors.black.withOpacity(.5),
2022-08-28 16:10:28 +02:00
constraints: const BoxConstraints(minWidth: double.infinity),
padding: const EdgeInsets.fromLTRB(8, 0, 8, 4),
child: Text(
label,
2022-11-12 10:55:33 +01:00
style: Theme.of(context).textTheme.labelLarge!.copyWith(
color: Theme.of(context).onDarkSurface,
),
2022-08-28 16:10:28 +02:00
textAlign: TextAlign.center,
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
],
),
),
],
);
if (onTap != null) {
content = Stack(
fit: StackFit.expand,
children: [
content,
Positioned.fill(
child: Material(
type: MaterialType.transparency,
child: InkWell(
onTap: onTap,
),
),
),
],
);
}
return Container(
2022-11-12 10:55:33 +01:00
color: Theme.of(context).listPlaceholderBackgroundColor,
2022-08-28 16:10:28 +02:00
constraints: const BoxConstraints.expand(),
child: content,
);
}
final String label;
2023-07-22 20:57:01 +02:00
final Widget? child;
2022-08-28 16:10:28 +02:00
final VoidCallback? onTap;
}