From 9102d2845c69211873e579ae8e2fb062955827db Mon Sep 17 00:00:00 2001 From: machiav3lli Date: Mon, 19 Sep 2022 00:41:15 +0200 Subject: [PATCH] Add: AppInfo Chips' group --- .../compose/components/appsheet/ChipGrid.kt | 44 +++++++++++++++++++ src/main/res/values/strings.xml | 1 + 2 files changed, 45 insertions(+) diff --git a/src/main/kotlin/com/machiav3lli/fdroid/ui/compose/components/appsheet/ChipGrid.kt b/src/main/kotlin/com/machiav3lli/fdroid/ui/compose/components/appsheet/ChipGrid.kt index abf0330e..825c8587 100644 --- a/src/main/kotlin/com/machiav3lli/fdroid/ui/compose/components/appsheet/ChipGrid.kt +++ b/src/main/kotlin/com/machiav3lli/fdroid/ui/compose/components/appsheet/ChipGrid.kt @@ -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 diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 8dd69bd9..c8272b87 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -218,4 +218,5 @@ Synchronization Our Telegram group Our Matrix group + minSDK