128 lines
4.0 KiB
Dart
128 lines
4.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../../common/theme/theme.dart';
|
|
import '../../../components/spacer/spacer.dart';
|
|
import '../customer_page.dart';
|
|
|
|
class CustomerTile extends StatelessWidget {
|
|
final Customer customer;
|
|
const CustomerTile({super.key, required this.customer});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
margin: EdgeInsets.symmetric(horizontal: AppValue.margin, vertical: 6),
|
|
decoration: BoxDecoration(
|
|
color: AppColor.white,
|
|
borderRadius: BorderRadius.circular(12),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withOpacity(0.05),
|
|
blurRadius: 10,
|
|
offset: Offset(0, 2),
|
|
),
|
|
],
|
|
),
|
|
child: ListTile(
|
|
contentPadding: EdgeInsets.all(16),
|
|
leading: CircleAvatar(
|
|
backgroundColor: _getMembershipColor(customer.membershipLevel),
|
|
child: Text(
|
|
customer.name[0].toUpperCase(),
|
|
style: AppStyle.sm.copyWith(
|
|
color: AppColor.white,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
title: Text(
|
|
customer.name,
|
|
style: AppStyle.lg.copyWith(fontWeight: FontWeight.bold),
|
|
),
|
|
subtitle: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
SpaceHeight(4),
|
|
Text(customer.email),
|
|
SpaceHeight(2),
|
|
Text(customer.phone),
|
|
SpaceHeight(4),
|
|
Row(
|
|
children: [
|
|
Container(
|
|
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
|
decoration: BoxDecoration(
|
|
color: _getMembershipColor(
|
|
customer.membershipLevel,
|
|
).withOpacity(0.1),
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: Text(
|
|
customer.membershipLevel,
|
|
style: AppStyle.sm.copyWith(
|
|
color: _getMembershipColor(customer.membershipLevel),
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
SpaceWidth(8),
|
|
Container(
|
|
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
|
decoration: BoxDecoration(
|
|
color: customer.isActive
|
|
? AppColor.success.withOpacity(0.1)
|
|
: AppColor.error.withOpacity(0.1),
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: Text(
|
|
customer.isActive ? 'Active' : 'Inactive',
|
|
style: AppStyle.sm.copyWith(
|
|
color: customer.isActive
|
|
? AppColor.success
|
|
: AppColor.error,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
trailing: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
Text(
|
|
'Rp ${customer.totalPurchases.toStringAsFixed(0)}',
|
|
style: AppStyle.md.copyWith(
|
|
fontWeight: FontWeight.bold,
|
|
color: AppColor.primary,
|
|
),
|
|
),
|
|
Text(
|
|
'${customer.totalOrders} orders',
|
|
style: AppStyle.sm.copyWith(color: AppColor.textSecondary),
|
|
),
|
|
],
|
|
),
|
|
onTap: () {},
|
|
),
|
|
);
|
|
}
|
|
|
|
Color _getMembershipColor(String level) {
|
|
switch (level) {
|
|
case 'Platinum':
|
|
return Color(0xFF9C27B0);
|
|
case 'Gold':
|
|
return Color(0xFFFF9800);
|
|
case 'Silver':
|
|
return Color(0xFF607D8B);
|
|
case 'Bronze':
|
|
return Color(0xFF795548);
|
|
default:
|
|
return AppColor.primary;
|
|
}
|
|
}
|
|
}
|