Skip to content

Commit

Permalink
🐛 FIX: alignment of snackbar for join/leave event button
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas Sulzer <[email protected]>
  • Loading branch information
violoncelloCH committed May 31, 2024
1 parent 739d744 commit d0fb474
Showing 1 changed file with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,31 +53,31 @@ fun JoinEventButton(event: Event, isOnline: Boolean, buttonWidth: Dp, refreshEve
}
}

// Create a button for joining or leaving the event.
Button(
// The button is enabled if the user is online and the event is not full.
enabled = isOnline && (event.participantCount < event.maxParticipants),
// When the button is clicked, the user joins or leaves the event.
onClick = { myEventsViewModel.joinOrLeaveEvent(event, refreshEvents) },
// Set the width of the button and a test tag for testing purposes.
modifier =
androidx.compose.ui.Modifier.width(buttonWidth)
.testTag("list_join_event_${event.eventId}")
) {
// The text of the button depends on whether the user has joined the event.
Text(
if (joinedEvents.map { it.eventId }.contains(event.eventId))
// If the user has joined the event, the button says "Leave".
stringResource(id = R.string.list_drawer_leave_event)
else
// If the user has not joined the event, the button says "Join".
stringResource(id = R.string.list_drawer_join_event)
)
}
Box {
// Create a button for joining or leaving the event.
Button(
// The button is enabled if the user is online and the event is not full.
enabled = isOnline && (event.participantCount < event.maxParticipants),
// When the button is clicked, the user joins or leaves the event.
onClick = { myEventsViewModel.joinOrLeaveEvent(event, refreshEvents) },
// Set the width of the button and a test tag for testing purposes.
modifier =
androidx.compose.ui.Modifier.width(buttonWidth).align(Alignment.Center)
.testTag("list_join_event_${event.eventId}")
) {
// The text of the button depends on whether the user has joined the event.
Text(
if (joinedEvents.map { it.eventId }.contains(event.eventId))
// If the user has joined the event, the button says "Leave".
stringResource(id = R.string.list_drawer_leave_event)
else
// If the user has not joined the event, the button says "Join".
stringResource(id = R.string.list_drawer_join_event)
)
}
SnackbarHost(
hostState = snackbarHostState,
modifier = Modifier.align(Alignment.BottomCenter)
modifier = Modifier.align(Alignment.Center)
)
}
}

0 comments on commit d0fb474

Please sign in to comment.