183 lines
5.6 KiB
Dart
183 lines
5.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class PackagePage extends StatelessWidget {
|
|
final ScrollController scrollController;
|
|
|
|
const PackagePage({super.key, required this.scrollController});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
children: [
|
|
// 自訂頂部 Bar
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
|
decoration: const BoxDecoration(
|
|
color: Color(0xFF9EAF9F),
|
|
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
IconButton(
|
|
icon: const Icon(Icons.close, color: Colors.white),
|
|
onPressed: () => Navigator.pop(context),
|
|
),
|
|
const SizedBox(width: 8),
|
|
const Text(
|
|
'信件包裹通知',
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 20,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
|
|
// 可滾動內容
|
|
Expanded(
|
|
child: Container(
|
|
color: const Color(0xFFF7F8FA),
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
|
child: ListView(
|
|
controller: scrollController,
|
|
children: [
|
|
const Text(
|
|
'📦 待領包裹',
|
|
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
|
),
|
|
const SizedBox(height: 12),
|
|
_buildParcelItem(
|
|
context: context,
|
|
date: '2025/04/16',
|
|
courier: '宅配 - 7-11 交貨便',
|
|
recipient: '林小安',
|
|
parcelId: 'P20240416001',
|
|
amount: 250,
|
|
),
|
|
_buildParcelItem(
|
|
context: context,
|
|
date: '2025/04/14',
|
|
courier: '黑貓宅急便',
|
|
recipient: '林小安',
|
|
parcelId: 'P20240414002',
|
|
amount: 120,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildParcelItem({
|
|
required String date,
|
|
required String courier,
|
|
required String recipient,
|
|
required String parcelId,
|
|
required int amount,
|
|
required BuildContext context,
|
|
}) {
|
|
return Container(
|
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
|
margin: const EdgeInsets.only(bottom: 16),
|
|
decoration: const BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.all(Radius.circular(12)),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Color(0x11000000),
|
|
blurRadius: 4,
|
|
offset: Offset(0, 2),
|
|
),
|
|
],
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
_buildRow(date, courier),
|
|
const SizedBox(height: 4),
|
|
_buildRow('收件人:$recipient', '包裹編號:$parcelId'),
|
|
const SizedBox(height: 4),
|
|
_buildRow('代收金額:\$${amount.toString()}', ''),
|
|
const SizedBox(height: 10),
|
|
Align(
|
|
alignment: Alignment.centerRight,
|
|
child: ElevatedButton(
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: const Color(0xFF4CAF50),
|
|
foregroundColor: Colors.white,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(6),
|
|
),
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 16,
|
|
vertical: 8,
|
|
),
|
|
),
|
|
onPressed: () {
|
|
showDialog(
|
|
context: context,
|
|
builder:
|
|
(ctx) => AlertDialog(
|
|
title: const Text('包裹已領取'),
|
|
content: const Text('您已確認領取此包裹。'),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(ctx),
|
|
child: const Text('確定'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
child: const Text('確認領取', style: TextStyle(fontSize: 13)),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildRow(String left, String right) {
|
|
return Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
left,
|
|
style: const TextStyle(fontSize: 14, color: Color(0xFF555555)),
|
|
),
|
|
Text(
|
|
right,
|
|
style: const TextStyle(fontSize: 14, color: Color(0xFF555555)),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
class PackagePageWrapper extends StatelessWidget {
|
|
const PackagePageWrapper({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return DraggableScrollableSheet(
|
|
initialChildSize: 0.95,
|
|
minChildSize: 0.5,
|
|
maxChildSize: 1.0,
|
|
expand: false,
|
|
builder: (_, scrollController) {
|
|
return Container(
|
|
decoration: const BoxDecoration(color: Colors.transparent),
|
|
child: PackagePage(scrollController: scrollController),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|