hyzp_ybqx-Commit092:已初步实现显示保存的用户列表,选择列表项目后能够成功登录

This commit is contained in:
WinUser01
2022-01-26 00:23:16 +08:00
parent dffaf9b467
commit 964c57c1e1
6 changed files with 576 additions and 12 deletions
+61 -9
View File
@@ -1,17 +1,19 @@
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:hyzp_ybqx/components/commonFun.dart';
class JdText extends StatefulWidget {
final String text;
final String title;
bool password;
final Object onChanged;
final Function(String) onChanged;
final int maxLines;
final double height;
TextEditingController controller;
final String endBtn;
final Function() onEndBtn;
final Function() onEndBtn2;
JdText(
{Key key,
@@ -22,7 +24,9 @@ class JdText extends StatefulWidget {
this.maxLines = 1,
this.height = 68,
this.controller,
this.endBtn})
this.endBtn,
this.onEndBtn,
this.onEndBtn2})
: super(key: key);
_JdTextState createState() => _JdTextState();
@@ -31,8 +35,40 @@ class JdText extends StatefulWidget {
class _JdTextState extends State<JdText> {
Icon ShowHiddenIcon = Icon(Icons.more_horiz);
// Flutter 监听TextField焦点
FocusNode _focusNode = FocusNode();
bool isFocus = false;
void initState() {
super.initState();
// _focusNode.addListener(() {
// setState(() {
// isFocus = _focusNode.hasFocus;
// widget.onEndBtn2();
// });
// });
//输入框焦点
_focusNode.addListener(() {
if (!_focusNode.hasFocus) {
print(widget.endBtn + ':失去焦点');
} else {
print(widget.endBtn + ':得到焦点');
if (null != widget.onEndBtn2) {
widget.onEndBtn2();
setState(() {});
}
}
});
}
//离开页面记着销毁和清除
@override
void dispose() {
// TODO: implement dispose
_focusNode.unfocus();
super.dispose();
}
@override
@@ -63,6 +99,7 @@ class _JdTextState extends State<JdText> {
//Flutter中Row中不能直接使用textfield控件
Expanded(
child: TextField(
focusNode: _focusNode,
textAlignVertical: TextAlignVertical(y: 1.0),
controller: widget.controller,
maxLines: 1,
@@ -91,14 +128,29 @@ class _JdTextState extends State<JdText> {
// alignment: Alignment(0, -1),
// padding: EdgeInsets.only(bottom: 23),
child: IconButton(
icon: Icon(Icons.highlight_off),
onPressed: () {
setState(() {
widget.controller.clear();
});
}),
padding: EdgeInsets.only(bottom: 0.0),
iconSize: 40,
icon: Icon(
Icons.arrow_drop_down,
color: g_users.isNotEmpty ? Colors.blueAccent : Colors.grey,
),
onPressed: widget.onEndBtn),
);
break;
// case 'ClearBtn':
// widget.controller = new TextEditingController();
// btn = Container(
// // alignment: Alignment(0, -1),
// // padding: EdgeInsets.only(bottom: 23),
// child: IconButton(
// icon: Icon(Icons.highlight_off),
// onPressed: () {
// setState(() {
// widget.controller.clear();
// });
// }),
// );
// break;
case 'ShowHiddenBtn':
btn = Container(
// alignment: Alignment(0, -1),