2025-12-29 First Commit

This commit is contained in:
DATAEXPRESS\4734
2025-12-29 15:20:40 +08:00
commit fb2603c6f0
92 changed files with 6006 additions and 0 deletions
+157
View File
@@ -0,0 +1,157 @@
import 'package:flutter/material.dart';
import './person_model.dart';
import 'package:url_launcher/url_launcher.dart'; // 用於撥打電話和發送郵件
class PersonDetail extends StatelessWidget {
final Person person;
const PersonDetail({required this.person, super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(person.personCName ?? '人員詳細資訊'),
),
body: SingleChildScrollView(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
// 姓名與職稱
CircleAvatar(
radius: 50,
backgroundColor: person.sexColor.withOpacity(0.2),
child: Icon(person.sexIcon, size: 60, color: person.sexColor),
),
const SizedBox(height: 10),
Text(
person.personCName ?? 'N/A',
style: const TextStyle(fontSize: 28.0, fontWeight: FontWeight.bold, color: Colors.black87),
),
Text(
person.jobName ?? 'N/A',
style: const TextStyle(fontSize: 18.0, color: Colors.black54),
),
const Divider(height: 30.0, thickness: 1),
// 聯絡資訊列表
_buildInfoTile(
Icons.badge,
'工號 / ID',
person.personId,
),
_buildInfoTile(
Icons.business,
'部門代號',
person.departmentId ?? 'N/A',
),
_buildActionTile(
context,
Icons.phone,
'公司電話',
person.tel ?? 'N/A',
person.tel,
'tel:',
),
_buildActionTile(
context,
Icons.smartphone,
'手機號碼',
person.cellphone ?? 'N/A',
person.cellphone,
'tel:',
),
_buildActionTile(
context,
Icons.email,
'電子郵件',
person.email ?? 'N/A',
person.email,
'mailto:',
),
],
),
),
);
}
// 靜態資訊欄位
Widget _buildInfoTile(IconData icon, String label, String value) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Row(
children: [
Icon(icon, color: Colors.grey[700], size: 24),
const SizedBox(width: 15),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
label,
style: const TextStyle(fontSize: 14, color: Colors.grey),
),
Text(
value,
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
),
],
),
),
],
),
);
}
// 可操作(點擊撥號/發送郵件)的欄位
Widget _buildActionTile(
BuildContext context, IconData icon, String label, String displayValue,
String? actionValue, String protocol) {
final canLaunch = actionValue != null && actionValue.isNotEmpty;
Future<void> _launchUrl() async {
if (canLaunch) {
final uri = Uri.parse('$protocol$actionValue');
if (!await launchUrl(uri)) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('無法打開 $displayValue')),
);
}
}
}
return Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: InkWell(
onTap: canLaunch ? _launchUrl : null,
child: Row(
children: [
Icon(icon, color: canLaunch ? Colors.deepPurple : Colors.grey[700], size: 24),
const SizedBox(width: 15),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
label,
style: const TextStyle(fontSize: 14, color: Colors.grey),
),
Text(
displayValue,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: canLaunch ? Colors.deepPurple : Colors.black,
decoration: canLaunch ? TextDecoration.underline : TextDecoration.none,
),
),
],
),
),
],
),
),
);
}
}