diff --git a/frontend/lib/screens/pages/invitation_details_page.dart b/frontend/lib/screens/pages/invitation_details_page.dart index 3158b75..84e25d1 100644 --- a/frontend/lib/screens/pages/invitation_details_page.dart +++ b/frontend/lib/screens/pages/invitation_details_page.dart @@ -6,11 +6,13 @@ import '../../utils/invitation_utils.dart'; class InvitationDetailsPage extends StatefulWidget { final int invitationId; final bool isOwner; + final bool isParticipant; const InvitationDetailsPage({ Key? key, required this.invitationId, required this.isOwner, + this.isParticipant = true, }) : super(key: key); @override @@ -505,38 +507,40 @@ class _InvitationDetailsPageState extends State { ), ), ], - SizedBox(height: 32), - Container( - width: double.infinity, - height: 56, - child: ElevatedButton( - onPressed: _isCancelling ? null : _cancelInvitation, - style: ElevatedButton.styleFrom( - backgroundColor: Colors.red, - foregroundColor: Colors.white, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12), + if (widget.isParticipant) ...[ + SizedBox(height: 32), + Container( + width: double.infinity, + height: 56, + child: ElevatedButton( + onPressed: _isCancelling ? null : _cancelInvitation, + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red, + foregroundColor: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + elevation: 2, ), - elevation: 2, + child: _isCancelling + ? SizedBox( + height: 20, + width: 20, + child: CircularProgressIndicator( + strokeWidth: 2, + valueColor: AlwaysStoppedAnimation(Colors.white), + ), + ) + : Text( + widget.isOwner ? 'Cancel Invitation' : 'Leave Invitation', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + ), + ), ), - child: _isCancelling - ? SizedBox( - height: 20, - width: 20, - child: CircularProgressIndicator( - strokeWidth: 2, - valueColor: AlwaysStoppedAnimation(Colors.white), - ), - ) - : Text( - widget.isOwner ? 'Cancel Invitation' : 'Leave Invitation', - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - ), - ), ), - ), + ], SizedBox(height: 32), ], ), diff --git a/frontend/lib/screens/pages/invitations_page.dart b/frontend/lib/screens/pages/invitations_page.dart index c1e5057..d25bb39 100644 --- a/frontend/lib/screens/pages/invitations_page.dart +++ b/frontend/lib/screens/pages/invitations_page.dart @@ -144,13 +144,14 @@ class _InvitationsPageState extends State } } - Future _navigateToInvitationDetails(Invitation invitation, bool isOwner) async { + Future _navigateToInvitationDetails(Invitation invitation, bool isOwner, {bool isParticipant = true}) async { final result = await Navigator.push( context, MaterialPageRoute( builder: (context) => InvitationDetailsPage( invitationId: invitation.id, isOwner: isOwner, + isParticipant: isParticipant, ), ), ); @@ -318,72 +319,130 @@ class _InvitationsPageState extends State ], ), SizedBox(height: 16), - SizedBox( - width: double.infinity, - height: 44, - child: ElevatedButton( - onPressed: isAccepting - ? null - : (isOwned || isAccepted || hasBeenAccepted) - ? () { - _navigateToInvitationDetails(invitation, isOwned); - } - : () { - _acceptInvitation(invitation); - }, - style: ElevatedButton.styleFrom( - backgroundColor: (isAccepted || hasBeenAccepted) - ? Colors.green - : (isOwned ? Color(0xFF6A4C93) : Color(0xFF6A4C93)), - foregroundColor: Colors.white, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - ), - elevation: 2, - ), - child: isAccepting - ? SizedBox( - height: 20, - width: 20, - child: CircularProgressIndicator( - strokeWidth: 2, - valueColor: AlwaysStoppedAnimation(Colors.white), - ), - ) - : hasBeenAccepted && animController != null - ? AnimatedBuilder( - animation: animController, - builder: (context, child) { - if (animController.value < 0.5) { - return Text( - 'View', - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - ), - ); - } else { - return Text( - 'View', - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - ), - ); - } + if (!isOwned && !isAccepted && !hasBeenAccepted) + Row( + children: [ + Expanded( + child: SizedBox( + height: 44, + child: ElevatedButton( + onPressed: () { + _navigateToInvitationDetails(invitation, false, isParticipant: false); }, - ) - : Text( - (isAccepted || hasBeenAccepted) - ? 'View' - : (isOwned ? 'View' : 'Accept Invite'), - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, + style: ElevatedButton.styleFrom( + backgroundColor: Colors.grey[600], + foregroundColor: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + elevation: 2, + ), + child: Text( + 'View', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + ), ), ), + ), + ), + SizedBox(width: 12), + Expanded( + child: SizedBox( + height: 44, + child: ElevatedButton( + onPressed: isAccepting + ? null + : () { + _acceptInvitation(invitation); + }, + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFF6A4C93), + foregroundColor: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + elevation: 2, + ), + child: isAccepting + ? SizedBox( + height: 20, + width: 20, + child: CircularProgressIndicator( + strokeWidth: 2, + valueColor: AlwaysStoppedAnimation(Colors.white), + ), + ) + : Text( + 'Accept Invite', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + ), + ), + ), + ), + ), + ], + ) + else + SizedBox( + width: double.infinity, + height: 44, + child: ElevatedButton( + onPressed: isAccepting + ? null + : (isOwned || isAccepted || hasBeenAccepted) + ? () { + _navigateToInvitationDetails(invitation, isOwned); + } + : () { + _acceptInvitation(invitation); + }, + style: ElevatedButton.styleFrom( + backgroundColor: (isAccepted || hasBeenAccepted) + ? Colors.green + : Color(0xFF6A4C93), + foregroundColor: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + elevation: 2, + ), + child: isAccepting + ? SizedBox( + height: 20, + width: 20, + child: CircularProgressIndicator( + strokeWidth: 2, + valueColor: AlwaysStoppedAnimation(Colors.white), + ), + ) + : hasBeenAccepted && animController != null + ? AnimatedBuilder( + animation: animController, + builder: (context, child) { + return Text( + 'View', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + ), + ); + }, + ) + : Text( + (isAccepted || hasBeenAccepted) + ? 'View' + : (isOwned ? 'View' : 'Accept Invite'), + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + ), + ), + ), ), - ), ], ), );