Skip to content

Commit

Permalink
Merge pull request #329 from joeloewi7178/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
joeloewi7178 authored Jan 14, 2024
2 parents 2ab7299 + b1fe61a commit 4787d4a
Show file tree
Hide file tree
Showing 33 changed files with 409 additions and 248 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ android {

defaultConfig {
applicationId = "com.joeloewi.croissant"
versionCode = 51
versionName = "1.2.2"
versionCode = 52
versionName = "1.2.3"
targetSdk = 34

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down
100 changes: 50 additions & 50 deletions app/src/main/kotlin/com/joeloewi/croissant/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ import com.joeloewi.croissant.ui.theme.CroissantTheme
import com.joeloewi.croissant.util.LocalActivity
import com.joeloewi.croissant.util.LocalHourFormat
import com.joeloewi.croissant.util.RequireAppUpdate
import com.joeloewi.croissant.util.isCompactWindowSize
import com.joeloewi.croissant.util.useNavRail
import com.joeloewi.croissant.viewmodel.MainActivityViewModel
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.collections.immutable.ImmutableList
Expand Down Expand Up @@ -186,6 +186,29 @@ fun CroissantApp(
CroissantNavigation.Settings
).toImmutableList()
}
val currentBackStackEntry by remember(navController) {
navController.currentBackStackEntryFlow
}.collectAsStateWithLifecycle(initialValue = null)
val isNavigationRailVisible by remember {
derivedStateOf {
!fullScreenDestinations.any { route ->
(currentBackStackEntry?.destination?.route?.contains(
route
) != false)
} && windowSizeClass.useNavRail()
&& currentBackStackEntry?.destination?.route == currentBackStackEntry?.destination?.parent?.startDestinationRoute
}
}
val isBottomNavigationBarVisible by remember {
derivedStateOf {
!fullScreenDestinations.any { route ->
(currentBackStackEntry?.destination?.route?.contains(
route
) != false)
} && !windowSizeClass.useNavRail()
&& currentBackStackEntry?.destination?.route == currentBackStackEntry?.destination?.parent?.startDestinationRoute
}
}

LaunchedEffect(navController) {
withContext(Dispatchers.IO + CoroutineExceptionHandler { _, _ -> }) {
Expand All @@ -204,20 +227,6 @@ fun CroissantApp(
Scaffold(
contentWindowInsets = WindowInsets.systemBars.only(WindowInsetsSides.Horizontal),
bottomBar = {
val currentBackStackEntry by remember(navController) {
navController.currentBackStackEntryFlow
}.collectAsStateWithLifecycle(initialValue = null)
val isBottomNavigationBarVisible by remember {
derivedStateOf {
!fullScreenDestinations.any { route ->
(currentBackStackEntry?.destination?.route?.contains(
route
) != false)
} && windowSizeClass.isCompactWindowSize()
&& currentBackStackEntry?.destination?.route == currentBackStackEntry?.destination?.parent?.startDestinationRoute
}
}

if (isBottomNavigationBarVisible) {
CroissantBottomNavigationBar(
croissantNavigations = croissantNavigations,
Expand All @@ -241,45 +250,36 @@ fun CroissantApp(
.padding(innerPadding)
) {
Row {
Column {
val currentBackStackEntry by navController.currentBackStackEntryFlow.collectAsStateWithLifecycle(
initialValue = null,
)
val isNavigationRailVisible by remember {
derivedStateOf {
!fullScreenDestinations.any { route ->
(currentBackStackEntry?.destination?.route?.contains(
route
) != false)
} && !windowSizeClass.isCompactWindowSize()
if (isNavigationRailVisible) {
CroissantNavigationRail(
croissantNavigations = croissantNavigations,
currentBackStackEntry = { currentBackStackEntry },
onClickNavigationButton = { route ->
navController.navigate(route) {
popUpTo(navController.graph.findStartDestination().id) {
saveState = true
}
launchSingleTop = true
restoreState = true
}
}
}

if (isNavigationRailVisible) {
CroissantNavigationRail(
croissantNavigations = croissantNavigations,
currentBackStackEntry = { currentBackStackEntry },
onClickNavigationButton = { route ->
navController.navigate(route) {
popUpTo(navController.graph.findStartDestination().id) {
saveState = true
}
launchSingleTop = true
restoreState = true
)
}
Column(
modifier = remember(isNavigationRailVisible) {
Modifier
.fillMaxSize(1f)
.run {
if (isNavigationRailVisible) {
navigationBarsPadding()
} else {
this
}
}
)
}
}
Column {
) {
CroissantNavHost(
modifier = Modifier.run {
if (windowSizeClass.isCompactWindowSize()) {
this
} else {
navigationBarsPadding()
}
},
modifier = Modifier.fillMaxSize(1f),
navController = StableWrapper(navController),
snackbarHostState = snackbarHostState,
deepLinkUri = deepLinkUri.toString()
Expand Down Expand Up @@ -594,7 +594,7 @@ private fun CroissantNavigationRail(
)
}
) {
croissantNavigations.forEach { croissantNavigation ->
croissantNavigations.fastForEach { croissantNavigation ->
key(croissantNavigation.route) {
val isSelected by remember(croissantNavigation.route) {
derivedStateOf { currentBackStackEntry()?.destination?.hierarchy?.any { it.route == croissantNavigation.route } == true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ import com.joeloewi.croissant.ui.theme.successContainerColor
import com.joeloewi.croissant.ui.theme.warningContainerColor
import com.joeloewi.croissant.util.LocalActivity
import com.joeloewi.croissant.util.generateCalendarDays
import com.joeloewi.croissant.util.isCompactWindowSize
import com.joeloewi.croissant.util.navigationIconButton
import com.joeloewi.croissant.util.useNavRail
import com.joeloewi.croissant.viewmodel.AttendanceLogsCalendarViewModel
import kotlinx.collections.immutable.ImmutableList
import kotlinx.coroutines.Dispatchers
Expand Down Expand Up @@ -316,7 +316,7 @@ private fun DayGridItem(
.padding(1.dp)
.fillMaxWidth()
.aspectRatio(
if (windowSizeClass.isCompactWindowSize()) {
if (!windowSizeClass.useNavRail()) {
0.5f
} else {
1f
Expand Down
Loading

0 comments on commit 4787d4a

Please sign in to comment.