feat: Phase 2 — 11 high-priority gaps implemented across home, auth, gamification, profile, and event detail

Phase 2 gaps completed:
- HOME-001: Hero slider pause-on-touch (GestureDetector wraps PageView)
- HOME-003: Calendar bottom sheet with TableCalendar (replaces custom dialog)
- AUTH-004: District dropdown on signup (14 Kerala districts)
- EVT-003: Mobile sticky "Book Now" bar + desktop CTA wired to CheckoutScreen
- ACH-001: Real achievements from dashboard API with fallback defaults
- GAM-002: 3-card EP row (Lifetime EP / Liquid EP / Reward Points)
- GAM-005: Horizontal tier roadmap Bronze→Silver→Gold→Platinum→Diamond
- CTR-001: Submission status chips (PENDING/APPROVED/REJECTED)
- CTR-002: +EP badge on approved submissions
- PROF-003: Gamification cards on profile screen with Consumer<GamificationProvider>
- UX-001: Shimmer skeleton loaders (shimmer ^3.0.0) replacing CircularProgressIndicator

Already complete (verified, no changes needed):
- HOME-002: Category shelves already built in _buildTypeSection()
- LDR-002: Podium visualization already built (_buildPodium / _buildDesktopPodium)
- BOOK-004: UPI handled natively by Razorpay SDK

Deferred: LOC-001/002 (needs Django haversine endpoint)
Skipped: AUTH-002 (OTP needs SMS provider decision)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-04 16:51:30 +05:30
parent 8955febd00
commit e365361451
12 changed files with 715 additions and 250 deletions

View File

@@ -7,6 +7,7 @@ import 'package:shared_preferences/shared_preferences.dart';
import '../core/auth/auth_guard.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:intl/intl.dart';
import 'package:table_calendar/table_calendar.dart';
import '../features/events/models/event_models.dart';
import '../features/events/services/events_service.dart';
@@ -22,6 +23,7 @@ import 'package:provider/provider.dart';
import '../features/gamification/providers/gamification_provider.dart';
import '../features/notifications/widgets/notification_bell.dart';
import '../features/notifications/providers/notification_provider.dart';
import '../widgets/skeleton_loader.dart';
class HomeScreen extends StatefulWidget {
const HomeScreen({Key? key}) : super(key: key);
@@ -660,7 +662,7 @@ class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateM
Future<void> _onDateChipTap(String label) async {
if (label == 'Date') {
// Open custom calendar dialog
final picked = await _showCalendarDialog();
final picked = await _showCalendarBottomSheet();
if (picked != null) {
setState(() {
_selectedCustomDate = picked;
@@ -963,173 +965,141 @@ class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateM
return dates;
}
/// Show a custom calendar dialog matching the app design.
Future<DateTime?> _showCalendarDialog() {
DateTime viewMonth = _selectedCustomDate ?? DateTime.now();
DateTime? selected = _selectedCustomDate;
/// Show a calendar bottom sheet with TableCalendar for date filtering.
Future<DateTime?> _showCalendarBottomSheet() {
DateTime focusedDay = _selectedCustomDate ?? DateTime.now();
DateTime? selectedDay = _selectedCustomDate;
final eventDates = _eventDates;
return showDialog<DateTime>(
return showModalBottomSheet<DateTime>(
context: context,
barrierColor: Colors.black54,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (ctx) {
return StatefulBuilder(builder: (ctx, setDialogState) {
final now = DateTime.now();
final today = DateTime(now.year, now.month, now.day);
return StatefulBuilder(builder: (ctx, setSheetState) {
final theme = Theme.of(ctx);
final isDark = theme.brightness == Brightness.dark;
// Calendar calculations
final firstDayOfMonth = DateTime(viewMonth.year, viewMonth.month, 1);
final daysInMonth = DateTime(viewMonth.year, viewMonth.month + 1, 0).day;
final startWeekday = firstDayOfMonth.weekday; // 1=Mon
const months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
const dayHeaders = ['M', 'T', 'W', 'T', 'F', 'S', 'S'];
return Center(
child: Container(
margin: const EdgeInsets.symmetric(horizontal: 28),
padding: const EdgeInsets.fromLTRB(20, 24, 20, 20),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(24),
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.15), blurRadius: 20, offset: const Offset(0, 8))],
),
child: Material(
color: Colors.transparent,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// Month navigation
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
_calendarNavButton(Icons.chevron_left, () {
setDialogState(() {
viewMonth = DateTime(viewMonth.year, viewMonth.month - 1, 1);
});
}),
Text(
'${months[viewMonth.month - 1]} ${viewMonth.year}',
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: Color(0xFF1A1A2E)),
),
_calendarNavButton(Icons.chevron_right, () {
setDialogState(() {
viewMonth = DateTime(viewMonth.year, viewMonth.month + 1, 1);
});
}),
],
return Container(
decoration: BoxDecoration(
color: isDark ? const Color(0xFF1E1E2E) : Colors.white,
borderRadius: const BorderRadius.vertical(top: Radius.circular(24)),
),
padding: const EdgeInsets.fromLTRB(16, 8, 16, 20),
child: SafeArea(
top: false,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// Drag handle
Container(
width: 40,
height: 4,
margin: const EdgeInsets.only(bottom: 16),
decoration: BoxDecoration(
color: Colors.grey[400],
borderRadius: BorderRadius.circular(2),
),
const SizedBox(height: 20),
),
// Day of week headers
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: dayHeaders.map((d) => SizedBox(
width: 36,
child: Center(child: Text(d, style: TextStyle(color: Colors.grey[500], fontWeight: FontWeight.w600, fontSize: 13))),
)).toList(),
// TableCalendar
TableCalendar(
firstDay: DateTime(2020),
lastDay: DateTime(2030),
focusedDay: focusedDay,
selectedDayPredicate: (day) =>
selectedDay != null && isSameDay(day, selectedDay),
onDaySelected: (selected, focused) {
setSheetState(() {
selectedDay = selected;
focusedDay = focused;
});
},
onPageChanged: (focused) {
setSheetState(() => focusedDay = focused);
},
eventLoader: (day) {
final normalized = DateTime(day.year, day.month, day.day);
return eventDates.contains(normalized) ? [true] : [];
},
startingDayOfWeek: StartingDayOfWeek.monday,
headerStyle: HeaderStyle(
formatButtonVisible: false,
titleCentered: true,
titleTextStyle: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: isDark ? Colors.white : const Color(0xFF1A1A2E),
),
leftChevronIcon: Icon(Icons.chevron_left,
color: isDark ? Colors.white70 : const Color(0xFF374151)),
rightChevronIcon: Icon(Icons.chevron_right,
color: isDark ? Colors.white70 : const Color(0xFF374151)),
),
const SizedBox(height: 12),
// Calendar grid
...List.generate(6, (weekRow) {
return Padding(
padding: const EdgeInsets.only(bottom: 4),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: List.generate(7, (weekCol) {
final cellIndex = weekRow * 7 + weekCol;
final dayNum = cellIndex - (startWeekday - 1) + 1;
if (dayNum < 1 || dayNum > daysInMonth) {
return const SizedBox(width: 36, height: 44);
}
final cellDate = DateTime(viewMonth.year, viewMonth.month, dayNum);
final isToday = cellDate == today;
final isSelected = selected != null &&
cellDate.year == selected!.year &&
cellDate.month == selected!.month &&
cellDate.day == selected!.day;
final hasEvent = eventDates.contains(cellDate);
return GestureDetector(
onTap: () {
setDialogState(() => selected = cellDate);
},
child: SizedBox(
width: 36,
height: 44,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 34,
height: 34,
decoration: BoxDecoration(
color: isSelected
? const Color(0xFF2563EB)
: Colors.transparent,
shape: BoxShape.circle,
border: isToday && !isSelected
? Border.all(color: const Color(0xFF2563EB), width: 1.5)
: null,
),
child: Center(
child: Text(
'$dayNum',
style: TextStyle(
fontSize: 15,
fontWeight: (isToday || isSelected) ? FontWeight.w700 : FontWeight.w500,
color: isSelected
? Colors.white
: isToday
? const Color(0xFF2563EB)
: const Color(0xFF374151),
),
),
),
),
// Event dot
if (hasEvent)
Container(
width: 5,
height: 5,
decoration: BoxDecoration(
color: isSelected ? Colors.white : const Color(0xFFEF4444),
shape: BoxShape.circle,
),
)
else
const SizedBox(height: 5),
],
),
),
);
}),
),
);
}),
const SizedBox(height: 12),
// Done button
SizedBox(
width: 160,
height: 48,
child: ElevatedButton(
onPressed: () => Navigator.of(ctx).pop(selected),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF2563EB),
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
elevation: 0,
),
child: const Text('Done', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600)),
calendarStyle: CalendarStyle(
selectedDecoration: const BoxDecoration(
color: Color(0xFF2563EB),
shape: BoxShape.circle,
),
todayDecoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(color: const Color(0xFF2563EB), width: 1.5),
),
todayTextStyle: const TextStyle(
color: Color(0xFF2563EB),
fontWeight: FontWeight.w700,
),
defaultTextStyle: TextStyle(
color: isDark ? Colors.white : const Color(0xFF374151),
),
weekendTextStyle: TextStyle(
color: isDark ? Colors.white70 : const Color(0xFF374151),
),
outsideTextStyle: TextStyle(
color: isDark ? Colors.white24 : Colors.grey[400]!,
),
markerDecoration: const BoxDecoration(
color: Color(0xFFEF4444),
shape: BoxShape.circle,
),
markerSize: 5,
markersMaxCount: 1,
),
daysOfWeekStyle: DaysOfWeekStyle(
weekdayStyle: TextStyle(
color: isDark ? Colors.white54 : Colors.grey[500],
fontWeight: FontWeight.w600,
fontSize: 13,
),
weekendStyle: TextStyle(
color: isDark ? Colors.white54 : Colors.grey[500],
fontWeight: FontWeight.w600,
fontSize: 13,
),
),
],
),
),
const SizedBox(height: 16),
// Done button
SizedBox(
width: 160,
height: 48,
child: ElevatedButton(
onPressed: () => Navigator.of(ctx).pop(selectedDay),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF2563EB),
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24)),
elevation: 0,
),
child: const Text('Done',
style: TextStyle(
fontSize: 16, fontWeight: FontWeight.w600)),
),
),
],
),
),
);
@@ -1138,22 +1108,6 @@ class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateM
);
}
Widget _calendarNavButton(IconData icon, VoidCallback onTap) {
return InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(20),
child: Container(
width: 40,
height: 40,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(color: Colors.grey[300]!),
),
child: Icon(icon, color: const Color(0xFF374151), size: 22),
),
);
}
Widget _buildHomeContent() {
return Container(
decoration: const BoxDecoration(
@@ -1268,32 +1222,38 @@ class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateM
: Column(
children: [
RepaintBoundary(
child: SizedBox(
height: 320,
child: PageView.builder(
controller: _heroPageController,
onPageChanged: (page) {
_heroPageNotifier.value = page;
// 8s delay after manual swipe for full read time
_startAutoScroll(delay: const Duration(seconds: 8));
},
itemCount: _heroEvents.length,
itemBuilder: (context, index) {
// Scale animation: active card = 1.0, adjacent = 0.94
return AnimatedBuilder(
animation: _heroPageController,
builder: (context, child) {
double scale = index == _heroPageNotifier.value ? 1.0 : 0.94;
if (_heroPageController.position.haveDimensions) {
scale = (1.0 -
(_heroPageController.page! - index).abs() * 0.06)
.clamp(0.94, 1.0);
}
return Transform.scale(scale: scale, child: child);
},
child: _buildHeroEventImage(_heroEvents[index]),
);
},
child: GestureDetector(
behavior: HitTestBehavior.translucent,
onPanDown: (_) => _autoScrollTimer?.cancel(),
onPanEnd: (_) => _startAutoScroll(delay: const Duration(seconds: 3)),
onPanCancel: () => _startAutoScroll(delay: const Duration(seconds: 3)),
child: SizedBox(
height: 320,
child: PageView.builder(
controller: _heroPageController,
onPageChanged: (page) {
_heroPageNotifier.value = page;
// 8s delay after manual swipe for full read time
_startAutoScroll(delay: const Duration(seconds: 8));
},
itemCount: _heroEvents.length,
itemBuilder: (context, index) {
// Scale animation: active card = 1.0, adjacent = 0.94
return AnimatedBuilder(
animation: _heroPageController,
builder: (context, child) {
double scale = index == _heroPageNotifier.value ? 1.0 : 0.94;
if (_heroPageController.position.haveDimensions) {
scale = (1.0 -
(_heroPageController.page! - index).abs() * 0.06)
.clamp(0.94, 1.0);
}
return Transform.scale(scale: scale, child: child);
},
child: _buildHeroEventImage(_heroEvents[index]),
);
},
),
),
),
),
@@ -1566,7 +1526,7 @@ class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateM
SizedBox(
height: 200,
child: _allFilteredByDate.isEmpty && _loading
? const Center(child: CircularProgressIndicator())
? Row(children: List.generate(3, (_) => const Padding(padding: EdgeInsets.only(right: 12), child: EventCardSkeleton())))
: _allFilteredByDate.isEmpty
? Center(child: Text(
_selectedDateFilter.isNotEmpty ? 'No events for "$_selectedDateFilter"' : 'No events found',
@@ -1660,9 +1620,9 @@ class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateM
// Event sections — shelves (All) or filtered list (specific category)
if (_loading)
const Padding(
padding: EdgeInsets.all(40),
child: Center(child: CircularProgressIndicator()),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20),
child: Column(children: List.generate(3, (_) => const Padding(padding: EdgeInsets.only(bottom: 8), child: EventListSkeleton()))),
)
else if (_allFilteredByDate.isEmpty && _selectedDateFilter.isNotEmpty)
Padding(