todotxt_reminder/lib/table.dart
2023-01-07 22:23:59 +01:00

73 lines
1.9 KiB
Dart

import 'package:flutter/material.dart';
import 'package:nextcloud_reminder/repeating_task.dart';
class ScrollTable extends StatefulWidget {
ScrollTable({super.key, required this.title});
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
final _ScrollTableState _internalState = _ScrollTableState();
@override
State<ScrollTable> createState() => _internalState;
void addTask(RepeatingTask task) {
_internalState.addTask(task);
}
}
class _ScrollTableState extends State<ScrollTable> {
final List<RepeatingTask> _content = [];
addTask(RepeatingTask task) {
setState(() {
_content.add(task);
});
}
List<Widget> _buildTitles() {
return List<Widget>.from(_content.map((RepeatingTask t) =>
Container(
alignment: Alignment.center,
width: 120.0,
height: 60.0,
color: Colors.white,
margin: const EdgeInsets.all(4.0),
child: Text(t.title, style: Theme
.of(context)
.textTheme
.labelMedium),
)));
}
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: _buildTitles(),
),
Flexible(
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: _content,
),
),
)
],
)
);
}
}