use persistent_bottom_nav_bar_v2 replace native bottom_nav_bar
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:topic/BottomNavBar.dart';
|
||||
import 'package:topic/main.dart';
|
||||
import 'package:topic/HomePage.dart';
|
||||
import 'package:topic/HistoricalRecord.dart';
|
||||
@@ -21,22 +22,25 @@ class PersonalInfo extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _PersonalInfoState extends State<PersonalInfo> {
|
||||
String _name = '', _phone = '', _age = '',_gender = '',_email = '';
|
||||
bool _isEditing=false;//是否為編輯狀態
|
||||
final TextEditingController _emailController = TextEditingController();//email輸入text
|
||||
String _name = '', _phone = '', _age = '', _gender = '', _email = '';
|
||||
bool _isEditing = false; //是否為編輯狀態
|
||||
final TextEditingController _emailController =
|
||||
TextEditingController(); //email輸入text
|
||||
|
||||
@override
|
||||
void initState() {//初始化
|
||||
void initState() {
|
||||
//初始化
|
||||
super.initState();
|
||||
_fetchData();
|
||||
}
|
||||
|
||||
void _fetchData() async {//MYSQL
|
||||
void _fetchData() async {
|
||||
//MYSQL
|
||||
print('傳遞過來的 email: ${widget.email}'); // 打印 email 來確認它是否正確傳遞
|
||||
|
||||
final conn = await MySQLConnection.createConnection(
|
||||
//host: '203.64.84.154',
|
||||
host:'10.0.2.2',
|
||||
host: '10.0.2.2',
|
||||
//127.0.0.1 10.0.2.2
|
||||
port: 3306,
|
||||
userName: 'root',
|
||||
@@ -50,17 +54,19 @@ class _PersonalInfoState extends State<PersonalInfo> {
|
||||
|
||||
try {
|
||||
print('ok');
|
||||
var result = await conn.execute('SELECT name, phone, age, gender, email FROM users WHERE email = :email',
|
||||
{'email': widget.email}, // 傳入參數 email
|
||||
var result = await conn.execute(
|
||||
'SELECT name, phone, age, gender, email FROM users WHERE email = :email',
|
||||
{'email': widget.email}, // 傳入參數 email
|
||||
);
|
||||
if (result.rows.isNotEmpty) {//有資料
|
||||
if (result.rows.isNotEmpty) {
|
||||
//有資料
|
||||
var row = result.rows.first;
|
||||
setState(() {
|
||||
_name = row.colAt(0)??'';//如果沒有資料就是空直
|
||||
_phone = row.colAt(1)??'';
|
||||
_age = row.colAt(2)??'';
|
||||
_gender = row.colAt(3)??'';
|
||||
_email = row.colAt(4)??'';
|
||||
_name = row.colAt(0) ?? ''; //如果沒有資料就是空直
|
||||
_phone = row.colAt(1) ?? '';
|
||||
_age = row.colAt(2) ?? '';
|
||||
_gender = row.colAt(3) ?? '';
|
||||
_email = row.colAt(4) ?? '';
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -103,7 +109,6 @@ class _PersonalInfoState extends State<PersonalInfo> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//頁面
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -116,7 +121,7 @@ class _PersonalInfoState extends State<PersonalInfo> {
|
||||
children: [
|
||||
Container(
|
||||
height: 100,
|
||||
color: Color(0xFFF5E3C3),//背景底色
|
||||
color: Color(0xFFF5E3C3), //背景底色
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.all(10.0),
|
||||
child: Center(
|
||||
@@ -132,10 +137,14 @@ class _PersonalInfoState extends State<PersonalInfo> {
|
||||
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text('姓名',style: TextStyle(fontSize: 20),),
|
||||
title: Text(
|
||||
'姓名',
|
||||
style: TextStyle(fontSize: 20),
|
||||
),
|
||||
subtitle: Text(_name),
|
||||
//trailing: Icon(Icons.arrow_forward_ios),//>
|
||||
onTap: () {//點了之後
|
||||
onTap: () {
|
||||
//點了之後
|
||||
},
|
||||
),
|
||||
Divider(),
|
||||
@@ -143,43 +152,37 @@ class _PersonalInfoState extends State<PersonalInfo> {
|
||||
title: Text('手機'),
|
||||
subtitle: Text(_phone),
|
||||
//trailing: Icon(Icons.arrow_forward_ios),
|
||||
onTap: () {
|
||||
|
||||
},
|
||||
onTap: () {},
|
||||
),
|
||||
Divider(),
|
||||
ListTile(
|
||||
title: Text('生日'),
|
||||
subtitle: Text(_age),
|
||||
//trailing: Icon(Icons.arrow_forward_ios),
|
||||
onTap: () {
|
||||
|
||||
},
|
||||
onTap: () {},
|
||||
),
|
||||
Divider(),
|
||||
ListTile(
|
||||
title: Text('性別'),
|
||||
subtitle: Text(_gender),
|
||||
//trailing: Icon(Icons.arrow_forward_ios),
|
||||
onTap: () {
|
||||
|
||||
},
|
||||
onTap: () {},
|
||||
),
|
||||
Divider(),
|
||||
ListTile(
|
||||
title: Text('EMAIL'),
|
||||
subtitle: //Text(_email),
|
||||
_isEditing
|
||||
? TextField(
|
||||
controller: _emailController,
|
||||
autofocus: true,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_email = value;
|
||||
});
|
||||
},
|
||||
)
|
||||
: Text(_email),
|
||||
_isEditing
|
||||
? TextField(
|
||||
controller: _emailController,
|
||||
autofocus: true,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_email = value;
|
||||
});
|
||||
},
|
||||
)
|
||||
: Text(_email),
|
||||
//trailing: Icon(Icons.arrow_forward_ios),
|
||||
|
||||
onTap: () {
|
||||
@@ -187,10 +190,12 @@ class _PersonalInfoState extends State<PersonalInfo> {
|
||||
},
|
||||
),
|
||||
Divider(),
|
||||
SizedBox(height: 20,width: 60,),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
width: 60,
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
},
|
||||
onPressed: () {},
|
||||
child: Text('修改資料'),
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: Color(0xFFF5E3C3), // 無背景颜色
|
||||
@@ -198,10 +203,12 @@ class _PersonalInfoState extends State<PersonalInfo> {
|
||||
shadowColor: Colors.transparent, // 去除陰影
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10,width: 60,),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
width: 60,
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
},
|
||||
onPressed: () {},
|
||||
child: Text('登出'),
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: Color(0xFFF5E3C3),
|
||||
@@ -212,63 +219,8 @@ class _PersonalInfoState extends State<PersonalInfo> {
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
),
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
items: [
|
||||
BottomNavigationBarItem(icon: Icon(Icons.home), label: '首頁'),
|
||||
BottomNavigationBarItem(icon: Icon(Icons.history_edu), label: '跌倒紀錄'),
|
||||
BottomNavigationBarItem(icon: Icon(Icons.lightbulb_outline), label: '知識補充'),
|
||||
BottomNavigationBarItem(icon: Icon(Icons.monitor_outlined), label: '切換畫面'),
|
||||
BottomNavigationBarItem(icon: Icon(Icons.person_sharp), label: '個人資料'),
|
||||
],
|
||||
currentIndex: 4,
|
||||
selectedItemColor: Colors.orange,
|
||||
unselectedItemColor: Colors.grey,
|
||||
onTap: (index) {
|
||||
if (index == 0) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => HomePage(
|
||||
email: _email,
|
||||
)),
|
||||
);
|
||||
}
|
||||
else if (index == 1) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => HistoricalRecord(
|
||||
email: widget.email,
|
||||
)),
|
||||
);
|
||||
}
|
||||
else if (index == 2) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => KnowledgePage(
|
||||
email: widget.email,
|
||||
)),
|
||||
);
|
||||
}
|
||||
else if (index == 3) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => MessagePage(
|
||||
email: widget.email,
|
||||
)),
|
||||
);
|
||||
}
|
||||
else if (index == 4) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => PersonalInfo(
|
||||
email: widget.email,
|
||||
)),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user