verify_food_page.dart 8.8 KB
import 'package:flutter/material.dart';
import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/system_app_bar.dart';

import '../../res/colors.dart';
import '../../utils/screen_util.dart';
import '../../utils/utils.dart';
import '../../widgets/h_empty_view.dart';
import '../../widgets/round_button.dart';
import '../../widgets/v_empty_view.dart';

/**
 * 核餐页面
 * */
class VerifyFoodPage extends StatefulWidget {
  VerifyFoodPage({Key key}) : super(key: key);

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

class _VerifyFoodPageState extends State<VerifyFoodPage> {
  bool confirmed = true; //已确认
  bool connected = false; //未接通
  bool undetermined = false; //待定

  TextEditingController customController = TextEditingController();
  FocusNode _cusdemNode = FocusNode();

  _itemRadioWidget(bool select, String title, {GestureTapCallback onTap}) {
    return InkWell(
        onTap: onTap,
        child: Row(children: [
          Image.asset(
            Utils.getImgPath(
                select ? 'plan_dish_select' : 'plan_dish_unselect'),
            width: w(20),
          ),
          HEmptyView(6),
          Text(
            title,
            style: TextStyle(color: MyColours.color_515151, fontSize: font(16)),
          ),
        ]));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: MyColours.color_ffffff,
      appBar: SystemAppBar('核餐确认'),
      body: Column(
        children: [
          Expanded(
              child: SingleChildScrollView(
                  child: Padding(
            padding: EdgeInsets.symmetric(horizontal: w(16), vertical: w(24)),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Row(
                  children: [
                    _itemRadioWidget(confirmed, '已确认', onTap: () {
                      if (!confirmed) {
                        setState(() {
                          confirmed = true;

                          connected = false;
                          undetermined = false;
                        });
                      }
                    }),
                    Spacer(),
                    _itemRadioWidget(connected, '未接通', onTap: () {
                      if (!connected) {
                        setState(() {
                          connected = true;

                          confirmed = false;
                          undetermined = false;
                        });
                      }
                    }),
                    Spacer(),
                    _itemRadioWidget(undetermined, '待定', onTap: () {
                      if (!undetermined) {
                        setState(() {
                          undetermined = true;
                          connected = false;
                          confirmed = false;
                        });
                      }
                    }),
                  ],
                ),
                VEmptyView(40),

                Text(
                  '备注',
                  style: TextStyle(
                      color: MyColours.color_515151, fontSize: font(15)),
                ),

                VEmptyView(30),
                //输入框
                Container(
                  width: double.infinity,
                  padding:
                      EdgeInsets.symmetric(horizontal: w(10), vertical: w(10)),
                  alignment: Alignment.topLeft,
                  decoration: BoxDecoration(
                      color: MyColours.color_ffffff,
                      border: Border.all(
                          color: MyColours.color_DBDBDB, width: w(1)),
                      borderRadius: BorderRadius.circular(r(8))),
                  child: TextField(
                      controller: customController,
                      focusNode: _cusdemNode,
                      style: TextStyle(
                          color: MyColours.color_333333,
                          fontSize: font(14),
                          textBaseline: TextBaseline.alphabetic),
                      textAlignVertical: TextAlignVertical.center,
                      maxLines: 5,
                      maxLength: 100,
                      decoration: InputDecoration(
                        hintText: "请输入备注或点击快捷选择标签",
                        hintStyle: TextStyle(
                          color: MyColours.color_979797,
                          fontSize: font(14),
                        ),
                        contentPadding: EdgeInsets.zero,
                        border: OutlineInputBorder(borderSide: BorderSide.none),
                      ),
                      keyboardType: TextInputType.text,
                      onChanged: (value) {
                        // setState(() {
                        //   currentRemark = value ?? "";
                        // });
                        // if (value.length < currRemark.length &&
                        //     currRemark.substring(value.length) != ',') {
                        //   setState(() {
                        //     currRemark = value ?? "";
                        //   });
                        //   if (sum == 0) {
                        //     for (int i = 0; i < remarks.length; i++) {
                        //       if (remarks[i].isSelect &&
                        //           remarks[i].remark == selectItem.last) {
                        //         setState(() {
                        //           remarks[i].isSelect = false;
                        //         });
                        //       }
                        //     }
                        //   }
                        //   sum++;
                        //   if (sum == selectItem.last.length ||
                        //       selectItem.length == 1 ||
                        //       selectItem.length == 0) {
                        //     selectItem.removeLast();
                        //     sum = 0;
                        //   }
                        // } else {
                        //   setState(() {
                        //     currRemark = value ?? "";
                        //   });
                        // }
                      }),
                ),
                VEmptyView(20),
                MyDivider(
                  double.infinity,
                  w(0.5),
                  color: MyColours.color_BFC4D4,
                ),
                VEmptyView(30),
                Container(
                    margin: EdgeInsets.only(bottom: w(10)),
                    child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Text(
                            '未接通、已确认、待定',
                            overflow: TextOverflow.ellipsis,
                            style: TextStyle(
                                color: MyColours.color_515151,
                                fontSize: font(14)),
                          ),
                          Text(
                            '张小娴 2023-12-16 15:23',
                            overflow: TextOverflow.ellipsis,
                            style: TextStyle(
                                color: MyColours.color_999999,
                                fontSize: font(14)),
                          ),
                        ]))
              ],
            ),
          ))),
          Container(
            padding: EdgeInsets.symmetric(horizontal: w(24), vertical: w(35)),
            child: Row(
              children: [
                RoundButton(
                  text: '取消',
                  width: w(100),
                  height: w(43),
                  radius: r(5),
                  fontSize: 32,
                  isBold: true,
                  gradientStart: MyColours.color_ffffff,
                  gradientEnd: MyColours.color_ffffff,
                  textColor: MyColours.color_438E93,
                  borderColor: MyColours.color_438E93,
                  onPressed: () {
                    Navigator.pop(context);
                  },
                ),
                HEmptyView(24),
                Expanded(
                    child: RoundButton(
                  text: '保存',
                  height: w(43),
                  radius: r(5),
                  isBold: true,
                  fontSize: 32,
                  gradientStart: MyColours.color_438E93,
                  gradientEnd: MyColours.color_438E93,
                  textColor: MyColours.color_ffffff,
                  borderColor: MyColours.color_438E93,
                  onPressed: () {
                    // _setBanquetDeposit();
                  },
                )),
              ],
            ),
          )
        ],
      ),
    );
  }
}