mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-23 03:12:15 +00:00
Update: Move sourcecode shortcut into TopBar
This commit is contained in:
parent
fc719f7e02
commit
d53d96cf2d
@ -9,7 +9,6 @@ import androidx.compose.foundation.layout.Box
|
|||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxHeight
|
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
@ -26,9 +25,7 @@ import androidx.compose.ui.Alignment
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.res.stringResource
|
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.machiav3lli.fdroid.R
|
|
||||||
import com.machiav3lli.fdroid.entity.ActionState
|
import com.machiav3lli.fdroid.entity.ActionState
|
||||||
import com.machiav3lli.fdroid.entity.DownloadState
|
import com.machiav3lli.fdroid.entity.DownloadState
|
||||||
import com.machiav3lli.fdroid.ui.compose.components.MainActionButton
|
import com.machiav3lli.fdroid.ui.compose.components.MainActionButton
|
||||||
@ -39,11 +36,8 @@ import com.machiav3lli.fdroid.utility.extension.text.formatSize
|
|||||||
@Composable
|
@Composable
|
||||||
fun AppInfoHeader(
|
fun AppInfoHeader(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
repoHost: String,
|
|
||||||
mainAction: ActionState?,
|
mainAction: ActionState?,
|
||||||
possibleActions: Set<ActionState>,
|
possibleActions: Set<ActionState>,
|
||||||
onSource: () -> Unit = { },
|
|
||||||
onSourceLong: () -> Unit = { },
|
|
||||||
onAction: (ActionState?) -> Unit = { }
|
onAction: (ActionState?) -> Unit = { }
|
||||||
) {
|
) {
|
||||||
Surface(
|
Surface(
|
||||||
@ -67,13 +61,6 @@ fun AppInfoHeader(
|
|||||||
onAction(mainAction)
|
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()) {
|
AnimatedVisibility(visible = possibleActions.isNotEmpty()) {
|
||||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||||
@ -116,6 +103,7 @@ fun TopBarHeader(
|
|||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.width(16.dp))
|
Spacer(modifier = Modifier.width(16.dp))
|
||||||
Column(
|
Column(
|
||||||
|
modifier = Modifier.weight(1f),
|
||||||
horizontalAlignment = Alignment.Start,
|
horizontalAlignment = Alignment.Start,
|
||||||
verticalArrangement = Arrangement.SpaceAround
|
verticalArrangement = Arrangement.SpaceAround
|
||||||
) {
|
) {
|
||||||
@ -151,8 +139,7 @@ fun SourceCodeCard(
|
|||||||
.clip(MaterialTheme.shapes.medium)
|
.clip(MaterialTheme.shapes.medium)
|
||||||
.combinedClickable(onClick = onClick, onLongClick = onLongClick)
|
.combinedClickable(onClick = onClick, onLongClick = onLongClick)
|
||||||
.background(MaterialTheme.colorScheme.surfaceColorAtElevation(1.dp))
|
.background(MaterialTheme.colorScheme.surfaceColorAtElevation(1.dp))
|
||||||
.padding(vertical = 8.dp, horizontal = 12.dp)
|
.padding(vertical = 18.dp, horizontal = 12.dp),
|
||||||
.fillMaxHeight(),
|
|
||||||
color = Color.Transparent
|
color = Color.Transparent
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
|
@ -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.LinkItem
|
||||||
import com.machiav3lli.fdroid.ui.compose.components.appsheet.PermissionsItem
|
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.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.components.appsheet.TopBarHeader
|
||||||
import com.machiav3lli.fdroid.ui.compose.theme.AppTheme
|
import com.machiav3lli.fdroid.ui.compose.theme.AppTheme
|
||||||
import com.machiav3lli.fdroid.ui.compose.utils.Callbacks
|
import com.machiav3lli.fdroid.ui.compose.utils.Callbacks
|
||||||
@ -416,7 +417,42 @@ class AppSheetX() : FullscreenBottomSheetDialogFragment(), Callbacks {
|
|||||||
appName = product.label,
|
appName = product.label,
|
||||||
packageName = product.packageName,
|
packageName = product.packageName,
|
||||||
icon = imageData,
|
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(
|
AppInfoChips(
|
||||||
product = product,
|
product = product,
|
||||||
@ -435,34 +471,9 @@ class AppSheetX() : FullscreenBottomSheetDialogFragment(), Callbacks {
|
|||||||
) {
|
) {
|
||||||
item {
|
item {
|
||||||
AppInfoHeader(
|
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,
|
mainAction = mainAction,
|
||||||
possibleActions = actions?.filter { it != mainAction }?.toSet()
|
possibleActions = actions?.filter { it != mainAction }?.toSet()
|
||||||
?: emptySet(),
|
?: 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) }
|
onAction = { onActionClick(it) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user