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
272 lines
8.0 KiB
Dart
272 lines
8.0 KiB
Dart
// lib/screens/contributor_profile_screen.dart
|
|
// CTR-004 — Public contributor profile page.
|
|
// Shows avatar, tier ring, EP stats, and submission grid for any contributor.
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../features/gamification/models/gamification_models.dart';
|
|
import '../features/gamification/services/gamification_service.dart';
|
|
import '../widgets/tier_avatar_ring.dart';
|
|
|
|
class ContributorProfileScreen extends StatefulWidget {
|
|
final String contributorId;
|
|
final String contributorName;
|
|
|
|
const ContributorProfileScreen({
|
|
super.key,
|
|
required this.contributorId,
|
|
required this.contributorName,
|
|
});
|
|
|
|
@override
|
|
State<ContributorProfileScreen> createState() => _ContributorProfileScreenState();
|
|
}
|
|
|
|
class _ContributorProfileScreenState extends State<ContributorProfileScreen> {
|
|
DashboardResponse? _data;
|
|
bool _loading = true;
|
|
String? _error;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_load();
|
|
}
|
|
|
|
Future<void> _load() async {
|
|
try {
|
|
final data = await GamificationService().getDashboardForUser(widget.contributorId);
|
|
if (mounted) {
|
|
setState(() {
|
|
_data = data;
|
|
_loading = false;
|
|
});
|
|
}
|
|
} catch (_) {
|
|
if (mounted) {
|
|
setState(() {
|
|
_error = 'Could not load profile';
|
|
_loading = false;
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: const Color(0xFF0F172A),
|
|
appBar: AppBar(
|
|
backgroundColor: const Color(0xFF0F172A),
|
|
foregroundColor: Colors.white,
|
|
title: Text(
|
|
widget.contributorName,
|
|
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
|
|
),
|
|
elevation: 0,
|
|
),
|
|
body: _loading
|
|
? const Center(
|
|
child: CircularProgressIndicator(color: Color(0xFF3B82F6)),
|
|
)
|
|
: _error != null
|
|
? Center(
|
|
child: Text(
|
|
_error!,
|
|
style: const TextStyle(color: Colors.white54),
|
|
),
|
|
)
|
|
: _buildContent(),
|
|
);
|
|
}
|
|
|
|
Widget _buildContent() {
|
|
final profile = _data!.profile;
|
|
final submissions = _data!.submissions;
|
|
final tierStr = tierLabel(profile.tier);
|
|
|
|
return CustomScrollView(
|
|
slivers: [
|
|
SliverToBoxAdapter(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(24),
|
|
child: Column(
|
|
children: [
|
|
// Avatar with tier ring
|
|
TierAvatarRing(
|
|
username: widget.contributorName,
|
|
tier: tierStr,
|
|
size: 88,
|
|
),
|
|
const SizedBox(height: 12),
|
|
Text(
|
|
widget.contributorName,
|
|
style: const TextStyle(
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.w700,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
const SizedBox(height: 4),
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 3),
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFF1E3A8A),
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: Text(
|
|
tierStr,
|
|
style: const TextStyle(fontSize: 12, color: Color(0xFF93C5FD)),
|
|
),
|
|
),
|
|
const SizedBox(height: 16),
|
|
// Stats row
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
children: [
|
|
_statCard('EP', '${profile.currentEp}'),
|
|
_statCard('Events', '${submissions.length}'),
|
|
_statCard(
|
|
'Approved',
|
|
'${submissions.where((s) => s.status.toUpperCase() == 'APPROVED').length}',
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
if (submissions.isNotEmpty)
|
|
SliverPadding(
|
|
padding: const EdgeInsets.fromLTRB(12, 8, 12, 24),
|
|
sliver: SliverGrid(
|
|
delegate: SliverChildBuilderDelegate(
|
|
(context, i) => _buildSubmissionTile(submissions[i]),
|
|
childCount: submissions.length,
|
|
),
|
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
|
crossAxisCount: 2,
|
|
crossAxisSpacing: 8,
|
|
mainAxisSpacing: 8,
|
|
childAspectRatio: 1.1,
|
|
),
|
|
),
|
|
)
|
|
else
|
|
const SliverToBoxAdapter(
|
|
child: Center(
|
|
child: Padding(
|
|
padding: EdgeInsets.all(32),
|
|
child: Text(
|
|
'No submissions yet',
|
|
style: TextStyle(color: Colors.white38),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _statCard(String label, String value) {
|
|
return Column(
|
|
children: [
|
|
Text(
|
|
value,
|
|
style: const TextStyle(
|
|
fontSize: 22,
|
|
fontWeight: FontWeight.w800,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
const SizedBox(height: 2),
|
|
Text(
|
|
label,
|
|
style: const TextStyle(fontSize: 12, color: Color(0xFF94A3B8)),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildSubmissionTile(SubmissionModel s) {
|
|
final Color statusColor;
|
|
switch (s.status.toUpperCase()) {
|
|
case 'APPROVED':
|
|
statusColor = const Color(0xFF22C55E);
|
|
break;
|
|
case 'REJECTED':
|
|
statusColor = const Color(0xFFEF4444);
|
|
break;
|
|
default:
|
|
statusColor = const Color(0xFFFBBF24); // PENDING
|
|
}
|
|
|
|
// SubmissionModel.images is List<String>; use first image if present.
|
|
final String? firstImage = s.images.isNotEmpty ? s.images.first : null;
|
|
|
|
return Container(
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFF1E293B),
|
|
borderRadius: BorderRadius.circular(10),
|
|
),
|
|
child: Stack(
|
|
children: [
|
|
if (firstImage != null && firstImage.isNotEmpty)
|
|
ClipRRect(
|
|
borderRadius: BorderRadius.circular(10),
|
|
child: SizedBox.expand(
|
|
child: Image.network(
|
|
firstImage,
|
|
fit: BoxFit.cover,
|
|
errorBuilder: (_, __, ___) => Container(color: const Color(0xFF334155)),
|
|
),
|
|
),
|
|
),
|
|
Positioned(
|
|
top: 6,
|
|
right: 6,
|
|
child: Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
|
decoration: BoxDecoration(
|
|
color: statusColor.withOpacity(0.9),
|
|
borderRadius: BorderRadius.circular(6),
|
|
),
|
|
child: Text(
|
|
s.status,
|
|
style: const TextStyle(
|
|
fontSize: 9,
|
|
color: Colors.white,
|
|
fontWeight: FontWeight.w700,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
if (s.eventName.isNotEmpty)
|
|
Positioned(
|
|
bottom: 0,
|
|
left: 0,
|
|
right: 0,
|
|
child: Container(
|
|
padding: const EdgeInsets.all(6),
|
|
decoration: const BoxDecoration(
|
|
gradient: LinearGradient(
|
|
begin: Alignment.bottomCenter,
|
|
end: Alignment.topCenter,
|
|
colors: [Colors.black87, Colors.transparent],
|
|
),
|
|
borderRadius: BorderRadius.vertical(bottom: Radius.circular(10)),
|
|
),
|
|
child: Text(
|
|
s.eventName,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: const TextStyle(fontSize: 10, color: Colors.white),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|