import 'package:flutter/material.dart';
import 'package:liftmanager/internal/wode/page/master_become.dart';
import 'package:liftmanager/res/colors.dart';
import 'package:liftmanager/utils/toast.dart';
import 'package:liftmanager/widgets/app_bar.dart';
// import 'package:liftmanager/widgets/click_item.dart';

class InputAccount extends StatefulWidget {
  InputAccount({Key key, this.phone, this.name, this.backBlock})
      : super(key: key);
  String phone;
  String name;
  Function backBlock;
  @override
  _InputAccountState createState() => _InputAccountState();
}

class _InputAccountState extends State<InputAccount> {
  @override
  Widget build(BuildContext context) {
    var _unameController = new TextEditingController();
    var _accountController = new TextEditingController();
    return Scaffold(
      appBar: MyAppBar(
        centerTitle: "绑定账号",
      ),
      body: Container(
        child: Column(
          children: [
            TextFieldItem(
              title: "支付宝账号",
              keyboardType: TextInputType.number,
              // isMust: true,
              content: widget.phone ?? "",
              controller: _accountController,
              hintText: "请输入",
              validator: (val) {
                return val.trim().length > 0 ? null : "请输入姓名";
              },
            ),
            TextFieldItem(
              title: "真实姓名",
              content: widget.name ?? "",
              controller: _unameController,
              hintText: "请输入",
              validator: (val) {
                return val.trim().length > 0 ? null : "请输入姓名";
              },
            ),
            Expanded(child: Container()),
            Container(
              margin: EdgeInsets.fromLTRB(25, 15, 25, 15),
              height: 44,
              width: double.infinity,
              decoration: BoxDecoration(
                color: Colours.blue_app_main,
                borderRadius: BorderRadius.circular(22),
              ),
              child: FlatButton(
                // padding: EdgeInsets.all(15.0),
                child: Text("保存"),
                textColor: Colors.white,
                onPressed: () {
                  if (_unameController.text == "") {
                    toasts('请输入真实姓名');
                    return;
                  }
                  if (_accountController.text == "") {
                    toasts('请输入支付宝账号');
                    return;
                  }
                  if (widget.backBlock != null) {
                    widget.backBlock(
                        _accountController.text, _unameController.text);
                  }
                  Navigator.of(context).pop();
                  // print(_unameController.text == "");
                  // if (_unameController.text == "") {
                  //   toasts('请输入简介信息');
                  // } else {
                  //   _submit(_unameController.text);
                  // }
                  // if ((_formKey.currentState as FormState).validate()) {
                  //   submit();
                  // }
                },
              ),
            ),
          ],
        ),
      ),
    );
  }
}
