儲存更新更新介面文字

This commit is contained in:
kuei
2024-09-26 18:16:42 +08:00
parent 064f8894be
commit ed40d6633d

View File

@@ -115,6 +115,7 @@ class _PersonalInfoState extends State<PersonalInfo> {
_email = _emailController.text;
_password = _passwordController.text;
_isEditing = false;
print('有道這裡1');
});
} catch (e) {
print('Error: $e');
@@ -140,7 +141,7 @@ class _PersonalInfoState extends State<PersonalInfo> {
body: Column(
children: [
Container(
height: 120,
height: 100,
color: Color(0xFFF5E3C3),
padding: EdgeInsets.only(top: 50, left: 20, right: 20),
child: Row(
@@ -321,62 +322,96 @@ class _BasicInfoPageState extends State<BasicInfoPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
/*appBar: AppBar(
title: Text('基本資料'),
backgroundColor: Color(0xFFE0D0A9),
),
body: ListView(
padding: EdgeInsets.all(16),
),*/
body: Column(
children: [
ListTile(
title: Text('姓名'),
subtitle: _isEditing
? TextField(
controller: _realnameController,
)
: Text(widget.realname),
Container(
height: 100,
color: Color(0xFFF5E3C3),
width: double.infinity,
padding: EdgeInsets.all(10.0),
/* child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, // 將返回鍵與標題分開
children: [
IconButton(
icon: Icon(Icons.arrow_back, color: Colors.black, size: 24),
onPressed: () {
Navigator.pop(context, true); // 返回上一頁
},
),
Text(
'基本資料',
style: TextStyle(fontSize: 24, height: 5),
),
],
),
Divider(),
ListTile(
title: Text('手機'),
subtitle: _isEditing
? TextField(
controller: _phoneController,
)
: Text(widget.phone),
),*/
child: Center(
child: Text(
'基本資料',
style: TextStyle(fontSize: 24, height: 5),
),
),
),
Divider(),
ListTile(
title: Text('性別'),
subtitle: _isEditing
? TextField(
controller: _genderController,
)
: Text(widget.gender),
),
Divider(),
ListTile(
title: Text('地址'),
subtitle: _isEditing
? TextField(
controller: _addressController,
)
: Text(widget.address),
),
SizedBox(height: 20),
ElevatedButton(
onPressed: () {
if (_isEditing) {
_saveChanges();
} else {
_toggleEdit();
}
},
child: Text(_isEditing ? '儲存變更' : '修改資料'),
style: TextButton.styleFrom(
backgroundColor: Color(0xFFF5E3C3),
textStyle: TextStyle(fontSize: 18),
shadowColor: Colors.transparent,
Expanded(
child: ListView(
padding: EdgeInsets.all(16),
children: [
ListTile(
title: Text('姓名'),
subtitle: _isEditing
? TextField(
controller: _realnameController,
)
: Text(_realnameController.text),//Controller.text才會跟著修正更新
),
Divider(),
ListTile(
title: Text('手機'),
subtitle: _isEditing
? TextField(
controller: _phoneController,
)
: Text(_phoneController.text),
),
Divider(),
ListTile(
title: Text('性別'),
subtitle: _isEditing
? TextField(
controller: _genderController,
)
: Text(_genderController.text),
),
Divider(),
ListTile(
title: Text('地址'),
subtitle: _isEditing
? TextField(
controller: _addressController,
)
: Text(_addressController.text),
),
SizedBox(height: 20),
ElevatedButton(
onPressed: () {
if (_isEditing) {
_saveChanges();
} else {
_toggleEdit();
}
},
child: Text(_isEditing ? '儲存變更' : '修改資料'),
style: TextButton.styleFrom(
backgroundColor: Color(0xFFF5E3C3),
textStyle: TextStyle(fontSize: 18),
shadowColor: Colors.transparent,
),
),
],
),
),
],
@@ -471,7 +506,7 @@ class _AccountPageState extends State<AccountPage> {
? TextField(
controller: _emailController,
)
: Text(widget.email),
: Text(_emailController.text),
),
Divider(),
ListTile(
@@ -492,7 +527,7 @@ class _AccountPageState extends State<AccountPage> {
),
)
: Text(widget.password),
: Text(_passwordController.text),
),
SizedBox(height: 20),
ElevatedButton(