diff --git a/src/main/kotlin/com/machiav3lli/fdroid/ui/compose/components/appsheet/Header.kt b/src/main/kotlin/com/machiav3lli/fdroid/ui/compose/components/appsheet/Header.kt index 6561b2a5..4d5fe6cf 100644 --- a/src/main/kotlin/com/machiav3lli/fdroid/ui/compose/components/appsheet/Header.kt +++ b/src/main/kotlin/com/machiav3lli/fdroid/ui/compose/components/appsheet/Header.kt @@ -9,7 +9,6 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding @@ -26,9 +25,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color -import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp -import com.machiav3lli.fdroid.R import com.machiav3lli.fdroid.entity.ActionState import com.machiav3lli.fdroid.entity.DownloadState import com.machiav3lli.fdroid.ui.compose.components.MainActionButton @@ -39,11 +36,8 @@ import com.machiav3lli.fdroid.utility.extension.text.formatSize @Composable fun AppInfoHeader( modifier: Modifier = Modifier, - repoHost: String, mainAction: ActionState?, possibleActions: Set, - onSource: () -> Unit = { }, - onSourceLong: () -> Unit = { }, onAction: (ActionState?) -> Unit = { } ) { Surface( @@ -67,13 +61,6 @@ fun AppInfoHeader( onAction(mainAction) } ) - SourceCodeCard( - modifier = Modifier.padding(vertical = 4.dp), - title = stringResource(id = R.string.source_code), - text = repoHost, - onClick = onSource, - onLongClick = onSourceLong - ) } AnimatedVisibility(visible = possibleActions.isNotEmpty()) { Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { @@ -116,6 +103,7 @@ fun TopBarHeader( ) Spacer(modifier = Modifier.width(16.dp)) Column( + modifier = Modifier.weight(1f), horizontalAlignment = Alignment.Start, verticalArrangement = Arrangement.SpaceAround ) { @@ -151,8 +139,7 @@ fun SourceCodeCard( .clip(MaterialTheme.shapes.medium) .combinedClickable(onClick = onClick, onLongClick = onLongClick) .background(MaterialTheme.colorScheme.surfaceColorAtElevation(1.dp)) - .padding(vertical = 8.dp, horizontal = 12.dp) - .fillMaxHeight(), + .padding(vertical = 18.dp, horizontal = 12.dp), color = Color.Transparent ) { Column( diff --git a/src/main/kotlin/com/machiav3lli/fdroid/ui/fragments/AppSheetX.kt b/src/main/kotlin/com/machiav3lli/fdroid/ui/fragments/AppSheetX.kt index b87d1006..df43b108 100644 --- a/src/main/kotlin/com/machiav3lli/fdroid/ui/fragments/AppSheetX.kt +++ b/src/main/kotlin/com/machiav3lli/fdroid/ui/fragments/AppSheetX.kt @@ -73,6 +73,7 @@ import com.machiav3lli.fdroid.ui.compose.components.appsheet.HtmlTextBlock import com.machiav3lli.fdroid.ui.compose.components.appsheet.LinkItem import com.machiav3lli.fdroid.ui.compose.components.appsheet.PermissionsItem import com.machiav3lli.fdroid.ui.compose.components.appsheet.ReleaseItem +import com.machiav3lli.fdroid.ui.compose.components.appsheet.SourceCodeCard import com.machiav3lli.fdroid.ui.compose.components.appsheet.TopBarHeader import com.machiav3lli.fdroid.ui.compose.theme.AppTheme import com.machiav3lli.fdroid.ui.compose.utils.Callbacks @@ -416,7 +417,42 @@ class AppSheetX() : FullscreenBottomSheetDialogFragment(), Callbacks { appName = product.label, packageName = product.packageName, icon = imageData, - state = downloadState + state = downloadState, + actions = { + SourceCodeCard( + modifier = Modifier.padding(vertical = 4.dp), + title = stringResource(id = R.string.source_code), + text = "@${ + (URI(product.source).host ?: stringResource(id = R.string.unknown)) + .removePrefix("www.") + .replaceFirstChar { + if (it.isLowerCase()) it.titlecase( + Locale.getDefault() + ) else it.toString() + } + }", + onClick = { + product.source.let { link -> + if (link.isNotEmpty()) { + requireContext().startActivity( + Intent(Intent.ACTION_VIEW, link.toUri()) + ) + } + } + }, + onLongClick = { + product.source.let { link -> + if (link.isNotEmpty()) { + copyLinkToClipboard( + coroutineScope, + snackbarHostState, + link + ) + } + } + } + ) + }, ) AppInfoChips( product = product, @@ -435,34 +471,9 @@ class AppSheetX() : FullscreenBottomSheetDialogFragment(), Callbacks { ) { item { AppInfoHeader( - repoHost = "@${ - (URI(product.source)?.host ?: stringResource(id = R.string.unknown)) - .removePrefix("www.") - .replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() } - }", mainAction = mainAction, possibleActions = actions?.filter { it != mainAction }?.toSet() ?: emptySet(), - onSource = { - product.source.let { link -> - if (link.isNotEmpty()) { - requireContext().startActivity( - Intent(Intent.ACTION_VIEW, link.toUri()) - ) - } - } - }, - onSourceLong = { - product.source.let { link -> - if (link.isNotEmpty()) { - copyLinkToClipboard( - coroutineScope, - snackbarHostState, - link - ) - } - } - }, onAction = { onActionClick(it) } ) }