/*
 * @Author: XianKaiQun
 * @Date: 2020-04-26 11:31:34
 * @LastEditors  : WuWei
 * @LastEditTime : 2022-02-24 18:09:25
 * @Descripttion: 计划任务详情-顶部任务简介
 */
part of '../index.dart';

///详情模块
class _DescComponent extends StatelessWidget {
  const _DescComponent({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    final store = Provider.of<PlanTaskDetailStore>(context);
    final data = store.data;
    final style = WTheme.of(context);
    final colorScheme = style.colorScheme;
    return SliverToBoxAdapter(
      child: Wisdom.stack(
        children: <Widget>[
          Wisdom(
            child: Wisdom.column(
              color: Colors.white,
              borderRadius: BorderRadius.circular(4.pt),
              padding: EdgeInsets.all(15.pt),
              crossAxisAlignment: CrossAxisAlignment.stretch,
              children: <Widget>[
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    RichText(
                      overflow: TextOverflow.ellipsis,
                      maxLines: 10,
                      text: TextSpan(children: [
                        WidgetSpan(
                          child: WTag(
                            color: colorScheme.minor,
                            child: WisText(
                              '计划',
                              size: 13.pt,
                            ),
                          ),
                        ),
                        TextSpan(
                          text: data?.title ?? '',
                          style: TextStyle(
                            fontSize: 15.pt,
                            color: colorScheme.mainTitle,
                            fontWeight: FontWeight.w600,
                          ),
                        ),
                      ]),
                    ).asExpanded(),
                  ],
                ),
                Wisdom.row(
                  margin: EdgeInsets.only(top: 15.pt),
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    WisText(
                      '限${store.limitedTime ?? '--'}前完成',
                      color: colorScheme.minor,
                      height: 2,
                      size: 12.pt,
                    ),
                  ],
                ),
                Divider(height: 30.pt),
                Wisdom.column(
                  crossAxisAlignment: CrossAxisAlignment.stretch,
                  children: <Widget>[
                    Wisdom.row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      margin: EdgeInsets.only(bottom: 15.pt),
                      children: <Widget>[
                        WisText(
                          '工作内容',
                          size: 15.pt,
                          color: colorScheme.mainTitle,
                          weight: FontWeight.w600,
                        ),
                        Wisdom.rich(
                          textAlign: TextAlign.right,
                          maxLines: 1,
                          overflow: TextOverflow.ellipsis,
                          padding: EdgeInsets.only(left: 15.pt),
                          children: [
                            TextSpan(
                              text: '所属类型：',
                              style: TextStyle(
                                color: colorScheme.placeholder,
                                fontSize: 14.pt,
                              ),
                            ),
                            TextSpan(
                              text: '${data?.inventoryName ?? '--'}',
                              style: TextStyle(
                                color: colorScheme.mainTitle,
                                fontSize: 14.pt,
                              ),
                            ),
                          ],
                        ).asExpanded(),
                      ],
                    ),
                    Text(
                      '${data?.content ?? ''}',
                      style: TextStyle(
                        fontSize: 14.pt,
                        fontWeight: FontWeight.w400,
                        color: colorScheme.minor,
                      ),
                    ),
                  ],
                ),
                Divider(height: 30.pt),
                if (store.data?.files?.length != null &&
                    store.data!.files!.length > 0) ...[
                  Wisdom.column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    padding: EdgeInsets.symmetric(vertical: 7.5.pt),
                    children: <Widget>[
                      Wisdom(
                        margin: EdgeInsets.only(bottom: 15.pt),
                        child: WisText(
                          '任务附件',
                          size: 15.pt,
                          color: colorScheme.mainTitle,
                          weight: FontWeight.w600,
                        ),
                      ),
                      Wisdom.column(
                        mainAxisSize: MainAxisSize.min,
                        children: store.data?.files?.length != null &&
                                store.data!.files!.length > 0
                            ? store.data!.files!
                                .map((item) => new _FileItem(itemData: item))
                                .toList()
                            : [],
                      ),
                    ],
                  ),
                ]
              ],
            ),
          ),
        ],
      ),
    );
  }
}
