儲存更新更新介面文字

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