1
0
mirror of https://github.com/git-touch/git-touch synced 2024-12-16 18:28:51 +01:00
git-touch-android-ios-app/lib/widgets/table_view.dart
2019-02-08 23:20:28 +08:00

79 lines
2.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'link.dart';
class TableViewItem {
final String text;
final bool checked;
final void Function() onTap;
final WidgetBuilder screenBuilder;
TableViewItem({
this.text,
this.checked = false,
this.onTap,
this.screenBuilder,
});
}
class TableView extends StatelessWidget {
final String title;
final List<TableViewItem> items;
TableView({this.title, this.items});
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.only(top: 30),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
padding: EdgeInsets.only(left: 8),
child: Text(
title,
style: TextStyle(
color: Colors.black54,
fontSize: 15,
fontWeight: FontWeight.w500,
),
),
),
Container(
decoration: BoxDecoration(
border: Border(bottom: BorderSide(color: Colors.black12)),
),
padding: EdgeInsets.only(top: 4),
),
]..addAll(items.map((item) {
List<Widget> children = [
Expanded(
child: Text(
item.text,
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w300),
),
),
];
if (item.checked) {
children
.add(Icon(Icons.check, color: CupertinoColors.activeBlue));
}
return Link(
beforeRedirect: item.onTap,
screenBuilder: item.screenBuilder,
child: Container(
decoration: BoxDecoration(
border: Border(bottom: BorderSide(color: Colors.black12)),
),
padding: EdgeInsets.all(12),
child: Row(children: children),
),
);
}).toList()),
),
);
}
}