/*
 * @Author: XianKaiQun
 * @Date: 2020-07-31 10:26:10
 * @LastEditors: XianKaiQun
 * @LastEditTime: 2020-09-30 16:56:38
 * @Description: 
 */
part of '../index.dart';

class _ListComponent extends StatelessWidget {
  const _ListComponent({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    final store = Provider.of<PrivateCleanListStore>(context);
    final style = WTheme.of(context);
    final colorScheme = style.colorScheme;
//final theme = Theme.of(context);
//final textTheme = theme.textTheme;

    final list = store.list;
    return WisSliverList.childBuilder(
      padding: EdgeInsets.all(15.pt),
      childCount: list.length,
      builder: (_, i) {
        final item = list[i];
        return WisCard(
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.vertical(
              top: Radius.circular(i == 0 ? 5.pt : 0),
              bottom: Radius.circular(i == list.length - 1 ? 5.pt : 0),
            ),
          ),
          child: WisCell(
            onTap: () => store.route2detail(item),
            padding: EdgeInsets.all(10.pt),
            bottomDivider: WisCellDivider.fill,
            title: Row(
              children: <Widget>[
                WTag(
                  plain: false,
                  color: item.state == 'normal'
                      ? colorScheme.primary
                      : colorScheme.danger,
                  child: Text(item.state == 'normal' ? '正常' : '异常'),
                ),
                Text('${item.createdName}'),
              ],
            ),
            subtitle: Text('${item.createdAt}'),
            trailing: Row(
              children: <Widget>[
                Text('详情'),
                Icon(Icons.chevron_right),
              ],
            ),
          ),
        );
      },
    );
  }
}
