Skip to content

Commit

Permalink
Update placeholder UI
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperDragonXD committed Sep 14, 2024
1 parent 6dab19a commit 9334255
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 85 deletions.
Original file line number Diff line number Diff line change
@@ -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,
),
),
) {}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 2 additions & 11 deletions app/src/main/kotlin/app/lawnchair/lawnicons/ui/destination/Home.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
}
}
}
Expand Down
70 changes: 0 additions & 70 deletions app/src/main/res/values-en-rUS/strings.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 9334255

Please sign in to comment.