diff --git a/app/src/main/kotlin/app/lawnchair/lawnicons/model/IconInfoModel.kt b/app/src/main/kotlin/app/lawnchair/lawnicons/model/IconInfoModel.kt index 4db96ebb6ad..05230377873 100644 --- a/app/src/main/kotlin/app/lawnchair/lawnicons/model/IconInfoModel.kt +++ b/app/src/main/kotlin/app/lawnchair/lawnicons/model/IconInfoModel.kt @@ -1,6 +1,8 @@ package app.lawnchair.lawnicons.model +import kotlinx.collections.immutable.ImmutableList + data class IconInfoModel( - val iconInfo: List, + val iconInfo: ImmutableList, val iconCount: Int, ) diff --git a/app/src/main/kotlin/app/lawnchair/lawnicons/repository/IconRepository.kt b/app/src/main/kotlin/app/lawnchair/lawnicons/repository/IconRepository.kt index 30f2adc84fb..9c5bc6ed4f9 100644 --- a/app/src/main/kotlin/app/lawnchair/lawnicons/repository/IconRepository.kt +++ b/app/src/main/kotlin/app/lawnchair/lawnicons/repository/IconRepository.kt @@ -6,6 +6,7 @@ import app.lawnchair.lawnicons.model.IconInfoModel import app.lawnchair.lawnicons.model.SearchInfo import app.lawnchair.lawnicons.util.getIconInfo import javax.inject.Inject +import kotlinx.collections.immutable.toPersistentList import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableStateFlow @@ -26,11 +27,11 @@ class IconRepository @Inject constructor(application: Application) { .sortedBy { it.name.lowercase() } .also { iconInfoModel.value = IconInfoModel( - iconInfo = it, + iconInfo = it.toPersistentList(), iconCount = it.size, ) searchedIconInfoModel.value = IconInfoModel( - iconInfo = it, + iconInfo = it.toPersistentList(), iconCount = it.size, ) } @@ -57,7 +58,7 @@ class IconRepository @Inject constructor(application: Application) { ), ).map { searchInfo -> searchInfo.iconInfo - } + }.toPersistentList() IconInfoModel( iconCount = it.size, iconInfo = filtered, diff --git a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/ContributorRow.kt b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/ContributorRow.kt index cb270cc6f3d..1d3c3bbdcc8 100644 --- a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/ContributorRow.kt +++ b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/ContributorRow.kt @@ -15,7 +15,7 @@ import androidx.compose.ui.platform.LocalInspectionMode import androidx.compose.ui.unit.dp import app.lawnchair.lawnicons.ui.components.core.SimpleListRow import app.lawnchair.lawnicons.ui.theme.LawniconsTheme -import app.lawnchair.lawnicons.ui.util.LawniconsPreview +import app.lawnchair.lawnicons.ui.util.PreviewLawnicons import coil.compose.AsyncImage import coil.request.ImageRequest @@ -70,9 +70,9 @@ fun ContributorRow( ) } -@LawniconsPreview +@PreviewLawnicons @Composable -fun ContributorRowPreview() { +private fun ContributorRowPreview() { LawniconsTheme { ContributorRow( name = "User", diff --git a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/ContributorRowPlaceholder.kt b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/ContributorRowPlaceholder.kt index b34aad4065e..37986076dc5 100644 --- a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/ContributorRowPlaceholder.kt +++ b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/ContributorRowPlaceholder.kt @@ -16,7 +16,7 @@ import app.lawnchair.lawnicons.ui.components.core.placeholder.material.fade import app.lawnchair.lawnicons.ui.components.core.placeholder.material.placeholder import app.lawnchair.lawnicons.ui.theme.LawniconsTheme import app.lawnchair.lawnicons.ui.util.Elevation -import app.lawnchair.lawnicons.ui.util.LawniconsPreview +import app.lawnchair.lawnicons.ui.util.PreviewLawnicons import app.lawnchair.lawnicons.ui.util.surfaceColorAtElevation @Composable @@ -63,9 +63,9 @@ fun ContributorRowPlaceholder( } } -@LawniconsPreview +@PreviewLawnicons @Composable -fun ContributorRowPlaceholderPreview() { +private fun ContributorRowPlaceholderPreview() { LawniconsTheme { ContributorRowPlaceholder() } diff --git a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/ExternalLinkRow.kt b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/ExternalLinkRow.kt index 75bdeae399e..fe92d2ef975 100644 --- a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/ExternalLinkRow.kt +++ b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/ExternalLinkRow.kt @@ -6,7 +6,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.platform.LocalContext import app.lawnchair.lawnicons.ui.components.core.SimpleListRow import app.lawnchair.lawnicons.ui.theme.LawniconsTheme -import app.lawnchair.lawnicons.ui.util.LawniconsPreview +import app.lawnchair.lawnicons.ui.util.PreviewLawnicons @Composable fun ExternalLinkRow( @@ -35,9 +35,9 @@ fun ExternalLinkRow( ) } -@LawniconsPreview +@PreviewLawnicons @Composable -fun ExternalLinkRowPreview() { +private fun ExternalLinkRowPreview() { LawniconsTheme { ExternalLinkRow( name = "User", diff --git a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/core/Card.kt b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/core/Card.kt index 5c41af0c552..505b3383fdb 100644 --- a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/core/Card.kt +++ b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/core/Card.kt @@ -12,7 +12,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import app.lawnchair.lawnicons.ui.theme.LawniconsTheme import app.lawnchair.lawnicons.ui.util.Elevation -import app.lawnchair.lawnicons.ui.util.LawniconsPreview +import app.lawnchair.lawnicons.ui.util.PreviewLawnicons @Composable fun Card( @@ -26,7 +26,7 @@ fun Card( text = label, style = MaterialTheme.typography.titleSmall, color = MaterialTheme.colorScheme.primary, - modifier = modifier.padding(start = 32.dp, bottom = 12.dp), + modifier = Modifier.padding(start = 32.dp, bottom = 12.dp), ) } Surface( @@ -44,9 +44,9 @@ fun Card( } } -@LawniconsPreview +@PreviewLawnicons @Composable -fun CardPreview() { +private fun CardPreview() { LawniconsTheme { Card( label = "Example", diff --git a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/core/LawniconsScaffold.kt b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/core/LawniconsScaffold.kt index c1a9d38ad5a..52ae3fd4dbd 100644 --- a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/core/LawniconsScaffold.kt +++ b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/core/LawniconsScaffold.kt @@ -17,7 +17,7 @@ import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.unit.dp import app.lawnchair.lawnicons.ui.components.home.ClickableIcon import app.lawnchair.lawnicons.ui.theme.LawniconsTheme -import app.lawnchair.lawnicons.ui.util.LawniconsPreview +import app.lawnchair.lawnicons.ui.util.PreviewLawnicons import app.lawnchair.lawnicons.ui.util.toPaddingValues @OptIn(ExperimentalMaterial3Api::class) @@ -68,9 +68,9 @@ fun LawniconsScaffold( } } -@LawniconsPreview +@PreviewLawnicons @Composable -fun LawniconsScaffoldPreview() { +private fun LawniconsScaffoldPreview() { LawniconsTheme { LawniconsScaffold( title = "Example small bar", @@ -87,9 +87,9 @@ fun LawniconsScaffoldPreview() { } } -@LawniconsPreview +@PreviewLawnicons @Composable -fun LawniconsScaffoldExpandedPreview() { +private fun LawniconsScaffoldExpandedPreview() { LawniconsTheme { LawniconsScaffold( title = "Example small bar", diff --git a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/core/SimpleListRow.kt b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/core/SimpleListRow.kt index 1c34596e5ec..6bdb1d3a107 100644 --- a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/core/SimpleListRow.kt +++ b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/core/SimpleListRow.kt @@ -7,7 +7,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.text.style.TextOverflow import app.lawnchair.lawnicons.ui.theme.LawniconsTheme -import app.lawnchair.lawnicons.ui.util.LawniconsPreview +import app.lawnchair.lawnicons.ui.util.PreviewLawnicons @Composable fun SimpleListRow( @@ -52,9 +52,9 @@ fun SimpleListRow( ) } -@LawniconsPreview +@PreviewLawnicons @Composable -fun SimpleListRowPreview() { +private fun SimpleListRowPreview() { LawniconsTheme { SimpleListRow( label = "Example", diff --git a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/core/SystemUi.kt b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/core/SystemUi.kt index 7e1e78c4ae9..dd915c8184d 100644 --- a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/core/SystemUi.kt +++ b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/core/SystemUi.kt @@ -24,7 +24,7 @@ fun SystemUi() { showSystemUi = true, ) @Composable -fun SystemUIPreview() { +private fun SystemUIPreview() { LawniconsTheme { SystemUi() } diff --git a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/core/TopAppBar.kt b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/core/TopAppBar.kt index ce27eb6aa57..3167592d59a 100644 --- a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/core/TopAppBar.kt +++ b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/core/TopAppBar.kt @@ -14,7 +14,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import app.lawnchair.lawnicons.ui.components.home.ClickableIcon import app.lawnchair.lawnicons.ui.theme.LawniconsTheme -import app.lawnchair.lawnicons.ui.util.LawniconsPreview +import app.lawnchair.lawnicons.ui.util.PreviewLawnicons @OptIn(ExperimentalMaterial3Api::class) @Composable @@ -44,9 +44,9 @@ fun TopAppBar( } @OptIn(ExperimentalMaterial3Api::class) -@LawniconsPreview +@PreviewLawnicons @Composable -fun SmallTopAppBarPreview() { +private fun SmallTopAppBarPreview() { LawniconsTheme { TopAppBar( navigationIcon = { @@ -65,9 +65,9 @@ fun SmallTopAppBarPreview() { } @OptIn(ExperimentalMaterial3Api::class) -@LawniconsPreview +@PreviewLawnicons @Composable -fun LargeTopAppBarPreview() { +private fun LargeTopAppBarPreview() { LawniconsTheme { TopAppBar( navigationIcon = { diff --git a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/ClickableIcon.kt b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/ClickableIcon.kt index 405f8c08ac7..be3b3d5e58e 100644 --- a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/ClickableIcon.kt +++ b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/ClickableIcon.kt @@ -17,14 +17,14 @@ import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import app.lawnchair.lawnicons.ui.theme.LawniconsTheme -import app.lawnchair.lawnicons.ui.util.LawniconsPreview +import app.lawnchair.lawnicons.ui.util.PreviewLawnicons @Composable fun ClickableIcon( - modifier: Modifier = Modifier, - size: Dp = 48.dp, onClick: () -> Unit, imageVector: ImageVector, + modifier: Modifier = Modifier, + size: Dp = 48.dp, tint: Color = MaterialTheme.colorScheme.onSurface, ) { Box( @@ -42,9 +42,9 @@ fun ClickableIcon( } } -@LawniconsPreview +@PreviewLawnicons @Composable -fun ClickableIconPreview() { +private fun ClickableIconPreview() { LawniconsTheme { ClickableIcon( imageVector = Icons.Rounded.Clear, diff --git a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/IconInfoPopup.kt b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/IconInfoPopup.kt index 8ce0d73b51c..35b415932e9 100644 --- a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/IconInfoPopup.kt +++ b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/IconInfoPopup.kt @@ -15,7 +15,6 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable -import androidx.compose.runtime.MutableState import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Modifier @@ -28,16 +27,16 @@ import androidx.compose.ui.unit.dp import app.lawnchair.lawnicons.R import app.lawnchair.lawnicons.model.IconInfo import app.lawnchair.lawnicons.ui.theme.LawniconsTheme -import app.lawnchair.lawnicons.ui.util.LawniconsPreview +import app.lawnchair.lawnicons.ui.util.PreviewLawnicons import app.lawnchair.lawnicons.ui.util.SampleData @Composable fun IconInfoPopup( iconInfo: IconInfo, - isPopupShown: MutableState, + isPopupShown: (Boolean) -> Unit, ) { AlertDialog( - onDismissRequest = { isPopupShown.value = false }, + onDismissRequest = { isPopupShown(false) }, title = { Text(text = iconInfo.name) }, icon = { if (LocalInspectionMode.current) { @@ -63,7 +62,7 @@ fun IconInfoPopup( } }, confirmButton = { - TextButton(onClick = { isPopupShown.value = false }) { + TextButton(onClick = { isPopupShown(false) }) { Text(text = stringResource(id = R.string.ok_button)) } }, @@ -95,14 +94,15 @@ fun IconInfoPopup( ) } -@LawniconsPreview +@PreviewLawnicons @Composable -fun IconInfoPopupPreview() { +private fun IconInfoPopupPreview() { val showPopup = remember { mutableStateOf(true) } LawniconsTheme { IconInfoPopup( iconInfo = SampleData.iconInfoSample, - isPopupShown = showPopup, - ) + ) { + showPopup.value = it + } } } diff --git a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/IconPreview.kt b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/IconPreview.kt index c4f2e3af06a..6dba658c1f2 100644 --- a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/IconPreview.kt +++ b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/IconPreview.kt @@ -27,7 +27,7 @@ import androidx.compose.ui.unit.dp import app.lawnchair.lawnicons.model.IconInfo import app.lawnchair.lawnicons.ui.theme.LawniconsTheme import app.lawnchair.lawnicons.ui.util.Elevation -import app.lawnchair.lawnicons.ui.util.LawniconsPreview +import app.lawnchair.lawnicons.ui.util.PreviewLawnicons import app.lawnchair.lawnicons.ui.util.SampleData import app.lawnchair.lawnicons.ui.util.surfaceColorAtElevation @@ -90,14 +90,15 @@ fun IconPreview( if (isIconInfoShown.value) { IconInfoPopup( iconInfo = iconInfo, - isPopupShown = isIconInfoShown, - ) + ) { + isIconInfoShown.value = it + } } } -@LawniconsPreview +@PreviewLawnicons @Composable -fun IconPreviewComposablePreview() { +private fun IconPreviewComposablePreview() { LawniconsTheme { IconPreview( iconInfo = SampleData.iconInfoSample, diff --git a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/IconPreviewGrid.kt b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/IconPreviewGrid.kt index 8ba2a51d19d..f3b6a9999e2 100644 --- a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/IconPreviewGrid.kt +++ b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/IconPreviewGrid.kt @@ -13,14 +13,15 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import app.lawnchair.lawnicons.model.IconInfo import app.lawnchair.lawnicons.ui.theme.LawniconsTheme -import app.lawnchair.lawnicons.ui.util.LawniconsPreview +import app.lawnchair.lawnicons.ui.util.PreviewLawnicons import app.lawnchair.lawnicons.ui.util.SampleData import app.lawnchair.lawnicons.ui.util.toPaddingValues +import kotlinx.collections.immutable.ImmutableList @Composable @ExperimentalFoundationApi fun IconPreviewGrid( - iconInfo: List, + iconInfo: ImmutableList, isExpandedScreen: Boolean, ) { LazyVerticalGrid( @@ -52,9 +53,9 @@ fun IconPreviewGrid( } @OptIn(ExperimentalFoundationApi::class) -@LawniconsPreview +@PreviewLawnicons @Composable -fun IconGridPreview() { +private fun IconGridPreview() { LawniconsTheme { IconPreviewGrid( SampleData.iconInfoList, diff --git a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/PlaceholderSearchBar.kt b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/PlaceholderSearchBar.kt index 20643728c89..641d14085d6 100644 --- a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/PlaceholderSearchBar.kt +++ b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/PlaceholderSearchBar.kt @@ -15,7 +15,7 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.zIndex import app.lawnchair.lawnicons.ui.theme.LawniconsTheme import app.lawnchair.lawnicons.ui.util.Elevation -import app.lawnchair.lawnicons.ui.util.LawniconsPreview +import app.lawnchair.lawnicons.ui.util.PreviewLawnicons import app.lawnchair.lawnicons.ui.util.surfaceColorAtElevation @Composable @@ -37,9 +37,9 @@ fun PlaceholderSearchBar() { ) } -@LawniconsPreview +@PreviewLawnicons @Composable -fun PlaceholderSearchBarPreview() { +private fun PlaceholderSearchBarPreview() { LawniconsTheme { PlaceholderSearchBar() } diff --git a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/SearchBar.kt b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/SearchBar.kt index 4168cc43e12..32b3eb0425b 100644 --- a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/SearchBar.kt +++ b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/components/home/SearchBar.kt @@ -51,9 +51,11 @@ import app.lawnchair.lawnicons.model.IconInfo import app.lawnchair.lawnicons.model.IconInfoModel import app.lawnchair.lawnicons.ui.theme.LawniconsTheme import app.lawnchair.lawnicons.ui.util.Destinations -import app.lawnchair.lawnicons.ui.util.LawniconsPreview +import app.lawnchair.lawnicons.ui.util.PreviewLawnicons import app.lawnchair.lawnicons.ui.util.SampleData import app.lawnchair.lawnicons.ui.util.toPaddingValues +import kotlinx.collections.immutable.ImmutableList +import kotlinx.collections.immutable.toPersistentList @Composable fun LawniconsSearchBar( @@ -84,7 +86,7 @@ fun LawniconsSearchBar( onClearAndBackClick: () -> Unit, onQueryChange: (String) -> Unit, iconCount: Int, - iconInfo: List, + iconInfo: ImmutableList, onNavigate: (String) -> Unit, isExpandedScreen: Boolean = false, ) { @@ -251,7 +253,7 @@ private fun SearchMenu( @Composable private fun SearchContents( - iconInfo: List, + iconInfo: ImmutableList, ) { when (iconInfo.size) { 1 -> { @@ -288,8 +290,9 @@ private fun SearchContents( if (isIconInfoShown.value) { IconInfoPopup( iconInfo = it, - isPopupShown = isIconInfoShown, - ) + ) { + isIconInfoShown.value = it + } } } } @@ -322,9 +325,9 @@ private fun SearchContents( } } -@LawniconsPreview +@PreviewLawnicons @Composable -fun SearchBarPreview() { +private fun SearchBarPreview() { var searchTerm by remember { mutableStateOf(value = "") } val iconInfo = SampleData.iconInfoList @@ -344,9 +347,9 @@ fun SearchBarPreview() { } } -@LawniconsPreview +@PreviewLawnicons @Composable -fun SearchIconPreview() { +private fun SearchIconPreview() { LawniconsTheme { Column { SearchIcon(active = true) {} @@ -355,9 +358,9 @@ fun SearchIconPreview() { } } -@LawniconsPreview +@PreviewLawnicons @Composable -fun SearchMenuPreview() { +private fun SearchMenuPreview() { LawniconsTheme { Column { SearchMenu(isQueryEmpty = false, {}, {}) diff --git a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/destination/About.kt b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/destination/About.kt index 29867b4eb68..86741a1e50f 100644 --- a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/destination/About.kt +++ b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/destination/About.kt @@ -31,7 +31,7 @@ import app.lawnchair.lawnicons.ui.theme.LawniconsTheme import app.lawnchair.lawnicons.ui.util.Contributor import app.lawnchair.lawnicons.ui.util.Destinations import app.lawnchair.lawnicons.ui.util.ExternalLink -import app.lawnchair.lawnicons.ui.util.LawniconsPreview +import app.lawnchair.lawnicons.ui.util.PreviewLawnicons import app.lawnchair.lawnicons.util.appIcon private val externalLinks = listOf( @@ -166,9 +166,9 @@ fun About(onBack: () -> Unit, onNavigate: (String) -> Unit, isExpandedScreen: Bo } } -@LawniconsPreview +@PreviewLawnicons @Composable -fun AboutPreview() { +private fun AboutPreview() { LawniconsTheme { About( {}, @@ -178,9 +178,9 @@ fun AboutPreview() { } } -@LawniconsPreview +@PreviewLawnicons @Composable -fun AboutPreviewExpanded() { +private fun AboutPreviewExpanded() { LawniconsTheme { About( {}, diff --git a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/destination/Acknowledgement.kt b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/destination/Acknowledgement.kt index 7ff08a910f9..187a44c4588 100644 --- a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/destination/Acknowledgement.kt +++ b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/destination/Acknowledgement.kt @@ -39,9 +39,9 @@ import app.lawnchair.lawnicons.viewmodel.AcknowledgementViewModel @Composable fun Acknowledgement( name: String?, - acknowledgementViewModel: AcknowledgementViewModel = hiltViewModel(), onBack: () -> Unit, isExpandedScreen: Boolean, + acknowledgementViewModel: AcknowledgementViewModel = hiltViewModel(), ) { requireNotNull(name) diff --git a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/destination/Acknowledgements.kt b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/destination/Acknowledgements.kt index fc006162f74..3ac00bfbcda 100644 --- a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/destination/Acknowledgements.kt +++ b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/destination/Acknowledgements.kt @@ -22,10 +22,10 @@ import app.lawnchair.lawnicons.viewmodel.AcknowledgementsViewModel @Composable fun Acknowledgements( - acknowledgementsViewModel: AcknowledgementsViewModel = hiltViewModel(), onBack: () -> Unit, onNavigate: (String) -> Unit, isExpandedScreen: Boolean, + acknowledgementsViewModel: AcknowledgementsViewModel = hiltViewModel(), ) { val ossLibraries by acknowledgementsViewModel.ossLibraries.collectAsState() 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 6f2715bfc40..120f7fcd904 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 @@ -26,18 +26,20 @@ import app.lawnchair.lawnicons.ui.components.ContributorRowPlaceholder import app.lawnchair.lawnicons.ui.components.ExternalLinkRow import app.lawnchair.lawnicons.ui.components.core.LawniconsScaffold import app.lawnchair.lawnicons.ui.theme.LawniconsTheme -import app.lawnchair.lawnicons.ui.util.LawniconsPreview +import app.lawnchair.lawnicons.ui.util.PreviewLawnicons import app.lawnchair.lawnicons.ui.util.toPaddingValues import app.lawnchair.lawnicons.viewmodel.ContributorsUiState import app.lawnchair.lawnicons.viewmodel.ContributorsViewModel +import kotlinx.collections.immutable.ImmutableList +import kotlinx.collections.immutable.persistentListOf const val CONTRIBUTOR_URL = "https://github.com/LawnchairLauncher/lawnicons/graphs/contributors" @Composable fun Contributors( - contributorsViewModel: ContributorsViewModel = hiltViewModel(), onBack: () -> Unit, isExpandedScreen: Boolean, + contributorsViewModel: ContributorsViewModel = hiltViewModel(), ) { val uiState by contributorsViewModel.uiState.collectAsState() Contributors( @@ -73,7 +75,7 @@ fun Contributors( } @Composable -fun ContributorList(contributors: List) { +fun ContributorList(contributors: ImmutableList) { LazyColumn( contentPadding = WindowInsets.navigationBars.toPaddingValues( additionalTop = 8.dp, @@ -141,10 +143,10 @@ fun ContributorListError( } } -@LawniconsPreview +@PreviewLawnicons @Composable -fun ContributorsScreenPreview() { - val contributors = listOf( +private fun ContributorsScreenPreview() { + val contributors = persistentListOf( GitHubContributor( id = 1, login = "Example", @@ -163,9 +165,9 @@ fun ContributorsScreenPreview() { } } -@LawniconsPreview +@PreviewLawnicons @Composable -fun ContributorsScreenLoadingPreview() { +private fun ContributorsScreenLoadingPreview() { LawniconsTheme { Contributors( ContributorsUiState.Loading, @@ -175,10 +177,10 @@ fun ContributorsScreenLoadingPreview() { } } -@LawniconsPreview +@PreviewLawnicons @Composable -fun ContributorListPreview() { - val contributors = listOf( +private fun ContributorListPreview() { + val contributors = persistentListOf( GitHubContributor( id = 1, login = "Example", @@ -193,9 +195,9 @@ fun ContributorListPreview() { } } -@LawniconsPreview +@PreviewLawnicons @Composable -fun ContributorListPlaceholderPreview() { +private fun ContributorListPlaceholderPreview() { LawniconsTheme { ContributorListPlaceholder() } 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 c87aaf9f1ac..b89a8cd745b 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 @@ -14,16 +14,16 @@ import app.lawnchair.lawnicons.ui.components.home.IconPreviewGrid import app.lawnchair.lawnicons.ui.components.home.LawniconsSearchBar import app.lawnchair.lawnicons.ui.components.home.PlaceholderSearchBar import app.lawnchair.lawnicons.ui.theme.LawniconsTheme -import app.lawnchair.lawnicons.ui.util.LawniconsPreview +import app.lawnchair.lawnicons.ui.util.PreviewLawnicons import app.lawnchair.lawnicons.ui.util.SampleData import app.lawnchair.lawnicons.viewmodel.LawniconsViewModel @OptIn(ExperimentalFoundationApi::class) @Composable fun Home( - lawniconsViewModel: LawniconsViewModel = hiltViewModel(), onNavigate: (String) -> Unit, isExpandedScreen: Boolean, + lawniconsViewModel: LawniconsViewModel = hiltViewModel(), ) { val iconInfoModel by lawniconsViewModel.iconInfoModel.collectAsState() val searchedIconInfoModel by lawniconsViewModel.searchedIconInfoModel.collectAsState() @@ -61,9 +61,9 @@ fun Home( } @OptIn(ExperimentalFoundationApi::class) -@LawniconsPreview +@PreviewLawnicons @Composable -fun HomePreview() { +private fun HomePreview() { var searchTerm by remember { mutableStateOf(value = "") } val iconInfo = SampleData.iconInfoList diff --git a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/util/PreviewUtils.kt b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/util/PreviewUtils.kt index 54687ad114c..2b3c2b8e08b 100644 --- a/app/src/main/kotlin/app/lawnchair/lawnicons/ui/util/PreviewUtils.kt +++ b/app/src/main/kotlin/app/lawnchair/lawnicons/ui/util/PreviewUtils.kt @@ -4,6 +4,7 @@ import android.content.res.Configuration import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Wallpapers import app.lawnchair.lawnicons.model.IconInfo +import kotlinx.collections.immutable.persistentListOf @Preview( name = "Normal", @@ -27,7 +28,7 @@ import app.lawnchair.lawnicons.model.IconInfo uiMode = Configuration.UI_MODE_NIGHT_YES, wallpaper = Wallpapers.RED_DOMINATED_EXAMPLE, ) -annotation class LawniconsPreview +annotation class PreviewLawnicons object SampleData { val iconInfoSample = IconInfo( @@ -36,7 +37,7 @@ object SampleData { packageName = "com.android.email", id = 1, ) - val iconInfoList = listOf( + val iconInfoList = persistentListOf( IconInfo( name = "Email", drawableName = "@drawable/email", diff --git a/app/src/main/kotlin/app/lawnchair/lawnicons/viewmodel/ContributorsViewModel.kt b/app/src/main/kotlin/app/lawnchair/lawnicons/viewmodel/ContributorsViewModel.kt index c17cc568c0b..f5dd2d57a52 100644 --- a/app/src/main/kotlin/app/lawnchair/lawnicons/viewmodel/ContributorsViewModel.kt +++ b/app/src/main/kotlin/app/lawnchair/lawnicons/viewmodel/ContributorsViewModel.kt @@ -7,6 +7,8 @@ import app.lawnchair.lawnicons.model.GitHubContributor import app.lawnchair.lawnicons.repository.GitHubContributorsRepository import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject +import kotlinx.collections.immutable.ImmutableList +import kotlinx.collections.immutable.toPersistentList import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.map @@ -17,7 +19,7 @@ import kotlinx.coroutines.launch sealed interface ContributorsUiState { data class Success( - val contributors: List, + val contributors: ImmutableList, ) : ContributorsUiState data object Loading : ContributorsUiState @@ -26,7 +28,7 @@ sealed interface ContributorsUiState { private data class ContributorsViewModelState( val isRefreshing: Boolean, - val contributors: List? = null, + val contributors: ImmutableList? = null, val hasError: Boolean = false, ) { fun toUiState(): ContributorsUiState = when { @@ -61,7 +63,7 @@ class ContributorsViewModel @Inject constructor( when { result.isSuccess -> it.copy( isRefreshing = false, - contributors = result.getOrThrow(), + contributors = result.getOrThrow().toPersistentList(), hasError = false, )