ca2_flutter/lib/widgets/task_row.dart

112 lines
3.0 KiB
Dart

import 'package:flutter/material.dart';
import 'avatar_badge.dart';
import '../models/task.dart';
import 'status_badge.dart';
/// Eine Zeile der Aufgabenliste:
/// Nummer, Titel, Status-Badge, Beschreibung und Avatar.
class TaskRow extends StatelessWidget {
final Task task;
final int number;
const TaskRow({super.key, required this.task, required this.number});
@override
Widget build(BuildContext context) {
return Container(
height: 51,
// Zeilen abwechselnd dunkler/heller (wie im Figma-Design)
color: number.isOdd ? const Color(0xFF0F1117) : const Color(0xFF131720),
padding: const EdgeInsets.fromLTRB(22, 0, 20, 1),
child: Row(
spacing: 12,
children: [
SizedBox(
width: 28,
child: Text(
number.toString().padLeft(2, '0'),
style: TextStyle(
fontSize: 11,
height: 17 / 11,
color: Color(0xFF64748B),
),
),
),
SizedBox(
width: 240,
child: Text(
task.title,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
height: 1.5,
color: Color(0xFFE2E8F0),
),
),
),
SizedBox(
width: 200,
child: Align(
alignment: Alignment.centerLeft,
child: _badge(task.status),
),
),
Expanded(
child: Text(
task.description,
style: TextStyle(
fontWeight: FontWeight.w400,
fontSize: 11,
height: 17 / 11,
color: Color(0xFF64748B),
),
),
),
SizedBox(
width: 36,
child: Align(
alignment: Alignment.centerRight,
child: AvatarBadge(
initials: task.initials,
color: task.avatarColor,
size: 26,
),
),
),
SizedBox(width: 32, height: 26), // column 6, empty
],
),
);
}
/// Wählt passend zum Status das Symbol, den Text und die Farben des Badges.
Widget _badge(TaskStatus status) {
if (status == TaskStatus.erledigt) {
return StatusBadge(
icon: '✓',
label: 'ERLEDIGT',
fillColor: Color(0xFF052E16),
borderColor: Color(0xFF10B981),
iconPadding: EdgeInsets.only(top: 2),
);
}
if (status == TaskStatus.inBearbeitung) {
return StatusBadge(
icon: '◈',
label: 'IN BEARBEITUNG',
fillColor: Color(0xFF1C1100),
borderColor: Color(0xFFF59E0B),
iconPadding: EdgeInsets.only(top: 2),
);
}
return StatusBadge(
icon: '○',
label: 'NICHT BEGONNEN',
fillColor: Color(0xFF0F1117),
borderColor: Color(0xFF64748B),
iconPadding: EdgeInsets.only(bottom: 2),
);
}
}