feat: add a view button to available invites to see participants
This commit is contained in:
parent
c060e26b5a
commit
2de55848f9
@ -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<InvitationDetailsPage> {
|
||||
),
|
||||
),
|
||||
],
|
||||
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<Color>(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<Color>(Colors.white),
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
widget.isOwner ? 'Cancel Invitation' : 'Leave Invitation',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
SizedBox(height: 32),
|
||||
],
|
||||
),
|
||||
|
||||
@ -144,13 +144,14 @@ class _InvitationsPageState extends State<InvitationsPage>
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _navigateToInvitationDetails(Invitation invitation, bool isOwner) async {
|
||||
Future<void> _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<InvitationsPage>
|
||||
],
|
||||
),
|
||||
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<Color>(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<Color>(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<Color>(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,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user