From eb4c2fba7742270e76ab4606192fe01c3da5c44e Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 16 Aug 2023 15:24:18 +0200 Subject: [PATCH] Fix issue detected by detekt --- .../features/location/api/StaticMapView.kt | 3 +- .../api/internal/StaticMapPlaceholder.kt | 30 ++++++++++--------- .../messagecomposer/MessageComposerView.kt | 5 ++-- .../impl/invite/RoomInviteMembersView.kt | 3 +- .../impl/members/RoomMemberListView.kt | 3 +- .../components/RequestVerificationHeader.kt | 4 +-- 6 files changed, 26 insertions(+), 22 deletions(-) diff --git a/features/location/api/src/main/kotlin/io/element/android/features/location/api/StaticMapView.kt b/features/location/api/src/main/kotlin/io/element/android/features/location/api/StaticMapView.kt index 50d400092a..716b6d88c6 100644 --- a/features/location/api/src/main/kotlin/io/element/android/features/location/api/StaticMapView.kt +++ b/features/location/api/src/main/kotlin/io/element/android/features/location/api/StaticMapView.kt @@ -111,7 +111,8 @@ fun StaticMapView( StaticMapPlaceholder( showProgress = painter.state is AsyncImagePainter.State.Loading, contentDescription = contentDescription, - modifier = Modifier.size(width = maxWidth, height = maxHeight), + width = maxWidth, + height = maxHeight, onLoadMapClick = { retryHash++ } ) } diff --git a/features/location/api/src/main/kotlin/io/element/android/features/location/api/internal/StaticMapPlaceholder.kt b/features/location/api/src/main/kotlin/io/element/android/features/location/api/internal/StaticMapPlaceholder.kt index 84349d97c9..bcab870d69 100644 --- a/features/location/api/src/main/kotlin/io/element/android/features/location/api/internal/StaticMapPlaceholder.kt +++ b/features/location/api/src/main/kotlin/io/element/android/features/location/api/internal/StaticMapPlaceholder.kt @@ -31,6 +31,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.PreviewParameterProvider +import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import io.element.android.features.location.api.R import io.element.android.libraries.designsystem.preview.DayNightPreviews @@ -44,34 +45,34 @@ import io.element.android.libraries.ui.strings.CommonStrings internal fun StaticMapPlaceholder( showProgress: Boolean, contentDescription: String?, + width: Dp, + height: Dp, modifier: Modifier = Modifier, onLoadMapClick: () -> Unit, ) { Box( contentAlignment = Alignment.Center, + modifier = modifier + .size(width = width, height = height) + .then(if (showProgress) Modifier else Modifier.clickable(onClick = onLoadMapClick)) ) { Image( painter = painterResource(id = R.drawable.blurred_map), contentDescription = contentDescription, - modifier = modifier, contentScale = ContentScale.FillBounds, + modifier = Modifier.size(width = width, height = height) ) if (showProgress) { CircularProgressIndicator() } else { - Box( - modifier = modifier.clickable(onClick = onLoadMapClick), - contentAlignment = Alignment.Center, + Column( + horizontalAlignment = Alignment.CenterHorizontally, ) { - Column( - horizontalAlignment = Alignment.CenterHorizontally, - ) { - Icon( - imageVector = Icons.Default.Refresh, - contentDescription = null - ) - Text(text = stringResource(id = CommonStrings.action_static_map_load)) - } + Icon( + imageVector = Icons.Default.Refresh, + contentDescription = null + ) + Text(text = stringResource(id = CommonStrings.action_static_map_load)) } } } @@ -85,7 +86,8 @@ internal fun StaticMapPlaceholderPreview( StaticMapPlaceholder( showProgress = values, contentDescription = null, - modifier = Modifier.size(400.dp), + width = 400.dp, + height = 400.dp, onLoadMapClick = {}, ) } diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/messagecomposer/MessageComposerView.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/messagecomposer/MessageComposerView.kt index 5c6c07d80e..844635cef7 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/messagecomposer/MessageComposerView.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/messagecomposer/MessageComposerView.kt @@ -55,7 +55,7 @@ fun MessageComposerView( state.eventSink(MessageComposerEvents.FocusChanged(hasFocus)) } - Box { + Box(modifier = modifier) { AttachmentsBottomSheet( state = state, onSendLocationClicked = onSendLocationClicked, @@ -69,8 +69,7 @@ fun MessageComposerView( onAddAttachment = ::onAddAttachment, onFocusChanged = ::onFocusChanged, composerCanSendMessage = state.isSendButtonVisible, - composerText = state.text, - modifier = modifier + composerText = state.text ) } } diff --git a/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/invite/RoomInviteMembersView.kt b/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/invite/RoomInviteMembersView.kt index 8f01569f01..689e132e01 100644 --- a/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/invite/RoomInviteMembersView.kt +++ b/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/invite/RoomInviteMembersView.kt @@ -64,6 +64,7 @@ fun RoomInviteMembersView( onSendPressed: (List) -> Unit = {}, ) { Scaffold( + modifier = modifier, topBar = { RoomInviteMembersTopBar( onBackPressed = { @@ -79,7 +80,7 @@ fun RoomInviteMembersView( } ) { padding -> Column( - modifier = modifier + modifier = Modifier .fillMaxWidth() .padding(padding) .consumeWindowInsets(padding), diff --git a/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/members/RoomMemberListView.kt b/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/members/RoomMemberListView.kt index b0bac12d4e..d35fa5ac84 100644 --- a/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/members/RoomMemberListView.kt +++ b/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/members/RoomMemberListView.kt @@ -76,6 +76,7 @@ fun RoomMemberListView( } Scaffold( + modifier = modifier, topBar = { if (!state.isSearchActive) { RoomMemberListTopBar( @@ -87,7 +88,7 @@ fun RoomMemberListView( } ) { padding -> Column( - modifier = modifier + modifier = Modifier .fillMaxWidth() .padding(padding) .consumeWindowInsets(padding), diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RequestVerificationHeader.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RequestVerificationHeader.kt index 9d6b54366a..762b74d904 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RequestVerificationHeader.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RequestVerificationHeader.kt @@ -50,9 +50,9 @@ internal fun RequestVerificationHeader( onDismissClicked: () -> Unit, modifier: Modifier = Modifier, ) { - Box(modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp)) { + Box(modifier = modifier.padding(horizontal = 16.dp, vertical = 8.dp)) { Surface( - modifier.fillMaxWidth(), + Modifier.fillMaxWidth(), shape = MaterialTheme.shapes.small, color = MaterialTheme.colorScheme.surfaceVariant ) {