flutter_timetable/lib/src/widgets/table.dart

74 lines
2.1 KiB
Dart
Raw Normal View History

2022-08-24 11:01:50 +02:00
part of timetable;
class Table extends StatelessWidget {
const Table({
required this.startHour,
required this.endHour,
2022-08-24 13:32:35 +02:00
this.columnHeight = 80,
this.theme = const TableTheme(),
2022-08-24 11:01:50 +02:00
Key? key,
}) : super(key: key);
final int startHour;
final int endHour;
2022-08-24 13:32:35 +02:00
final double columnHeight;
final TableTheme theme;
2022-08-24 11:01:50 +02:00
@override
Widget build(BuildContext context) {
return Column(
children: [
for (int i = startHour; i <= endHour; i++) ...[
SizedBox(
2022-08-24 13:32:35 +02:00
height: i == endHour ? columnHeight / 2 : columnHeight,
2022-08-24 11:01:50 +02:00
child: Column(
children: [
Row(
children: [
Text(
2022-08-24 12:03:32 +02:00
'${i.toString().padLeft(2, '0')}:00',
2022-08-24 13:32:35 +02:00
style: theme.timeStyle,
2022-08-24 11:01:50 +02:00
),
const SizedBox(
width: 5,
),
Expanded(
child: Container(
2022-08-24 13:32:35 +02:00
height: theme.lineHeight,
color: theme.lineColor,
2022-08-24 11:01:50 +02:00
),
)
],
),
if (i != endHour) ...[
const Spacer(),
Container(
margin: const EdgeInsets.only(
left: 40,
),
2022-08-24 13:32:35 +02:00
height: theme.lineHeight,
2022-08-24 11:01:50 +02:00
child: Row(
children: [
for (int i = 0; i < 25; i++) ...[
Container(
width:
(MediaQuery.of(context).size.width - 40) / 25,
2022-08-24 13:32:35 +02:00
height: theme.lineHeight,
color:
i.isEven ? theme.lineColor : Colors.transparent,
2022-08-24 11:01:50 +02:00
),
],
],
),
),
const Spacer(),
],
],
),
),
],
],
);
}
}