/*
 * @Author: ChenYaJin
 * @Date: 2021-11-04 17:42:24
 * @LastEditors: ChenYaJin
 * @LastEditTime: 2023-02-15 11:40:13
 * @Description:  报修处理-详情-底部按钮
 */
part of '../index.dart';

class _BottomDetailComponent extends StatefulWidget {
  _BottomDetailComponent({Key? key}) : super(key: key);

  @override
  __BottomDetailComponentState createState() => __BottomDetailComponentState();
}

class __BottomDetailComponentState extends State<_BottomDetailComponent> {
  final modalformKey = GlobalKey<FormState>();
  late FocusNode myFocusNode;
  @override
  void initState() {
    super.initState();

    myFocusNode = FocusNode();
  }

  @override
  void dispose() {
    // Clean up the focus node when the Form is disposed.
    myFocusNode.dispose();

    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    final _store = Provider.of<RepairDetailStore>(context);
    final style = WTheme.of(context);
    final colorScheme = style.colorScheme;
    if (_store.repairDetail?.status == 'waitAccept')
      return BottomAppBar(
        elevation: 0,
        color: Color(0xFFF8F8F8),
        child: Wisdom.row(
          height: 60.pt,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          padding: EdgeInsets.only(left: 10.pt),
          children: <Widget>[
            Wisdom(
              onTap: () => _store.putAccept(),
              minWidth: 100.pt,
              alignment: Alignment.center,
              child: Container(
                height: 44.pt,
                margin: EdgeInsets.only(right: 15.pt),
                decoration: BoxDecoration(
                  gradient: LinearGradient(
                    colors: [
                      Color.fromRGBO(77, 128, 255, 1),
                      Color.fromRGBO(15, 103, 248, 1)
                    ],
                    begin: Alignment.centerLeft,
                    end: Alignment.centerRight,
                  ),
                  borderRadius: BorderRadius.circular(25.pt),
                ),
                child: Center(
                  child: Text(
                    '确认受理',
                    style: TextStyle(
                      fontSize: 14.pt,
                      color: Colors.white,
                    ),
                  ),
                ),
              ),
            ).asExpanded(),
          ],
        ),
      );
    if (_store.repairDetail?.status == 'accept')
      return BottomAppBar(
        elevation: 0,
        color: Color(0xFFF8F8F8),
        child: Wisdom.row(
          height: 60.pt,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          padding: EdgeInsets.only(left: 10.pt),
          children: <Widget>[
            Wisdom.column(
              width: 65.pt,
              onTap: () => _store.route2assigner(),
              alignment: Alignment.center,
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Image(
                  image: AssetList.$assign_png_image,
                  height: 20.pt,
                ),
                Text('转派',
                    style:
                        TextStyle(fontSize: 10.pt, color: colorScheme.primary)),
              ],
            ),
            Wisdom.column(
              width: 65.pt,
              onTap: () => _store.route2RepairCost(_store.repairDetail),
              alignment: Alignment.center,
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Image(
                  image: AssetList.$cost_png_image,
                  height: 20.pt,
                ),
                Text('费用',
                    style:
                        TextStyle(fontSize: 10.pt, color: colorScheme.primary)),
              ],
            ),
            Wisdom.column(
              width: 65.pt,
              onTap: () => _store.route2RepairHandup(),
              alignment: Alignment.center,
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Image(
                  image: AssetList.$handup_png_image,
                  height: 20.pt,
                ),
                Text('挂起',
                    style:
                        TextStyle(fontSize: 10.pt, color: colorScheme.primary)),
              ],
            ),
            Wisdom(
                onTap: () => _store.route2RepairSolve(),
                minWidth: 100.pt,
                alignment: Alignment.center,
                child: Container(
                  height: 44.pt,
                  margin: EdgeInsets.only(right: 15.pt),
                  decoration: BoxDecoration(
                    gradient: LinearGradient(
                      colors: [
                        Color.fromRGBO(77, 128, 255, 1),
                        Color.fromRGBO(15, 103, 248, 1)
                      ],
                      begin: Alignment.centerLeft,
                      end: Alignment.centerRight,
                    ),
                    borderRadius: BorderRadius.circular(25.pt),
                  ),
                  child: Center(
                    child: Text(
                      '已解决',
                      style: TextStyle(
                        fontSize: 14.pt,
                        color: Colors.white,
                      ),
                    ),
                  ),
                )).asExpanded(),
          ],
        ),
      );
    if (_store.repairDetail?.status == 'hangUp')
      return BottomAppBar(
        elevation: 0,
        color: Color(0xFFF8F8F8),
        child: Wisdom.row(
          height: 60.pt,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          padding: EdgeInsets.only(left: 10.pt),
          children: <Widget>[
            Wisdom.column(
              width: 100.pt,
              onTap: () => _store.route2RepairCost(_store.repairDetail),
              alignment: Alignment.center,
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Image(
                  image: AssetList.$cost_png_image,
                  height: 20.pt,
                ),
                Text('费用',
                    style:
                        TextStyle(fontSize: 10.pt, color: colorScheme.primary)),
              ],
            ),
            Wisdom.column(
              onTap: () => _store.route2RepairSolve(),
              minWidth: 100.pt,
              mainAxisAlignment: MainAxisAlignment.center,
              alignment: Alignment.center,
              children: [
                Container(
                  height: 44.pt,
                  margin: EdgeInsets.only(right: 15.pt),
                  decoration: BoxDecoration(
                    gradient: LinearGradient(
                      colors: [
                        Color.fromRGBO(77, 128, 255, 1),
                        Color.fromRGBO(15, 103, 248, 1)
                      ],
                      begin: Alignment.centerLeft,
                      end: Alignment.centerRight,
                    ),
                    borderRadius: BorderRadius.circular(25.pt),
                  ),
                  child: Center(
                    child: Text(
                      '已解决',
                      style: TextStyle(
                        fontSize: 14.pt,
                        color: Colors.white,
                      ),
                    ),
                  ),
                )
              ],
            ).asExpanded(),
          ],
        ),
      );
    if (_store.repairDetail?.status == 'solve' ||
        _store.repairDetail?.status == 'evaluate')
      return BottomAppBar(
        elevation: 0,
        child: Wisdom.row(
          height: 60.pt,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          padding: EdgeInsets.only(left: 10.pt),
          children: <Widget>[
            if (_store.repairDetail!.paidService != null &&
                _store.repairDetail!.paidService != false) ...[
              Wisdom.column(
                width: 100.pt,
                onTap: () => _store.route2RepairCost(_store.repairDetail),
                alignment: Alignment.center,
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Image.asset(
                    'lib/assets/cost.png',
                    height: 20.pt,
                    package: 'repair_package',
                  ),
                  WisText(
                    '费用',
                    size: 10.pt,
                    color: colorScheme.primary,
                  ),
                ],
              ),
            ],
            Wisdom.column(
              onTap: () => _store.route2ReportOpen(_store.repairDetail!),
              minWidth: 100.pt,
              mainAxisAlignment: MainAxisAlignment.center,
              alignment: Alignment.center,
              children: [
                Container(
                  height: 44.pt,
                  margin: EdgeInsets.only(right: 15.pt),
                  decoration: BoxDecoration(
                    gradient: LinearGradient(
                      colors: [
                        Color.fromRGBO(77, 128, 255, 1),
                        Color.fromRGBO(15, 103, 248, 1)
                      ],
                      begin: Alignment.centerLeft,
                      end: Alignment.centerRight,
                    ),
                    borderRadius: BorderRadius.circular(25.pt),
                  ),
                  child: Center(
                    child: Text(
                      '重新开启',
                      style: TextStyle(
                        fontSize: 14.pt,
                        color: Colors.white,
                      ),
                    ),
                  ),
                )
              ],
            ).asExpanded(),
          ],
        ),
      );
    else {
      return Wisdom(
        height: 0.pt,
      );
    }
  }
}
