cpd_2022_zi/lib/widgets/entry_detail_widget.dart

59 lines
1.9 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 15:46:40 +01:00
return entryComment != null
? ExpansionTile(
iconColor: Colors.white,
collapsedIconColor: Colors.white,
collapsedShape: shape,
shape: shape,
leading: icon,
title: title,
collapsedBackgroundColor: color,
backgroundColor:
Theme.of(context).colorScheme.secondary.withOpacity(0.8),
children: entryComment != null
? [
Row(mainAxisAlignment: MainAxisAlignment.start, children: [
Padding(
padding: const EdgeInsets.fromLTRB(10, 0, 10, 10),
child: 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
}
}