/*
 * @Author: WuWei
 * @Date: 2020-06-19 10:30:37
 * @LastEditors  : WuWei
 * @LastEditTime : 2021-06-08 08:58:50
 * @Description:任务详情-文件展示
 */

part of '../index.dart';

class _FileItem extends StatelessWidget {
  const _FileItem({Key? key, this.itemData}) : super(key: key);

  final itemData;

  @override
  Widget build(BuildContext context) {
    final store = Provider.of<PrivateTaskDetailStore>(context);
    final style = WTheme.of(context);
    final colorScheme = style.colorScheme;
    final String baseUrl = APPConfig.baseURL;
    return Wisdom.row(
      margin: EdgeInsets.only(bottom: 5.pt),
      onTap: () => {
        if (itemData.type == 'file')
          {
            store.route2perview(
              baseUrl + 'file/download/' + itemData.accessoryId,
              itemData?.accessoryName,
            ),
          }
        else
          {
            store.onShowImage(itemData.accessoryId),
          }
      },
      // .pdf, .doc, .docx, .xls, .xlsx, .pptx, .ppt, image/*
      children: [
        WisText(
          itemData?.accessoryName,
          size: 14.pt,
          maxLines: 1,
          color: colorScheme.primary,
          overflow: TextOverflow.ellipsis,
        ).asExpanded(),
      ],
    );
  }
}
