feat: Phase 1 critical gaps — gamification API, Razorpay checkout, Google OAuth, notifications
- Fix gamification endpoints to use Node.js server (app.eventifyplus.com)
- Replace 6 mock gamification methods with real API calls (dashboard, leaderboard, shop, redeem, submit)
- Add booking models, service, payment service (Razorpay), checkout provider
- Add 3-step CheckoutScreen with Razorpay native modal integration
- Add Google OAuth login (Flutter + Django backend)
- Add full notifications system (Django model + 3 endpoints + Flutter UI)
- Register CheckoutProvider, NotificationProvider in main.dart MultiProvider
- Wire notification bell in HomeScreen app bar
- Add razorpay_flutter ^1.3.7 and google_sign_in ^6.2.2 packages
2026-04-04 15:46:53 +05:30
|
|
|
// lib/screens/checkout_screen.dart
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
|
import '../features/booking/providers/checkout_provider.dart';
|
|
|
|
|
import '../features/booking/services/payment_service.dart';
|
|
|
|
|
import '../features/booking/models/booking_models.dart';
|
|
|
|
|
import '../core/utils/error_utils.dart';
|
|
|
|
|
import 'tickets_booked_screen.dart';
|
|
|
|
|
|
|
|
|
|
class CheckoutScreen extends StatefulWidget {
|
|
|
|
|
final int eventId;
|
|
|
|
|
final String eventName;
|
|
|
|
|
final String? eventImage;
|
|
|
|
|
|
|
|
|
|
const CheckoutScreen({
|
|
|
|
|
Key? key,
|
|
|
|
|
required this.eventId,
|
|
|
|
|
required this.eventName,
|
|
|
|
|
this.eventImage,
|
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<CheckoutScreen> createState() => _CheckoutScreenState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _CheckoutScreenState extends State<CheckoutScreen> {
|
|
|
|
|
late final PaymentService _paymentService;
|
|
|
|
|
final _formKey = GlobalKey<FormState>();
|
|
|
|
|
final _nameCtrl = TextEditingController();
|
|
|
|
|
final _emailCtrl = TextEditingController();
|
|
|
|
|
final _phoneCtrl = TextEditingController();
|
feat: Phase 3 — 26 medium-priority gaps implemented
P3-A/K Profile: Eventify ID glassmorphic badge (tap-to-copy), DiceBear
Notionists avatar via TierAvatarRing, district picker (14 pills)
with 183-day cooldown lock, multipart photo upload to server
P3-B Home: Top Events converted to PageView scroll-snap
(viewportFraction 0.9 + PageScrollPhysics)
P3-C Event detail: contributor widget (tier ring + name + navigation),
related events horizontal row; added getEventsByCategory() to
EventsService; added contributorId/Name/Tier fields to EventModel
P3-D Kerala pincodes: 463-entry JSON (all 14 districts), registered as
asset, async-loaded in SearchScreen replacing hardcoded 32 cities
P3-E Checkout: promo code field + Apply/Remove button in Step 2,
discountAmount subtracted from total, applyPromo()/resetPromo()
methods in CheckoutProvider
P3-F/G Gamification: reward cycle countdown + EP→RP progress bar (blue→
amber) in contribute + profile screens; TierAvatarRing in podium
and all leaderboard rows; GlassCard current-user stats card at
top of leaderboard tab
P3-H New ContributorProfileScreen: tier ring, stats, submission grid
with status chips; getDashboardForUser() in GamificationService;
wired from leaderboard row taps
P3-I Achievements: 11 default badges (up from 6), 6 new icon map
entries; progress % labels already confirmed present
P3-J Reviews: CustomPainter circular arc rating ring (amber, 84px)
replaces large rating number in ReviewSummary
P3-L Share rank card: RepaintBoundary → PNG capture → Share.shareXFiles;
share button wired in profile header and leaderboard tab
P3-M SafeArea audit: home bottom nav, contribute/achievements scroll
padding, profile CustomScrollView top inset
New files: tier_avatar_ring.dart, glass_card.dart,
eventify_bottom_sheet.dart, contributor_profile_screen.dart,
share_rank_card.dart, assets/data/kerala_pincodes.json
New dep: path_provider ^2.1.0
2026-04-04 17:17:36 +05:30
|
|
|
final _promoCtrl = TextEditingController();
|
feat: Phase 1 critical gaps — gamification API, Razorpay checkout, Google OAuth, notifications
- Fix gamification endpoints to use Node.js server (app.eventifyplus.com)
- Replace 6 mock gamification methods with real API calls (dashboard, leaderboard, shop, redeem, submit)
- Add booking models, service, payment service (Razorpay), checkout provider
- Add 3-step CheckoutScreen with Razorpay native modal integration
- Add Google OAuth login (Flutter + Django backend)
- Add full notifications system (Django model + 3 endpoints + Flutter UI)
- Register CheckoutProvider, NotificationProvider in main.dart MultiProvider
- Wire notification bell in HomeScreen app bar
- Add razorpay_flutter ^1.3.7 and google_sign_in ^6.2.2 packages
2026-04-04 15:46:53 +05:30
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
_paymentService = PaymentService();
|
|
|
|
|
_paymentService.initialize(
|
|
|
|
|
onSuccess: _onPaymentSuccess,
|
|
|
|
|
onError: _onPaymentError,
|
|
|
|
|
);
|
|
|
|
|
_prefillUserData();
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
|
context.read<CheckoutProvider>().initForEvent(widget.eventId, widget.eventName);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> _prefillUserData() async {
|
|
|
|
|
final prefs = await SharedPreferences.getInstance();
|
|
|
|
|
_emailCtrl.text = prefs.getString('email') ?? '';
|
|
|
|
|
_nameCtrl.text = prefs.getString('display_name') ?? '';
|
|
|
|
|
_phoneCtrl.text = prefs.getString('phone_number') ?? '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _onPaymentSuccess(dynamic response) {
|
|
|
|
|
final provider = context.read<CheckoutProvider>();
|
|
|
|
|
provider.markPaymentSuccess(response.paymentId ?? 'success');
|
|
|
|
|
Navigator.pushReplacement(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(builder: (_) => const TicketsBookedScreen()),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _onPaymentError(dynamic response) {
|
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
|
|
|
SnackBar(
|
|
|
|
|
content: Text('Payment failed: ${response.message ?? "Please try again"}'),
|
|
|
|
|
backgroundColor: Colors.red,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
_paymentService.dispose();
|
|
|
|
|
_nameCtrl.dispose();
|
|
|
|
|
_emailCtrl.dispose();
|
|
|
|
|
_phoneCtrl.dispose();
|
feat: Phase 3 — 26 medium-priority gaps implemented
P3-A/K Profile: Eventify ID glassmorphic badge (tap-to-copy), DiceBear
Notionists avatar via TierAvatarRing, district picker (14 pills)
with 183-day cooldown lock, multipart photo upload to server
P3-B Home: Top Events converted to PageView scroll-snap
(viewportFraction 0.9 + PageScrollPhysics)
P3-C Event detail: contributor widget (tier ring + name + navigation),
related events horizontal row; added getEventsByCategory() to
EventsService; added contributorId/Name/Tier fields to EventModel
P3-D Kerala pincodes: 463-entry JSON (all 14 districts), registered as
asset, async-loaded in SearchScreen replacing hardcoded 32 cities
P3-E Checkout: promo code field + Apply/Remove button in Step 2,
discountAmount subtracted from total, applyPromo()/resetPromo()
methods in CheckoutProvider
P3-F/G Gamification: reward cycle countdown + EP→RP progress bar (blue→
amber) in contribute + profile screens; TierAvatarRing in podium
and all leaderboard rows; GlassCard current-user stats card at
top of leaderboard tab
P3-H New ContributorProfileScreen: tier ring, stats, submission grid
with status chips; getDashboardForUser() in GamificationService;
wired from leaderboard row taps
P3-I Achievements: 11 default badges (up from 6), 6 new icon map
entries; progress % labels already confirmed present
P3-J Reviews: CustomPainter circular arc rating ring (amber, 84px)
replaces large rating number in ReviewSummary
P3-L Share rank card: RepaintBoundary → PNG capture → Share.shareXFiles;
share button wired in profile header and leaderboard tab
P3-M SafeArea audit: home bottom nav, contribute/achievements scroll
padding, profile CustomScrollView top inset
New files: tier_avatar_ring.dart, glass_card.dart,
eventify_bottom_sheet.dart, contributor_profile_screen.dart,
share_rank_card.dart, assets/data/kerala_pincodes.json
New dep: path_provider ^2.1.0
2026-04-04 17:17:36 +05:30
|
|
|
_promoCtrl.dispose();
|
feat: Phase 1 critical gaps — gamification API, Razorpay checkout, Google OAuth, notifications
- Fix gamification endpoints to use Node.js server (app.eventifyplus.com)
- Replace 6 mock gamification methods with real API calls (dashboard, leaderboard, shop, redeem, submit)
- Add booking models, service, payment service (Razorpay), checkout provider
- Add 3-step CheckoutScreen with Razorpay native modal integration
- Add Google OAuth login (Flutter + Django backend)
- Add full notifications system (Django model + 3 endpoints + Flutter UI)
- Register CheckoutProvider, NotificationProvider in main.dart MultiProvider
- Wire notification bell in HomeScreen app bar
- Add razorpay_flutter ^1.3.7 and google_sign_in ^6.2.2 packages
2026-04-04 15:46:53 +05:30
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: AppBar(
|
|
|
|
|
title: const Text('Checkout', style: TextStyle(fontWeight: FontWeight.w600)),
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
foregroundColor: Colors.black,
|
|
|
|
|
elevation: 0,
|
|
|
|
|
),
|
|
|
|
|
body: Consumer<CheckoutProvider>(
|
|
|
|
|
builder: (ctx, provider, _) {
|
|
|
|
|
if (provider.loading && provider.availableTickets.isEmpty) {
|
|
|
|
|
return const Center(child: CircularProgressIndicator());
|
|
|
|
|
}
|
|
|
|
|
if (provider.error != null && provider.availableTickets.isEmpty) {
|
|
|
|
|
return Center(
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
Text(provider.error!, style: const TextStyle(color: Colors.red)),
|
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
|
ElevatedButton(
|
|
|
|
|
onPressed: () => provider.initForEvent(widget.eventId, widget.eventName),
|
|
|
|
|
child: const Text('Retry'),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return Column(
|
|
|
|
|
children: [
|
|
|
|
|
_buildStepIndicator(provider),
|
|
|
|
|
Expanded(child: _buildCurrentStep(provider)),
|
|
|
|
|
_buildBottomBar(provider),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildStepIndicator(CheckoutProvider provider) {
|
|
|
|
|
final steps = ['Tickets', 'Details', 'Payment'];
|
|
|
|
|
final currentIdx = provider.currentStep.index;
|
|
|
|
|
return Container(
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
child: Row(
|
|
|
|
|
children: List.generate(steps.length, (i) {
|
|
|
|
|
final isActive = i <= currentIdx;
|
|
|
|
|
return Expanded(
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
width: 28, height: 28,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
shape: BoxShape.circle,
|
|
|
|
|
color: isActive ? const Color(0xFF0B63D6) : Colors.grey.shade300,
|
|
|
|
|
),
|
|
|
|
|
child: Center(
|
|
|
|
|
child: Text('${i + 1}', style: TextStyle(
|
|
|
|
|
color: isActive ? Colors.white : Colors.grey,
|
|
|
|
|
fontSize: 13, fontWeight: FontWeight.w600,
|
|
|
|
|
)),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 6),
|
|
|
|
|
Text(steps[i], style: TextStyle(
|
|
|
|
|
fontSize: 13,
|
|
|
|
|
fontWeight: isActive ? FontWeight.w600 : FontWeight.w400,
|
|
|
|
|
color: isActive ? Colors.black : Colors.grey,
|
|
|
|
|
)),
|
|
|
|
|
if (i < steps.length - 1) Expanded(
|
|
|
|
|
child: Container(
|
|
|
|
|
height: 1,
|
|
|
|
|
margin: const EdgeInsets.symmetric(horizontal: 8),
|
|
|
|
|
color: i < currentIdx ? const Color(0xFF0B63D6) : Colors.grey.shade300,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildCurrentStep(CheckoutProvider provider) {
|
|
|
|
|
switch (provider.currentStep) {
|
|
|
|
|
case CheckoutStep.tickets:
|
|
|
|
|
return _buildTicketSelection(provider);
|
|
|
|
|
case CheckoutStep.details:
|
|
|
|
|
return _buildDetailsForm(provider);
|
|
|
|
|
case CheckoutStep.payment:
|
|
|
|
|
return _buildPaymentReview(provider);
|
|
|
|
|
case CheckoutStep.confirmation:
|
|
|
|
|
return const Center(child: Text('Booking confirmed!'));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildTicketSelection(CheckoutProvider provider) {
|
|
|
|
|
if (provider.availableTickets.isEmpty) {
|
|
|
|
|
return const Center(child: Text('No tickets available for this event.'));
|
|
|
|
|
}
|
|
|
|
|
return ListView(
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
children: [
|
|
|
|
|
Text(widget.eventName, style: const TextStyle(fontSize: 20, fontWeight: FontWeight.w700)),
|
|
|
|
|
const SizedBox(height: 20),
|
|
|
|
|
...provider.availableTickets.map((ticket) {
|
|
|
|
|
final cartMatches = provider.cart.where((c) => c.ticket.id == ticket.id);
|
|
|
|
|
final cartItem = cartMatches.isNotEmpty ? cartMatches.first : null;
|
|
|
|
|
final qty = cartItem?.quantity ?? 0;
|
|
|
|
|
return Container(
|
|
|
|
|
margin: const EdgeInsets.only(bottom: 12),
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
border: Border.all(color: qty > 0 ? const Color(0xFF0B63D6) : Colors.grey.shade200),
|
|
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(ticket.ticketType, style: const TextStyle(fontWeight: FontWeight.w600, fontSize: 16)),
|
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
|
Text('Rs ${ticket.price.toStringAsFixed(0)}', style: const TextStyle(color: Color(0xFF0B63D6), fontWeight: FontWeight.w700, fontSize: 18)),
|
|
|
|
|
if (ticket.description != null) ...[
|
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
|
Text(ticket.description!, style: TextStyle(color: Colors.grey.shade600, fontSize: 13)),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: const Icon(Icons.remove_circle_outline),
|
|
|
|
|
onPressed: qty > 0 ? () => provider.setTicketQuantity(ticket, qty - 1) : null,
|
|
|
|
|
),
|
|
|
|
|
Text('$qty', style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600)),
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: const Icon(Icons.add_circle_outline, color: Color(0xFF0B63D6)),
|
|
|
|
|
onPressed: qty < ticket.availableQuantity
|
|
|
|
|
? () => provider.setTicketQuantity(ticket, qty + 1)
|
|
|
|
|
: null,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildDetailsForm(CheckoutProvider provider) {
|
|
|
|
|
return SingleChildScrollView(
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
child: Form(
|
|
|
|
|
key: _formKey,
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
const Text('Contact Details', style: TextStyle(fontSize: 18, fontWeight: FontWeight.w700)),
|
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
|
_field('Full Name', _nameCtrl, validator: (v) => v!.isEmpty ? 'Required' : null),
|
|
|
|
|
_field('Email', _emailCtrl, type: TextInputType.emailAddress, validator: (v) => v!.isEmpty ? 'Required' : null),
|
|
|
|
|
_field('Phone', _phoneCtrl, type: TextInputType.phone, validator: (v) => v!.isEmpty ? 'Required' : null),
|
feat: Phase 3 — 26 medium-priority gaps implemented
P3-A/K Profile: Eventify ID glassmorphic badge (tap-to-copy), DiceBear
Notionists avatar via TierAvatarRing, district picker (14 pills)
with 183-day cooldown lock, multipart photo upload to server
P3-B Home: Top Events converted to PageView scroll-snap
(viewportFraction 0.9 + PageScrollPhysics)
P3-C Event detail: contributor widget (tier ring + name + navigation),
related events horizontal row; added getEventsByCategory() to
EventsService; added contributorId/Name/Tier fields to EventModel
P3-D Kerala pincodes: 463-entry JSON (all 14 districts), registered as
asset, async-loaded in SearchScreen replacing hardcoded 32 cities
P3-E Checkout: promo code field + Apply/Remove button in Step 2,
discountAmount subtracted from total, applyPromo()/resetPromo()
methods in CheckoutProvider
P3-F/G Gamification: reward cycle countdown + EP→RP progress bar (blue→
amber) in contribute + profile screens; TierAvatarRing in podium
and all leaderboard rows; GlassCard current-user stats card at
top of leaderboard tab
P3-H New ContributorProfileScreen: tier ring, stats, submission grid
with status chips; getDashboardForUser() in GamificationService;
wired from leaderboard row taps
P3-I Achievements: 11 default badges (up from 6), 6 new icon map
entries; progress % labels already confirmed present
P3-J Reviews: CustomPainter circular arc rating ring (amber, 84px)
replaces large rating number in ReviewSummary
P3-L Share rank card: RepaintBoundary → PNG capture → Share.shareXFiles;
share button wired in profile header and leaderboard tab
P3-M SafeArea audit: home bottom nav, contribute/achievements scroll
padding, profile CustomScrollView top inset
New files: tier_avatar_ring.dart, glass_card.dart,
eventify_bottom_sheet.dart, contributor_profile_screen.dart,
share_rank_card.dart, assets/data/kerala_pincodes.json
New dep: path_provider ^2.1.0
2026-04-04 17:17:36 +05:30
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
Consumer<CheckoutProvider>(
|
|
|
|
|
builder: (context, provider, _) {
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: _promoCtrl,
|
|
|
|
|
textCapitalization: TextCapitalization.characters,
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
labelText: 'Promo Code (optional)',
|
|
|
|
|
border: OutlineInputBorder(borderRadius: BorderRadius.circular(10)),
|
|
|
|
|
filled: true,
|
|
|
|
|
fillColor: Colors.grey.shade50,
|
|
|
|
|
suffixIcon: provider.promoApplied
|
|
|
|
|
? const Icon(Icons.check_circle, color: Colors.green, size: 20)
|
|
|
|
|
: null,
|
|
|
|
|
),
|
|
|
|
|
enabled: !provider.promoApplied,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 8),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 56,
|
|
|
|
|
child: provider.promoApplied
|
|
|
|
|
? OutlinedButton(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
provider.resetPromo();
|
|
|
|
|
_promoCtrl.clear();
|
|
|
|
|
},
|
|
|
|
|
style: OutlinedButton.styleFrom(foregroundColor: Colors.red),
|
|
|
|
|
child: const Text('Remove'),
|
|
|
|
|
)
|
|
|
|
|
: ElevatedButton(
|
|
|
|
|
onPressed: provider.loading
|
|
|
|
|
? null
|
|
|
|
|
: () async {
|
|
|
|
|
final ok = await provider.applyPromo(_promoCtrl.text);
|
|
|
|
|
if (mounted) {
|
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
|
|
|
SnackBar(
|
|
|
|
|
content: Text(provider.promoMessage ??
|
|
|
|
|
(ok ? 'Promo applied!' : 'Invalid promo code')),
|
|
|
|
|
backgroundColor: ok ? Colors.green : Colors.red,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
|
backgroundColor: const Color(0xFF0B63D6),
|
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
|
),
|
|
|
|
|
child: const Text('Apply'),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
if (provider.promoApplied && provider.promoMessage != null) ...[
|
|
|
|
|
const SizedBox(height: 6),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
const Icon(Icons.local_offer, size: 14, color: Colors.green),
|
|
|
|
|
const SizedBox(width: 4),
|
|
|
|
|
Text(
|
|
|
|
|
'${provider.promoMessage} — saves \u20b9${provider.discountAmount.toStringAsFixed(0)}',
|
|
|
|
|
style: const TextStyle(fontSize: 12, color: Colors.green),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
feat: Phase 1 critical gaps — gamification API, Razorpay checkout, Google OAuth, notifications
- Fix gamification endpoints to use Node.js server (app.eventifyplus.com)
- Replace 6 mock gamification methods with real API calls (dashboard, leaderboard, shop, redeem, submit)
- Add booking models, service, payment service (Razorpay), checkout provider
- Add 3-step CheckoutScreen with Razorpay native modal integration
- Add Google OAuth login (Flutter + Django backend)
- Add full notifications system (Django model + 3 endpoints + Flutter UI)
- Register CheckoutProvider, NotificationProvider in main.dart MultiProvider
- Wire notification bell in HomeScreen app bar
- Add razorpay_flutter ^1.3.7 and google_sign_in ^6.2.2 packages
2026-04-04 15:46:53 +05:30
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _field(String label, TextEditingController ctrl, {TextInputType? type, String? Function(String?)? validator}) {
|
|
|
|
|
return Padding(
|
|
|
|
|
padding: const EdgeInsets.only(bottom: 16),
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: ctrl,
|
|
|
|
|
keyboardType: type,
|
|
|
|
|
validator: validator,
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
labelText: label,
|
|
|
|
|
border: OutlineInputBorder(borderRadius: BorderRadius.circular(10)),
|
|
|
|
|
filled: true,
|
|
|
|
|
fillColor: Colors.grey.shade50,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildPaymentReview(CheckoutProvider provider) {
|
|
|
|
|
return ListView(
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
children: [
|
|
|
|
|
const Text('Order Summary', style: TextStyle(fontSize: 18, fontWeight: FontWeight.w700)),
|
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
|
...provider.cart.map((item) => Padding(
|
|
|
|
|
padding: const EdgeInsets.only(bottom: 8),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
Text('${item.ticket.ticketType} x${item.quantity}'),
|
|
|
|
|
Text('Rs ${item.subtotal.toStringAsFixed(0)}', style: const TextStyle(fontWeight: FontWeight.w600)),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
const Divider(height: 32),
|
feat: Phase 3 — 26 medium-priority gaps implemented
P3-A/K Profile: Eventify ID glassmorphic badge (tap-to-copy), DiceBear
Notionists avatar via TierAvatarRing, district picker (14 pills)
with 183-day cooldown lock, multipart photo upload to server
P3-B Home: Top Events converted to PageView scroll-snap
(viewportFraction 0.9 + PageScrollPhysics)
P3-C Event detail: contributor widget (tier ring + name + navigation),
related events horizontal row; added getEventsByCategory() to
EventsService; added contributorId/Name/Tier fields to EventModel
P3-D Kerala pincodes: 463-entry JSON (all 14 districts), registered as
asset, async-loaded in SearchScreen replacing hardcoded 32 cities
P3-E Checkout: promo code field + Apply/Remove button in Step 2,
discountAmount subtracted from total, applyPromo()/resetPromo()
methods in CheckoutProvider
P3-F/G Gamification: reward cycle countdown + EP→RP progress bar (blue→
amber) in contribute + profile screens; TierAvatarRing in podium
and all leaderboard rows; GlassCard current-user stats card at
top of leaderboard tab
P3-H New ContributorProfileScreen: tier ring, stats, submission grid
with status chips; getDashboardForUser() in GamificationService;
wired from leaderboard row taps
P3-I Achievements: 11 default badges (up from 6), 6 new icon map
entries; progress % labels already confirmed present
P3-J Reviews: CustomPainter circular arc rating ring (amber, 84px)
replaces large rating number in ReviewSummary
P3-L Share rank card: RepaintBoundary → PNG capture → Share.shareXFiles;
share button wired in profile header and leaderboard tab
P3-M SafeArea audit: home bottom nav, contribute/achievements scroll
padding, profile CustomScrollView top inset
New files: tier_avatar_ring.dart, glass_card.dart,
eventify_bottom_sheet.dart, contributor_profile_screen.dart,
share_rank_card.dart, assets/data/kerala_pincodes.json
New dep: path_provider ^2.1.0
2026-04-04 17:17:36 +05:30
|
|
|
if (provider.promoApplied) ...[
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
Text('Subtotal', style: TextStyle(color: Colors.grey.shade700)),
|
|
|
|
|
Text('Rs ${provider.subtotal.toStringAsFixed(0)}', style: TextStyle(color: Colors.grey.shade700)),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
const Icon(Icons.local_offer, size: 14, color: Colors.green),
|
|
|
|
|
const SizedBox(width: 4),
|
|
|
|
|
Text(
|
|
|
|
|
provider.couponCode != null ? 'Promo (${provider.couponCode})' : 'Promo discount',
|
|
|
|
|
style: const TextStyle(color: Colors.green),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Text('- Rs ${provider.discountAmount.toStringAsFixed(0)}',
|
|
|
|
|
style: const TextStyle(color: Colors.green, fontWeight: FontWeight.w600)),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
],
|
feat: Phase 1 critical gaps — gamification API, Razorpay checkout, Google OAuth, notifications
- Fix gamification endpoints to use Node.js server (app.eventifyplus.com)
- Replace 6 mock gamification methods with real API calls (dashboard, leaderboard, shop, redeem, submit)
- Add booking models, service, payment service (Razorpay), checkout provider
- Add 3-step CheckoutScreen with Razorpay native modal integration
- Add Google OAuth login (Flutter + Django backend)
- Add full notifications system (Django model + 3 endpoints + Flutter UI)
- Register CheckoutProvider, NotificationProvider in main.dart MultiProvider
- Wire notification bell in HomeScreen app bar
- Add razorpay_flutter ^1.3.7 and google_sign_in ^6.2.2 packages
2026-04-04 15:46:53 +05:30
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
const Text('Total', style: TextStyle(fontSize: 18, fontWeight: FontWeight.w700)),
|
|
|
|
|
Text('Rs ${provider.total.toStringAsFixed(0)}', style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w700, color: Color(0xFF0B63D6))),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 24),
|
|
|
|
|
if (_nameCtrl.text.isNotEmpty) ...[
|
|
|
|
|
Text('Name: ${_nameCtrl.text}', style: TextStyle(color: Colors.grey.shade700)),
|
|
|
|
|
Text('Email: ${_emailCtrl.text}', style: TextStyle(color: Colors.grey.shade700)),
|
|
|
|
|
Text('Phone: ${_phoneCtrl.text}', style: TextStyle(color: Colors.grey.shade700)),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildBottomBar(CheckoutProvider provider) {
|
|
|
|
|
return Container(
|
|
|
|
|
padding: EdgeInsets.fromLTRB(16, 12, 16, MediaQuery.of(context).padding.bottom + 12),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.08), blurRadius: 12, offset: const Offset(0, -4))],
|
|
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
if (provider.currentStep != CheckoutStep.tickets)
|
|
|
|
|
TextButton(
|
|
|
|
|
onPressed: provider.previousStep,
|
|
|
|
|
child: const Text('Back'),
|
|
|
|
|
),
|
|
|
|
|
const Spacer(),
|
|
|
|
|
if (provider.currentStep == CheckoutStep.tickets)
|
|
|
|
|
ElevatedButton(
|
|
|
|
|
onPressed: provider.hasItems ? provider.nextStep : null,
|
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
|
backgroundColor: const Color(0xFF0B63D6),
|
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 14),
|
|
|
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
|
|
|
|
),
|
|
|
|
|
child: Text('Continue Rs ${provider.subtotal.toStringAsFixed(0)}'),
|
|
|
|
|
)
|
|
|
|
|
else if (provider.currentStep == CheckoutStep.details)
|
|
|
|
|
ElevatedButton(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
if (_formKey.currentState?.validate() ?? false) {
|
|
|
|
|
provider.setShipping(ShippingDetails(
|
|
|
|
|
name: _nameCtrl.text,
|
|
|
|
|
email: _emailCtrl.text,
|
|
|
|
|
phone: _phoneCtrl.text,
|
|
|
|
|
));
|
|
|
|
|
provider.nextStep();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
|
backgroundColor: const Color(0xFF0B63D6),
|
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 14),
|
|
|
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
|
|
|
|
),
|
|
|
|
|
child: const Text('Review Order'),
|
|
|
|
|
)
|
|
|
|
|
else if (provider.currentStep == CheckoutStep.payment)
|
|
|
|
|
ElevatedButton(
|
|
|
|
|
onPressed: provider.loading ? null : () => _processPayment(provider),
|
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
|
backgroundColor: const Color(0xFF0B63D6),
|
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 14),
|
|
|
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
|
|
|
|
),
|
|
|
|
|
child: provider.loading
|
|
|
|
|
? const SizedBox(width: 20, height: 20, child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white))
|
|
|
|
|
: Text('Pay Rs ${provider.total.toStringAsFixed(0)}'),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> _processPayment(CheckoutProvider provider) async {
|
|
|
|
|
try {
|
|
|
|
|
await provider.processCheckout();
|
|
|
|
|
_paymentService.openPayment(
|
|
|
|
|
amount: provider.total,
|
|
|
|
|
email: _emailCtrl.text,
|
|
|
|
|
phone: _phoneCtrl.text,
|
|
|
|
|
eventName: widget.eventName,
|
|
|
|
|
);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
|
|
|
SnackBar(content: Text(userFriendlyError(e)), backgroundColor: Colors.red),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|