add auth, format
This commit is contained in:
@@ -204,9 +204,7 @@ class LoyaltyPage extends ConsumerWidget {
|
||||
return Card(
|
||||
elevation: 5,
|
||||
margin: EdgeInsets.zero,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
@@ -228,17 +226,11 @@ class LoyaltyPage extends ConsumerWidget {
|
||||
children: [
|
||||
Text(
|
||||
'Hạng hiện tại: DIAMOND',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppColors.grey500,
|
||||
),
|
||||
style: TextStyle(fontSize: 13, color: AppColors.grey500),
|
||||
),
|
||||
Text(
|
||||
'Hạng kế tiếp: PLATINUM',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppColors.grey500,
|
||||
),
|
||||
style: TextStyle(fontSize: 13, color: AppColors.grey500),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -265,10 +257,7 @@ class LoyaltyPage extends ConsumerWidget {
|
||||
child: RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: const TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppColors.grey500,
|
||||
),
|
||||
style: TextStyle(fontSize: 13, color: AppColors.grey500),
|
||||
children: [
|
||||
TextSpan(text: 'Còn '),
|
||||
TextSpan(
|
||||
@@ -414,9 +403,7 @@ class LoyaltyPage extends ConsumerWidget {
|
||||
return Card(
|
||||
elevation: 1,
|
||||
margin: EdgeInsets.zero,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
@@ -436,7 +423,10 @@ class LoyaltyPage extends ConsumerWidget {
|
||||
_buildBenefitItem('Ưu tiên xử lý đơn hàng'),
|
||||
_buildBenefitItem('Tặng 500 điểm vào ngày sinh nhật'),
|
||||
_buildBenefitItem('Tư vấn thiết kế miễn phí'),
|
||||
_buildBenefitItem('Mời tham gia sự kiện VIP độc quyền', isLast: true),
|
||||
_buildBenefitItem(
|
||||
'Mời tham gia sự kiện VIP độc quyền',
|
||||
isLast: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -450,11 +440,7 @@ class LoyaltyPage extends ConsumerWidget {
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.check_circle,
|
||||
size: 20,
|
||||
color: Color(0xFF4A00E0),
|
||||
),
|
||||
const Icon(Icons.check_circle, size: 20, color: Color(0xFF4A00E0)),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
|
||||
@@ -65,7 +65,9 @@ class PointsHistoryPage extends ConsumerWidget {
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Transaction List
|
||||
...entries.map((entry) => _buildTransactionCard(context, ref, entry)),
|
||||
...entries.map(
|
||||
(entry) => _buildTransactionCard(context, ref, entry),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -82,9 +84,7 @@ class PointsHistoryPage extends ConsumerWidget {
|
||||
return Card(
|
||||
elevation: 1,
|
||||
margin: EdgeInsets.zero,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
@@ -101,20 +101,13 @@ class PointsHistoryPage extends ConsumerWidget {
|
||||
color: AppColors.grey900,
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
Icons.filter_list,
|
||||
color: AppColors.primaryBlue,
|
||||
size: 20,
|
||||
),
|
||||
Icon(Icons.filter_list, color: AppColors.primaryBlue, size: 20),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
'Thời gian hiệu lực: 01/01/2023 - 31/12/2023',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: AppColors.grey500,
|
||||
),
|
||||
style: TextStyle(fontSize: 12, color: AppColors.grey500),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -137,14 +130,14 @@ class PointsHistoryPage extends ConsumerWidget {
|
||||
|
||||
// Get transaction amount if it's a purchase
|
||||
final datasource = ref.read(pointsHistoryLocalDataSourceProvider);
|
||||
final transactionAmount = datasource.getTransactionAmount(entry.description);
|
||||
final transactionAmount = datasource.getTransactionAmount(
|
||||
entry.description,
|
||||
);
|
||||
|
||||
return Card(
|
||||
elevation: 1,
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
@@ -199,11 +192,16 @@ class PointsHistoryPage extends ConsumerWidget {
|
||||
OutlinedButton(
|
||||
onPressed: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Chức năng khiếu nại đang phát triển')),
|
||||
const SnackBar(
|
||||
content: Text('Chức năng khiếu nại đang phát triển'),
|
||||
),
|
||||
);
|
||||
},
|
||||
style: OutlinedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 6,
|
||||
),
|
||||
side: const BorderSide(color: AppColors.grey500),
|
||||
foregroundColor: AppColors.grey900,
|
||||
textStyle: const TextStyle(fontSize: 12),
|
||||
@@ -235,8 +233,8 @@ class PointsHistoryPage extends ConsumerWidget {
|
||||
color: entry.points > 0
|
||||
? AppColors.success
|
||||
: entry.points < 0
|
||||
? AppColors.danger
|
||||
: AppColors.grey900,
|
||||
? AppColors.danger
|
||||
: AppColors.grey900,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
@@ -282,10 +280,7 @@ class PointsHistoryPage extends ConsumerWidget {
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
'Kéo xuống để làm mới',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColors.grey500,
|
||||
),
|
||||
style: TextStyle(fontSize: 14, color: AppColors.grey500),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -316,10 +311,7 @@ class PointsHistoryPage extends ConsumerWidget {
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
error.toString(),
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColors.grey500,
|
||||
),
|
||||
style: const TextStyle(fontSize: 14, color: AppColors.grey500),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
|
||||
@@ -37,13 +37,20 @@ class RewardsPage extends ConsumerWidget {
|
||||
icon: const Icon(Icons.arrow_back, color: Colors.black),
|
||||
onPressed: () => context.pop(),
|
||||
),
|
||||
title: const Text('Đổi quà tặng', style: TextStyle(color: Colors.black)),
|
||||
title: const Text(
|
||||
'Đổi quà tặng',
|
||||
style: TextStyle(color: Colors.black),
|
||||
),
|
||||
elevation: AppBarSpecs.elevation,
|
||||
backgroundColor: AppColors.white,
|
||||
foregroundColor: AppColors.grey900,
|
||||
centerTitle: false,
|
||||
actions: const [
|
||||
SizedBox(width: AppSpacing.sm),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.info_outline, color: Colors.black),
|
||||
onPressed: () => _showInfoDialog(context),
|
||||
),
|
||||
const SizedBox(width: AppSpacing.sm),
|
||||
],
|
||||
),
|
||||
body: RefreshIndicator(
|
||||
@@ -72,26 +79,20 @@ class RewardsPage extends ConsumerWidget {
|
||||
sliver: filteredGifts.isEmpty
|
||||
? _buildEmptyState()
|
||||
: SliverGrid(
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
childAspectRatio: 0.7,
|
||||
crossAxisSpacing: 0,
|
||||
mainAxisSpacing: 0,
|
||||
),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
final gift = filteredGifts[index];
|
||||
return RewardCard(
|
||||
gift: gift,
|
||||
onRedeem: () => _handleRedeemGift(
|
||||
context,
|
||||
ref,
|
||||
gift,
|
||||
),
|
||||
);
|
||||
},
|
||||
childCount: filteredGifts.length,
|
||||
),
|
||||
gridDelegate:
|
||||
const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
childAspectRatio: 0.7,
|
||||
crossAxisSpacing: 0,
|
||||
mainAxisSpacing: 0,
|
||||
),
|
||||
delegate: SliverChildBuilderDelegate((context, index) {
|
||||
final gift = filteredGifts[index];
|
||||
return RewardCard(
|
||||
gift: gift,
|
||||
onRedeem: () => _handleRedeemGift(context, ref, gift),
|
||||
);
|
||||
}, childCount: filteredGifts.length),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -100,6 +101,84 @@ class RewardsPage extends ConsumerWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// Show info dialog with usage instructions
|
||||
void _showInfoDialog(BuildContext context) {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text(
|
||||
'Hướng dẫn sử dụng',
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
|
||||
),
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Text(
|
||||
'Đây là nội dung hướng dẫn sử dụng cho tính năng Đổi quà tặng:',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildInfoItem(
|
||||
'Sử dụng điểm tích lũy của bạn để đổi các phần quà giá trị trong danh mục.',
|
||||
),
|
||||
_buildInfoItem(
|
||||
'Bấm vào một phần quà để xem chi tiết và điều kiện áp dụng.',
|
||||
),
|
||||
_buildInfoItem(
|
||||
'Khi xác nhận đổi quà, bạn có thể chọn "Nhận hàng tại Showroom".',
|
||||
),
|
||||
_buildInfoItem(
|
||||
'Nếu chọn "Nhận hàng tại Showroom", bạn sẽ cần chọn Showroom bạn muốn đến nhận từ danh sách thả xuống.',
|
||||
),
|
||||
_buildInfoItem(
|
||||
'Quà đã đổi sẽ được chuyển vào mục "Quà của tôi" (trong trang Hội viên).',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
ElevatedButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.primaryBlue,
|
||||
foregroundColor: Colors.white,
|
||||
minimumSize: const Size(double.infinity, 44),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: const Text('Đóng'),
|
||||
),
|
||||
],
|
||||
actionsPadding: const EdgeInsets.fromLTRB(20, 0, 20, 20),
|
||||
contentPadding: const EdgeInsets.fromLTRB(20, 16, 20, 16),
|
||||
titlePadding: const EdgeInsets.fromLTRB(20, 20, 20, 8),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Build info item with bullet point
|
||||
Widget _buildInfoItem(String text) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(top: 6),
|
||||
child: Icon(Icons.circle, size: 6, color: AppColors.grey500),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(text, style: TextStyle(fontSize: 14, height: 1.5)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Build category filter pills
|
||||
Widget _buildCategoryFilter(
|
||||
BuildContext context,
|
||||
@@ -237,10 +316,7 @@ class RewardsPage extends ConsumerWidget {
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
'Vui lòng thử lại sau',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColors.grey500,
|
||||
),
|
||||
style: TextStyle(fontSize: 14, color: AppColors.grey500),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -290,10 +366,7 @@ class RewardsPage extends ConsumerWidget {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Text(
|
||||
'Chi phí:',
|
||||
style: TextStyle(fontSize: 13),
|
||||
),
|
||||
const Text('Chi phí:', style: TextStyle(fontSize: 13)),
|
||||
Text(
|
||||
'${numberFormat.format(gift.pointsCost)} điểm',
|
||||
style: const TextStyle(
|
||||
@@ -363,9 +436,7 @@ class RewardsPage extends ConsumerWidget {
|
||||
children: [
|
||||
const Icon(Icons.check_circle, color: Colors.white),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text('Đổi quà "${gift.name}" thành công!'),
|
||||
),
|
||||
Expanded(child: Text('Đổi quà "${gift.name}" thành công!')),
|
||||
],
|
||||
),
|
||||
backgroundColor: AppColors.success,
|
||||
|
||||
@@ -38,7 +38,9 @@ class PointsHistory extends _$PointsHistory {
|
||||
Future<void> refresh() async {
|
||||
state = const AsyncValue.loading();
|
||||
state = await AsyncValue.guard(() async {
|
||||
return await ref.read(pointsHistoryLocalDataSourceProvider).getAllEntries();
|
||||
return await ref
|
||||
.read(pointsHistoryLocalDataSourceProvider)
|
||||
.getAllEntries();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,25 +22,17 @@ class RewardCard extends ConsumerWidget {
|
||||
/// Callback when redeem button is pressed
|
||||
final VoidCallback onRedeem;
|
||||
|
||||
const RewardCard({
|
||||
required this.gift,
|
||||
required this.onRedeem,
|
||||
super.key,
|
||||
});
|
||||
const RewardCard({required this.gift, required this.onRedeem, super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final hasEnoughPoints = ref.watch(
|
||||
hasEnoughPointsProvider(gift.pointsCost),
|
||||
);
|
||||
final hasEnoughPoints = ref.watch(hasEnoughPointsProvider(gift.pointsCost));
|
||||
final numberFormat = NumberFormat('#,###', 'vi_VN');
|
||||
|
||||
return Card(
|
||||
elevation: 2,
|
||||
margin: EdgeInsets.symmetric(horizontal: 8, vertical: 8),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
@@ -158,9 +150,7 @@ class RewardCard extends ConsumerWidget {
|
||||
placeholder: (context, url) => Container(
|
||||
color: AppColors.grey100,
|
||||
child: const Center(
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
),
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
),
|
||||
),
|
||||
errorWidget: (context, url, error) => Container(
|
||||
|
||||
Reference in New Issue
Block a user