From 1407e219d2361c5ba174b4acb437a78975eea74c Mon Sep 17 00:00:00 2001 From: machiav3lli Date: Sun, 9 Oct 2022 23:08:17 +0200 Subject: [PATCH] Update: Use ActionChip for sort/filter and download-all chips --- .../fdroid/ui/pages/ExplorePage.kt | 30 ++-------- .../fdroid/ui/pages/InstalledPage.kt | 59 +++++-------------- .../machiav3lli/fdroid/ui/pages/LatestPage.kt | 29 ++------- 3 files changed, 24 insertions(+), 94 deletions(-) diff --git a/src/main/kotlin/com/machiav3lli/fdroid/ui/pages/ExplorePage.kt b/src/main/kotlin/com/machiav3lli/fdroid/ui/pages/ExplorePage.kt index 6766beaf..d4d3395d 100644 --- a/src/main/kotlin/com/machiav3lli/fdroid/ui/pages/ExplorePage.kt +++ b/src/main/kotlin/com/machiav3lli/fdroid/ui/pages/ExplorePage.kt @@ -7,13 +7,8 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.SuggestionChip -import androidx.compose.material3.SuggestionChipDefaults -import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.SideEffect import androidx.compose.runtime.getValue @@ -31,6 +26,7 @@ import com.machiav3lli.fdroid.content.Preferences import com.machiav3lli.fdroid.entity.Section import com.machiav3lli.fdroid.ui.activities.MainActivityX import com.machiav3lli.fdroid.ui.compose.ProductsVerticalRecycler +import com.machiav3lli.fdroid.ui.compose.components.ActionChip import com.machiav3lli.fdroid.ui.compose.components.CategoryChip import com.machiav3lli.fdroid.ui.compose.icons.Phosphor import com.machiav3lli.fdroid.ui.compose.icons.phosphor.FunnelSimple @@ -88,26 +84,10 @@ fun ExplorePage(viewModel: MainNavFragmentViewModelX) { mutableStateOf(false) } - SuggestionChip( - shape = MaterialTheme.shapes.medium, - colors = SuggestionChipDefaults.suggestionChipColors( - containerColor = MaterialTheme.colorScheme.surface, - labelColor = MaterialTheme.colorScheme.onSurface, - ), - onClick = { - mainActivityX.navigateSortFilter(NavItem.Explore.destination) - }, - icon = { - Icon( - modifier = Modifier.size(18.dp), - imageVector = Phosphor.FunnelSimple, - contentDescription = stringResource(id = R.string.sort_filter) - ) - }, - label = { - Text(text = stringResource(id = R.string.sort_filter)) - } - ) + ActionChip( + textId = R.string.sort_filter, + icon = Phosphor.FunnelSimple + ) { mainActivityX.navigateSortFilter(NavItem.Explore.destination) } Spacer(modifier = Modifier.weight(1f)) CategoryChip( category = stringResource(id = R.string.favorite_applications), diff --git a/src/main/kotlin/com/machiav3lli/fdroid/ui/pages/InstalledPage.kt b/src/main/kotlin/com/machiav3lli/fdroid/ui/pages/InstalledPage.kt index 233796fe..42aa2f75 100644 --- a/src/main/kotlin/com/machiav3lli/fdroid/ui/pages/InstalledPage.kt +++ b/src/main/kotlin/com/machiav3lli/fdroid/ui/pages/InstalledPage.kt @@ -15,8 +15,6 @@ import androidx.compose.material3.ElevatedButton import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.SuggestionChip -import androidx.compose.material3.SuggestionChipDefaults import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.SideEffect @@ -37,6 +35,7 @@ import com.machiav3lli.fdroid.database.entity.Product import com.machiav3lli.fdroid.ui.activities.MainActivityX import com.machiav3lli.fdroid.ui.compose.ProductsHorizontalRecycler import com.machiav3lli.fdroid.ui.compose.ProductsVerticalRecycler +import com.machiav3lli.fdroid.ui.compose.components.ActionChip import com.machiav3lli.fdroid.ui.compose.icons.Phosphor import com.machiav3lli.fdroid.ui.compose.icons.phosphor.CaretDown import com.machiav3lli.fdroid.ui.compose.icons.phosphor.CaretUp @@ -117,32 +116,18 @@ fun InstalledPage(viewModel: MainNavFragmentViewModelX) { ) } Spacer(modifier = Modifier.weight(1f)) - SuggestionChip( - shape = MaterialTheme.shapes.medium, - colors = SuggestionChipDefaults.suggestionChipColors( - containerColor = MaterialTheme.colorScheme.surface, - labelColor = MaterialTheme.colorScheme.onSurface, - ), - onClick = { - secondaryList?.let { - mainActivityX.syncConnection.binder?.updateApps( - it.map( - Product::toItem - ) + ActionChip( + textId = R.string.update_all, + icon = Phosphor.Download, + ) { + secondaryList?.let { + mainActivityX.syncConnection.binder?.updateApps( + it.map( + Product::toItem ) - } - }, - icon = { - Icon( - modifier = Modifier.size(18.dp), - imageVector = Phosphor.Download, - contentDescription = stringResource(id = R.string.update_all) ) - }, - label = { - Text(text = stringResource(id = R.string.update_all)) } - ) + } } AnimatedVisibility(visible = updatesVisible) { ProductsHorizontalRecycler(secondaryList, repositoriesMap) { item -> @@ -159,26 +144,10 @@ fun InstalledPage(viewModel: MainNavFragmentViewModelX) { text = stringResource(id = R.string.installed_applications), modifier = Modifier.weight(1f), ) - SuggestionChip( - shape = MaterialTheme.shapes.medium, - colors = SuggestionChipDefaults.suggestionChipColors( - containerColor = MaterialTheme.colorScheme.surface, - labelColor = MaterialTheme.colorScheme.onSurface, - ), - onClick = { - mainActivityX.navigateSortFilter(NavItem.Installed.destination) - }, - icon = { - Icon( - modifier = Modifier.size(18.dp), - imageVector = Phosphor.FunnelSimple, - contentDescription = stringResource(id = R.string.sort_filter) - ) - }, - label = { - Text(text = stringResource(id = R.string.sort_filter)) - } - ) + ActionChip( + textId = R.string.sort_filter, + icon = Phosphor.FunnelSimple + ) { mainActivityX.navigateSortFilter(NavItem.Installed.destination) } } ProductsVerticalRecycler( productsList = primaryList?.sortedBy { it.label.lowercase() }, diff --git a/src/main/kotlin/com/machiav3lli/fdroid/ui/pages/LatestPage.kt b/src/main/kotlin/com/machiav3lli/fdroid/ui/pages/LatestPage.kt index e645c588..60d38d77 100644 --- a/src/main/kotlin/com/machiav3lli/fdroid/ui/pages/LatestPage.kt +++ b/src/main/kotlin/com/machiav3lli/fdroid/ui/pages/LatestPage.kt @@ -4,14 +4,10 @@ import androidx.compose.foundation.background import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.SuggestionChip -import androidx.compose.material3.SuggestionChipDefaults import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.SideEffect @@ -28,6 +24,7 @@ import com.machiav3lli.fdroid.R import com.machiav3lli.fdroid.content.Preferences import com.machiav3lli.fdroid.ui.activities.MainActivityX import com.machiav3lli.fdroid.ui.compose.ProductsHorizontalRecycler +import com.machiav3lli.fdroid.ui.compose.components.ActionChip import com.machiav3lli.fdroid.ui.compose.components.ProductsListItem import com.machiav3lli.fdroid.ui.compose.icons.Phosphor import com.machiav3lli.fdroid.ui.compose.icons.phosphor.FunnelSimple @@ -97,26 +94,10 @@ fun LatestPage(viewModel: MainNavFragmentViewModelX) { text = stringResource(id = R.string.recently_updated), modifier = Modifier.weight(1f), ) - SuggestionChip( - shape = MaterialTheme.shapes.medium, - colors = SuggestionChipDefaults.suggestionChipColors( - containerColor = MaterialTheme.colorScheme.surface, - labelColor = MaterialTheme.colorScheme.onSurface, - ), - onClick = { - mainActivityX.navigateSortFilter(NavItem.Latest.destination) - }, - icon = { - Icon( - modifier = Modifier.size(18.dp), - imageVector = Phosphor.FunnelSimple, - contentDescription = stringResource(id = R.string.sort_filter) - ) - }, - label = { - Text(text = stringResource(id = R.string.sort_filter)) - } - ) + ActionChip( + textId = R.string.sort_filter, + icon = Phosphor.FunnelSimple + ) { mainActivityX.navigateSortFilter(NavItem.Latest.destination) } } } items(