compose: details: Pass screen directly in single parameter
Reduces the function parameter hell for navigating to extra pane. Credits to Torsten for suggesting this. Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -256,14 +256,8 @@ private fun ScreenContentApp(
|
|||||||
exodusReport = exodusReport,
|
exodusReport = exodusReport,
|
||||||
hasValidUpdate = hasValidUpdate,
|
hasValidUpdate = hasValidUpdate,
|
||||||
onNavigateUp = onNavigateUp,
|
onNavigateUp = onNavigateUp,
|
||||||
onNavigateToDetailsDevProfile = { showExtraPane(Screen.DevProfile(it)) },
|
onNavigateToScreen = { screen -> showExtraPane(screen) },
|
||||||
onNavigateToDetailsMore = { showExtraPane(Screen.DetailsMore) },
|
|
||||||
onNavigateToDetailsScreenshot = { showExtraPane(Screen.DetailsScreenshot(it)) },
|
|
||||||
onNavigateToDetailsReview = { showExtraPane(Screen.DetailsReview) },
|
|
||||||
onNavigateToDetailsExodus = { showExtraPane(Screen.DetailsExodus) },
|
|
||||||
onNavigateToDetailsPermission = { showExtraPane(Screen.DetailsPermission) },
|
|
||||||
onDownload = onDownload,
|
onDownload = onDownload,
|
||||||
onManualDownload = { showExtraPane(Screen.DetailsManualDownload) },
|
|
||||||
onCancelDownload = onCancelDownload,
|
onCancelDownload = onCancelDownload,
|
||||||
onUninstall = onUninstall,
|
onUninstall = onUninstall,
|
||||||
onOpen = onOpen,
|
onOpen = onOpen,
|
||||||
@@ -274,7 +268,7 @@ private fun ScreenContentApp(
|
|||||||
},
|
},
|
||||||
supportingPane = {
|
supportingPane = {
|
||||||
AnimatedPane {
|
AnimatedPane {
|
||||||
ScreenContentAppSupporting(
|
ScreenContentAppSupportingPane(
|
||||||
suggestions = suggestions,
|
suggestions = suggestions,
|
||||||
onNavigateToAppDetails = onNavigateToAppDetails,
|
onNavigateToAppDetails = onNavigateToAppDetails,
|
||||||
menuActions = { if (!shouldShowMenuOnMainPane) SetupMenu() }
|
menuActions = { if (!shouldShowMenuOnMainPane) SetupMenu() }
|
||||||
@@ -330,14 +324,8 @@ private fun ScreenContentAppMainPane(
|
|||||||
exodusReport: Report?,
|
exodusReport: Report?,
|
||||||
hasValidUpdate: Boolean,
|
hasValidUpdate: Boolean,
|
||||||
onNavigateUp: () -> Unit,
|
onNavigateUp: () -> Unit,
|
||||||
onNavigateToDetailsDevProfile: (developerName: String) -> Unit,
|
onNavigateToScreen: (screen: Screen) -> Unit,
|
||||||
onNavigateToDetailsMore: () -> Unit,
|
|
||||||
onNavigateToDetailsScreenshot: (index: Int) -> Unit,
|
|
||||||
onNavigateToDetailsReview: () -> Unit,
|
|
||||||
onNavigateToDetailsExodus: () -> Unit,
|
|
||||||
onNavigateToDetailsPermission: () -> Unit,
|
|
||||||
onDownload: () -> Unit,
|
onDownload: () -> Unit,
|
||||||
onManualDownload: () -> Unit,
|
|
||||||
onCancelDownload: () -> Unit,
|
onCancelDownload: () -> Unit,
|
||||||
onUninstall: () -> Unit,
|
onUninstall: () -> Unit,
|
||||||
onOpen: () -> Unit,
|
onOpen: () -> Unit,
|
||||||
@@ -387,7 +375,7 @@ private fun ScreenContentAppMainPane(
|
|||||||
primaryActionDisplayName = primaryActionName,
|
primaryActionDisplayName = primaryActionName,
|
||||||
secondaryActionDisplayName = stringResource(R.string.title_manual_download),
|
secondaryActionDisplayName = stringResource(R.string.title_manual_download),
|
||||||
onPrimaryAction = onDownload,
|
onPrimaryAction = onDownload,
|
||||||
onSecondaryAction = onManualDownload
|
onSecondaryAction = { onNavigateToScreen(Screen.DetailsManualDownload) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -418,7 +406,7 @@ private fun ScreenContentAppMainPane(
|
|||||||
app = app,
|
app = app,
|
||||||
inProgress = isDownloading || isInstalling,
|
inProgress = isDownloading || isInstalling,
|
||||||
progress = progress,
|
progress = progress,
|
||||||
onNavigateToDetailsDevProfile = onNavigateToDetailsDevProfile,
|
onNavigateToDetailsDevProfile = { onNavigateToScreen(Screen.DevProfile(it)) },
|
||||||
hasValidUpdate = hasValidUpdate
|
hasValidUpdate = hasValidUpdate
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -429,18 +417,18 @@ private fun ScreenContentAppMainPane(
|
|||||||
HeaderComposable(
|
HeaderComposable(
|
||||||
title = stringResource(R.string.details_more_about_app),
|
title = stringResource(R.string.details_more_about_app),
|
||||||
subtitle = app.shortDescription,
|
subtitle = app.shortDescription,
|
||||||
onClick = onNavigateToDetailsMore
|
onClick = { onNavigateToScreen(Screen.DetailsMore) }
|
||||||
)
|
)
|
||||||
|
|
||||||
AppScreenshots(
|
AppScreenshots(
|
||||||
screenshots = app.screenshots,
|
screenshots = app.screenshots,
|
||||||
onNavigateToScreenshot = onNavigateToDetailsScreenshot
|
onNavigateToScreenshot = { onNavigateToScreen(Screen.DetailsScreenshot(it)) }
|
||||||
)
|
)
|
||||||
|
|
||||||
AppRatingAndReviews(
|
AppRatingAndReviews(
|
||||||
rating = app.rating,
|
rating = app.rating,
|
||||||
featuredReviews = featuredReviews,
|
featuredReviews = featuredReviews,
|
||||||
onNavigateToDetailsReview = onNavigateToDetailsReview
|
onNavigateToDetailsReview = { onNavigateToScreen(Screen.DetailsReview) }
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!isAnonymous && app.testingProgram?.isAvailable == true) {
|
if (!isAnonymous && app.testingProgram?.isAvailable == true) {
|
||||||
@@ -462,7 +450,11 @@ private fun ScreenContentAppMainPane(
|
|||||||
} else {
|
} else {
|
||||||
stringResource(R.string.details_no_permission)
|
stringResource(R.string.details_no_permission)
|
||||||
},
|
},
|
||||||
onClick = if (app.permissions.isNotEmpty()) onNavigateToDetailsPermission else null
|
onClick = if (app.permissions.isNotEmpty()) {
|
||||||
|
{ onNavigateToScreen(Screen.DetailsPermission) }
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
if (dataSafetyReport != null) {
|
if (dataSafetyReport != null) {
|
||||||
@@ -475,7 +467,7 @@ private fun ScreenContentAppMainPane(
|
|||||||
AppPrivacy(
|
AppPrivacy(
|
||||||
report = exodusReport,
|
report = exodusReport,
|
||||||
onNavigateToDetailsExodus = if (!exodusReport?.trackers.isNullOrEmpty()) {
|
onNavigateToDetailsExodus = if (!exodusReport?.trackers.isNullOrEmpty()) {
|
||||||
onNavigateToDetailsExodus
|
{ onNavigateToScreen(Screen.DetailsExodus) }
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
@@ -494,7 +486,7 @@ private fun ScreenContentAppMainPane(
|
|||||||
* Composable to display similar and related app suggestions
|
* Composable to display similar and related app suggestions
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
private fun ScreenContentAppSupporting(
|
private fun ScreenContentAppSupportingPane(
|
||||||
menuActions: @Composable (RowScope.() -> Unit) = {},
|
menuActions: @Composable (RowScope.() -> Unit) = {},
|
||||||
suggestions: List<App> = emptyList(),
|
suggestions: List<App> = emptyList(),
|
||||||
onNavigateToAppDetails: (packageName: String) -> Unit = {}
|
onNavigateToAppDetails: (packageName: String) -> Unit = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user