cpd_2022_zi/lib/widgets/entry_detail_widget.dart

55 lines
1.8 KiB
Dart
Raw Normal View History

2023-03-06 00:05:11 +01:00
import 'package:flutter/material.dart';
2023-03-06 14:55:56 +01:00
import 'package:smoke_cess_app/widgets/entry_detail_title.dart';
2023-03-06 00:05:11 +01:00
class EntryDetail extends StatelessWidget {
final DateTime date;
final String entryData;
2023-03-06 14:55:56 +01:00
final String? entryComment;
final IconData iconData;
2023-03-06 00:05:11 +01:00
const EntryDetail(
{super.key,
required this.date,
required this.entryData,
2023-03-06 14:55:56 +01:00
required this.iconData,
required this.entryComment});
2023-03-06 00:05:11 +01:00
@override
Widget build(BuildContext context) {
2023-03-06 14:55:56 +01:00
final Icon icon = Icon(iconData, color: Colors.white);
final ShapeBorder shape = RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
);
final Color color = Theme.of(context).colorScheme.primary.withOpacity(0.8);
final Widget title = EntryDetailTitle(date: date, entryData: entryData);
2023-03-06 00:05:11 +01:00
return Card(
2023-03-06 14:55:56 +01:00
child: entryComment != null
? ExpansionTile(
2023-03-06 14:58:15 +01:00
iconColor: Colors.white,
collapsedIconColor: Colors.white,
2023-03-06 14:55:56 +01:00
collapsedShape: shape,
shape: shape,
leading: icon,
title: title,
collapsedBackgroundColor: color,
backgroundColor:
Theme.of(context).colorScheme.secondary.withOpacity(0.8),
children: entryComment != null
? [
Text(
entryComment ?? '',
style: const TextStyle(
color: Colors.white, fontWeight: FontWeight.bold),
)
]
: [],
)
: ListTile(
shape: shape,
leading: icon,
title: title,
tileColor: color,
));
2023-03-06 00:05:11 +01:00
}
}