tgyuuAn / BaekyoungE

์ž์—ฐ์–ด ์ฒ˜๋ฆฌ ๊ธฐ๋ฐ˜ ์ง„๋กœ ์ƒ๋‹ด chat bot ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜
6 stars 0 forks source link

Base/#3 #5

Closed tgyuuAn closed 6 months ago

tgyuuAn commented 6 months ago

1. ๐Ÿ“„ ๊ด€๋ จ๋œ ์ด์Šˆ ๋ฐ ์†Œ๊ฐœ

closed #3

2. ๐Ÿ”ฅ๋ณ€๊ฒฝ๋œ ์ 

3. ๐Ÿ“ธ ์Šคํฌ๋ฆฐ์ƒท(์„ ํƒ)

image

4. ๐Ÿ’ก์•Œ๊ฒŒ๋œ ํ˜น์€ ๊ถ๊ธˆํ•œ ์‚ฌํ•ญ๋“ค

1. ๐Ÿ‘๏ธ BottomNavigation VIsibiliy ๋กœ์ง




1-1. BottomBarState๋ฅผ remember๋กœ ์ €์žฅ ํ•ด๋†“๋Š”๋‹ค.

(์ด๋ฒˆ ํ”„๋กœ์ ํŠธ์˜ ๊ฒฝ์šฐ AuthScreen์ด ์ฒซ ๋ฒˆ์งธ์ธ๋ฐ, BottomNavigation์ด ์•ˆ๋ณด์ด๋Š” ๊ฒƒ์œผ๋กœ ์‹œ์ž‘ํ•˜๋ฏ€๋กœ false๋กœ ์„ค์ •)

var bottomBarState by rememberSaveable { mutableStateOf(false) }




1-2. BottomNavigation์„ AnimatedVisibility๋กœ ๊ฐ์‹ธ์ค€๋‹ค.

์ด๊ฑด ๋‚˜์ค‘์— https://github.com/tgyuuAn/Baekyoung-i/issues/9#issuecomment-1838824814 ๋กœ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ ๋˜์—ˆ๋‹ค.

๋ฐ‘ ๋ถ€๋ถ„ ๋ด๋„ ๋˜๊ณ  ์•ˆ ๋ด๋„ ๋˜๊ณ ..







์—ฌ๊ธฐ์„œ visible = bottomBarState๋ฅผ ๋„ฃ์–ด์คŒ.

    AnimatedVisibility(
        visible = bottomBarState,
        enter = slideInVertically(initialOffsetY = { it }),
        exit = slideOutVertically(targetOffsetY = { it }),
        content = {
            BottomNavigation(
                backgroundColor = BaekyoungTheme.colors.white,
                modifier = modifier
            ) {
                TopLevelDestination.entries.forEach { destination ->
                    val isSelect = currentRoute == destination.route
                    BottomNavigationItem(
                        selected = isSelect,
                        onClick = { onNavigateToDestination(destination) },
                        icon = {
                            destination.selectedIcon
                        },
                        selectedContentColor = BaekyoungTheme.colors.blueFF,
                        unselectedContentColor = BaekyoungTheme.colors.gray95,
                        label = {
                            Text(
                                text = stringResource(id = destination.titleTextId),
                                style = BaekyoungTheme.typography.labelNormal,
                                color = if (isSelect) BaekyoungTheme.colors.blueFF
                                else BaekyoungTheme.colors.gray95
                            )
                        }
                    )
                }
            }
        }
    )

์• ๋‹ˆ๋ฉ”์ด์…˜ ์ˆ˜์ •์ž ์— ์žฌ๋ฐŒ๋Š” ์• ๋‹ˆ๋ฉ”์ด์…˜์ด ๋งŽ๋”๋ผ. ๋‚˜์ค‘์— ๊ณต๋ถ€ํ•ด์•ผ๊ฒ ๋‹ค.







2. ๐ŸŒŽ ๋‹ค์ค‘ Package ํ˜น์€ ๋‹ค์ค‘ Module์—์„œ Navigation ๊ด€๋ฆฌ๋ฐฉ๋ฒ•.




์•„๋ž˜ ์ฒ˜๋Ÿผ ๊ฐ ๋ชจ๋“ˆ ํ˜น์€ ํŒจํ‚ค์ง€์—

navigation์ด๋ผ๋Š” ํŒจํ‚ค์ง€๋ฅผ ๋งŒ๋“ค์–ด์„œ,

MainNavigation (app ๋ชจ๋“ˆ ํ˜น์€ MainActivity) ์—์„œ ํ•ด๋‹น ๋„ค๋น„๊ฒŒ์ด์…˜ ๊ทธ๋ž˜ํ”„์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋„๋ก

NavGraphBuilder.authScreen() ์ฒ˜๋Ÿผ ํ™•์žฅ ํ•จ์ˆ˜๋ฅผ ๋งŒ๋“ค์–ด์ค€๋‹ค.

์ด ๋•Œ, ํ•ด๋‹น ๋ชจ๋“ˆ ํ˜น์€ ํŒจํ‚ค์ง€๋กœ ํ–ฅํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•˜๋Š” navigateToAuth() ๋„ ํ•ด๋‹น ๋ชจ๋“ˆ ํ˜น์€ ํŒจํ‚ค์ง€์—์„œ ์ œ๊ณตํ•œ๋‹ค.

ํ•ด๋‹น ํ•จ์ˆ˜์—์„œ ๋ฐ”๋กœ AuthScreen()์„ ๋„์›Œ์ค„ ์ˆ˜๋„ ์žˆ์ง€๋งŒ,

AuthRoute()๋ผ๋Š” ๋ž˜ํ•‘ ํ•จ์ˆ˜๋ฅผ ๋งŒ๋“ค์–ด์„œ, ํ•ด๋‹น ๋„ค๋น„๊ฒŒ์ด์…˜ ๋‚ด๋ถ€์— ๋„์›Œ์ค„ ํ™”๋ฉด์„ ์‰ฝ๊ฒŒ ๊ฐˆ์•„ ๋ผ์šธ ์ˆ˜ ์žˆ๋„๋ก ํ•œ๋‹ค. (์ด๊ฑด ์„ ํƒ์‚ฌํ•ญ์ด๋‹ค.)

const val authNavigationRoute = "auth_route"

fun NavController.navigateToAuth(navOptions: NavOptions?) {
    this.navigate(authNavigationRoute, navOptions)
}

fun NavGraphBuilder.authScreen() {
    composable(route = authNavigationRoute) {
        AuthRoute()
    }
}

@Composable
internal fun AuthRoute() {
    var id by remember { mutableStateOf("") }
    var password by remember { mutableStateOf("") }

    val idChanged: (String) -> Unit = { textValue ->
        id = textValue
    }

    val passwordChanged: (String) -> Unit = { textValue ->
        password = textValue
    }

    AuthScreen(
        id = id,
        password = password,
        idChanged = idChanged,
        passwordChanged = passwordChanged,
    )
}

์ฐธ๊ณ  :

  1. NowInAndroid Github

  2. Best Practices for Compose Navigation in Multi-Module Project