This commit is contained in:
Rishad7594
2026-04-08 08:00:33 +05:30
parent 4c57391bbd
commit d921ac2b78
4 changed files with 650 additions and 198 deletions

View File

@@ -44,7 +44,7 @@ const _districts = [
'Malappuram', 'Kozhikode', 'Wayanad', 'Kannur', 'Kasaragod', 'Other',
];
const _categories = [
const _categories_fallback = [
'Music', 'Food', 'Arts', 'Sports', 'Tech', 'Community',
'Dance', 'Film', 'Business', 'Health', 'Education', 'Other',
];
@@ -88,7 +88,7 @@ class _ContributeScreenState extends State<ContributeScreen>
DateTime? _selectedDate;
TimeOfDay? _selectedTime;
String _selectedCategory = _categories.first;
String _selectedCategory = 'Music';
String _selectedDistrict = _districts.first;
List<XFile> _images = [];
bool _submitting = false;
@@ -135,6 +135,13 @@ class _ContributeScreenState extends State<ContributeScreen>
body: Center(child: BouncingLoader(color: Colors.white)),
);
}
// Sync _selectedCategory with provider data if it's missing from current list
if (provider.eventCategories.isNotEmpty && !provider.eventCategories.contains(_selectedCategory)) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) setState(() => _selectedCategory = provider.eventCategories.first);
});
}
return Scaffold(
backgroundColor: Colors.white, // Changed from _blue
body: SafeArea(
@@ -287,9 +294,36 @@ class _ContributeScreenState extends State<ContributeScreen>
child: Center(
child: Column(
children: [
Icon(Icons.emoji_events_outlined, size: 48, color: Colors.grey.shade300),
const SizedBox(height: 12),
Text('No rankings available for this area.', style: TextStyle(color: Colors.grey.shade400)),
Container(
padding: const EdgeInsets.all(24),
decoration: BoxDecoration(
color: Colors.amber.withOpacity(0.1),
shape: BoxShape.circle,
),
child: const Icon(Icons.emoji_events_rounded, size: 72, color: Colors.amber),
),
const SizedBox(height: 24),
const Text(
'No Contributor Yet',
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.w800,
color: _darkText,
),
),
const SizedBox(height: 10),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 40),
child: Text(
'No contributors in $currentDistrict yet. Be the first to join the ranks!',
textAlign: TextAlign.center,
style: const TextStyle(
color: _subText,
fontSize: 15,
height: 1.5,
),
),
),
],
),
),
@@ -1181,7 +1215,13 @@ class _ContributeScreenState extends State<ContributeScreen>
children: [
_inputLabel('Category', required: true),
const SizedBox(height: 6),
_dropdown(_selectedCategory, _categories, (v) => setState(() => _selectedCategory = v!)),
if (provider.eventCategories.isEmpty)
const SizedBox(
height: 48,
child: Center(child: SizedBox(width: 20, height: 20, child: CircularProgressIndicator(strokeWidth: 2))),
)
else
_dropdown(_selectedCategory, provider.eventCategories, (v) => setState(() => _selectedCategory = v!)),
],
),
),
@@ -1799,7 +1839,7 @@ class _ContributeScreenState extends State<ContributeScreen>
_mapsLinkCtl.clear();
_selectedDate = null;
_selectedTime = null;
_selectedCategory = _categories.first;
_selectedCategory = _categories_fallback.first;
_selectedDistrict = _districts.first;
_images.clear();
_coordMessage = null;