/*
 * @Author       : WuWei
 * @LastEditors  : WuWei
 * @Date         : 2023-01-12 09:05:54
 * @LastEditTime : 2023-02-08 16:01:49
 * @Description  : 任务添加、编辑-输入任务标题
 */

part of '../index.dart';

class _TitleComponent extends StatelessWidget {
  const _TitleComponent({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    final store = Provider.of<EditStore>(context, listen: false);
    final style = WTheme.of(context);
    final colorScheme = style.colorScheme;
    return SliverToBoxAdapter(
      child: Wisdom.column(
        color: Colors.white,
        padding: EdgeInsets.only(right: 15.pt),
        margin: EdgeInsets.only(bottom: 10.pt),
        borderRadius: BorderRadius.circular(10.pt),
        boxShadow: [
          BoxShadow(
            offset: Offset(0, 2.pt),
            color: Color(0x08000000),
            blurRadius: 10.pt,
            spreadRadius: 2.5.pt,
          ),
        ],
        children: <Widget>[
          Observer(builder: (_) {
            return WFInput(
              type: InputType.singleLine,
              isRequired: true,
              isShowRequired: false,
              padding: EdgeInsets.only(left: 5.pt),
              maxLength: 64,
              hintText: '请输入任务标题',
              hintStyle: TextStyle(
                fontSize: 18.pt,
                color: colorScheme.placeholder2,
                fontWeight: FontWeight.w500,
              ),
              minLines: 2,
              maxLines: 2,
              initialValue: store.params['title'] ?? null,
              onInput: (v) => store.paramsChange('title', v),
              // title: WisText('任务标题', color: colorScheme.mainTitle, size: 15.pt),
            );
          }),
          Wisdom(
            margin: EdgeInsets.only(left: 15.pt, bottom: 10.pt),
            border: Border(
              bottom: BorderSide(
                width: 0.5,
                color: colorScheme.divider,
              ),
            ),
          ),
          Observer(builder: (_) {
            return WFInput(
              type: InputType.multiLine,
              isRequired: true,
              isShowRequired: false,
              maxLength: 256,
              hintStyle: TextStyle(
                fontSize: 15.pt,
                color: colorScheme.placeholder2,
                fontWeight: FontWeight.w300,
              ),
              initialValue: store.params['content'] ?? null,
              onInput: (v) => store.paramsChange('content', v),
              // title: WisText('工作内容', color: colorScheme.mainTitle, size: 15.pt),
              hintText: '输入工作内容，不超过256个字',
            );
          }),
          Wisdom(
            margin: EdgeInsets.only(left: 15.pt),
            border: Border(
              bottom: BorderSide(
                width: 0.5,
                color: colorScheme.divider,
              ),
            ),
          ),
          Observer(builder: (context) {
            return Wisdom(
              padding: EdgeInsets.symmetric(horizontal: 15.pt),
              margin: EdgeInsets.only(bottom: 10.pt),
              // border: Border(bottom: Divider.createBorderSide(context)),
              color: Colors.white,
              child: WFImagePicker(
                maxCount: 3,
                currentCount: store.imageList.length,
                images: store.imageList,
                isRequired: false,
                title: WisText('', color: colorScheme.mainTitle, size: 15.pt),
                onSelected: (v) => store.onSelectImages(v),
                onDelete: (v) => store.onDeleteImages(v),
              ),
            );
          }),
        ],
      ),
    );
  }
}
