diff --git a/frontend/lib/screens/pages/invitations_page.dart b/frontend/lib/screens/pages/invitations_page.dart index d25bb39..c5acd22 100644 --- a/frontend/lib/screens/pages/invitations_page.dart +++ b/frontend/lib/screens/pages/invitations_page.dart @@ -144,7 +144,11 @@ class _InvitationsPageState extends State } } - Future _navigateToInvitationDetails(Invitation invitation, bool isOwner, {bool isParticipant = true}) async { + Future _navigateToInvitationDetails( + Invitation invitation, + bool isOwner, { + bool isParticipant = true, + }) async { final result = await Navigator.push( context, MaterialPageRoute( @@ -155,7 +159,7 @@ class _InvitationsPageState extends State ), ), ); - + if (result == true) { _loadInvitations(); } @@ -319,7 +323,7 @@ class _InvitationsPageState extends State ], ), SizedBox(height: 16), - if (!isOwned && !isAccepted && !hasBeenAccepted) + if (!isOwned && !isAccepted && !hasBeenAccepted) Row( children: [ Expanded( @@ -327,7 +331,11 @@ class _InvitationsPageState extends State height: 44, child: ElevatedButton( onPressed: () { - _navigateToInvitationDetails(invitation, false, isParticipant: false); + _navigateToInvitationDetails( + invitation, + false, + isParticipant: false, + ); }, style: ElevatedButton.styleFrom( backgroundColor: Colors.grey[600], @@ -352,8 +360,8 @@ class _InvitationsPageState extends State child: SizedBox( height: 44, child: ElevatedButton( - onPressed: isAccepting - ? null + onPressed: isAccepting + ? null : () { _acceptInvitation(invitation); }, @@ -371,7 +379,9 @@ class _InvitationsPageState extends State width: 20, child: CircularProgressIndicator( strokeWidth: 2, - valueColor: AlwaysStoppedAnimation(Colors.white), + valueColor: AlwaysStoppedAnimation( + Colors.white, + ), ), ) : Text( @@ -391,15 +401,15 @@ class _InvitationsPageState extends State width: double.infinity, height: 44, child: ElevatedButton( - onPressed: isAccepting - ? null - : (isOwned || isAccepted || hasBeenAccepted) - ? () { - _navigateToInvitationDetails(invitation, isOwned); - } - : () { - _acceptInvitation(invitation); - }, + onPressed: isAccepting + ? null + : (isOwned || isAccepted || hasBeenAccepted) + ? () { + _navigateToInvitationDetails(invitation, isOwned); + } + : () { + _acceptInvitation(invitation); + }, style: ElevatedButton.styleFrom( backgroundColor: (isAccepted || hasBeenAccepted) ? Colors.green @@ -416,7 +426,9 @@ class _InvitationsPageState extends State width: 20, child: CircularProgressIndicator( strokeWidth: 2, - valueColor: AlwaysStoppedAnimation(Colors.white), + valueColor: AlwaysStoppedAnimation( + Colors.white, + ), ), ) : hasBeenAccepted && animController != null @@ -569,16 +581,9 @@ class _CreateInvitationPageState extends State { int? _selectedTagIndex; bool _isSubmitting = false; - final List> _availableTags = [ - {"id": 1, "name": "Sports", "color_hex": "#FF6B35", "icon_name": "sports_soccer"}, - {"id": 2, "name": "Food", "color_hex": "#F7931E", "icon_name": "restaurant"}, - {"id": 3, "name": "Gaming", "color_hex": "#FFD23F", "icon_name": "games"}, - {"id": 4, "name": "Study", "color_hex": "#06FFA5", "icon_name": "menu_book"}, - {"id": 5, "name": "Social", "color_hex": "#118AB2", "icon_name": "group"}, - {"id": 6, "name": "Travel", "color_hex": "#06D6A0", "icon_name": "flight"}, - {"id": 7, "name": "Music", "color_hex": "#8E44AD", "icon_name": "music_note"}, - {"id": 8, "name": "Movies", "color_hex": "#E74C3C", "icon_name": "movie"}, - ]; + // Use centralized tag configuration from InvitationUtils + List> get _availableTags => + InvitationUtils.availableTags; @override void dispose() { @@ -589,33 +594,6 @@ class _CreateInvitationPageState extends State { super.dispose(); } - IconData _getIconFromName(String iconName) { - switch (iconName) { - case 'sports_soccer': - return Icons.sports_soccer; - case 'restaurant': - return Icons.restaurant; - case 'games': - return Icons.games; - case 'menu_book': - return Icons.menu_book; - case 'group': - return Icons.group; - case 'flight': - return Icons.flight; - case 'music_note': - return Icons.music_note; - case 'movie': - return Icons.movie; - default: - return Icons.category; - } - } - - Color _getColorFromHex(String hexColor) { - return Color(int.parse(hexColor.substring(1, 7), radix: 16) + 0xFF000000); - } - Future _selectDate() async { final DateTime? picked = await showDatePicker( context: context, @@ -996,12 +974,16 @@ class _CreateInvitationPageState extends State { ), decoration: BoxDecoration( color: isSelected - ? _getColorFromHex(tag['color_hex']) + ? InvitationUtils.getColorFromHex( + tag['color_hex'], + ) : Colors.grey[100], borderRadius: BorderRadius.circular(20), border: Border.all( color: isSelected - ? _getColorFromHex(tag['color_hex']) + ? InvitationUtils.getColorFromHex( + tag['color_hex'], + ) : Colors.grey[300]!, width: 2, ), @@ -1010,11 +992,13 @@ class _CreateInvitationPageState extends State { mainAxisSize: MainAxisSize.min, children: [ Icon( - _getIconFromName(tag['icon_name']), + InvitationUtils.getIconFromName( + tag['icon_name'], + ), size: 18, color: isSelected ? Colors.white - : _getColorFromHex( + : InvitationUtils.getColorFromHex( tag['color_hex'], ), ), @@ -1054,7 +1038,10 @@ class _CreateInvitationPageState extends State { width: 20, child: CircularProgressIndicator( strokeWidth: 2, - valueColor: AlwaysStoppedAnimation(Colors.white), + valueColor: + AlwaysStoppedAnimation( + Colors.white, + ), ), ) : Text( diff --git a/frontend/lib/utils/invitation_utils.dart b/frontend/lib/utils/invitation_utils.dart index ea366d2..868a731 100644 --- a/frontend/lib/utils/invitation_utils.dart +++ b/frontend/lib/utils/invitation_utils.dart @@ -1,32 +1,59 @@ import 'package:flutter/material.dart'; class InvitationUtils { + // Centralized tag configuration + static const List> availableTags = [ + {"id": 1, "name": "Coffee", "color_hex": "#8B4513", "icon_name": "coffee"}, + { + "id": 2, + "name": "Lunch", + "color_hex": "#FF6347", + "icon_name": "restaurant", + }, + { + "id": 3, + "name": "Exercise", + "color_hex": "#32CD32", + "icon_name": "fitness_center", + }, + { + "id": 4, + "name": "Sports", + "color_hex": "#FF4500", + "icon_name": "sports_soccer", + }, + { + "id": 5, + "name": "Gaming", + "color_hex": "#9932CC", + "icon_name": "sports_esports", + }, + { + "id": 6, + "name": "Learning/Networking", + "color_hex": "#4169E1", + "icon_name": "school", + }, + {"id": 7, "name": "Other", "color_hex": "#708090", "icon_name": "category"}, + ]; + static IconData getIconFromName(String iconName) { switch (iconName) { - case 'sports_soccer': - return Icons.sports_soccer; - case 'restaurant': - return Icons.restaurant; - case 'games': - return Icons.games; - case 'menu_book': - return Icons.menu_book; - case 'group': - return Icons.group; - case 'flight': - return Icons.flight; - case 'music_note': - return Icons.music_note; - case 'movie': - return Icons.movie; + // Primary supported icons (from availableTags) case 'coffee': return Icons.coffee; - case 'local_dining': - return Icons.local_dining; - case 'sports': - return Icons.sports; + case 'restaurant': + return Icons.restaurant; + case 'fitness_center': + return Icons.fitness_center; + case 'sports_soccer': + return Icons.sports_soccer; + case 'sports_esports': + return Icons.sports_esports; case 'school': return Icons.school; + case 'category': + return Icons.category; default: return Icons.category; }