Add: AppInfo Chips' group

This commit is contained in:
machiav3lli 2022-09-19 00:41:15 +02:00
parent d72cea8036
commit 9102d2845c
2 changed files with 45 additions and 0 deletions

View File

@ -1,14 +1,58 @@
package com.machiav3lli.fdroid.ui.compose.components.appsheet
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.rememberScrollState
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.machiav3lli.fdroid.R
import com.machiav3lli.fdroid.database.entity.Product
import com.machiav3lli.fdroid.database.entity.Release
import com.machiav3lli.fdroid.ui.compose.components.CategoryChip
import com.machiav3lli.fdroid.ui.compose.utils.CustomChip
import com.machiav3lli.fdroid.ui.compose.utils.StaggeredGrid
import com.machiav3lli.fdroid.utility.extension.text.formatSize
import java.text.DateFormat
import java.util.*
@Composable
fun AppInfoChips(
modifier: Modifier = Modifier,
product: Product,
latestRelease: Release?
) {
val list = listOfNotNull(
"v${product.version}",
product.displayRelease?.size?.formatSize().orEmpty(),
DateFormat.getDateInstance().format(Date(product.updated)),
if (latestRelease?.minSdkVersion != 0) "${stringResource(id = R.string.min_sdk)} ${latestRelease?.minSdkVersion}"
else null,
if (product.antiFeatures.isNotEmpty()) stringResource(id = R.string.anti_features)
else null,
*product.licenses.toTypedArray(),
)
LazyRow(
modifier = modifier.height(54.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp),
contentPadding = PaddingValues(8.dp)
) {
items(list) { text ->
CategoryChip(
category = text,
isSelected = false
)
}
}
}
// TODO: Convert Permissions and AntiFeatures to Custom Interface

View File

@ -218,4 +218,5 @@
<string name="prefs_sync">Synchronization</string>
<string name="group_telegram">Our Telegram group</string>
<string name="group_matrix">Our Matrix group</string>
<string name="min_sdk">minSDK</string>
</resources>