/*
 * @Author: XianKaiQun
 * @Date: 2020-09-14 14:44:57
 * @LastEditors: XianKaiQun
 * @LastEditTime: 2020-09-17 10:13:29
 * @Description: 
 */
part of '../index.dart';

class _ListComponent extends StatelessWidget {
  const _ListComponent({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
// final style = WTheme.of(context);
// final colorScheme = style.colorScheme;
    final store = Provider.of<PrivateIndexStore>(context);
    return WisSliverList.childBuilder(
        childCount: store.list.length,
        builder: (_, i) {
          final item = store.list[i];
          return DynamicCardComponent(
            type: item.type,
            imgUrl: item.imgUrl,
            dtype: item.classId != null
                ? store.classList
                    .firstWhere((element) => element.id == item.classId)
                    .name
                : '--',
            publisher: item.publishByName ?? '--',
            creator: item.createdByName,
            content: item.title,
            dateTime: item.updateAt,
            likeNum: '${item.likes ?? 0}',
            photos: (item.url ?? '') == '' ? [] : item.url!.split(','),
            // 服务动态 权限去除 所有人可操作 2023.09.13
            onDelete: () => store.onDelete(item.id),
            toDetail: () => store.toDetail(item),
            onUndo: () => store.onUndo(item),
          );
        });
  }
}
