Skip to content

Commit

Permalink
Re-enable modifier missing check rule (LawnchairLauncher#1970)
Browse files Browse the repository at this point in the history
  • Loading branch information
Goooler authored Apr 13, 2024
1 parent 2097071 commit f0e76f6
Show file tree
Hide file tree
Showing 18 changed files with 87 additions and 37 deletions.
7 changes: 5 additions & 2 deletions app/src/main/kotlin/app/lawnchair/lawnicons/ui/Lawnicons.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,18 @@ import soup.compose.material.motion.animation.rememberSlideDistance

@Composable
@ExperimentalFoundationApi
fun Lawnicons(windowSizeClass: WindowSizeClass) {
fun Lawnicons(
windowSizeClass: WindowSizeClass,
modifier: Modifier = Modifier,
) {
val navController = rememberNavController()
val isRtl = LocalLayoutDirection.current == LayoutDirection.Rtl
val slideDistance = rememberSlideDistance()
val isExpandedScreen = windowSizeClass.widthSizeClass == WindowWidthSizeClass.Expanded

LawniconsTheme {
Surface(
modifier = Modifier.fillMaxSize(),
modifier = modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background,
) {
NavHost(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import coil.request.ImageRequest
fun ContributorRow(
name: String,
photoUrl: String,
modifier: Modifier = Modifier,
profileUrl: String? = null,
socialUrl: String? = null,
description: String? = null,
Expand All @@ -44,6 +45,7 @@ fun ContributorRow(
}

SimpleListRow(
modifier = modifier,
background = background,
first = first,
last = last,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ import app.lawnchair.lawnicons.ui.util.PreviewLawnicons

@Composable
fun ContributorRowPlaceholder(
modifier: Modifier = Modifier,
first: Boolean = false,
last: Boolean = false,
divider: Boolean = true,
) {
Row {
Row(
modifier = modifier,
) {
ListRow(
divider = divider,
background = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package app.lawnchair.lawnicons.ui.components
import android.content.Intent
import android.net.Uri
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import app.lawnchair.lawnicons.ui.components.core.SimpleListRow
import app.lawnchair.lawnicons.ui.theme.LawniconsTheme
Expand All @@ -12,6 +13,7 @@ import app.lawnchair.lawnicons.ui.util.PreviewLawnicons
fun ExternalLinkRow(
name: String,
url: String,
modifier: Modifier = Modifier,
divider: Boolean = true,
background: Boolean = false,
first: Boolean = false,
Expand All @@ -26,6 +28,7 @@ fun ExternalLinkRow(
}

SimpleListRow(
modifier = modifier,
background = background,
first = first,
last = last,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ fun LawniconsScaffold(
title: String,
onBack: () -> Unit,
isExpandedScreen: Boolean,
modifier: Modifier = Modifier,
content: @Composable (PaddingValues) -> Unit,
) {
var scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior()
Expand All @@ -34,7 +35,7 @@ fun LawniconsScaffold(
}

Scaffold(
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
modifier = modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
topBar = {
TopAppBar(
scrollBehavior = scrollBehavior,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ fun TopAppBar(
navigationIcon: @Composable () -> Unit,
scrollBehavior: TopAppBarScrollBehavior,
title: String,
modifier: Modifier = Modifier,
isExpandedScreen: Boolean = false,
) {
if (!isExpandedScreen) {
LargeTopAppBar(
modifier = modifier,
scrollBehavior = scrollBehavior,
navigationIcon = navigationIcon,
title = {
Expand All @@ -34,6 +36,7 @@ fun TopAppBar(
)
} else {
TopAppBar(
modifier = modifier,
scrollBehavior = scrollBehavior,
navigationIcon = navigationIcon,
title = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import app.lawnchair.lawnicons.ui.util.SampleData
@Composable
fun IconInfoPopup(
iconInfo: IconInfo,
modifier: Modifier = Modifier,
isPopupShown: (Boolean) -> Unit,
) {
val sheetState = rememberModalBottomSheetState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,25 @@ private fun ColorScheme.iconColor(): Color {
@Composable
fun IconPreview(
iconInfo: IconInfo,
modifier: Modifier = Modifier,
iconBackground: Color? = null,
) {
val isIconInfoShown = remember { mutableStateOf(false) }

val modifier = Modifier
.padding(all = 8.dp)
.aspectRatio(ratio = 1F)
.clip(shape = CircleShape)
.clickable(onClick = { isIconInfoShown.value = true })
.background(
color = iconBackground ?: if (isIconInfoShown.value) {
MaterialTheme.colorScheme.surfaceVariant
} else {
MaterialTheme.colorScheme.iconColor()
},
)

Box(
contentAlignment = Alignment.Center,
modifier = modifier,
modifier = modifier
.padding(all = 8.dp)
.aspectRatio(ratio = 1F)
.clip(shape = CircleShape)
.clickable(onClick = { isIconInfoShown.value = true })
.background(
color = iconBackground ?: if (isIconInfoShown.value) {
MaterialTheme.colorScheme.surfaceVariant
} else {
MaterialTheme.colorScheme.iconColor()
},
),
) {
if (LocalInspectionMode.current) {
val icon = when (iconInfo.id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ import kotlinx.collections.immutable.ImmutableList
fun IconPreviewGrid(
iconInfo: ImmutableList<IconInfo>,
isExpandedScreen: Boolean,
modifier: Modifier = Modifier,
) {
LazyVerticalGrid(
modifier = Modifier
modifier = modifier
.statusBarsPadding()
.padding(top = 26.dp),
columns = GridCells.Adaptive(minSize = 80.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,21 @@ import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.DpOffset
import androidx.compose.ui.unit.dp

@Composable
fun OverflowMenu(block: @Composable OverflowMenuScope.() -> Unit) {
fun OverflowMenu(
modifier: Modifier = Modifier,
block: @Composable OverflowMenuScope.() -> Unit,
) {
val showMenu = remember { mutableStateOf(false) }
val overflowMenuScope = remember { OverflowMenuScopeImpl(showMenu) }

Box {
Box(
modifier = modifier,
) {
ClickableIcon(
imageVector = Icons.Rounded.MoreVert,
size = 52.dp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ import app.lawnchair.lawnicons.ui.theme.LawniconsTheme
import app.lawnchair.lawnicons.ui.util.PreviewLawnicons

@Composable
fun PlaceholderSearchBar() {
fun PlaceholderSearchBar(
modifier: Modifier = Modifier,
) {
Row(
content = {},
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
modifier = modifier
.zIndex(1f)
.statusBarsPadding()
.padding(top = 8.dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,19 @@ fun LawniconsSearchBar(
onQueryChange: (String) -> Unit,
iconInfoModel: IconInfoModel,
onNavigate: (String) -> Unit,
modifier: Modifier = Modifier,
isExpandedScreen: Boolean = false,
) {
LawniconsSearchBar(
query,
isQueryEmpty,
onClearAndBackClick,
onQueryChange,
iconInfoModel.iconCount,
iconInfoModel.iconInfo,
onNavigate,
isExpandedScreen,
query = query,
isQueryEmpty = isQueryEmpty,
onClearAndBackClick = onClearAndBackClick,
onQueryChange = onQueryChange,
iconCount = iconInfoModel.iconCount,
iconInfo = iconInfoModel.iconInfo,
onNavigate = onNavigate,
isExpandedScreen = isExpandedScreen,
modifier = modifier,
)
}

Expand All @@ -87,12 +89,13 @@ fun LawniconsSearchBar(
iconCount: Int,
iconInfo: ImmutableList<IconInfo>,
onNavigate: (String) -> Unit,
modifier: Modifier = Modifier,
isExpandedScreen: Boolean = false,
) {
var active by rememberSaveable { mutableStateOf(false) }

Box(
modifier = Modifier
modifier = modifier
.then(
if (!active || isExpandedScreen) {
Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,16 @@ private val specialThanks = listOf(
)

@Composable
fun About(onBack: () -> Unit, onNavigate: (String) -> Unit, isExpandedScreen: Boolean) {
fun About(
onBack: () -> Unit,
onNavigate: (String) -> Unit,
isExpandedScreen: Boolean,
modifier: Modifier = Modifier,
) {
val context = LocalContext.current

LawniconsScaffold(
modifier = modifier,
title = stringResource(id = R.string.about),
onBack = onBack,
isExpandedScreen = isExpandedScreen,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ fun Acknowledgement(
name: String?,
onBack: () -> Unit,
isExpandedScreen: Boolean,
modifier: Modifier = Modifier,
acknowledgementViewModel: AcknowledgementViewModel = hiltViewModel(),
) {
requireNotNull(name)
Expand All @@ -52,6 +53,7 @@ fun Acknowledgement(
).collectAsState()

LawniconsScaffold(
modifier = modifier,
title = name,
onBack = onBack,
isExpandedScreen = isExpandedScreen,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ fun Acknowledgements(
onBack: () -> Unit,
onNavigate: (String) -> Unit,
isExpandedScreen: Boolean,
modifier: Modifier = Modifier,
acknowledgementsViewModel: AcknowledgementsViewModel = hiltViewModel(),
) {
val ossLibraries by acknowledgementsViewModel.ossLibraries.collectAsState()

LawniconsScaffold(
modifier = modifier,
title = stringResource(id = R.string.acknowledgements),
onBack = onBack,
isExpandedScreen = isExpandedScreen,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ const val CONTRIBUTOR_URL = "https://github.com/LawnchairLauncher/lawnicons/grap
fun Contributors(
onBack: () -> Unit,
isExpandedScreen: Boolean,
modifier: Modifier = Modifier,
contributorsViewModel: ContributorsViewModel = hiltViewModel(),
) {
val uiState by contributorsViewModel.uiState.collectAsState()
Contributors(
uiState = uiState,
onBack = onBack,
isExpandedScreen = isExpandedScreen,
modifier = modifier,
)
}

Expand All @@ -54,8 +56,10 @@ fun Contributors(
uiState: ContributorsUiState,
onBack: () -> Unit,
isExpandedScreen: Boolean,
modifier: Modifier = Modifier,
) {
LawniconsScaffold(
modifier = modifier,
title = stringResource(id = R.string.contributors),
onBack = onBack,
isExpandedScreen = isExpandedScreen,
Expand All @@ -75,8 +79,12 @@ fun Contributors(
}

@Composable
fun ContributorList(contributors: ImmutableList<GitHubContributor>) {
private fun ContributorList(
contributors: ImmutableList<GitHubContributor>,
modifier: Modifier = Modifier,
) {
LazyColumn(
modifier = modifier,
contentPadding = WindowInsets.navigationBars.toPaddingValues(
additionalTop = 8.dp,
additionalBottom = 8.dp,
Expand Down Expand Up @@ -110,9 +118,12 @@ fun ContributorList(contributors: ImmutableList<GitHubContributor>) {
}

@Composable
fun ContributorListPlaceholder() {
private fun ContributorListPlaceholder(
modifier: Modifier = Modifier,
) {
val itemCount = 20
LazyColumn(
modifier = modifier,
contentPadding = WindowInsets.navigationBars.toPaddingValues(
additionalTop = 8.dp,
additionalBottom = 8.dp,
Expand All @@ -129,7 +140,7 @@ fun ContributorListPlaceholder() {
}

@Composable
fun ContributorListError(
private fun ContributorListError(
onBack: () -> Unit,
) {
val context = LocalContext.current
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.hilt.navigation.compose.hiltViewModel
import app.lawnchair.lawnicons.ui.components.home.IconPreviewGrid
import app.lawnchair.lawnicons.ui.components.home.LawniconsSearchBar
Expand All @@ -23,13 +24,15 @@ import app.lawnchair.lawnicons.viewmodel.LawniconsViewModel
fun Home(
onNavigate: (String) -> Unit,
isExpandedScreen: Boolean,
modifier: Modifier = Modifier,
lawniconsViewModel: LawniconsViewModel = hiltViewModel(),
) {
val iconInfoModel by lawniconsViewModel.iconInfoModel.collectAsState()
val searchedIconInfoModel by lawniconsViewModel.searchedIconInfoModel.collectAsState()
var searchTerm by rememberSaveable { mutableStateOf(value = "") }

Crossfade(
modifier = modifier,
targetState = iconInfoModel != null,
label = "",
) { targetState ->
Expand Down
Loading

0 comments on commit f0e76f6

Please sign in to comment.