CommunityAPP/lib/personal_page.dart

299 lines
9.1 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import 'login_page.dart';
import 'edit_profile.dart';
2025-05-09 14:47:54 +08:00
import 'feedback.dart';
2025-05-09 16:49:13 +08:00
import 'reapair.dart';
import 'visitor.dart';
import 'package.dart';
import 'bill.dart';
class PersonalPage extends StatelessWidget {
const PersonalPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFFF7F8FA),
appBar: AppBar(
backgroundColor: const Color(0xFF9EAF9F),
title: const Text(
'我的社區',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
),
centerTitle: true,
),
body: ListView(
padding: const EdgeInsets.all(16),
children: [
_buildProfileSection(context),
const SizedBox(height: 10),
_buildCommunityInfoSection(context),
const SizedBox(height: 10),
_buildQuickMenu(context),
const SizedBox(height: 10),
_buildNotificationsSection(),
const SizedBox(height: 30),
_buildLogoutButton(context),
const SizedBox(height: 60),
],
),
);
}
Widget _buildProfileSection(BuildContext context) {
return Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
),
child: Row(
children: [
GestureDetector(
onTap: () {
// TODO: 點擊頭像事件
},
child: const CircleAvatar(
radius: 30,
backgroundImage: AssetImage('assets/images/avatar.png'),
),
),
const SizedBox(width: 16),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
Text(
'林小安',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
SizedBox(height: 4),
Text(
'住戶編號B205',
style: TextStyle(fontSize: 14, color: Colors.grey),
),
Text(
'社區:綠光花園',
style: TextStyle(fontSize: 14, color: Colors.grey),
),
],
),
),
TextButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const EditProfilePage(),
),
);
},
style: TextButton.styleFrom(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
backgroundColor: Colors.white,
side: const BorderSide(color: Colors.green),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
),
child: const Text(
'✏️ 修改',
style: TextStyle(fontSize: 13, color: Colors.green),
),
),
],
),
);
}
Widget _buildCommunityInfoSection(BuildContext context) {
return Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
),
child: Stack(
children: [
2025-06-03 17:50:50 +08:00
// 左邊社區資訊,右邊預留空間避免被按鈕擋住
Padding(
padding: const EdgeInsets.only(right: 120), // 預留右上角空間
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
Text('社區地址:新北市板橋區幸福路 88 號', style: TextStyle(fontSize: 12)),
SizedBox(height: 6),
Text('管理室電話02-2233-4455', style: TextStyle(fontSize: 12)),
SizedBox(height: 6),
Text(
'管委會 Emailservice@garden-community.tw',
style: TextStyle(fontSize: 12),
),
],
),
),
2025-06-03 17:50:50 +08:00
// 右上角意見箱按鈕
Positioned(
top: 0,
right: 0,
child: OutlinedButton(
onPressed: () {
2025-05-09 14:47:54 +08:00
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const FeedbackPage()),
);
},
style: OutlinedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
side: const BorderSide(color: Colors.grey),
padding: const EdgeInsets.symmetric(
horizontal: 14,
vertical: 6,
),
),
child: const Text('📝 意見箱', style: TextStyle(fontSize: 13)),
),
),
],
),
);
}
Widget _buildQuickMenu(BuildContext context) {
return Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
),
child: GridView.count(
shrinkWrap: true,
crossAxisCount: 4,
crossAxisSpacing: 12,
mainAxisSpacing: 12,
physics: const NeverScrollableScrollPhysics(),
children: [
2025-06-03 17:50:50 +08:00
_buildMenuItem('繳費通知', 'payment.png', () {
showModalBottomSheet(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (_) => BillPageWrapper(),
);
}),
_buildMenuItem('報修申請', 'repair.png', () {
showModalBottomSheet(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (_) => const RepairPageWrapper(),
2025-05-09 16:49:13 +08:00
);
}),
_buildMenuItem('包裹通知', 'package.png', () {
showModalBottomSheet(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (context) => PackagePageWrapper(),
);
}),
_buildMenuItem('訪客', 'visitor.png', () {
showModalBottomSheet(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (context) => const VisitorPageWrapper(),
);
}),
],
),
);
}
Widget _buildMenuItem(
String label,
String iconAssetName,
VoidCallback onTap,
) {
return GestureDetector(
onTap: onTap,
child: Container(
decoration: BoxDecoration(
color: const Color(0xFFF1F1F1),
borderRadius: BorderRadius.circular(8),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
GestureDetector(
onTap: onTap,
child: Image.asset(
'assets/icons/$iconAssetName',
width: 28,
height: 28,
),
),
const SizedBox(height: 6),
Text(label, style: const TextStyle(fontSize: 12)),
],
),
),
);
}
Widget _buildNotificationsSection() {
return Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
Text('📢 最新通知', style: TextStyle(fontSize: 16)),
SizedBox(height: 10),
Divider(),
Text('水塔清洗公告4/18 上午停水)', style: TextStyle(fontSize: 14)),
Divider(),
Text('您有 1 件包裹尚未領取', style: TextStyle(fontSize: 14)),
Divider(),
Text('電梯定期保養預告4/20', style: TextStyle(fontSize: 14)),
],
),
);
}
Widget _buildLogoutButton(BuildContext context) {
return Center(
child: ElevatedButton.icon(
onPressed: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (context) => const LoginPage()),
);
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFFF08080),
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
shadowColor: Colors.black,
elevation: 6,
),
/*icon: GestureDetector(
onTap: () {},
child: Image.asset('assets/icons/logout.png', width: 18, height: 18),
),*/
label: const Text(
'登出',
style: TextStyle(fontSize: 16, color: Colors.white),
),
),
);
}
}