plan_new_dish_first_page.dart 8.59 KB
import 'package:flutter/material.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:one_key/widgets/v_empty_view.dart';

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

/***
 * 4.2我的-我的排菜-创建新排菜前置条件录入
 */

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

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

class _PlanNewDishFirstPageState extends State<PlanNewDishFirstPage> {
  Widget _selectItem(String title, bool select, String hintText,
      TextEditingController controller) {
    return Row(
      children: [
        HEmptyView(86),
        Image.asset(
            Utils.getImgPath(
                select ? 'plan_dish_select' : 'plan_dish_unselect'),
            width: w(20)),
        HEmptyView(10),
        Text(
          title,
          style: TextStyle(fontSize: font(16), color: MyColours.color_515151),
        ),
        HEmptyView(20),
        select
            ? Expanded(
                child: TextField(
                maxLines: 1,
                controller: controller,
                // focusNode: _focusNode,
                // autofocus: true,

                style: TextStyle(
                    color: MyColours.color_438E93, fontSize: font(14)),
                textAlign: TextAlign.right,
                textAlignVertical: TextAlignVertical.center,
                decoration: InputDecoration(
                  hintText: hintText,
                  hintStyle: TextStyle(
                    color: MyColours.color_438E93,
                    fontSize: font(14),
                  ),
                  isCollapsed: true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
                  border: OutlineInputBorder(borderSide: BorderSide.none),
                  contentPadding: EdgeInsets.zero,
                ),
                keyboardType: TextInputType.numberWithOptions(decimal: true),
                textInputAction: TextInputAction.done,

                onChanged: (value) {
                  // setState(() {});
                  // _searchSellerLocation();
                  // customerProvider.searchData(value);
                },
                onEditingComplete: () {
                  FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
                  // contantShowModel.searchData(
                  //     contantShowModel.controller.text);
                  // _searchSellerLocation();
                  // _focusNode.unfocus();
                },
              ))
            : SizedBox(),
        select
            ? Text(
                '元',
                style: TextStyle(
                    fontSize: font(16), color: MyColours.color_515151),
              )
            : SizedBox(),
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: SystemAppBar(
        '预点菜',
        onTap: () {
          Navigator.pop(context);
        },
      ),
      backgroundColor: MyColours.color_ffffff,
      body: Column(
        children: [
          Padding(
              padding: EdgeInsets.symmetric(horizontal: w(20)),
              child: MyDivider(
                double.infinity,
                w(1),
                color: MyColours.color_DBDBDB,
              )),
          Expanded(
            child: SingleChildScrollView(
              // controller: controller,
              child: Padding(
                padding: EdgeInsets.symmetric(horizontal: w(20)),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(
                      height: w(48),
                      child: Row(
                        children: [
                          Text(
                            '就餐人数',
                            style: TextStyle(
                                fontSize: font(16),
                                color: MyColours.color_515151),
                          ),
                          Spacer(),
                          Image.asset(
                            Utils.getImgPath('plan_dish_minus'),
                            width: w(16),
                          ),
                          Container(
                              width: w(50),
                              // constraints: BoxConstraints(minWidth: w(20)),
                              child: TextField(
                                maxLines: 1,
                                // controller:
                                // focusNode: _focusNode,
                                // autofocus: true,

                                style: TextStyle(
                                    color: MyColours.color_438E93,
                                    fontSize: font(16)),
                                textAlign: TextAlign.center,
                                // textAlignVertical: TextAlignVertical.center,
                                decoration: InputDecoration(
                                  hintText: "人数",
                                  hintStyle: TextStyle(
                                    color: MyColours.color_999999,
                                    fontSize: font(16),
                                  ),
                                  // isCollapsed:
                                  //     true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
                                  border: OutlineInputBorder(
                                      borderSide: BorderSide.none),
                                  contentPadding: EdgeInsets.zero,
                                ),
                                keyboardType: TextInputType.numberWithOptions(decimal: true),
                                textInputAction: TextInputAction.done,

                                onChanged: (value) {
                                  // setState(() {});
                                  // _searchSellerLocation();
                                  // customerProvider.searchData(value);
                                },
                                onEditingComplete: () {
                                  FocusScope.of(context)
                                      .requestFocus(FocusNode()); //点击空白处隐藏键盘
                                  // contantShowModel.searchData(
                                  //     contantShowModel.controller.text);
                                  // _searchSellerLocation();
                                  // _focusNode.unfocus();
                                },
                              )),
                          Image.asset(
                            Utils.getImgPath('plan_dish_add'),
                            width: w(16),
                          ),
                        ],
                      ),
                    ),
                    VEmptyView(24),
                    Text(
                      '用餐标准',
                      style: TextStyle(
                          fontSize: font(16), color: MyColours.color_515151),
                    ),
                    VEmptyView(48),
                    _selectItem('预计人均', false, '点击这里输入预计人均金额', null),
                    VEmptyView(30),
                    _selectItem('预计总价', true, '点击这里输入预计总金额', null),
                    VEmptyView(46),
                    MyDivider(
                      double.infinity,
                      w(1),
                      color: MyColours.color_DBDBDB,
                    ),
                  ],
                ),
              ),
            ),
          ),
          Padding(
            padding: EdgeInsets.only(
                top: w(12), bottom: w(25), left: w(45), right: w(45)),
            child: RoundButton(
              text: '菜单选菜',
              gradientStart: MyColours.color_438E93,
              gradientEnd: MyColours.color_438E93,
              width: double.infinity,
              height: w(43),
              radius: r(5),
              fontSize: 36,
              isBold: false,
              onPressed: () {
                NavigatorUtil.goPlanNewDishPage(context);
              },
            ),
          )
        ],
      ),
    );
  }
}