input_buttom_widget.dart 6.57 KB
import 'package:flutter/material.dart';

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

class InputButtomWidget extends StatefulWidget {
  final ValueChanged onEditingCompleteText;

  InputButtomWidget({Key key, this.onEditingCompleteText}) : super(key: key);

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

class _InputButtomWidgetState extends State<InputButtomWidget> {
  final TextEditingController controller = TextEditingController();
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      backgroundColor: Colors.transparent,
      body: new Column(
        children: <Widget>[
          Expanded(
              child: new GestureDetector(
            child: new Container(
              color: Colors.transparent,
            ),
            onTap: () {
              Navigator.pop(context);
            },
          )),
          new Container(
              color: Color(0xFFF4F4F4),
              padding: EdgeInsets.only(left: 16, top: 8, bottom: 8, right: 16),
              child: Row(children: [
                // Container(
                //   decoration: BoxDecoration(color: Colors.white),
                //   child: TextField(
                //     controller: controller,
                //     autofocus: true,
                //     style: TextStyle(fontSize: 16),
                //     //设置键盘按钮为发送
                //     textInputAction: TextInputAction.send,
                //     keyboardType: TextInputType.multiline,
                //     onEditingComplete: () {
                //       //点击发送调用
                //       print('onEditingComplete');
                //       onEditingCompleteText(controller.text);
                //       Navigator.pop(context);
                //     },
                //     decoration: InputDecoration(
                //       hintText: '评论',
                //       isDense: true,
                //       contentPadding: EdgeInsets.only(
                //           left: 10, top: 5, bottom: 5, right: 10),
                //       border: const OutlineInputBorder(
                //         gapPadding: 0,
                //         borderSide: BorderSide(
                //           width: 0,
                //           style: BorderStyle.none,
                //         ),
                //       ),
                //     ),

                //     minLines: 1,
                //     maxLines: 5,
                //   ),
                // ),
                Expanded(
                    child: Container(
                        decoration: BoxDecoration(
                            color: MyColours.color_ffffff,
                            borderRadius: BorderRadius.circular(r(8))),
                        padding:
                            EdgeInsets.symmetric(horizontal: w(4), vertical: 0),
                        child: TextField(
                          controller: controller,
                          minLines: 1,
                          maxLines: 5,
                          autofocus: true,

                          // //光标颜色
                          // cursorColor:
                          //     widget.isSelect ? Colors.white : MyColours.color_199095,
                          //输入文本的样式
                          // inputFormatters: lenghtLimit
                          //     ? [
                          //         LengthLimitingTextInputFormatter(10),
                          //       ]
                          //     : [],
                          // textAlignVertical: TextAlignVertical.center,
                          textAlign: TextAlign.left,
                          style: TextStyle(
                            fontSize: font(14),
                          ),

                          decoration: InputDecoration(
                            contentPadding: EdgeInsets.zero,
                            border:
                                OutlineInputBorder(borderSide: BorderSide.none),
                            hintText: '评论',
                            hintStyle: TextStyle(
                              color: MyColours.color_999999,
                              fontSize: font(14),
                            ),
                            enabledBorder: new UnderlineInputBorder(
                              borderSide: BorderSide.none,
                            ),
                            focusedBorder: new UnderlineInputBorder(
                              borderSide: BorderSide.none,
                            ),
                          ),
                          onChanged: (value) {
                            // name = value;
                            setState(() {});
                          },
                          //设置键盘按钮为发送
                          // textInputAction: TextInputAction.send,
                          keyboardType: TextInputType.multiline,

                          onEditingComplete: () {
                            //点击发送调用
                            // print('onEditingComplete');
                            // onEditingCompleteText(controller.text);
                            // Navigator.pop(context);
                          },
                        ))),
                HEmptyView(20),
                RoundButton(
                  text: '发送',
                  width: w(54),
                  height: w(28),
                  gradientStart: controller.text.trim().length > 0
                      ? MyColours.color_438E93
                      : MyColours.color_ffffff,
                  gradientEnd: controller.text.trim().length > 0
                      ? MyColours.color_438E93
                      : MyColours.color_ffffff,
                  textColor: controller.text.trim().length > 0
                      ? MyColours.color_F8F9FD
                      : MyColours.color_999999,
                  fontSize: 24,
                  borderColor: controller.text.trim().length > 0
                      ? MyColours.color_438E93
                      : MyColours.color_999999,
                  radius: r(15),
                  onPressed: () {
                    if (controller.text.trim().length == 0) {
                      return;
                    }
                    print('onEditingComplete');
                    widget.onEditingCompleteText(controller.text);
                    Navigator.pop(context);
                  },
                ),
              ]))
        ],
      ),
    );
  }
}