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(
|
final result = await Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
@ -155,7 +159,7 @@ class _InvitationsPageState extends State<InvitationsPage>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (result == true) {
|
if (result == true) {
|
||||||
_loadInvitations();
|
_loadInvitations();
|
||||||
}
|
}
|
||||||
@ -319,7 +323,7 @@ class _InvitationsPageState extends State<InvitationsPage>
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(height: 16),
|
SizedBox(height: 16),
|
||||||
if (!isOwned && !isAccepted && !hasBeenAccepted)
|
if (!isOwned && !isAccepted && !hasBeenAccepted)
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -327,7 +331,11 @@ class _InvitationsPageState extends State<InvitationsPage>
|
|||||||
height: 44,
|
height: 44,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
_navigateToInvitationDetails(invitation, false, isParticipant: false);
|
_navigateToInvitationDetails(
|
||||||
|
invitation,
|
||||||
|
false,
|
||||||
|
isParticipant: false,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: Colors.grey[600],
|
backgroundColor: Colors.grey[600],
|
||||||
@ -352,8 +360,8 @@ class _InvitationsPageState extends State<InvitationsPage>
|
|||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 44,
|
height: 44,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: isAccepting
|
onPressed: isAccepting
|
||||||
? null
|
? null
|
||||||
: () {
|
: () {
|
||||||
_acceptInvitation(invitation);
|
_acceptInvitation(invitation);
|
||||||
},
|
},
|
||||||
@ -371,7 +379,9 @@ class _InvitationsPageState extends State<InvitationsPage>
|
|||||||
width: 20,
|
width: 20,
|
||||||
child: CircularProgressIndicator(
|
child: CircularProgressIndicator(
|
||||||
strokeWidth: 2,
|
strokeWidth: 2,
|
||||||
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
|
valueColor: AlwaysStoppedAnimation<Color>(
|
||||||
|
Colors.white,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: Text(
|
: Text(
|
||||||
@ -391,15 +401,15 @@ class _InvitationsPageState extends State<InvitationsPage>
|
|||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: 44,
|
height: 44,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: isAccepting
|
onPressed: isAccepting
|
||||||
? null
|
? null
|
||||||
: (isOwned || isAccepted || hasBeenAccepted)
|
: (isOwned || isAccepted || hasBeenAccepted)
|
||||||
? () {
|
? () {
|
||||||
_navigateToInvitationDetails(invitation, isOwned);
|
_navigateToInvitationDetails(invitation, isOwned);
|
||||||
}
|
}
|
||||||
: () {
|
: () {
|
||||||
_acceptInvitation(invitation);
|
_acceptInvitation(invitation);
|
||||||
},
|
},
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: (isAccepted || hasBeenAccepted)
|
backgroundColor: (isAccepted || hasBeenAccepted)
|
||||||
? Colors.green
|
? Colors.green
|
||||||
@ -416,7 +426,9 @@ class _InvitationsPageState extends State<InvitationsPage>
|
|||||||
width: 20,
|
width: 20,
|
||||||
child: CircularProgressIndicator(
|
child: CircularProgressIndicator(
|
||||||
strokeWidth: 2,
|
strokeWidth: 2,
|
||||||
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
|
valueColor: AlwaysStoppedAnimation<Color>(
|
||||||
|
Colors.white,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: hasBeenAccepted && animController != null
|
: hasBeenAccepted && animController != null
|
||||||
@ -569,16 +581,9 @@ class _CreateInvitationPageState extends State<CreateInvitationPage> {
|
|||||||
int? _selectedTagIndex;
|
int? _selectedTagIndex;
|
||||||
bool _isSubmitting = false;
|
bool _isSubmitting = false;
|
||||||
|
|
||||||
final List<Map<String, dynamic>> _availableTags = [
|
// Use centralized tag configuration from InvitationUtils
|
||||||
{"id": 1, "name": "Sports", "color_hex": "#FF6B35", "icon_name": "sports_soccer"},
|
List<Map<String, dynamic>> get _availableTags =>
|
||||||
{"id": 2, "name": "Food", "color_hex": "#F7931E", "icon_name": "restaurant"},
|
InvitationUtils.availableTags;
|
||||||
{"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"},
|
|
||||||
];
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
@ -589,33 +594,6 @@ class _CreateInvitationPageState extends State<CreateInvitationPage> {
|
|||||||
super.dispose();
|
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 {
|
Future<void> _selectDate() async {
|
||||||
final DateTime? picked = await showDatePicker(
|
final DateTime? picked = await showDatePicker(
|
||||||
context: context,
|
context: context,
|
||||||
@ -996,12 +974,16 @@ class _CreateInvitationPageState extends State<CreateInvitationPage> {
|
|||||||
),
|
),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: isSelected
|
color: isSelected
|
||||||
? _getColorFromHex(tag['color_hex'])
|
? InvitationUtils.getColorFromHex(
|
||||||
|
tag['color_hex'],
|
||||||
|
)
|
||||||
: Colors.grey[100],
|
: Colors.grey[100],
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: isSelected
|
color: isSelected
|
||||||
? _getColorFromHex(tag['color_hex'])
|
? InvitationUtils.getColorFromHex(
|
||||||
|
tag['color_hex'],
|
||||||
|
)
|
||||||
: Colors.grey[300]!,
|
: Colors.grey[300]!,
|
||||||
width: 2,
|
width: 2,
|
||||||
),
|
),
|
||||||
@ -1010,11 +992,13 @@ class _CreateInvitationPageState extends State<CreateInvitationPage> {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(
|
||||||
_getIconFromName(tag['icon_name']),
|
InvitationUtils.getIconFromName(
|
||||||
|
tag['icon_name'],
|
||||||
|
),
|
||||||
size: 18,
|
size: 18,
|
||||||
color: isSelected
|
color: isSelected
|
||||||
? Colors.white
|
? Colors.white
|
||||||
: _getColorFromHex(
|
: InvitationUtils.getColorFromHex(
|
||||||
tag['color_hex'],
|
tag['color_hex'],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -1054,7 +1038,10 @@ class _CreateInvitationPageState extends State<CreateInvitationPage> {
|
|||||||
width: 20,
|
width: 20,
|
||||||
child: CircularProgressIndicator(
|
child: CircularProgressIndicator(
|
||||||
strokeWidth: 2,
|
strokeWidth: 2,
|
||||||
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
|
valueColor:
|
||||||
|
AlwaysStoppedAnimation<Color>(
|
||||||
|
Colors.white,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: Text(
|
: Text(
|
||||||
|
|||||||
@ -1,32 +1,59 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class InvitationUtils {
|
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) {
|
static IconData getIconFromName(String iconName) {
|
||||||
switch (iconName) {
|
switch (iconName) {
|
||||||
case 'sports_soccer':
|
// Primary supported icons (from availableTags)
|
||||||
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;
|
|
||||||
case 'coffee':
|
case 'coffee':
|
||||||
return Icons.coffee;
|
return Icons.coffee;
|
||||||
case 'local_dining':
|
case 'restaurant':
|
||||||
return Icons.local_dining;
|
return Icons.restaurant;
|
||||||
case 'sports':
|
case 'fitness_center':
|
||||||
return Icons.sports;
|
return Icons.fitness_center;
|
||||||
|
case 'sports_soccer':
|
||||||
|
return Icons.sports_soccer;
|
||||||
|
case 'sports_esports':
|
||||||
|
return Icons.sports_esports;
|
||||||
case 'school':
|
case 'school':
|
||||||
return Icons.school;
|
return Icons.school;
|
||||||
|
case 'category':
|
||||||
|
return Icons.category;
|
||||||
default:
|
default:
|
||||||
return Icons.category;
|
return Icons.category;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user