歷史資料-新增詳細資料頁面
This commit is contained in:
parent
37ab8411c3
commit
5f4b90e491
|
|
@ -23,14 +23,10 @@ class _HistoricalRecordState extends State<HistoricalRecord> {
|
||||||
|
|
||||||
final conn = await MySQLConnection.createConnection(
|
final conn = await MySQLConnection.createConnection(
|
||||||
host: '203.64.84.154',
|
host: '203.64.84.154',
|
||||||
//host: '10.0.2.2',
|
|
||||||
//127.0.0.1 10.0.2.2
|
|
||||||
port: 33061,
|
port: 33061,
|
||||||
userName: 'root',
|
userName: 'root',
|
||||||
password: 'Topic@2024',
|
password: 'Topic@2024',
|
||||||
//password: '0000',
|
databaseName: 'care',
|
||||||
databaseName: 'care', //testdb
|
|
||||||
//databaseName: 'testdb',
|
|
||||||
);
|
);
|
||||||
await conn.connect();
|
await conn.connect();
|
||||||
|
|
||||||
|
|
@ -44,13 +40,14 @@ class _HistoricalRecordState extends State<HistoricalRecord> {
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
_results = result.rows
|
_results = result.rows
|
||||||
.map((row) => {
|
.map((row) =>
|
||||||
'長者ID': row.colAt(0), //去裝資料庫的行數
|
{
|
||||||
'姓名': row.colAt(8),
|
'長者ID': row.colAt(4), //去裝資料庫的行數
|
||||||
'跌倒時間': row.colAt(1),
|
'姓名': row.colAt(8),
|
||||||
'跌倒原因': row.colAt(2),
|
'跌倒時間': row.colAt(1),
|
||||||
'跌倒地點': row.colAt(7),
|
'跌倒原因': row.colAt(2),
|
||||||
})
|
'跌倒地點': row.colAt(7),
|
||||||
|
})
|
||||||
.toList();
|
.toList();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -81,23 +78,94 @@ class _HistoricalRecordState extends State<HistoricalRecord> {
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
padding: EdgeInsets.symmetric(vertical: 5), // 调整列表视图的 padding
|
padding: EdgeInsets.symmetric(vertical: 5), // 调整列表视图的 padding
|
||||||
|
|
||||||
itemCount: _results.length,
|
itemCount: _results.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
return ListTile(
|
return Padding(
|
||||||
title: Text(_results[index]['姓名']),
|
padding: const EdgeInsets.symmetric(
|
||||||
subtitle: Text(
|
vertical: 4.0, horizontal: 16.0),
|
||||||
' 長者ID: ${_results[index]['長者ID']},\n '
|
child:Card(
|
||||||
'跌倒時間: ${_results[index]['跌倒時間']},\n '
|
elevation: 4, // 卡片陰影效果
|
||||||
'跌倒原因: ${_results[index]['跌倒原因']},\n '
|
shape: RoundedRectangleBorder(
|
||||||
'跌倒地點: ${_results[index]['跌倒地點']}\n',
|
borderRadius: BorderRadius.circular(10.0), // 圓角卡片
|
||||||
|
),
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border(
|
||||||
|
left: BorderSide(color: Color(0xFFFFCC99), width: 5.0), // 左邊框
|
||||||
|
top: BorderSide(color: Color(0xFFFFCC99), width: 5.0), // 上邊框
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(10.0), // 圓角
|
||||||
|
),
|
||||||
|
child: ListTile(
|
||||||
|
title: Text(
|
||||||
|
_results[index]['姓名'],
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 18,
|
||||||
|
),),
|
||||||
|
subtitle: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text('長者ID: ${_results[index]['長者ID']}\n'
|
||||||
|
'跌倒時間: ${_results[index]['跌倒時間']}\n'
|
||||||
|
'跌倒原因: ${_results[index]['跌倒原因']}\n'
|
||||||
|
'跌倒地點: ${_results[index]['跌倒地點']}\n',
|
||||||
|
style: TextStyle(fontSize: 16, color: Colors.black), // 統一字體樣式
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
// 點擊時導向詳細資料頁面,並傳遞資料
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) =>
|
||||||
|
FallDetailPage(fallDetail: _results[index]),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
SizedBox(height: 70),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 新增詳細資料頁面
|
||||||
|
class FallDetailPage extends StatelessWidget {
|
||||||
|
final Map<String, dynamic> fallDetail;
|
||||||
|
|
||||||
|
FallDetailPage({required this.fallDetail});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text('${fallDetail['姓名']} 的詳細資料'),
|
||||||
|
),
|
||||||
|
body: Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text('長者ID: ${fallDetail['長者ID']}', style: TextStyle(fontSize: 18)),
|
||||||
|
SizedBox(height: 10),
|
||||||
|
Text('跌倒時間: ${fallDetail['跌倒時間']}', style: TextStyle(fontSize: 18)),
|
||||||
|
SizedBox(height: 10),
|
||||||
|
Text('跌倒原因: ${fallDetail['跌倒原因']}', style: TextStyle(fontSize: 18)),
|
||||||
|
SizedBox(height: 10),
|
||||||
|
Text('跌倒地點: ${fallDetail['跌倒地點']}', style: TextStyle(fontSize: 18)),
|
||||||
|
// 在這裡可以添加更多詳細資料
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user