forked from mash-up-kr/ssam-d-Android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat] mash-up-kr#111 KeyLinkApp 및 KeyLinkAppState 추가
* bottomBar * snackbarhost에 KeyLinkSnackbar 연결 * NavHost * appState
- Loading branch information
1 parent
a069330
commit a1f8a6d
Showing
2 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
presentation/src/main/java/com/mashup/presentation/KeyLinkApp.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
presentation/src/main/java/com/mashup/presentation/KeyLinkAppState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | ||
// | ||
// } | ||
} | ||
} |