/*
 * @Author: ChenYaJin
 * @Date: 2021-11-04 17:42:24
 * @LastEditors: ChenYaJin
 * @LastEditTime: 2023-02-15 11:28:17
 * @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<PrivateReportDetailStore>(context);
    final style = WTheme.of(context);
    final colorScheme = style.colorScheme;
    if (_store.reportDetail?.status == 'waitAccept')
      return BottomAppBar(
        elevation: 0,
        child: Wisdom.row(
          height: 60.pt,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          padding: EdgeInsets.only(left: 10.pt),
          children: <Widget>[
            Wisdom.column(
              onTap: () => _store.putAccept(),
              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.reportDetail?.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.asset(
                  'lib/assets/assign.png',
                  height: 20.pt,
                  package: 'repair_package',
                ),
                Text('转派',
                    style:
                        TextStyle(fontSize: 10.pt, color: colorScheme.primary)),
              ],
            ),
            Wisdom.column(
              width: 65.pt,
              onTap: () => _store.route2RepairCost(_store.reportDetail),
              alignment: Alignment.center,
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Image.asset(
                  'lib/assets/cost.png',
                  height: 20.pt,
                  package: 'repair_package',
                ),
                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.asset(
                  'lib/assets/handup.png',
                  height: 20.pt,
                  package: 'repair_package',
                ),
                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.reportDetail?.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.reportDetail),
              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.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.reportDetail?.status == 'solve' ||
        (_store.reportDetail?.status == 'evaluate'))
      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>[
            if (_store.reportDetail!.paidService != null &&
                _store.reportDetail!.paidService != false) ...[
              Wisdom.column(
                width: 100.pt,
                onTap: () => _store.route2RepairCost(_store.reportDetail),
                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.reportDetail!),
              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,
      );
    }
  }
}
