Merge pull request #3037 from element-hq/feature/fga/timeline_cancelable_focus

Feature/fga/timeline cancelable focus
This commit is contained in:
ganfra 2024-06-18 10:59:54 +02:00 committed by GitHub
commit 2b5ea96110
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 121 additions and 62 deletions

View file

@ -51,7 +51,8 @@ fun ProgressDialog(
modifier: Modifier = Modifier,
text: String? = null,
type: ProgressDialogType = ProgressDialogType.Indeterminate,
isCancellable: Boolean = false,
properties: DialogProperties = DialogProperties(dismissOnBackPress = false, dismissOnClickOutside = false),
showCancelButton: Boolean = false,
onDismissRequest: () -> Unit = {},
) {
DisposableEffect(Unit) {
@ -61,12 +62,12 @@ fun ProgressDialog(
}
Dialog(
onDismissRequest = onDismissRequest,
properties = DialogProperties(dismissOnBackPress = false, dismissOnClickOutside = false)
properties = properties,
) {
ProgressDialogContent(
modifier = modifier,
text = text,
isCancellable = isCancellable,
showCancelButton = showCancelButton,
onCancelClick = onDismissRequest,
progressIndicator = {
when (type) {
@ -97,7 +98,7 @@ sealed interface ProgressDialogType {
private fun ProgressDialogContent(
modifier: Modifier = Modifier,
text: String? = null,
isCancellable: Boolean = false,
showCancelButton: Boolean = false,
onCancelClick: () -> Unit = {},
progressIndicator: @Composable () -> Unit = {
CircularProgressIndicator(
@ -125,7 +126,7 @@ private fun ProgressDialogContent(
color = MaterialTheme.colorScheme.primary,
)
}
if (isCancellable) {
if (showCancelButton) {
Spacer(modifier = Modifier.height(24.dp))
Box(
modifier = Modifier.fillMaxWidth(),
@ -145,12 +146,12 @@ private fun ProgressDialogContent(
@Composable
internal fun ProgressDialogContentPreview() = ElementThemedPreview {
DialogPreview {
ProgressDialogContent(text = "test dialog content", isCancellable = true)
ProgressDialogContent(text = "test dialog content", showCancelButton = true)
}
}
@PreviewsDayNight
@Composable
internal fun ProgressDialogPreview() = ElementPreview {
ProgressDialog(text = "test dialog content", isCancellable = true)
ProgressDialog(text = "test dialog content", showCancelButton = true)
}

View file

@ -87,6 +87,7 @@ import org.matrix.rustcomponents.sdk.use
import timber.log.Timber
import uniffi.matrix_sdk.RoomPowerLevelChanges
import java.io.File
import kotlin.coroutines.cancellation.CancellationException
import org.matrix.rustcomponents.sdk.Room as InnerRoom
import org.matrix.rustcomponents.sdk.Timeline as InnerTimeline
@ -183,6 +184,10 @@ class RustMatrixRoom(
}
}.mapFailure {
it.toFocusEventException()
}.onFailure {
if (it is CancellationException) {
throw it
}
}
}