多语言后端数据
This commit is contained in:
@@ -37,6 +37,11 @@ class _EditBedPageState extends State<EditBedPage> {
|
||||
super.initState();
|
||||
editedData = Map.from(widget.data); // 创建副本
|
||||
_nameController = TextEditingController(text: editedData['name']);
|
||||
|
||||
// 添加监听器
|
||||
_nameController.addListener(() {
|
||||
setState(() {}); // 每次文字变化刷新UI
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -181,84 +186,178 @@ class _EditBedPageState extends State<EditBedPage> {
|
||||
height: 193.rpx,
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsets.symmetric(horizontal: 60.rpx),
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
height: bodysize!.maxHeight * 0.076,
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: Color(0xFF929699),
|
||||
width: 0))),
|
||||
child: TextFormField(
|
||||
// autofocus: true,
|
||||
controller: _nameController,
|
||||
obscureText: false,
|
||||
onChanged: (val) {
|
||||
editedData['name'] = val;
|
||||
},
|
||||
textAlign: TextAlign.center,
|
||||
maxLength: AppConstants().text_length,
|
||||
decoration: InputDecoration(
|
||||
hintText: "请输入设备的名称".tr,
|
||||
contentPadding:
|
||||
const EdgeInsetsDirectional
|
||||
.fromSTEB(10, 0, 10, 0),
|
||||
labelStyle: TextStyle(
|
||||
fontFamily: 'Readex Pro',
|
||||
letterSpacing: 0,
|
||||
fontSize: 36.rpx, // 设置输入文字大小
|
||||
color: Colors.white, // 设置输入文字颜色
|
||||
),
|
||||
hintStyle: TextStyle(
|
||||
fontFamily: 'Readex Pro',
|
||||
letterSpacing: 0,
|
||||
color: Color(0xFF929699),
|
||||
fontSize: 36.rpx,
|
||||
),
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: const BorderSide(
|
||||
color: Color(0x00000000),
|
||||
width: 2,
|
||||
),
|
||||
borderRadius:
|
||||
BorderRadius.circular(8),
|
||||
),
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: const BorderSide(
|
||||
color: Color(0x00000000),
|
||||
width: 2,
|
||||
),
|
||||
borderRadius:
|
||||
BorderRadius.circular(8),
|
||||
),
|
||||
errorBorder: UnderlineInputBorder(
|
||||
borderSide: const BorderSide(
|
||||
color: Color(0x00000000),
|
||||
width: 2,
|
||||
),
|
||||
borderRadius:
|
||||
BorderRadius.circular(8),
|
||||
),
|
||||
focusedErrorBorder:
|
||||
UnderlineInputBorder(
|
||||
borderSide: const BorderSide(
|
||||
color: Color(0x00000000),
|
||||
width: 2,
|
||||
),
|
||||
borderRadius:
|
||||
BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontFamily: 'Readex Pro',
|
||||
letterSpacing: 0,
|
||||
color: Colors.white,
|
||||
fontSize: 36.rpx,
|
||||
padding:
|
||||
EdgeInsets.symmetric(horizontal: 60.rpx),
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
height: bodysize!.maxHeight * 0.076,
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: Color(0xFF929699), // 灰色底部线
|
||||
width: 0.5, // 根据需要设置宽度
|
||||
),
|
||||
),
|
||||
))
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
TextFormField(
|
||||
controller: _nameController,
|
||||
obscureText: false,
|
||||
onChanged: (val) {
|
||||
editedData['name'] = val;
|
||||
},
|
||||
textAlign: TextAlign.center,
|
||||
textAlignVertical:
|
||||
TextAlignVertical.center,
|
||||
maxLength: AppConstants().text_length,
|
||||
buildCounter: (_,
|
||||
{int? currentLength,
|
||||
bool? isFocused,
|
||||
int? maxLength}) =>
|
||||
null,
|
||||
decoration: InputDecoration(
|
||||
hintText: "请输入设备的名称".tr,
|
||||
contentPadding:
|
||||
const EdgeInsets.symmetric(
|
||||
vertical: 0, horizontal: 10),
|
||||
labelStyle: TextStyle(
|
||||
fontFamily: 'Readex Pro',
|
||||
letterSpacing: 0,
|
||||
fontSize: 36.rpx,
|
||||
color: Colors.white,
|
||||
),
|
||||
hintStyle: TextStyle(
|
||||
fontFamily: 'Readex Pro',
|
||||
letterSpacing: 0,
|
||||
fontSize: 36.rpx,
|
||||
color: const Color(0xFF929699),
|
||||
),
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide.none,
|
||||
borderRadius:
|
||||
BorderRadius.circular(8),
|
||||
),
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide.none,
|
||||
borderRadius:
|
||||
BorderRadius.circular(8),
|
||||
),
|
||||
errorBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide.none,
|
||||
borderRadius:
|
||||
BorderRadius.circular(8),
|
||||
),
|
||||
focusedErrorBorder:
|
||||
UnderlineInputBorder(
|
||||
borderSide: BorderSide.none,
|
||||
borderRadius:
|
||||
BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontFamily: 'Readex Pro',
|
||||
fontSize: 36.rpx,
|
||||
color: Colors.white,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
cursorColor: Colors.white,
|
||||
),
|
||||
|
||||
// 自定义右下角计数器
|
||||
Positioned(
|
||||
bottom: 2.rpx,
|
||||
right: 10.rpx,
|
||||
child: Text(
|
||||
'${_nameController.text.characters.length} / ${AppConstants().text_length}',
|
||||
style: TextStyle(
|
||||
fontSize: 24.rpx,
|
||||
color: const Color(0xFF929699),
|
||||
fontFamily: 'Readex Pro',
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Container(
|
||||
// alignment: Alignment.center,
|
||||
// height: bodysize!.maxHeight * 0.076,
|
||||
// decoration: const BoxDecoration(
|
||||
// border: Border(
|
||||
// bottom: BorderSide(
|
||||
// color: Color(0xFF929699),
|
||||
// width: 0))),
|
||||
// child: TextFormField(
|
||||
// // autofocus: true,
|
||||
// controller: _nameController,
|
||||
// obscureText: false,
|
||||
// onChanged: (val) {
|
||||
// editedData['name'] = val;
|
||||
// },
|
||||
// textAlign: TextAlign.center,
|
||||
// maxLength: AppConstants().text_length,
|
||||
// decoration: InputDecoration(
|
||||
// hintText: "请输入设备的名称".tr,
|
||||
// contentPadding:
|
||||
// const EdgeInsetsDirectional
|
||||
// .fromSTEB(10, 0, 10, 0),
|
||||
// labelStyle: TextStyle(
|
||||
// fontFamily: 'Readex Pro',
|
||||
// letterSpacing: 0,
|
||||
// fontSize: 36.rpx, // 设置输入文字大小
|
||||
// color: Colors.white, // 设置输入文字颜色
|
||||
// ),
|
||||
// hintStyle: TextStyle(
|
||||
// fontFamily: 'Readex Pro',
|
||||
// letterSpacing: 0,
|
||||
// color: Color(0xFF929699),
|
||||
// fontSize: 36.rpx,
|
||||
// ),
|
||||
// enabledBorder: UnderlineInputBorder(
|
||||
// borderSide: const BorderSide(
|
||||
// color: Color(0x00000000),
|
||||
// width: 2,
|
||||
// ),
|
||||
// borderRadius:
|
||||
// BorderRadius.circular(8),
|
||||
// ),
|
||||
// focusedBorder: UnderlineInputBorder(
|
||||
// borderSide: const BorderSide(
|
||||
// color: Color(0x00000000),
|
||||
// width: 2,
|
||||
// ),
|
||||
// borderRadius:
|
||||
// BorderRadius.circular(8),
|
||||
// ),
|
||||
// errorBorder: UnderlineInputBorder(
|
||||
// borderSide: const BorderSide(
|
||||
// color: Color(0x00000000),
|
||||
// width: 2,
|
||||
// ),
|
||||
// borderRadius:
|
||||
// BorderRadius.circular(8),
|
||||
// ),
|
||||
// focusedErrorBorder:
|
||||
// UnderlineInputBorder(
|
||||
// borderSide: const BorderSide(
|
||||
// color: Color(0x00000000),
|
||||
// width: 2,
|
||||
// ),
|
||||
// borderRadius:
|
||||
// BorderRadius.circular(8),
|
||||
// ),
|
||||
// ),
|
||||
// style: TextStyle(
|
||||
// fontFamily: 'Readex Pro',
|
||||
// letterSpacing: 0,
|
||||
// color: Colors.white,
|
||||
// fontSize: 36.rpx,
|
||||
// ),
|
||||
// ),
|
||||
// )
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user