Skip to content

Commit

Permalink
Updated compose version and cleanups (#91)
Browse files Browse the repository at this point in the history
* Updated compose version to `1.2.0-alpha08` and clean-ups

Co-authored-by: kasem-sm <[email protected]>
  • Loading branch information
kasem-sm and kasem-sm authored Apr 21, 2022
1 parent d7a1bf8 commit dff39ce
Show file tree
Hide file tree
Showing 25 changed files with 68 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -26,6 +26,6 @@ internal fun NavController.isNotAuthRoute(): Boolean {
}

@Composable
internal fun NavController.isProfileScreenRoute(): Boolean {
fun NavController.isProfileScreenRoute(): Boolean {
return currentRouteAsState() == Routes.ProfileScreen.route
}
2 changes: 1 addition & 1 deletion app/src/main/java/kasem/sm/slime/ui/navigation/NavHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 8 additions & 8 deletions app/src/main/java/kasem/sm/slime/ui/navigation/Screens.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
Expand Down Expand Up @@ -64,7 +64,7 @@ internal fun NavGraphBuilder.attachLoginScreen(
}
}

internal fun NavGraphBuilder.attachHomeScreen(
fun NavGraphBuilder.attachHomeScreen(
imageLoader: ImageLoader,
navController: NavController,
snackbarHostState: SnackbarHostState,
Expand All @@ -87,7 +87,7 @@ internal fun NavGraphBuilder.attachHomeScreen(
}
}

internal fun NavGraphBuilder.attachExploreScreen(
fun NavGraphBuilder.attachExploreScreen(
navController: NavController,
imageLoader: ImageLoader,
snackbarHostState: SnackbarHostState,
Expand All @@ -114,7 +114,7 @@ internal fun NavGraphBuilder.attachExploreScreen(
}
}

internal fun NavGraphBuilder.attachProfileScreen(
fun NavGraphBuilder.attachProfileScreen(
navController: NavController
) {
composable(Routes.ProfileScreen.route) {
Expand All @@ -130,7 +130,7 @@ internal fun NavGraphBuilder.attachProfileScreen(
}
}

internal fun NavGraphBuilder.attachArticleDetailScreen(
fun NavGraphBuilder.attachArticleDetailScreen(
imageLoader: ImageLoader,
snackbarHostState: SnackbarHostState,
) {
Expand All @@ -150,7 +150,7 @@ internal fun NavGraphBuilder.attachArticleDetailScreen(
}
}

internal fun NavGraphBuilder.attachSelectTopicsScreen(
fun NavGraphBuilder.attachSelectTopicsScreen(
navController: NavController,
snackbarHostState: SnackbarHostState,
) {
Expand All @@ -171,7 +171,7 @@ internal fun NavGraphBuilder.attachSelectTopicsScreen(
}
}

internal fun NavGraphBuilder.attachListScreen(
fun NavGraphBuilder.attachListScreen(
imageLoader: ImageLoader,
snackbarHostState: SnackbarHostState,
navController: NavController
Expand Down Expand Up @@ -201,7 +201,7 @@ internal fun NavGraphBuilder.attachListScreen(
}
}

internal fun NavGraphBuilder.attachBookmarksScreen(
fun NavGraphBuilder.attachBookmarksScreen(
imageLoader: ImageLoader,
navController: NavController
) {
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/Accompanist.kt
Original file line number Diff line number Diff line change
@@ -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 =
Expand Down
6 changes: 3 additions & 3 deletions buildSrc/src/main/java/Compose.kt
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/Jetbrains.kt
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/Lifecycle.kt
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion common-ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
13 changes: 11 additions & 2 deletions common-ui/src/main/java/kasem/sm/common_ui/EmptyDataView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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(),
Expand All @@ -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")))
}
})
}
}
5 changes: 4 additions & 1 deletion common-ui/src/main/java/kasem/sm/common_ui/SlimeHeader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions common-ui/src/main/java/kasem/sm/common_ui/SlimeTextField.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -61,6 +62,7 @@ fun SlimeTextField(
)
}

@OptIn(ExperimentalMaterialApi::class)
@Composable
fun defaultTextFieldColors() = textFieldColors(
focusedIndicatorColor = MaterialTheme.colorScheme.primary,
Expand Down
4 changes: 0 additions & 4 deletions core/src/main/java/kasem/sm/core/domain/ObservableLoader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
10 changes: 0 additions & 10 deletions core/src/main/java/kasem/sm/core/utils/IMapper.kt

This file was deleted.

4 changes: 2 additions & 2 deletions database/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ 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
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
Expand All @@ -32,7 +32,6 @@ internal fun ListContent(
onArticleClick: (Int) -> Unit,
updateSubscription: () -> Unit,
showAuthenticationSheet: () -> Unit,
saveScrollPosition: (Int) -> Unit,
onBookmarkClick: (Int) -> Unit,
listState: LazyListState,
) {
Expand Down Expand Up @@ -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
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -109,7 +109,7 @@ internal fun BookmarksContent(
}

items(bookmarkedArticles) { article ->
ArticleView(
ArticleCard(
article = article,
imageLoader = imageLoader,
onArticleClick = onArticleClick,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
}
Expand Down
Loading

0 comments on commit dff39ce

Please sign in to comment.