/*
 * @Author: XianKaiQun
 * @Date: 2020-08-19 16:43:51
 * @LastEditors  : WuWei
 * @LastEditTime : 2022-01-19 11:26:29
 * @Description: 
 */
part of '../index.dart';

///防作弊照片
class _AntiCheatingComponent extends StatelessWidget {
  const _AntiCheatingComponent({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    final style = WTheme.of(context);
    final colorScheme = style.colorScheme;
    final theme = Theme.of(context);
    final textTheme = theme.textTheme;
    final store = Provider.of<PrivateCleanDetailStore>(context);
    final data = store.data;
    final photos = data?.photos ?? [];
    if (photos.length == 0) return SliverToBoxAdapter();

    final urls = photos.map((e) => AppParseUtil.image(e)).toList();

    final imageproviders =
        urls.map((e) => CachedNetworkImageProvider(e)).toList();

    return SliverToBoxAdapter(
      child: WisCard(
        margin: EdgeInsets.fromLTRB(15.pt, 0, 15.pt, 15.pt),
        padding: EdgeInsets.all(15.pt),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            Text(
              '现场照片',
              style: textTheme.titleMedium!.copyWith(
                fontWeight: FontWeight.bold,
              ),
            ),
            SizedBox(height: 15.pt),
            Wrap(
              spacing: 10.pt,
              runSpacing: 10.pt,
              children: <Widget>[
                for (var i = 0; i < urls.length; i++)
                  Wisdom(
                    onTap: () => WisPhotoViewUtil.show(imageproviders, i),
                    width: 98.pt,
                    height: 98.pt,
                    color: colorScheme.background,
                    border: Border.all(color: colorScheme.divider),
                    child: WImage(image: imageproviders[i], fit: BoxFit.cover),
                  ),
              ],
            )
          ],
        ),
      ),
    );
  }
}
