diff --git a/android/build.gradle.kts b/android/build.gradle.kts index 119a3eff..815d4ee2 100644 --- a/android/build.gradle.kts +++ b/android/build.gradle.kts @@ -55,7 +55,6 @@ dependencies { implementation(projects.common) implementation(projects.database) implementation(compose.material3) - implementation(libs.accompanist.insets) implementation(libs.accompanist.swiperefresh) implementation(libs.accompanist.sysuicontroller) implementation(libs.androidx.activity.compose) diff --git a/android/src/main/kotlin/dev/msfjarvis/claw/android/ui/LobstersApp.kt b/android/src/main/kotlin/dev/msfjarvis/claw/android/ui/LobstersApp.kt index 1fcdc45b..6ee5545e 100644 --- a/android/src/main/kotlin/dev/msfjarvis/claw/android/ui/LobstersApp.kt +++ b/android/src/main/kotlin/dev/msfjarvis/claw/android/ui/LobstersApp.kt @@ -1,5 +1,6 @@ package dev.msfjarvis.claw.android.ui +import androidx.compose.foundation.layout.navigationBarsPadding import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.material.icons.Icons @@ -31,9 +32,6 @@ import androidx.navigation.compose.rememberNavController import androidx.navigation.navArgument import androidx.navigation.navDeepLink import androidx.paging.compose.collectAsLazyPagingItems -import com.google.accompanist.insets.ProvideWindowInsets -import com.google.accompanist.insets.navigationBarsPadding -import com.google.accompanist.insets.statusBarsPadding import com.google.accompanist.systemuicontroller.rememberSystemUiController import dev.msfjarvis.claw.android.R import dev.msfjarvis.claw.android.ui.decorations.ClawAppBar @@ -76,115 +74,112 @@ fun LobstersApp( LocalHTMLConverter provides htmlConverter, colorScheme = decideColorScheme(LocalContext.current), ) { - ProvideWindowInsets { - val currentUiMode = LocalConfiguration.current.uiMode - val systemBarsColor = MaterialTheme.colorScheme.surfaceColorAtNavigationBarElevation() - val backgroundColor = MaterialTheme.colorScheme.background - val navItems = - listOf( - NavigationItem( - label = "Hottest", - route = Destinations.Hottest.getRoute(), - icon = painterResource(R.drawable.ic_whatshot_24dp), - ) { coroutineScope.launch { networkListState.animateScrollToItem(index = 0) } }, - NavigationItem( - label = "Saved", - route = Destinations.Saved.getRoute(), - icon = painterResource(commonR.drawable.ic_favorite_24dp), - ) { coroutineScope.launch { savedListState.animateScrollToItem(index = 0) } }, - ) + val currentUiMode = LocalConfiguration.current.uiMode + val systemBarsColor = MaterialTheme.colorScheme.surfaceColorAtNavigationBarElevation() + val backgroundColor = MaterialTheme.colorScheme.background + val navItems = + listOf( + NavigationItem( + label = "Hottest", + route = Destinations.Hottest.getRoute(), + icon = painterResource(R.drawable.ic_whatshot_24dp), + ) { coroutineScope.launch { networkListState.animateScrollToItem(index = 0) } }, + NavigationItem( + label = "Saved", + route = Destinations.Saved.getRoute(), + icon = painterResource(commonR.drawable.ic_favorite_24dp), + ) { coroutineScope.launch { savedListState.animateScrollToItem(index = 0) } }, + ) - SideEffect { systemUiController.setStatusBarColor(color = systemBarsColor) } + SideEffect { systemUiController.setStatusBarColor(color = systemBarsColor) } - // Track UI mode as a key to force a navbar color update when dark theme is toggled - LaunchedEffect(currentDestination, currentUiMode) { - val color = - if (navItems.none { item -> item.route == currentDestination }) { - backgroundColor - } else { - systemBarsColor - } - systemUiController.setNavigationBarColor(color = color) - } + // Track UI mode as a key to force a navbar color update when dark theme is toggled + LaunchedEffect(currentDestination, currentUiMode) { + val color = + if (navItems.none { item -> item.route == currentDestination }) { + backgroundColor + } else { + systemBarsColor + } + systemUiController.setNavigationBarColor(color = color) + } - Scaffold( - topBar = { - ClawAppBar( - modifier = Modifier.statusBarsPadding(), - backgroundColor = systemBarsColor, - navigationIcon = { - if (navItems.none { it.route == currentDestination }) { - IconButton(onClick = { navController.popBackStack() }) { - Icon( - imageVector = Icons.Filled.ArrowBack, - contentDescription = "Go back to previous screen", - ) - } - } - }, - title = { - if (navItems.any { it.route == currentDestination }) { - Text(text = stringResource(commonR.string.app_name), fontWeight = FontWeight.Bold) + Scaffold( + topBar = { + ClawAppBar( + backgroundColor = systemBarsColor, + navigationIcon = { + if (navItems.none { it.route == currentDestination }) { + IconButton(onClick = { navController.popBackStack() }) { + Icon( + imageVector = Icons.Filled.ArrowBack, + contentDescription = "Go back to previous screen", + ) } - }, - ) - }, - bottomBar = { - ClawNavigationBar( - navController = navController, - items = navItems, - isVisible = navItems.any { it.route == currentDestination }, - ) - }, - ) { paddingValues -> - NavHost( - navController, - startDestination = Destinations.startDestination.getRoute(), + } + }, + title = { + if (navItems.any { it.route == currentDestination }) { + Text(text = stringResource(commonR.string.app_name), fontWeight = FontWeight.Bold) + } + }, + ) + }, + bottomBar = { + ClawNavigationBar( + navController = navController, + items = navItems, + isVisible = navItems.any { it.route == currentDestination }, + ) + }, + ) { paddingValues -> + NavHost( + navController, + startDestination = Destinations.startDestination.getRoute(), + ) { + val uri = LobstersApi.BASE_URL + composable( + route = Destinations.Hottest.getRoute(), + deepLinks = + listOf(navDeepLink { uriPattern = uri }, navDeepLink { uriPattern = "$uri/" }), ) { - val uri = LobstersApi.BASE_URL - composable( - route = Destinations.Hottest.getRoute(), - deepLinks = - listOf(navDeepLink { uriPattern = uri }, navDeepLink { uriPattern = "$uri/" }), - ) { - setWebUri("https://lobste.rs/") - HottestPosts( - items = networkPosts, - listState = networkListState, - isPostSaved = viewModel::isPostSaved, - reloadPosts = viewModel::reloadPosts, - postActions = postActions, - modifier = Modifier.padding(bottom = paddingValues.calculateBottomPadding()), - ) - } - composable(Destinations.Saved.getRoute()) { - setWebUri(null) - DatabasePosts( - items = savedPosts, - listState = savedListState, - isSaved = viewModel::isPostSaved, - postActions = postActions, - modifier = Modifier.padding(bottom = paddingValues.calculateBottomPadding()), - ) - } - composable( - route = Destinations.Comments.getRoute("{postId}"), - arguments = listOf(navArgument("postId") { type = NavType.StringType }), - deepLinks = - listOf( - navDeepLink { uriPattern = "$uri/s/{postId}/.*" }, - navDeepLink { uriPattern = "$uri/s/{postId}" }, - ), - ) { backStackEntry -> - val postId = requireNotNull(backStackEntry.arguments?.getString("postId")) - setWebUri("https://lobste.rs/s/$postId") - CommentsPage( - postId = postId, - getDetails = viewModel::getPostComments, - modifier = Modifier.navigationBarsPadding(), - postActions = postActions, - ) - } + setWebUri("https://lobste.rs/") + HottestPosts( + items = networkPosts, + listState = networkListState, + isPostSaved = viewModel::isPostSaved, + reloadPosts = viewModel::reloadPosts, + postActions = postActions, + modifier = Modifier.padding(bottom = paddingValues.calculateBottomPadding()), + ) + } + composable(Destinations.Saved.getRoute()) { + setWebUri(null) + DatabasePosts( + items = savedPosts, + listState = savedListState, + isSaved = viewModel::isPostSaved, + postActions = postActions, + modifier = Modifier.padding(bottom = paddingValues.calculateBottomPadding()), + ) + } + composable( + route = Destinations.Comments.getRoute("{postId}"), + arguments = listOf(navArgument("postId") { type = NavType.StringType }), + deepLinks = + listOf( + navDeepLink { uriPattern = "$uri/s/{postId}/.*" }, + navDeepLink { uriPattern = "$uri/s/{postId}" }, + ), + ) { backStackEntry -> + val postId = requireNotNull(backStackEntry.arguments?.getString("postId")) + setWebUri("https://lobste.rs/s/$postId") + CommentsPage( + postId = postId, + getDetails = viewModel::getPostComments, + modifier = Modifier.navigationBarsPadding(), + postActions = postActions, + ) } } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b4ba23e0..084ec7bd 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -10,7 +10,6 @@ serialization = "1.3.2" sqldelight = "1.5.3" [libraries] -accompanist-insets = { module = "com.google.accompanist:accompanist-insets", version.ref = "accompanist" } accompanist-swiperefresh = { module = "com.google.accompanist:accompanist-swiperefresh", version.ref = "accompanist" } accompanist-sysuicontroller = { module = "com.google.accompanist:accompanist-systemuicontroller", version.ref = "accompanist" } androidx-activity-compose = "androidx.activity:activity-compose:1.6.0-alpha01"