Refactor(ToolStore): Optimize the prompt when there is nothing
This commit is contained in:
@@ -80,6 +80,7 @@ internal fun ToolStoreRoute(
|
|||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
toolStorePagingItems = toolStorePagingItems,
|
toolStorePagingItems = toolStorePagingItems,
|
||||||
installInfo = installInfo,
|
installInfo = installInfo,
|
||||||
|
searchValue = searchValue,
|
||||||
onNavigateToToolView = onNavigateToToolView,
|
onNavigateToToolView = onNavigateToToolView,
|
||||||
onChangeInstallStatus = viewModel::changeInstallInfo,
|
onChangeInstallStatus = viewModel::changeInstallInfo,
|
||||||
onChangeInstallType = {
|
onChangeInstallType = {
|
||||||
@@ -94,6 +95,7 @@ internal fun ToolStoreScreen(
|
|||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
toolStorePagingItems: LazyPagingItems<ToolEntity>,
|
toolStorePagingItems: LazyPagingItems<ToolEntity>,
|
||||||
installInfo: ToolStoreUiState.InstallInfo,
|
installInfo: ToolStoreUiState.InstallInfo,
|
||||||
|
searchValue: String,
|
||||||
onNavigateToToolView: (username: String, toolId: String, preview: Boolean) -> Unit,
|
onNavigateToToolView: (username: String, toolId: String, preview: Boolean) -> Unit,
|
||||||
onChangeInstallStatus: (status: ToolStoreUiState.InstallInfo.Status) -> Unit,
|
onChangeInstallStatus: (status: ToolStoreUiState.InstallInfo.Status) -> Unit,
|
||||||
onChangeInstallType: (type: ToolStoreUiState.InstallInfo.Type) -> Unit,
|
onChangeInstallType: (type: ToolStoreUiState.InstallInfo.Type) -> Unit,
|
||||||
@@ -112,11 +114,15 @@ internal fun ToolStoreScreen(
|
|||||||
|
|
||||||
val infiniteTransition = rememberInfiniteTransition(label = "infiniteTransition")
|
val infiniteTransition = rememberInfiniteTransition(label = "infiniteTransition")
|
||||||
|
|
||||||
var installTool by remember { mutableStateOf(ToolEntity(
|
var installTool by remember {
|
||||||
toolId = "Unknown",
|
mutableStateOf(
|
||||||
authorUsername = "Unknown",
|
ToolEntity(
|
||||||
ver = "Unknown"
|
toolId = "Unknown",
|
||||||
)) }
|
authorUsername = "Unknown",
|
||||||
|
ver = "Unknown"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
modifier.fillMaxSize()
|
modifier.fillMaxSize()
|
||||||
@@ -146,7 +152,7 @@ internal fun ToolStoreScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toolStorePagingItems.loadState.refresh is LoadState.Loading || toolStorePagingItems.loadState.append is LoadState.Loading) {
|
if (toolStorePagingItems.loadState.refresh is LoadState.Loading) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
@@ -169,6 +175,21 @@ internal fun ToolStoreScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (itemsAvailable == 0 && !isToolLoading) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.fillMaxSize(),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.Center
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = stringResource(
|
||||||
|
if (searchValue.isEmpty()) R.string.core_nothing
|
||||||
|
else R.string.core_nothing_found
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
state.DraggableScrollbar(
|
state.DraggableScrollbar(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxHeight()
|
.fillMaxHeight()
|
||||||
@@ -349,11 +370,14 @@ private fun InstallAlertDialog(
|
|||||||
when (status) {
|
when (status) {
|
||||||
ToolStoreUiState.InstallInfo.Status.Pending ->
|
ToolStoreUiState.InstallInfo.Status.Pending ->
|
||||||
TextButton(onClick = onInstallTool) {
|
TextButton(onClick = onInstallTool) {
|
||||||
Text(text = stringResource(
|
Text(
|
||||||
when (type) {
|
text = stringResource(
|
||||||
ToolStoreUiState.InstallInfo.Type.Install -> R.string.core_install
|
when (type) {
|
||||||
ToolStoreUiState.InstallInfo.Type.Upgrade -> R.string.core_upgrade
|
ToolStoreUiState.InstallInfo.Type.Install -> R.string.core_install
|
||||||
}))
|
ToolStoreUiState.InstallInfo.Type.Upgrade -> R.string.core_upgrade
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolStoreUiState.InstallInfo.Status.Success,
|
ToolStoreUiState.InstallInfo.Status.Success,
|
||||||
|
|||||||
Reference in New Issue
Block a user