Layout changes, fix bugs in new entry page
This commit is contained in:
@@ -9,10 +9,12 @@ class LegCard extends StatelessWidget {
|
||||
super.key,
|
||||
required this.leg,
|
||||
this.showEditButton = true,
|
||||
this.showDate = true,
|
||||
});
|
||||
|
||||
final Leg leg;
|
||||
final bool showEditButton;
|
||||
final bool showDate;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -26,7 +28,7 @@ class LegCard extends StatelessWidget {
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(_formatDateTime(leg.beginTime)),
|
||||
if (showDate) Text(_formatDateTime(leg.beginTime)),
|
||||
if (leg.headcode.isNotEmpty)
|
||||
Text(
|
||||
'Headcode: ${leg.headcode}',
|
||||
@@ -126,13 +128,32 @@ class LegCard extends StatelessWidget {
|
||||
|
||||
List<Widget> _buildLocoChips(BuildContext context, Leg leg) {
|
||||
final theme = Theme.of(context);
|
||||
final textTheme = theme.textTheme;
|
||||
return leg.locos
|
||||
.map(
|
||||
(loco) => Chip(
|
||||
label: Text('${loco.locoClass} ${loco.number}'),
|
||||
avatar: const Icon(Icons.directions_railway, size: 16),
|
||||
backgroundColor: theme.colorScheme.surfaceContainerHighest,
|
||||
),
|
||||
(loco) {
|
||||
final powering = loco.powering == true;
|
||||
final iconColor =
|
||||
powering ? theme.colorScheme.primary : theme.disabledColor;
|
||||
final labelStyle = powering
|
||||
? null
|
||||
: textTheme.bodyMedium?.copyWith(color: theme.disabledColor);
|
||||
final background = powering
|
||||
? theme.colorScheme.surfaceContainerHighest
|
||||
: theme.colorScheme.surfaceVariant;
|
||||
return Chip(
|
||||
label: Text(
|
||||
'${loco.locoClass} ${loco.number}',
|
||||
style: labelStyle,
|
||||
),
|
||||
avatar: Icon(
|
||||
Icons.directions_railway,
|
||||
size: 16,
|
||||
color: iconColor,
|
||||
),
|
||||
backgroundColor: background,
|
||||
);
|
||||
},
|
||||
)
|
||||
.toList();
|
||||
}
|
||||
@@ -192,4 +213,3 @@ class LegCard extends StatelessWidget {
|
||||
return [trimmed];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user