1
Fork 0
mirror of https://github.com/Steffo99/twom.git synced 2024-11-21 15:44:26 +00:00

Add progress indicator to MemberListItem

This commit is contained in:
Steffo 2024-02-05 00:10:00 +01:00
parent b0e337f44b
commit 6d7880b615
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0

View file

@ -6,6 +6,7 @@ import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.DropdownMenu import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
@ -71,6 +72,7 @@ fun MemberListItem(
val rsvp = observeRSVP(room = room, member = member) ?: return val rsvp = observeRSVP(room = room, member = member) ?: return
var running by rememberSaveable { mutableStateOf(false) }
var expanded by rememberSaveable { mutableStateOf(false) } var expanded by rememberSaveable { mutableStateOf(false) }
val alpha = if (rsvp.answer == RSVPAnswer.PENDING) 0.4f else 1.0f val alpha = if (rsvp.answer == RSVPAnswer.PENDING) 0.4f else 1.0f
@ -99,10 +101,14 @@ fun MemberListItem(
.size(40.dp) .size(40.dp)
.clip(MaterialTheme.shapes.extraLarge) .clip(MaterialTheme.shapes.extraLarge)
) { ) {
AvatarUser( if (running) {
user = user, CircularProgressIndicator()
alpha = alpha, } else {
) AvatarUser(
user = user,
alpha = alpha,
)
}
} }
}, },
trailingContent = { trailingContent = {
@ -139,13 +145,15 @@ fun MemberListItem(
val userId = member.userId val userId = member.userId
Log.d("Room", "Uninviting `$userId`...") Log.d("Room", "Uninviting `$userId`...")
running = true
// FIXME: Errors for this aren't displayed as I don't have any idea of where to place the relevant text on the UI, but also are so unlikely to occour that it should be ok to disregard it
try { try {
room.membershipService().remove(userId) room.membershipService().remove(userId)
} catch (e: Throwable) { } catch (e: Throwable) {
Log.e("Room", "Failed to uninvite `$userId`: $e") Log.e("Room", "Failed to uninvite `$userId`: $e")
return@SendUninvite return@SendUninvite
} finally {
running = false
} }
Log.d("Room", "Successfully uninvited `$userId`!") Log.d("Room", "Successfully uninvited `$userId`!")