From dff39ce5fa29e68c1345e0be3d5ad9d8f2400e45 Mon Sep 17 00:00:00 2001 From: Kasem SM <83884225+kasem-sm@users.noreply.github.com> Date: Fri, 22 Apr 2022 00:13:52 +0530 Subject: [PATCH] Updated compose version and cleanups (#91) * Updated compose version to `1.2.0-alpha08` and clean-ups Co-authored-by: kasem-sm --- .../sm/slime/ui/navigation/NavExtensions.kt | 6 ++-- .../kasem/sm/slime/ui/navigation/NavHost.kt | 2 +- .../kasem/sm/slime/ui/navigation/Screens.kt | 16 +++++----- buildSrc/src/main/java/Accompanist.kt | 2 +- buildSrc/src/main/java/Compose.kt | 6 ++-- buildSrc/src/main/java/Jetbrains.kt | 2 +- buildSrc/src/main/java/Lifecycle.kt | 2 +- common-ui/build.gradle | 2 +- .../java/kasem/sm/common_ui/EmptyDataView.kt | 13 ++++++-- .../java/kasem/sm/common_ui/SlimeHeader.kt | 5 ++- .../java/kasem/sm/common_ui/SlimeTextField.kt | 2 ++ .../kasem/sm/core/domain/ObservableLoader.kt | 4 --- .../main/java/kasem/sm/core/utils/IMapper.kt | 10 ------ database/build.gradle | 4 +-- .../kasem/sm/article/common_ui/ArticleCard.kt | 3 +- .../kasem/sm/article/common_ui/ArticleView.kt | 32 ------------------- .../kasem/sm/ui_article_list/ListContent.kt | 11 +++---- .../kasem/sm/ui_bookmarks/BookmarksContent.kt | 4 +-- .../kasem/sm/ui_explore/ExploreContent.kt | 5 +-- .../components/DiscoverArticlesView.kt | 5 ++- .../java/com/slime/ui_home/HomeContent.kt | 11 +++---- .../main/java/com/slime/ui_home/HomeScreen.kt | 9 +++--- .../src/main/java/com/slime/ui_home/HomeVM.kt | 12 +------ .../components/WorkInProgressView.kt | 17 +++++----- version.properties | 6 ++-- 25 files changed, 68 insertions(+), 123 deletions(-) delete mode 100644 core/src/main/java/kasem/sm/core/utils/IMapper.kt delete mode 100644 features/article/common-article-ui/src/main/java/kasem/sm/article/common_ui/ArticleView.kt diff --git a/app/src/main/java/kasem/sm/slime/ui/navigation/NavExtensions.kt b/app/src/main/java/kasem/sm/slime/ui/navigation/NavExtensions.kt index 04b65d3f..57594d76 100644 --- a/app/src/main/java/kasem/sm/slime/ui/navigation/NavExtensions.kt +++ b/app/src/main/java/kasem/sm/slime/ui/navigation/NavExtensions.kt @@ -10,12 +10,12 @@ import androidx.navigation.compose.currentBackStackEntryAsState import kasem.sm.common_ui.util.Routes @Composable -internal fun NavController.currentRouteAsState(): String? { +fun NavController.currentRouteAsState(): String? { return currentBackStackEntryAsState().value?.destination?.route } @Composable -internal fun NavController.isNotAuthRoute(): Boolean { +fun NavController.isNotAuthRoute(): Boolean { return when (currentRouteAsState()) { Routes.HomeScreen.route -> true Routes.ExploreScreen().route -> true @@ -26,6 +26,6 @@ internal fun NavController.isNotAuthRoute(): Boolean { } @Composable -internal fun NavController.isProfileScreenRoute(): Boolean { +fun NavController.isProfileScreenRoute(): Boolean { return currentRouteAsState() == Routes.ProfileScreen.route } diff --git a/app/src/main/java/kasem/sm/slime/ui/navigation/NavHost.kt b/app/src/main/java/kasem/sm/slime/ui/navigation/NavHost.kt index 8a1a2a6d..a616cdc0 100644 --- a/app/src/main/java/kasem/sm/slime/ui/navigation/NavHost.kt +++ b/app/src/main/java/kasem/sm/slime/ui/navigation/NavHost.kt @@ -19,7 +19,7 @@ import kasem.sm.common_ui.util.Routes.Main @OptIn(ExperimentalMaterialNavigationApi::class) @Composable -internal fun NavHost( +fun NavHost( navController: NavHostController, bottomSheetNavigator: BottomSheetNavigator, imageLoader: ImageLoader, diff --git a/app/src/main/java/kasem/sm/slime/ui/navigation/Screens.kt b/app/src/main/java/kasem/sm/slime/ui/navigation/Screens.kt index 67f8db59..b19e6bc9 100644 --- a/app/src/main/java/kasem/sm/slime/ui/navigation/Screens.kt +++ b/app/src/main/java/kasem/sm/slime/ui/navigation/Screens.kt @@ -29,7 +29,7 @@ import kasem.sm.ui_explore.ExploreScreen import kasem.sm.ui_profile.ProfileScreen import kasem.sm.ui_subscribe_topic.SubscribeTopicScreen -internal fun NavGraphBuilder.attachRegistrationScreen( +fun NavGraphBuilder.attachRegistrationScreen( navController: NavController, snackbarHostState: SnackbarHostState, ) { @@ -64,7 +64,7 @@ internal fun NavGraphBuilder.attachLoginScreen( } } -internal fun NavGraphBuilder.attachHomeScreen( +fun NavGraphBuilder.attachHomeScreen( imageLoader: ImageLoader, navController: NavController, snackbarHostState: SnackbarHostState, @@ -87,7 +87,7 @@ internal fun NavGraphBuilder.attachHomeScreen( } } -internal fun NavGraphBuilder.attachExploreScreen( +fun NavGraphBuilder.attachExploreScreen( navController: NavController, imageLoader: ImageLoader, snackbarHostState: SnackbarHostState, @@ -114,7 +114,7 @@ internal fun NavGraphBuilder.attachExploreScreen( } } -internal fun NavGraphBuilder.attachProfileScreen( +fun NavGraphBuilder.attachProfileScreen( navController: NavController ) { composable(Routes.ProfileScreen.route) { @@ -130,7 +130,7 @@ internal fun NavGraphBuilder.attachProfileScreen( } } -internal fun NavGraphBuilder.attachArticleDetailScreen( +fun NavGraphBuilder.attachArticleDetailScreen( imageLoader: ImageLoader, snackbarHostState: SnackbarHostState, ) { @@ -150,7 +150,7 @@ internal fun NavGraphBuilder.attachArticleDetailScreen( } } -internal fun NavGraphBuilder.attachSelectTopicsScreen( +fun NavGraphBuilder.attachSelectTopicsScreen( navController: NavController, snackbarHostState: SnackbarHostState, ) { @@ -171,7 +171,7 @@ internal fun NavGraphBuilder.attachSelectTopicsScreen( } } -internal fun NavGraphBuilder.attachListScreen( +fun NavGraphBuilder.attachListScreen( imageLoader: ImageLoader, snackbarHostState: SnackbarHostState, navController: NavController @@ -201,7 +201,7 @@ internal fun NavGraphBuilder.attachListScreen( } } -internal fun NavGraphBuilder.attachBookmarksScreen( +fun NavGraphBuilder.attachBookmarksScreen( imageLoader: ImageLoader, navController: NavController ) { diff --git a/buildSrc/src/main/java/Accompanist.kt b/buildSrc/src/main/java/Accompanist.kt index 7e7d539c..dc132153 100644 --- a/buildSrc/src/main/java/Accompanist.kt +++ b/buildSrc/src/main/java/Accompanist.kt @@ -1,5 +1,5 @@ object Accompanist { - private const val accompanistVersion = "0.24.6-alpha" + private const val accompanistVersion = "0.24.7-alpha" private const val prefix = "com.google.accompanist:accompanist" const val navigationAnimation = diff --git a/buildSrc/src/main/java/Compose.kt b/buildSrc/src/main/java/Compose.kt index bb3a79e4..3739072c 100644 --- a/buildSrc/src/main/java/Compose.kt +++ b/buildSrc/src/main/java/Compose.kt @@ -1,9 +1,9 @@ object Compose { private const val compostActivity = "1.6.0-alpha01" private const val compostNavigation = "2.5.0-alpha01" - private const val composeVersion = "1.2.0-alpha07" - private const val composeMaterial3Version = "1.0.0-alpha09" - const val composeCompiler = "1.2.0-alpha07" + private const val composeVersion = "1.2.0-alpha08" + private const val composeMaterial3Version = "1.0.0-alpha10" + const val composeCompiler = "1.2.0-alpha08" const val ui = "androidx.compose.ui:ui:$composeVersion" const val material = "androidx.compose.material:material:$composeVersion" diff --git a/buildSrc/src/main/java/Jetbrains.kt b/buildSrc/src/main/java/Jetbrains.kt index c603134b..92946fd5 100644 --- a/buildSrc/src/main/java/Jetbrains.kt +++ b/buildSrc/src/main/java/Jetbrains.kt @@ -1,5 +1,5 @@ object Jetbrains { - private const val kotlin = "1.6.10" + private const val kotlin = "1.6.20" private const val serializationGradleVersion = "1.6.0-RC2" private const val serializationCoreVersion = "1.3.2" diff --git a/buildSrc/src/main/java/Lifecycle.kt b/buildSrc/src/main/java/Lifecycle.kt index e37cda71..d8adcc4f 100644 --- a/buildSrc/src/main/java/Lifecycle.kt +++ b/buildSrc/src/main/java/Lifecycle.kt @@ -1,5 +1,5 @@ object Lifecycle { - private const val version = "2.5.0-alpha04" + private const val version = "2.5.0-beta01" const val runtime = "androidx.lifecycle:lifecycle-runtime-ktx:$version" const val viewModel = "androidx.lifecycle:lifecycle-viewmodel-ktx:$version" diff --git a/common-ui/build.gradle b/common-ui/build.gradle index 68987884..173416b0 100644 --- a/common-ui/build.gradle +++ b/common-ui/build.gradle @@ -21,5 +21,5 @@ dependencies { implementation(Accompanist.swipeRefresh) implementation(Accompanist.flowLayout) implementation Accompanist.sysUiController - implementation "org.jetbrains.kotlin:kotlin-reflect:1.6.10" + implementation "org.jetbrains.kotlin:kotlin-reflect:1.6.21" } diff --git a/common-ui/src/main/java/kasem/sm/common_ui/EmptyDataView.kt b/common-ui/src/main/java/kasem/sm/common_ui/EmptyDataView.kt index f282fee1..54075c82 100644 --- a/common-ui/src/main/java/kasem/sm/common_ui/EmptyDataView.kt +++ b/common-ui/src/main/java/kasem/sm/common_ui/EmptyDataView.kt @@ -4,6 +4,8 @@ */ package kasem.sm.common_ui +import android.content.Intent +import android.net.Uri import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.wrapContentSize @@ -12,6 +14,7 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp @@ -20,8 +23,10 @@ fun EmptyView( modifier: Modifier = Modifier, message: String = "Nothing found!", emoji: String = "\uD83D\uDE25", - onContributeClick: () -> Unit = { } + onContributeClick: (() -> Unit?)? = null ) { + val context = LocalContext.current + Column( modifier = modifier .wrapContentSize(), @@ -41,6 +46,10 @@ fun EmptyView( fontSize = 20.withScale(), fontFamily = LocalSlimeFont.current.secondaryMedium ) - SlimeElevatedButton(text = "Contribute", onClick = onContributeClick) + SlimeElevatedButton(text = "Contribute", onClick = { + onContributeClick?.invoke() ?: kotlin.run { + context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/kasem-sm/SlimeKT"))) + } + }) } } diff --git a/common-ui/src/main/java/kasem/sm/common_ui/SlimeHeader.kt b/common-ui/src/main/java/kasem/sm/common_ui/SlimeHeader.kt index 0c6dc0a7..d4269253 100644 --- a/common-ui/src/main/java/kasem/sm/common_ui/SlimeHeader.kt +++ b/common-ui/src/main/java/kasem/sm/common_ui/SlimeHeader.kt @@ -5,12 +5,14 @@ package kasem.sm.common_ui import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @Composable @@ -24,7 +26,8 @@ fun SlimeHeader( text = text, color = color, modifier = modifier - .fillMaxWidth(), + .fillMaxWidth() + .padding(vertical = 10.dp), fontFamily = fontFamily, fontSize = 22.withScale(), lineHeight = 35.sp diff --git a/common-ui/src/main/java/kasem/sm/common_ui/SlimeTextField.kt b/common-ui/src/main/java/kasem/sm/common_ui/SlimeTextField.kt index d2dec689..8ad3ea37 100644 --- a/common-ui/src/main/java/kasem/sm/common_ui/SlimeTextField.kt +++ b/common-ui/src/main/java/kasem/sm/common_ui/SlimeTextField.kt @@ -8,6 +8,7 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions +import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.ExposedDropdownMenuDefaults.textFieldColors import androidx.compose.material.TextField import androidx.compose.material3.MaterialTheme @@ -61,6 +62,7 @@ fun SlimeTextField( ) } +@OptIn(ExperimentalMaterialApi::class) @Composable fun defaultTextFieldColors() = textFieldColors( focusedIndicatorColor = MaterialTheme.colorScheme.primary, diff --git a/core/src/main/java/kasem/sm/core/domain/ObservableLoader.kt b/core/src/main/java/kasem/sm/core/domain/ObservableLoader.kt index fa539d23..1851fda1 100644 --- a/core/src/main/java/kasem/sm/core/domain/ObservableLoader.kt +++ b/core/src/main/java/kasem/sm/core/domain/ObservableLoader.kt @@ -39,8 +39,4 @@ class ObservableLoader { fun stop() { loadingState.value = count.decrementAndGet() } - - fun startWhen(status: Boolean) { - loadingState.value = if (status) count.incrementAndGet() else count.decrementAndGet() - } } diff --git a/core/src/main/java/kasem/sm/core/utils/IMapper.kt b/core/src/main/java/kasem/sm/core/utils/IMapper.kt deleted file mode 100644 index 74ccfcf5..00000000 --- a/core/src/main/java/kasem/sm/core/utils/IMapper.kt +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright (C) 2022, Kasem S.M - * All rights reserved. - */ -package kasem.sm.core.utils - -// interface IMapper { -// suspend fun map(from: F?): T -// suspend fun map(from: List): List -// } diff --git a/database/build.gradle b/database/build.gradle index 607e00a7..82329845 100644 --- a/database/build.gradle +++ b/database/build.gradle @@ -38,9 +38,9 @@ dependencies { // Instrumentation Test androidTestImplementation "com.google.truth:truth:1.1.3" androidTestImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test:runner:1.5.0-alpha01' + androidTestImplementation 'androidx.test:runner:1.5.0-alpha02' androidTestImplementation "androidx.arch.core:core-testing:2.1.0" - androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.0" + androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.1" androidTestImplementation 'com.google.dagger:hilt-android-testing:2.41' kaptAndroidTest 'com.google.dagger:hilt-android-compiler:2.41' } diff --git a/features/article/common-article-ui/src/main/java/kasem/sm/article/common_ui/ArticleCard.kt b/features/article/common-article-ui/src/main/java/kasem/sm/article/common_ui/ArticleCard.kt index c0b69537..419872a1 100644 --- a/features/article/common-article-ui/src/main/java/kasem/sm/article/common_ui/ArticleCard.kt +++ b/features/article/common-article-ui/src/main/java/kasem/sm/article/common_ui/ArticleCard.kt @@ -44,15 +44,14 @@ fun ArticleCard( modifier: Modifier = Modifier, article: Article, imageLoader: ImageLoader, - index: Int = 0, onArticleClick: (Int) -> Unit, onBookmarkClick: (Int) -> Unit ) { SlimeCard( modifier = modifier .fillMaxWidth() + .padding(vertical = 2.dp) .height(120.dp) - .padding(if (index == 0) 0.dp else 5.dp) .clip(RoundedCornerShape(12.dp)) .clickWithRipple { onArticleClick(article.id) diff --git a/features/article/common-article-ui/src/main/java/kasem/sm/article/common_ui/ArticleView.kt b/features/article/common-article-ui/src/main/java/kasem/sm/article/common_ui/ArticleView.kt deleted file mode 100644 index 166596b6..00000000 --- a/features/article/common-article-ui/src/main/java/kasem/sm/article/common_ui/ArticleView.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2022, Kasem S.M - * All rights reserved. - */ -package kasem.sm.article.common_ui - -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import coil.ImageLoader -import kasem.sm.article.domain.model.Article - -@Composable -fun ArticleView( - modifier: Modifier = Modifier, - article: Article, - imageLoader: ImageLoader, - onArticleClick: (Int) -> Unit, - index: Int = 0, - saveScrollPosition: (Int) -> Unit = {}, - onBookmarkClick: (Int) -> Unit -) { - ArticleCard( - modifier = modifier, - article = article, - imageLoader = imageLoader, - onArticleClick = onArticleClick, - index = index, - onBookmarkClick = onBookmarkClick - ) - - saveScrollPosition(index) -} diff --git a/ui-article-list/src/main/java/kasem/sm/ui_article_list/ListContent.kt b/ui-article-list/src/main/java/kasem/sm/ui_article_list/ListContent.kt index c9ce6440..6887bbf5 100644 --- a/ui-article-list/src/main/java/kasem/sm/ui_article_list/ListContent.kt +++ b/ui-article-list/src/main/java/kasem/sm/ui_article_list/ListContent.kt @@ -9,7 +9,7 @@ import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.lazy.LazyListState -import androidx.compose.foundation.lazy.itemsIndexed +import androidx.compose.foundation.lazy.items import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment @@ -17,7 +17,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.semantics.semantics import androidx.compose.ui.semantics.testTag import coil.ImageLoader -import kasem.sm.article.common_ui.ArticleView +import kasem.sm.article.common_ui.ArticleCard import kasem.sm.common_ui.EmptyView import kasem.sm.common_ui.SlimeScreenColumn import kasem.sm.common_ui.SlimeSwipeRefresh @@ -32,7 +32,6 @@ internal fun ListContent( onArticleClick: (Int) -> Unit, updateSubscription: () -> Unit, showAuthenticationSheet: () -> Unit, - saveScrollPosition: (Int) -> Unit, onBookmarkClick: (Int) -> Unit, listState: LazyListState, ) { @@ -71,13 +70,11 @@ internal fun ListContent( } } - itemsIndexed(state.articles) { index, article -> - ArticleView( + items(state.articles) { article -> + ArticleCard( article = article, imageLoader = imageLoader, onArticleClick = onArticleClick, - index = index, - saveScrollPosition = saveScrollPosition, onBookmarkClick = onBookmarkClick ) } diff --git a/ui-bookmarks/src/main/java/kasem/sm/ui_bookmarks/BookmarksContent.kt b/ui-bookmarks/src/main/java/kasem/sm/ui_bookmarks/BookmarksContent.kt index c2cf03d7..b2ec3189 100644 --- a/ui-bookmarks/src/main/java/kasem/sm/ui_bookmarks/BookmarksContent.kt +++ b/ui-bookmarks/src/main/java/kasem/sm/ui_bookmarks/BookmarksContent.kt @@ -30,7 +30,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.semantics.semantics import androidx.compose.ui.semantics.testTag import coil.ImageLoader -import kasem.sm.article.common_ui.ArticleView +import kasem.sm.article.common_ui.ArticleCard import kasem.sm.article.domain.model.Article import kasem.sm.common_ui.EmptyView import kasem.sm.common_ui.SlimeHeader @@ -109,7 +109,7 @@ internal fun BookmarksContent( } items(bookmarkedArticles) { article -> - ArticleView( + ArticleCard( article = article, imageLoader = imageLoader, onArticleClick = onArticleClick, diff --git a/ui-explore/src/main/java/kasem/sm/ui_explore/ExploreContent.kt b/ui-explore/src/main/java/kasem/sm/ui_explore/ExploreContent.kt index a62d8a56..50f27fe7 100644 --- a/ui-explore/src/main/java/kasem/sm/ui_explore/ExploreContent.kt +++ b/ui-explore/src/main/java/kasem/sm/ui_explore/ExploreContent.kt @@ -5,7 +5,6 @@ package kasem.sm.ui_explore import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth @@ -42,9 +41,7 @@ internal fun ExploreContent( .fillMaxSize() .background(MaterialTheme.colorScheme.surface) ) { - SlimeScreenColumn( - verticalArrangement = Arrangement.SpaceAround - ) { + SlimeScreenColumn { item { SlimeHeader(text = stringResource(id = R.string.recommend_article_header)) } diff --git a/ui-explore/src/main/java/kasem/sm/ui_explore/components/DiscoverArticlesView.kt b/ui-explore/src/main/java/kasem/sm/ui_explore/components/DiscoverArticlesView.kt index f6d8df43..5399be0d 100644 --- a/ui-explore/src/main/java/kasem/sm/ui_explore/components/DiscoverArticlesView.kt +++ b/ui-explore/src/main/java/kasem/sm/ui_explore/components/DiscoverArticlesView.kt @@ -5,7 +5,7 @@ package kasem.sm.ui_explore.components import androidx.compose.foundation.lazy.LazyListScope -import androidx.compose.foundation.lazy.itemsIndexed +import androidx.compose.foundation.lazy.items import coil.ImageLoader import kasem.sm.article.common_ui.ArticleCard import kasem.sm.article.domain.model.Article @@ -16,12 +16,11 @@ internal fun LazyListScope.discoverArticlesView( onArticleClick: (Int) -> Unit, onBookmarkClick: (Int) -> Unit ) { - itemsIndexed(articles) { index, article -> + items(articles) { article -> ArticleCard( article = article, imageLoader = imageLoader, onArticleClick = onArticleClick, - index = index, onBookmarkClick = onBookmarkClick ) } diff --git a/ui-home/src/main/java/com/slime/ui_home/HomeContent.kt b/ui-home/src/main/java/com/slime/ui_home/HomeContent.kt index 030c657a..1dc96efd 100644 --- a/ui-home/src/main/java/com/slime/ui_home/HomeContent.kt +++ b/ui-home/src/main/java/com/slime/ui_home/HomeContent.kt @@ -11,7 +11,7 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyListState -import androidx.compose.foundation.lazy.itemsIndexed +import androidx.compose.foundation.lazy.items import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment @@ -22,7 +22,7 @@ import coil.ImageLoader import com.slime.ui_home.components.DailyReadArticle import com.slime.ui_home.components.SearchBar import com.slime.ui_home.components.TopicsView -import kasem.sm.article.common_ui.ArticleView +import kasem.sm.article.common_ui.ArticleCard import kasem.sm.common_ui.EmptyView import kasem.sm.common_ui.R import kasem.sm.common_ui.SlimeHeader @@ -39,7 +39,6 @@ internal fun HomeContent( onQueryChange: (String) -> Unit, onTopicChange: (String) -> Unit, onArticleClick: (Int) -> Unit, - saveScrollPosition: (Int) -> Unit, navigateToSubscriptionScreen: () -> Unit, onBookmarkClick: (Int) -> Unit, listState: LazyListState, @@ -99,13 +98,11 @@ internal fun HomeContent( EmptyView() } - itemsIndexed(state.articles) { index, article -> - ArticleView( + items(state.articles) { article -> + ArticleCard( article = article, imageLoader = imageLoader, onArticleClick = onArticleClick, - index = index, - saveScrollPosition = saveScrollPosition, onBookmarkClick = onBookmarkClick ) } diff --git a/ui-home/src/main/java/com/slime/ui_home/HomeScreen.kt b/ui-home/src/main/java/com/slime/ui_home/HomeScreen.kt index 92c0d599..9e4c4cca 100644 --- a/ui-home/src/main/java/com/slime/ui_home/HomeScreen.kt +++ b/ui-home/src/main/java/com/slime/ui_home/HomeScreen.kt @@ -26,10 +26,10 @@ fun HomeScreen( val listState = rememberLazyListState() - val handlerEnabledWhen = viewModel.queryIsNotEmpty() + val isBackHandlerEnabled = viewModel.queryIsNotEmpty() backHandler( - enabled = handlerEnabledWhen, + enabled = isBackHandlerEnabled, onBack = viewModel::resetToDefaults ) @@ -48,11 +48,10 @@ fun HomeScreen( onQueryChange = viewModel::onQueryChange, onTopicChange = viewModel::onQueryChange, onArticleClick = onArticleClick, - saveScrollPosition = viewModel::saveScrollPosition, navigateToSubscriptionScreen = { navigateTo(Routes.SubscribeTopicScreen.route) }, - listState = listState, - onBookmarkClick = viewModel::updateBookmarkStatus + onBookmarkClick = viewModel::updateBookmarkStatus, + listState = listState ) } diff --git a/ui-home/src/main/java/com/slime/ui_home/HomeVM.kt b/ui-home/src/main/java/com/slime/ui_home/HomeVM.kt index cf4c8498..dc8e4ede 100644 --- a/ui-home/src/main/java/com/slime/ui_home/HomeVM.kt +++ b/ui-home/src/main/java/com/slime/ui_home/HomeVM.kt @@ -39,12 +39,12 @@ class HomeVM @Inject constructor( private val getArticles: GetArticles, private val bookmarkArticle: BookmarkArticle, private val getSubscribedTopics: GetSubscribedTopics, - private val savedStateHandle: SavedStateHandle, private val dispatchers: SlimeDispatchers, private val observeArticles: ObserveArticles, private val observeAuthState: ObserveAuthState, observeDailyReadArticle: ObserveDailyReadArticle, observeSubscribedTopics: ObserveSubscribedTopics, + savedStateHandle: SavedStateHandle, ) : ViewModel() { private val searchQuery = SavedMutableState( @@ -145,15 +145,6 @@ class HomeVM @Inject constructor( observeArticles() } - /** - * Saves the latest scroll position to the savedState - * as after process death, we will retrieve it from savedState - * to scroll the list to the position for best user experience. - */ - fun saveScrollPosition(updatedPosition: Int) { - savedStateHandle[LIST_POSITION_KEY] = updatedPosition - } - fun resetToDefaults() { if (searchQuery.value.isNotEmpty()) { onQueryChange(DEFAULT_SEARCH_QUERY) @@ -171,7 +162,6 @@ class HomeVM @Inject constructor( } companion object { - const val LIST_POSITION_KEY = "slime_list_position" const val QUERY_KEY = "slime_query" } } diff --git a/ui-profile/src/main/java/kasem/sm/ui_profile/components/WorkInProgressView.kt b/ui-profile/src/main/java/kasem/sm/ui_profile/components/WorkInProgressView.kt index 5e389423..a2cc5c10 100644 --- a/ui-profile/src/main/java/kasem/sm/ui_profile/components/WorkInProgressView.kt +++ b/ui-profile/src/main/java/kasem/sm/ui_profile/components/WorkInProgressView.kt @@ -16,14 +16,13 @@ internal fun WorkInProgressView() { EmptyView( message = "Work In Progress", - emoji = "👷‍♂️⚒", - onContributeClick = { - context.startActivity( - Intent( - Intent.ACTION_VIEW, - "https://github.com/kasem-sm/SlimeKT/issues/63".toUri() - ) + emoji = "👷‍♂️⚒" + ) { + context.startActivity( + Intent( + Intent.ACTION_VIEW, + "https://github.com/kasem-sm/SlimeKT/issues/63".toUri() ) - } - ) + ) + } } diff --git a/version.properties b/version.properties index dc3e4841..7deee5db 100644 --- a/version.properties +++ b/version.properties @@ -1,5 +1,5 @@ -#Sat Apr 16 05:53:03 IST 2022 +#Fri Apr 22 00:02:24 IST 2022 MAJOR=0 MINOR=0 -VERSION_CODE=16 -PATCH=3816 +VERSION_CODE=21 +PATCH=3849