compose: Expose modifier for root composables

This will allow adapting them as needed from different screens

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2025-04-30 18:34:24 +08:00
parent 097f5a7375
commit ea9ab9ebbc
29 changed files with 99 additions and 42 deletions

View File

@@ -5,7 +5,6 @@
package com.aurora.store.compose.composables
import androidx.annotation.StringRes
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
@@ -24,6 +23,7 @@ import com.aurora.store.R
/**
* Composable to display sticky header in list
* @param modifier The modifier to be applied to the composable
* @param title Title to display
* @param actionTitle Title for the action button
* @param onAction Callback when action button is clicked
@@ -32,12 +32,13 @@ import com.aurora.store.R
*/
@Composable
fun ActionHeaderComposable(
modifier: Modifier = Modifier,
title: String,
actionTitle: String,
onAction: () -> Unit = {}
) {
Row(
modifier = Modifier
modifier = modifier
.fillMaxWidth()
.padding(
horizontal = dimensionResource(R.dimen.padding_medium),

View File

@@ -35,6 +35,7 @@ import com.aurora.store.R
/**
* Composable for displaying package details in a list for blacklisting
* @param modifier The modifier to be applied to the composable
* @param icon Icon for the package
* @param displayName User-readable name of the package
* @param packageName Name of the package
@@ -46,6 +47,7 @@ import com.aurora.store.R
*/
@Composable
fun BlackListComposable(
modifier: Modifier = Modifier,
icon: Bitmap,
displayName: String,
packageName: String,
@@ -56,7 +58,7 @@ fun BlackListComposable(
onClick: () -> Unit = {}
) {
Row(
modifier = Modifier
modifier = modifier
.fillMaxWidth()
.clickable(enabled = isEnabled, onClick = onClick)
.padding(

View File

@@ -32,13 +32,18 @@ import com.aurora.store.compose.composables.preview.coilPreviewProvider
/**
* Composable to show a category in a list
* @param modifier The modifier to be applied to the composable
* @param category [Category] details to display
* @param onClick Callback when this composable is clicked
*/
@Composable
fun CategoryComposable(category: Category, onClick: () -> Unit = {}) {
fun CategoryComposable(
modifier: Modifier = Modifier,
category: Category,
onClick: () -> Unit = {}
) {
Row(
modifier = Modifier
modifier = modifier
.fillMaxWidth()
.clickable(onClick = onClick)
.padding(dimensionResource(R.dimen.padding_small)),

View File

@@ -25,6 +25,7 @@ import com.aurora.store.R
/**
* Composable to display device details for spoofing in a list
* @param modifier The modifier to be applied to the composable
* @param userReadableName Name of the device, obtained through `UserReadableName` property
* @param manufacturer Name of the device manufacturer, obtained through `Build.MANUFACTURER` property
* @param androidVersionSdk Android version on the device, obtained through `Build.VERSION.SDK_INT` property
@@ -34,6 +35,7 @@ import com.aurora.store.R
*/
@Composable
fun DeviceComposable(
modifier: Modifier = Modifier,
userReadableName: String,
manufacturer: String,
androidVersionSdk: String,
@@ -42,7 +44,7 @@ fun DeviceComposable(
onClick: () -> Unit = {}
) {
Row(
modifier = Modifier
modifier = modifier
.fillMaxWidth()
.clickable(onClick = onClick)
.padding(dimensionResource(R.dimen.padding_small)),

View File

@@ -26,14 +26,20 @@ import com.aurora.store.R
/**
* Composable to display dispenser URL in a list
* @param modifier The modifier to be applied to the composable
* @param url URL of the dispenser
* @param onClick Callback when this URL is clicked
* @param onClear Callback when the clear button is clicked
*/
@Composable
fun DispenserComposable(url: String, onClick: () -> Unit = {}, onClear: () -> Unit = {}) {
fun DispenserComposable(
modifier: Modifier = Modifier,
url: String,
onClick: () -> Unit = {},
onClear: () -> Unit = {}
) {
Row(
modifier = Modifier
modifier = modifier
.fillMaxWidth()
.clickable(onClick = onClick)
.padding(dimensionResource(R.dimen.padding_small)),

View File

@@ -5,7 +5,6 @@
package com.aurora.store.compose.composables
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
@@ -44,19 +43,20 @@ import com.aurora.store.util.CommonUtil.getETAString
/**
* Composable to display details of a download in a list
* @param modifier The modifier to be applied to the composable
* @param download [Download] to display
* @param onClick Callback when this composable is clicked
* @param onLongClick Callback when this composable is long clicked
*/
@Composable
@OptIn(ExperimentalFoundationApi::class)
fun DownloadComposable(
modifier: Modifier = Modifier,
download: Download,
onClick: () -> Unit = {},
onLongClick: (() -> Unit) = {}
) {
Row(
modifier = Modifier
modifier = modifier
.fillMaxWidth()
.combinedClickable(onClick = onClick, onLongClick = onLongClick)
.padding(

View File

@@ -45,18 +45,20 @@ import com.aurora.store.data.room.favourite.Favourite
/**
* Composable to display a favourite app in a list
* @param modifier The modifier to be applied to the composable
* @param favourite A [Favourite] app to display
* @param onClick Callback when this composable is clicked
* @param onClear Callback when the favourite button is clicked to remove the app from favourites
*/
@Composable
fun FavouriteComposable(
modifier: Modifier = Modifier,
favourite: Favourite,
onClick: () -> Unit = {},
onClear: () -> Unit = {}
) {
Row(
modifier = Modifier
modifier = modifier
.fillMaxWidth()
.clickable(onClick = onClick)
.padding(

View File

@@ -28,6 +28,7 @@ import com.aurora.store.R
/**
* Composable to display sticky header in list
* @param modifier The modifier to be applied to the composable
* @param title Title to display
* @param subtitle Optional subtitle to display
* @param onClick Callback when this composable is clicked
@@ -35,9 +36,14 @@ import com.aurora.store.R
* @see ActionHeaderComposable
*/
@Composable
fun HeaderComposable(title: String, subtitle: String? = null, onClick: (() -> Unit)? = null) {
fun HeaderComposable(
modifier: Modifier = Modifier,
title: String,
subtitle: String? = null,
onClick: (() -> Unit)? = null
) {
Row(
modifier = Modifier
modifier = modifier
.fillMaxWidth()
.clip(RoundedCornerShape(dimensionResource(R.dimen.radius_small)))
.clickable(onClick = { if (onClick != null) onClick() }, enabled = onClick != null)

View File

@@ -32,7 +32,7 @@ import com.aurora.store.compose.composables.preview.AppPreviewProvider
/**
* Composable to show some information
* @param modifier Modifier to change the composable
* @param modifier The modifier to be applied to the composable
* @param title Title of the information
* @param description Information to show
* @param icon Optional icon representing the information

View File

@@ -7,7 +7,6 @@ package com.aurora.store.compose.composables
import android.graphics.Bitmap
import android.graphics.Color
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Column
@@ -33,6 +32,7 @@ import com.aurora.store.R
/**
* Composable for displaying installed package details in a list
* @param modifier The modifier to be applied to the composable
* @param icon Icon for the package
* @param displayName User-readable name of the package
* @param packageName Name of the package
@@ -42,8 +42,8 @@ import com.aurora.store.R
* @param onLongClick Callback whe composable is long clicked
*/
@Composable
@OptIn(ExperimentalFoundationApi::class)
fun InstalledAppComposable(
modifier: Modifier = Modifier,
icon: Bitmap,
displayName: String,
packageName: String,
@@ -53,7 +53,7 @@ fun InstalledAppComposable(
onLongClick: () -> Unit = {}
) {
Row(
modifier = Modifier
modifier = modifier
.fillMaxWidth()
.combinedClickable(onClick = onClick, onLongClick = onLongClick)
.padding(

View File

@@ -27,18 +27,20 @@ import com.aurora.store.data.model.InstallerInfo
/**
* Composable to display installer details in a list
* @param modifier The modifier to be applied to the composable
* @param installerInfo A [InstallerInfo] object to display details
* @param isSelected Whether this installer is selected
* @param onClick Callback when this composable is clicked
*/
@Composable
fun InstallerComposable(
modifier: Modifier = Modifier,
installerInfo: InstallerInfo,
isSelected: Boolean = false,
onClick: () -> Unit = {}
) {
Row(
modifier = Modifier
modifier = modifier
.fillMaxWidth()
.clickable(onClick = onClick)
.padding(dimensionResource(R.dimen.padding_small)),

View File

@@ -30,13 +30,14 @@ import com.aurora.store.data.model.Link
/**
* Composable to show link details in a list
* @param modifier The modifier to be applied to the composable
* @param link [Link] to show details
* @param onClick Callback when the composable is clicked
*/
@Composable
fun LinkComposable(link: Link, onClick: () -> Unit = {}) {
fun LinkComposable(modifier: Modifier = Modifier, link: Link, onClick: () -> Unit = {}) {
Row(
modifier = Modifier
modifier = modifier
.fillMaxWidth()
.clickable(onClick = onClick)
.padding(dimensionResource(R.dimen.padding_small)),

View File

@@ -25,6 +25,7 @@ import java.util.Locale
/**
* Composable to display locale details in a list
* @param modifier The modifier to be applied to the composable
* @param displayName Display name of the locale
* @param displayLanguage Display name of the language in the locale
* @param isChecked Whether the locale is checked/selected
@@ -32,13 +33,14 @@ import java.util.Locale
*/
@Composable
fun LocaleComposable(
modifier: Modifier = Modifier,
displayName: String,
displayLanguage: String,
isChecked: Boolean = false,
onClick: () -> Unit = {}
) {
Row(
modifier = Modifier
modifier = modifier
.fillMaxWidth()
.clickable(onClick = onClick)
.padding(dimensionResource(R.dimen.padding_small)),

View File

@@ -27,18 +27,20 @@ import com.aurora.store.data.model.PermissionType
/**
* Composable to display permission details in a list
* @param modifier The modifier to be applied to the composable
* @param permission [Permission] to display
* @param isGranted If the permission has been granted
* @param onAction Callback when the user clicks the action button
*/
@Composable
fun PermissionComposable(
modifier: Modifier = Modifier,
permission: Permission,
isGranted: Boolean = false,
onAction: () -> Unit = {}
) {
Row(
modifier = Modifier
modifier = modifier
.fillMaxWidth()
.padding(dimensionResource(R.dimen.padding_small)),
verticalAlignment = Alignment.CenterVertically,

View File

@@ -35,6 +35,7 @@ import com.aurora.store.R
/**
* A top app bar composable to be used with Scaffold in different Screen
* @param modifier The modifier to be applied to the composable
* @param searchHint Hint to show to the user in search bar
* @param onNavigateUp Action when user clicks the navigation icon
* @param onSearch Callback for a search
@@ -43,6 +44,7 @@ import com.aurora.store.R
@Composable
@OptIn(ExperimentalMaterial3Api::class)
fun SearchAppBarComposable(
modifier: Modifier = Modifier,
@StringRes searchHint: Int? = null,
onNavigateUp: () -> Unit,
onSearch: (query: String) -> Unit,
@@ -52,6 +54,7 @@ fun SearchAppBarComposable(
var query by rememberSaveable { mutableStateOf("") }
TopAppBar(
modifier = modifier,
title = {
TextField(
modifier = Modifier.fillMaxWidth(),

View File

@@ -32,18 +32,20 @@ import com.aurora.store.R
/**
* Composable for displaying search suggestions in a list
* @param modifier The modifier to be applied to the composable
* @param searchSuggestEntry A [SearchSuggestEntry] to display search suggestion
* @param onClick Callback when this composable is clicked
* @param onAction Callback when action button is clicked
*/
@Composable
fun SearchSuggestionComposable(
modifier: Modifier = Modifier,
searchSuggestEntry: SearchSuggestEntry,
onClick: () -> Unit = {},
onAction: () -> Unit = {}
) {
Row(
modifier = Modifier
modifier = modifier
.fillMaxWidth()
.clickable(onClick = onClick)
.padding(dimensionResource(R.dimen.padding_medium)),

View File

@@ -21,14 +21,15 @@ import com.aurora.store.R
/**
* Composable to display a sticky header in a list
* @param modifier The modifier to be applied to the composable
* @param title Title to display
* @see HeaderComposable
* @see ActionHeaderComposable
*/
@Composable
fun TextDividerComposable(@StringRes title: Int) {
fun TextDividerComposable(modifier: Modifier = Modifier, @StringRes title: Int) {
Row(
modifier = Modifier
modifier = modifier
.fillMaxWidth()
.padding(dimensionResource(R.dimen.padding_small))
) {

View File

@@ -14,6 +14,7 @@ import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
@@ -21,6 +22,7 @@ import com.aurora.store.R
/**
* A top app bar composable to be used with Scaffold in different Screen
* @param modifier The modifier to be applied to the composable
* @param title Title of the screen
* @param navigationIcon Icon for the navigation button
* @param onNavigateUp Action when user clicks the navigation icon
@@ -29,12 +31,14 @@ import com.aurora.store.R
@Composable
@OptIn(ExperimentalMaterial3Api::class)
fun TopAppBarComposable(
modifier: Modifier = Modifier,
title: String? = null,
navigationIcon: ImageVector = Icons.AutoMirrored.Filled.ArrowBack,
onNavigateUp: (() -> Unit)? = null,
actions: @Composable (RowScope.() -> Unit) = {}
) {
TopAppBar(
modifier = modifier,
title = { if (title != null) Text(text = title) },
navigationIcon = {
if (onNavigateUp != null) {

View File

@@ -7,6 +7,7 @@ package com.aurora.store.compose.composables
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import com.aurora.store.R
@@ -16,10 +17,12 @@ import com.aurora.store.R
*
* This is useful for occupying spaces in composable where alignment is not respected such as
* DropDownMenu.
* @param modifier The modifier to be applied to the composable
*/
@Composable
fun TransparentIconComposable() {
fun TransparentIconComposable(modifier: Modifier = Modifier) {
Icon(
modifier = modifier,
painter = painterResource(R.drawable.ic_transparent),
contentDescription = null
)

View File

@@ -38,7 +38,7 @@ import com.aurora.store.compose.composables.preview.coilPreviewProvider
/**
* Composable to show icon for an app that can be animated to also show install progress
* @param modifier Modifier to alter the composable
* @param modifier The modifier to be applied to the composable
* @param iconUrl URL of the app icon
* @param progress Progress to show, for e.g. download or install
* @param inProgress Whether to show indeterminate or determinate progress bar

View File

@@ -37,16 +37,17 @@ import com.aurora.store.compose.composables.preview.coilPreviewProvider
/**
* Composable for displaying minimal app details in a horizontal-scrollable list
* @param modifier The modifier to be applied to the composable
* @param app [App] to display
* @param onClick Callback when the composable is clicked
* @see AppListComposable
*/
@Composable
fun AppComposable(app: App, onClick: () -> Unit = {}) {
fun AppComposable(modifier: Modifier = Modifier, app: App, onClick: () -> Unit = {}) {
val context = LocalContext.current
Column(
modifier = Modifier
modifier = modifier
.width(dimensionResource(R.dimen.icon_size_cluster))
.clickable(onClick = onClick)
.padding(dimensionResource(R.dimen.padding_xsmall))

View File

@@ -40,14 +40,15 @@ import com.aurora.store.util.CommonUtil
/**
* Composable for displaying minimal app details in a vertical-scrollable list
* @param modifier The modifier to be applied to the composable
* @param app [App] to display
* @param onClick Callback when the composable is clicked
* @see AppComposable
*/
@Composable
fun AppListComposable(app: App, onClick: () -> Unit = {}) {
fun AppListComposable(modifier: Modifier = Modifier, app: App, onClick: () -> Unit = {}) {
Row(
modifier = Modifier
modifier = modifier
.fillMaxWidth()
.clickable(onClick = onClick)
.padding(

View File

@@ -19,7 +19,7 @@ import com.aurora.store.R
/**
* Composable to display an indeterminate circular progress indicator
* @param modifier Modifier for the composable
* @param modifier The modifier to be applied to the composable
*/
@Composable
fun AppProgressComposable(modifier: Modifier = Modifier) {

View File

@@ -11,6 +11,7 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
@@ -21,13 +22,20 @@ import com.aurora.store.compose.composables.preview.AppPreviewProvider
/**
* Composable to show a tag related to an app
* @param modifier The modifier to be applied to the composable
* @param label Label of the tag
* @param icon Icon of the tag
* @param onClick Callback when this composable is clicked
*/
@Composable
fun AppTagComposable(label: String, @DrawableRes icon: Int, onClick: () -> Unit = {}) {
fun AppTagComposable(
modifier: Modifier = Modifier,
label: String,
@DrawableRes icon: Int,
onClick: () -> Unit = {}
) {
FilterChip(
modifier = modifier,
onClick = onClick,
label = { Text(text = label, style = MaterialTheme.typography.bodySmall) },
leadingIcon = { Icon(painter = painterResource(icon), contentDescription = label) },

View File

@@ -26,7 +26,7 @@ import com.aurora.store.R
/**
* Composable to show error message when no apps are available for a request
* @param modifier Modifier for the composable
* @param modifier The modifier to be applied to the composable
* @param icon Drawable for error
* @param message Message for error
* @param actionMessage Message to show on action button; defaults to null with button not visible

View File

@@ -20,11 +20,12 @@ import com.aurora.store.data.model.ExodusTracker
/**
* Composable to display details about a tracker reported by Exodus Privacy
* @param modifier The modifier to be applied to the composable
* @param tracker Tracker to display details about
*/
@Composable
fun ExodusComposable(tracker: ExodusTracker) {
Column(modifier = Modifier.padding(dimensionResource(R.dimen.padding_small))) {
fun ExodusComposable(modifier: Modifier = Modifier, tracker: ExodusTracker) {
Column(modifier = modifier.padding(dimensionResource(R.dimen.padding_small))) {
Text(
text = tracker.name,
style = MaterialTheme.typography.bodyMedium,

View File

@@ -23,13 +23,14 @@ import com.aurora.store.R
/**
* Composable to show a progress bar with rating for an app
* @param modifier The modifier to be applied to the composable
* @param label Label of the rating, for e.g. 5
* @param rating Current rating, for e.g. 0.3
*/
@Composable
fun RatingComposable(label: String, rating: Float) {
fun RatingComposable(modifier: Modifier = Modifier, label: String, rating: Float) {
Row(
modifier = Modifier
modifier = modifier
.fillMaxWidth()
.padding(horizontal = dimensionResource(R.dimen.padding_small)),
verticalAlignment = Alignment.CenterVertically,

View File

@@ -37,12 +37,13 @@ import com.aurora.store.compose.composables.preview.coilPreviewProvider
/**
* Composable for viewing a review about an app
* @param modifier The modifier to be applied to the composable
* @param review [Review] about an app
*/
@Composable
fun ReviewComposable(review: Review) {
fun ReviewComposable(modifier: Modifier = Modifier, review: Review) {
Row(
modifier = Modifier
modifier = modifier
.fillMaxWidth()
.padding(
horizontal = dimensionResource(R.dimen.padding_medium),

View File

@@ -30,8 +30,8 @@ import com.aurora.store.compose.composables.preview.coilPreviewProvider
/**
* Composable to display a screenshot of an app
* @param modifier The modifier to be applied to the composable
* @param url URL of the screenshot
* @param modifier Modifier for the composable
*/
@Composable
fun ScreenshotComposable(modifier: Modifier = Modifier, url: String) {