From 93342555610e704701d37ab0800d7eb913304100 Mon Sep 17 00:00:00 2001 From: SuperDragonXD <70206496+SuperDragonXD@users.noreply.github.com> Date: Sat, 14 Sep 2024 20:14:57 +0800 Subject: [PATCH] Update placeholder UI --- .../ui/components/home/PlaceholderUI.kt | 155 ++++++++++++++++++ .../lawnicons/ui/destination/Contributors.kt | 11 ++ .../lawnicons/ui/destination/Home.kt | 13 +- app/src/main/res/values-en-rUS/strings.xml | 70 -------- .../lawnicons/helper/AppfilterDiffCreator.kt | 10 +- 5 files changed, 174 insertions(+), 85 deletions(-) create mode 100644 app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/PlaceholderUI.kt delete mode 100644 app/src/main/res/values-en-rUS/strings.xml diff --git a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/PlaceholderUI.kt b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/PlaceholderUI.kt new file mode 100644 index 00000000000..36301c012f5 --- /dev/null +++ b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/PlaceholderUI.kt @@ -0,0 +1,155 @@ +/* + * Copyright 2024 Lawnchair Launcher + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package app.lawnchair.lawnicons.ui.components.home + +import android.annotation.SuppressLint +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.WindowInsets +import androidx.compose.foundation.layout.aspectRatio +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.navigationBars +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.lazy.grid.GridCells +import androidx.compose.foundation.lazy.grid.GridItemSpan +import androidx.compose.foundation.lazy.grid.LazyVerticalGrid +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.material3.BottomAppBar +import androidx.compose.material3.BottomAppBarDefaults +import androidx.compose.material3.CenterAlignedTopAppBar +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Scaffold +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.unit.dp +import app.lawnchair.lawnicons.ui.components.core.placeholder.PlaceholderHighlight +import app.lawnchair.lawnicons.ui.components.core.placeholder.fade +import app.lawnchair.lawnicons.ui.components.core.placeholder.placeholder +import app.lawnchair.lawnicons.ui.components.core.placeholder.shimmer +import app.lawnchair.lawnicons.ui.util.toPaddingValues + +@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter") +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun PlaceholderUI( + showDummyCard: Boolean, + modifier: Modifier = Modifier, +) { + val contentPadding = IconPreviewGridPadding.Defaults + Scaffold( + modifier = modifier, + bottomBar = { + BottomAppBar( + modifier = Modifier.placeholder( + visible = true, + color = BottomAppBarDefaults.containerColor, + highlight = PlaceholderHighlight.shimmer( + MaterialTheme.colorScheme.surfaceContainer, + ), + ), + ) {} + }, + ) { + LazyVerticalGrid( + columns = GridCells.Adaptive(80.dp), + userScrollEnabled = false, + contentPadding = WindowInsets.navigationBars.toPaddingValues( + additionalStart = contentPadding.horizontalPadding, + additionalTop = contentPadding.topPadding, + additionalEnd = contentPadding.horizontalPadding, + ), + ) { + item( + span = { GridItemSpan(maxLineSpan) }, + ) { + CenterAlignedTopAppBar( + title = { + Row( + verticalAlignment = Alignment.CenterVertically, + ) { + Box( + modifier = Modifier + .size(36.dp) + .clip(CircleShape) + .placeholder( + visible = true, + color = MaterialTheme.colorScheme.surfaceContainer, + highlight = PlaceholderHighlight.fade(), + ), + ) + Spacer(modifier = Modifier.width(8.dp)) + Box( + modifier = Modifier + .width(96.dp) + .height(16.dp) + .clip(MaterialTheme.shapes.small) + .placeholder( + visible = true, + color = MaterialTheme.colorScheme.surfaceContainer, + highlight = PlaceholderHighlight.fade(), + ), + ) + } + }, + ) + } + if (showDummyCard) { + item(span = { GridItemSpan(maxLineSpan) }) { + Box( + modifier = Modifier + .padding(horizontal = 8.dp) + .padding(bottom = 12.dp) + .height(48.dp) + .fillMaxWidth() + .clip(CircleShape) + .placeholder( + visible = true, + color = MaterialTheme.colorScheme.surfaceContainer, + highlight = PlaceholderHighlight.shimmer( + MaterialTheme.colorScheme.surfaceContainerHigh, + ), + ), + ) {} + } + } + + items(100) { + Box( + contentAlignment = Alignment.Center, + modifier = Modifier + .padding(all = 8.dp) + .aspectRatio(ratio = 1F) + .clip(shape = CircleShape) + .placeholder( + visible = true, + color = MaterialTheme.colorScheme.iconColor, + highlight = PlaceholderHighlight.shimmer( + MaterialTheme.colorScheme.surfaceContainer, + ), + ), + ) {} + } + } + } +} diff --git a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/destination/Contributors.kt b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/destination/Contributors.kt index 124c0c8b5a1..1a677077f2e 100644 --- a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/destination/Contributors.kt +++ b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/destination/Contributors.kt @@ -153,7 +153,18 @@ private fun ContributorListPlaceholder( LazyColumn( modifier = modifier, contentPadding = contentPadding, + userScrollEnabled = false, ) { + item { + ContributorRowPlaceholder( + first = true, + last = true, + divider = false, + ) + } + item { + Spacer(modifier = Modifier.height(16.dp)) + } items(itemCount) { ContributorRowPlaceholder( first = it == 0, diff --git a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/destination/Home.kt b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/destination/Home.kt index 6db59cfbf7d..8a4981aae31 100644 --- a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/destination/Home.kt +++ b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/destination/Home.kt @@ -3,12 +3,9 @@ package app.lawnchair.lawnicons.ui.destination import android.annotation.SuppressLint import androidx.compose.animation.Crossfade import androidx.compose.foundation.ExperimentalFoundationApi -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.lazy.grid.GridItemSpan import androidx.compose.foundation.lazy.grid.rememberLazyGridState -import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.Scaffold import androidx.compose.material3.SnackbarHost import androidx.compose.material3.SnackbarHostState @@ -17,7 +14,6 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.remember -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.platform.LocalContext @@ -36,6 +32,7 @@ import app.lawnchair.lawnicons.ui.components.home.IconPreviewGrid import app.lawnchair.lawnicons.ui.components.home.IconPreviewGridPadding import app.lawnchair.lawnicons.ui.components.home.IconRequestFAB import app.lawnchair.lawnicons.ui.components.home.NewIconsCard +import app.lawnchair.lawnicons.ui.components.home.PlaceholderUI import app.lawnchair.lawnicons.ui.components.home.search.PlaceholderSearchBar import app.lawnchair.lawnicons.ui.theme.LawniconsTheme import app.lawnchair.lawnicons.ui.util.PreviewLawnicons @@ -166,13 +163,7 @@ private fun Home( if (isExpandedScreen) { PlaceholderSearchBar() } else { - Column( - verticalArrangement = Arrangement.Center, - horizontalAlignment = Alignment.CenterHorizontally, - modifier = Modifier.fillMaxSize(), - ) { - CircularProgressIndicator() - } + PlaceholderUI(newIconsInfoModel.iconCount != 0) } } } diff --git a/app/src/main/res/values-en-rUS/strings.xml b/app/src/main/res/values-en-rUS/strings.xml deleted file mode 100644 index 72a16c0059c..00000000000 --- a/app/src/main/res/values-en-rUS/strings.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - Version %s - - - - - Pick an icon - - Search - - %s not found - - About - - - - Icon request form - - - Contributors - - Core contributors - - See all contributors - - View on GitHub - - Share details - - Core app - Icons - Infrastructure - - - Special thanks - - For inspiring the app icon - - For naming the app - - Open-source licenses - - - Name - - Drawable - - Component name - - Mapped components - - If the icon is outdated due to rebranding, create an issue on GitHub. - - Toggle visibility of contents - - Request icons - Copy to clipboard - Copied text - - Request missing icons from the bottom bar - Copied icon request details to clipboard. To request them, submit the details into the form. - Open form - Clear - New icons in v%1$s - New icons (%1$s) - diff --git a/svg-processor/src/main/kotlin/app/lawnchair/lawnicons/helper/AppfilterDiffCreator.kt b/svg-processor/src/main/kotlin/app/lawnchair/lawnicons/helper/AppfilterDiffCreator.kt index 66b1089230a..d51108c8950 100644 --- a/svg-processor/src/main/kotlin/app/lawnchair/lawnicons/helper/AppfilterDiffCreator.kt +++ b/svg-processor/src/main/kotlin/app/lawnchair/lawnicons/helper/AppfilterDiffCreator.kt @@ -33,7 +33,8 @@ object AppfilterDiffCreator { if (fetchProcess.waitFor() != 0) { throw RuntimeException("Failed to execute $fetchCommand: $output") } else { - val describeCommand = listOf("git", "describe", "--tags", "--abbrev=0") + val describeCommand = + listOf("git", "describe", "--tags", "--abbrev=0", "--start=main") val describeProcess = ProcessBuilder(describeCommand) .redirectErrorStream(true) .start() @@ -99,9 +100,10 @@ object AppfilterDiffCreator { resDir: String, appFilterFile: String, ) { - val mainLines = readFileContents(appFilterFile) - val developLines = getPreviousReleaseLines(appFilterFile) - val diff = getLineDiff(mainLines, developLines) + val diff = getLineDiff( + getPreviousReleaseLines(appFilterFile), + readFileContents(appFilterFile), + ) writeDiffToFile(diff, resDir) }