feat: update the tags and their icons and colours
This commit is contained in:
parent
2de55848f9
commit
959b818b20
@ -144,7 +144,11 @@ class _InvitationsPageState extends State<InvitationsPage>
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _navigateToInvitationDetails(Invitation invitation, bool isOwner, {bool isParticipant = true}) async {
|
||||
Future<void> _navigateToInvitationDetails(
|
||||
Invitation invitation,
|
||||
bool isOwner, {
|
||||
bool isParticipant = true,
|
||||
}) async {
|
||||
final result = await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
@ -155,7 +159,7 @@ class _InvitationsPageState extends State<InvitationsPage>
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
if (result == true) {
|
||||
_loadInvitations();
|
||||
}
|
||||
@ -319,7 +323,7 @@ class _InvitationsPageState extends State<InvitationsPage>
|
||||
],
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
if (!isOwned && !isAccepted && !hasBeenAccepted)
|
||||
if (!isOwned && !isAccepted && !hasBeenAccepted)
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
@ -327,7 +331,11 @@ class _InvitationsPageState extends State<InvitationsPage>
|
||||
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<InvitationsPage>
|
||||
child: SizedBox(
|
||||
height: 44,
|
||||
child: ElevatedButton(
|
||||
onPressed: isAccepting
|
||||
? null
|
||||
onPressed: isAccepting
|
||||
? null
|
||||
: () {
|
||||
_acceptInvitation(invitation);
|
||||
},
|
||||
@ -371,7 +379,9 @@ class _InvitationsPageState extends State<InvitationsPage>
|
||||
width: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
Colors.white,
|
||||
),
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
@ -391,15 +401,15 @@ class _InvitationsPageState extends State<InvitationsPage>
|
||||
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<InvitationsPage>
|
||||
width: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
Colors.white,
|
||||
),
|
||||
),
|
||||
)
|
||||
: hasBeenAccepted && animController != null
|
||||
@ -569,16 +581,9 @@ class _CreateInvitationPageState extends State<CreateInvitationPage> {
|
||||
int? _selectedTagIndex;
|
||||
bool _isSubmitting = false;
|
||||
|
||||
final List<Map<String, dynamic>> _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<Map<String, dynamic>> get _availableTags =>
|
||||
InvitationUtils.availableTags;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
@ -589,33 +594,6 @@ class _CreateInvitationPageState extends State<CreateInvitationPage> {
|
||||
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<void> _selectDate() async {
|
||||
final DateTime? picked = await showDatePicker(
|
||||
context: context,
|
||||
@ -996,12 +974,16 @@ class _CreateInvitationPageState extends State<CreateInvitationPage> {
|
||||
),
|
||||
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<CreateInvitationPage> {
|
||||
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<CreateInvitationPage> {
|
||||
width: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
|
||||
valueColor:
|
||||
AlwaysStoppedAnimation<Color>(
|
||||
Colors.white,
|
||||
),
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
|
||||
@ -1,32 +1,59 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class InvitationUtils {
|
||||
// Centralized tag configuration
|
||||
static const List<Map<String, dynamic>> 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;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user