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

83 lines
2.2 KiB
Dart
Raw Normal View History

2022-08-28 22:10:28 +08:00
import 'package:flutter/material.dart';
import 'package:nc_photos/theme.dart';
class CollectionListSmall extends StatelessWidget {
const CollectionListSmall({
2023-07-23 02:57:01 +08:00
super.key,
2022-08-28 22:10:28 +08:00
required this.label,
2023-07-23 02:57:01 +08:00
required this.child,
2022-08-28 22:10:28 +08:00
this.onTap,
2023-07-23 02:57:01 +08:00
});
2022-08-28 22:10:28 +08:00
@override
2023-07-23 02:57:01 +08:00
Widget build(BuildContext context) {
2022-08-28 22:10:28 +08:00
Widget content = Stack(
children: [
2023-07-23 02:57:01 +08:00
SizedBox.expand(child: child),
2022-08-28 22:10:28 +08: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 17:55:33 +08:00
Colors.black.withOpacity(.5),
2022-08-28 22:10:28 +08:00
],
),
),
),
Container(
2022-11-12 17:55:33 +08:00
color: Colors.black.withOpacity(.5),
2022-08-28 22:10:28 +08:00
constraints: const BoxConstraints(minWidth: double.infinity),
padding: const EdgeInsets.fromLTRB(8, 0, 8, 4),
child: Text(
label,
2022-11-12 17:55:33 +08:00
style: Theme.of(context).textTheme.labelLarge!.copyWith(
color: Theme.of(context).onDarkSurface,
),
2022-08-28 22:10:28 +08: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 17:55:33 +08:00
color: Theme.of(context).listPlaceholderBackgroundColor,
2022-08-28 22:10:28 +08:00
constraints: const BoxConstraints.expand(),
child: content,
);
}
final String label;
2023-07-23 02:57:01 +08:00
final Widget? child;
2022-08-28 22:10:28 +08:00
final VoidCallback? onTap;
}