Skip to content

Commit

Permalink
[feat] mash-up-kr#111 KeyLinkApp 및 KeyLinkAppState 추가
Browse files Browse the repository at this point in the history
* bottomBar
* snackbarhost에 KeyLinkSnackbar 연결
* NavHost
* appState
  • Loading branch information
JaesungLeee committed Jul 4, 2023
1 parent a069330 commit a1f8a6d
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 0 deletions.
53 changes: 53 additions & 0 deletions presentation/src/main/java/com/mashup/presentation/KeyLinkApp.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.mashup.presentation

import androidx.compose.foundation.layout.padding
import androidx.compose.material.Scaffold
import androidx.compose.material.SnackbarDuration
import androidx.compose.material.SnackbarHostState
import androidx.compose.material.SnackbarResult
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import com.mashup.presentation.navigation.KeyLinkNavHost
import com.mashup.presentation.ui.common.KeyLinkSnackBar
import com.mashup.presentation.ui.theme.Black

/**
* Ssam_D_Android
* @author jaesung
* @created 2023/07/04
*/
@Composable
fun KeyLinkApp(
appState: KeyLinkAppState = rememberKeyLinkAppState()
) {
val snackbarHostState = remember { SnackbarHostState() }

Scaffold(
bottomBar = {
if (appState.isBottomBarVisible()) {
KeyLinkBottomNavigationBar()
}
},
backgroundColor = Black,
snackbarHost = { KeyLinkSnackBar(snackBarHostState = snackbarHostState) }
) { innerPadding ->
KeyLinkNavHost(
appState = appState,
startDestination = "",
modifier = Modifier.padding(innerPadding),
onShowSnackbar = { message, action ->
snackbarHostState.showSnackbar(
message = message,
actionLabel = action,
duration = SnackbarDuration.Short
) == SnackbarResult.ActionPerformed
}
)
}
}

@Composable
fun KeyLinkBottomNavigationBar() {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.mashup.presentation

import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.runtime.remember
import androidx.navigation.NavDestination
import androidx.navigation.NavHostController
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController

/**
* Ssam_D_Android
* @author jaesung
* @created 2023/07/04
*/

@Composable
fun rememberKeyLinkAppState(
navController: NavHostController = rememberNavController()
): KeyLinkAppState {
return remember(navController) {
KeyLinkAppState(navController)
}
}

/**
* KeyLinkAppState에는 전반적인 어플리케이션 자체의 상태가 포함됩니다.
* 1. Navigation Destination
* 2. Multiple BackStack
* 3. BottomNavigation Visibility
* 4. NetworkMonitor(isOffline / isOnline)
* 5. ...
*/
@Stable
class KeyLinkAppState(
val navController: NavHostController
) {
val currentDestination: NavDestination?
@Composable get() = navController.currentBackStackEntryAsState().value?.destination


@Composable
fun isBottomBarVisible(): Boolean {
return true
// return when(currentDestination?.route) {
//
// }
}
}

0 comments on commit a1f8a6d

Please sign in to comment.