個人資料加入username

This commit is contained in:
kuei 2024-09-12 20:36:40 +08:00
parent 89948f582a
commit 4be851ab86

View File

@ -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, //
),
],
),
),