1
0
mirror of https://github.com/git-touch/git-touch synced 2024-12-20 20:13:55 +01:00
git-touch-android-ios-app/lib/widgets/list_group.dart

55 lines
1.4 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
2019-02-10 05:16:52 +01:00
import '../widgets/empty.dart';
2019-03-10 14:26:05 +01:00
var borderColor = Color.fromRGBO(27, 31, 35, .15);
class ListGroup<T> extends StatelessWidget {
final Widget title;
final List<T> items;
2019-02-06 06:06:11 +01:00
final Widget Function(T item, int index) itemBuilder;
2019-03-10 14:26:05 +01:00
final EdgeInsetsGeometry padding;
2019-03-10 14:26:05 +01:00
ListGroup({
@required this.title,
@required this.items,
@required this.itemBuilder,
this.padding = const EdgeInsets.only(left: 10, right: 10, bottom: 10),
});
2019-02-06 06:06:11 +01:00
Widget _buildItem(MapEntry<int, T> entry) {
return Container(
decoration: BoxDecoration(
2019-03-10 14:26:05 +01:00
border: Border(top: BorderSide(color: borderColor)),
),
2019-02-06 06:06:11 +01:00
child: itemBuilder(entry.value, entry.key),
);
}
@override
Widget build(BuildContext context) {
2019-03-10 14:26:05 +01:00
return Container(
padding: padding,
child: Container(
2019-03-10 14:26:05 +01:00
decoration: BoxDecoration(
border: Border.all(color: borderColor),
borderRadius: BorderRadius.all(Radius.circular(3)),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Container(
2019-03-10 14:26:05 +01:00
color: Color(0xfff6f8fa),
2019-02-04 14:38:29 +01:00
padding: EdgeInsets.all(8),
child: title,
),
2019-02-10 05:16:52 +01:00
items.isEmpty
? EmptyWidget()
: Column(
children: items.asMap().entries.map(_buildItem).toList())
],
),
),
);
}
}