個人資料加入username
This commit is contained in:
parent
89948f582a
commit
4be851ab86
|
|
@ -14,12 +14,12 @@ class PersonalInfo extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _PersonalInfoState extends State<PersonalInfo> {
|
||||
String _name = '', _phone = '', _gender = '', _address = '', _email = '', _password = '';
|
||||
String _username='',_realname = '', _phone = '', _gender = '', _address = '', _email = '', _password = '';
|
||||
|
||||
bool _isEditing = false; //是否為編輯狀態
|
||||
bool _passwordNotVisible = true;
|
||||
|
||||
final TextEditingController _nameController = TextEditingController();
|
||||
final TextEditingController _realnameController = TextEditingController();
|
||||
final TextEditingController _phoneController = TextEditingController();
|
||||
final TextEditingController _genderController = TextEditingController();
|
||||
final TextEditingController _addressController = TextEditingController();
|
||||
|
|
@ -60,12 +60,13 @@ class _PersonalInfoState extends State<PersonalInfo> {
|
|||
//有資料
|
||||
var row = result.rows.first;
|
||||
setState(() {
|
||||
_name = row.colAt(0) ?? ''; //如果沒有資料就是空直
|
||||
_phone = row.colAt(1) ?? '';
|
||||
_gender = row.colAt(2) ?? '';
|
||||
_address = row.colAt(3) ?? '';
|
||||
_email = row.colAt(4) ?? '';
|
||||
_password = row.colAt(5) ?? '';
|
||||
_username =row.colAt(0)??'';
|
||||
_realname = row.colAt(1) ?? ''; //如果沒有資料就是空直
|
||||
_phone = row.colAt(2) ?? '';
|
||||
_gender = row.colAt(3) ?? '';
|
||||
_address = row.colAt(4) ?? '';
|
||||
_email = row.colAt(5) ?? '';
|
||||
_password = row.colAt(6) ?? '';
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
@ -79,7 +80,7 @@ class _PersonalInfoState extends State<PersonalInfo> {
|
|||
setState(() {
|
||||
if (!_isEditing) {
|
||||
// 當進入編輯模式時,將當前的資料賦予控制器
|
||||
_nameController.text = _name;
|
||||
_realnameController.text = _realname;
|
||||
_phoneController.text = _phone;
|
||||
_genderController.text = _gender;
|
||||
_addressController.text = _address;
|
||||
|
|
@ -104,9 +105,9 @@ class _PersonalInfoState extends State<PersonalInfo> {
|
|||
|
||||
try {
|
||||
await conn.execute(
|
||||
'UPDATE HomeLogin SET homeName = :homeName, homePhone = :homePhone, homeGender = :homeGender, homeAddress = :homeAddress, homeEmail = :new_email, homePassword = :homePassword WHERE homeEmail = :old_email',
|
||||
'UPDATE HomeLogin SET homeRealName = :homeRealName , homePhone = :homePhone, homeGender = :homeGender, homeAddress = :homeAddress, homeEmail = :new_email, homePassword = :homePassword WHERE homeEmail = :old_email',
|
||||
{
|
||||
'homeName': _nameController.text,
|
||||
'homeRealName': _realnameController.text,
|
||||
'homePhone': _phoneController.text,
|
||||
'homeGender': _genderController.text,
|
||||
'homeAddress': _addressController.text,
|
||||
|
|
@ -116,7 +117,7 @@ class _PersonalInfoState extends State<PersonalInfo> {
|
|||
},
|
||||
);
|
||||
setState(() {
|
||||
_name = _nameController.text;
|
||||
_realname = _realnameController.text;
|
||||
_phone = _phoneController.text;
|
||||
_gender = _genderController.text;
|
||||
_address = _addressController.text;
|
||||
|
|
@ -124,7 +125,7 @@ class _PersonalInfoState extends State<PersonalInfo> {
|
|||
_password = _passwordController.text;
|
||||
|
||||
// 清空控制器內容
|
||||
_nameController.clear();
|
||||
_realnameController.clear();
|
||||
_phoneController.clear();
|
||||
_genderController.clear();
|
||||
_addressController.clear();
|
||||
|
|
@ -184,12 +185,29 @@ class _PersonalInfoState extends State<PersonalInfo> {
|
|||
padding: EdgeInsets.symmetric(vertical: 5), // 调整列表视图的 padding
|
||||
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(
|
||||
'使用名稱',
|
||||
style: TextStyle(fontSize: 20),
|
||||
),
|
||||
subtitle: Text(_username),
|
||||
),
|
||||
Divider(),
|
||||
ListTile(
|
||||
title: Text(
|
||||
'姓名',
|
||||
style: TextStyle(fontSize: 20),
|
||||
),
|
||||
subtitle: Text(_name),
|
||||
subtitle: _isEditing
|
||||
? TextField(
|
||||
controller: _realnameController,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_realname = value;
|
||||
});
|
||||
},
|
||||
)
|
||||
: Text(_realname),
|
||||
),
|
||||
Divider(),
|
||||
ListTile(
|
||||
|
|
@ -310,6 +328,9 @@ class _PersonalInfoState extends State<PersonalInfo> {
|
|||
shadowColor: Colors.transparent,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 50, // 增加底部間距,確保按鈕不被遮蓋
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user