195 lines
6.0 KiB
Dart
195 lines
6.0 KiB
Dart
/// Address Card Widget
|
|
///
|
|
/// Displays a saved address with edit/delete actions.
|
|
library;
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:worker/core/constants/ui_constants.dart';
|
|
import 'package:worker/core/theme/colors.dart';
|
|
|
|
/// Address Card Widget
|
|
///
|
|
/// Shows address details with name, phone, address text, default badge,
|
|
/// and action buttons (edit/delete).
|
|
class AddressCard extends StatelessWidget {
|
|
final String name;
|
|
final String phone;
|
|
final String address;
|
|
final bool isDefault;
|
|
final VoidCallback? onEdit;
|
|
final VoidCallback? onDelete;
|
|
final VoidCallback? onSetDefault;
|
|
|
|
const AddressCard({
|
|
super.key,
|
|
required this.name,
|
|
required this.phone,
|
|
required this.address,
|
|
this.isDefault = false,
|
|
this.onEdit,
|
|
this.onDelete,
|
|
this.onSetDefault,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
padding: const EdgeInsets.all(16),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(AppRadius.card),
|
|
border: isDefault
|
|
? Border.all(color: AppColors.primaryBlue, width: 2)
|
|
: null,
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withValues(alpha: 0.05),
|
|
blurRadius: 8,
|
|
offset: const Offset(0, 2),
|
|
),
|
|
],
|
|
),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// Address Content
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// Header (Name + Badge or Set Default Button)
|
|
Row(
|
|
children: [
|
|
Flexible(
|
|
child: Text(
|
|
name,
|
|
style: const TextStyle(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w500,
|
|
color: Color(0xFF212121),
|
|
),
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
const SizedBox(width: 8),
|
|
if (isDefault)
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 8,
|
|
vertical: 2,
|
|
),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.primaryBlue,
|
|
borderRadius: BorderRadius.circular(4),
|
|
),
|
|
child: const Text(
|
|
'Mặc định',
|
|
style: TextStyle(
|
|
fontSize: 11,
|
|
fontWeight: FontWeight.w500,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
)
|
|
else if (onSetDefault != null)
|
|
TextButton(
|
|
onPressed: onSetDefault,
|
|
style: TextButton.styleFrom(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 8,
|
|
vertical: 2,
|
|
),
|
|
minimumSize: Size.zero,
|
|
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
),
|
|
child: const Text(
|
|
'Đặt mặc định',
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color: AppColors.primaryBlue,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
// Phone
|
|
Text(
|
|
phone,
|
|
style: const TextStyle(
|
|
fontSize: 14,
|
|
color: AppColors.grey500,
|
|
),
|
|
),
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
// Address Text
|
|
Text(
|
|
address,
|
|
style: const TextStyle(
|
|
fontSize: 14,
|
|
color: Color(0xFF212121),
|
|
height: 1.4,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
|
|
const SizedBox(width: 12),
|
|
|
|
// Actions
|
|
Column(
|
|
children: [
|
|
// Edit Button
|
|
if (onEdit != null)
|
|
InkWell(
|
|
onTap: onEdit,
|
|
borderRadius: BorderRadius.circular(8),
|
|
child: Container(
|
|
width: 36,
|
|
height: 36,
|
|
decoration: BoxDecoration(
|
|
border: Border.all(color: const Color(0xFFE2E8F0)),
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: const Icon(
|
|
Icons.edit,
|
|
size: 18,
|
|
color: AppColors.primaryBlue,
|
|
),
|
|
),
|
|
),
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
// Delete Button
|
|
if (onDelete != null)
|
|
InkWell(
|
|
onTap: onDelete,
|
|
borderRadius: BorderRadius.circular(8),
|
|
child: Container(
|
|
width: 36,
|
|
height: 36,
|
|
decoration: BoxDecoration(
|
|
border: Border.all(color: const Color(0xFFE2E8F0)),
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: const Icon(
|
|
Icons.delete,
|
|
size: 18,
|
|
color: AppColors.danger,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|