feat: product redeem page

This commit is contained in:
efrilm
2025-08-29 14:39:05 +07:00
parent fb7c9a19a9
commit 2870f39bcb
4 changed files with 961 additions and 136 deletions
+19 -78
View File
@@ -2,6 +2,7 @@ import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import '../../../common/theme/theme.dart';
import '../../router/app_router.gr.dart';
// Models
class PointCard {
@@ -53,6 +54,9 @@ class Product {
final int pointsRequired;
final String description;
final bool isPopular;
final String? fullDescription;
final String? validUntil;
final String? termsAndConditions;
Product({
required this.id,
@@ -61,6 +65,9 @@ class Product {
required this.pointsRequired,
required this.description,
this.isPopular = false,
this.fullDescription,
this.validUntil,
this.termsAndConditions,
});
}
@@ -293,7 +300,13 @@ class _RewardPageState extends State<RewardPage> {
SliverAppBar(
elevation: 0,
backgroundColor: AppColor.white,
title: Text("Rewards"),
title: Text(
"Rewards",
style: AppStyle.h5.copyWith(
fontWeight: FontWeight.w600,
color: AppColor.textPrimary,
),
),
centerTitle: true,
floating: false,
pinned: true, // Made sticky
@@ -836,83 +849,11 @@ class _RewardPageState extends State<RewardPage> {
}
void _redeemProduct(Product product) {
showDialog(
context: context,
builder: (context) => AlertDialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
title: Text(
"Redeem Product",
style: AppStyle.lg.copyWith(fontWeight: FontWeight.w600),
),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(product.image, style: TextStyle(fontSize: 48)),
SizedBox(height: 12),
Text(
product.name,
style: AppStyle.md.copyWith(fontWeight: FontWeight.w600),
),
SizedBox(height: 8),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.stars, color: AppColor.warning, size: 16),
SizedBox(width: 4),
Text(
"${product.pointsRequired} Points",
style: AppStyle.sm.copyWith(
fontWeight: FontWeight.w600,
color: AppColor.primary,
),
),
],
),
],
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: Text(
"Cancel",
style: AppStyle.sm.copyWith(color: AppColor.textSecondary),
),
),
ElevatedButton(
onPressed: () {
Navigator.pop(context);
_showRedeemSuccess(product);
},
style: ElevatedButton.styleFrom(
backgroundColor: AppColor.primary,
foregroundColor: AppColor.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
child: Text(
"Redeem",
style: AppStyle.sm.copyWith(
fontWeight: FontWeight.w600,
color: AppColor.white,
),
),
),
],
),
);
}
void _showRedeemSuccess(Product product) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
"Successfully redeemed ${product.name}!",
style: AppStyle.sm.copyWith(color: AppColor.white),
),
backgroundColor: AppColor.success,
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
context.router.push(
ProductRedeemRoute(
product: product,
merchant: selectedMerchant!,
pointCard: pointCard,
),
);
}