From 072d1b1d6dd07e60cd37bb31cea7c795323c1ee6 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sat, 17 Aug 2024 12:48:22 +0900 Subject: [PATCH] =?UTF-8?q?[FEATURE]#97=20:=20AnimatedVisibilty=20->=20Ani?= =?UTF-8?q?matedContent=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/com/bff/wespot/MainActivity.kt | 101 ++++++++++-------- app/src/main/res/values/strings.xml | 2 + 2 files changed, 56 insertions(+), 47 deletions(-) diff --git a/app/src/main/kotlin/com/bff/wespot/MainActivity.kt b/app/src/main/kotlin/com/bff/wespot/MainActivity.kt index 22d3850dc..7d2644446 100644 --- a/app/src/main/kotlin/com/bff/wespot/MainActivity.kt +++ b/app/src/main/kotlin/com/bff/wespot/MainActivity.kt @@ -7,10 +7,10 @@ import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.animation.AnimatedContent -import androidx.compose.animation.AnimatedVisibility -import androidx.compose.animation.animateContentSize +import androidx.compose.animation.core.tween import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut +import androidx.compose.animation.togetherWith import androidx.compose.foundation.Image import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement @@ -21,7 +21,6 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.IconButton @@ -153,56 +152,64 @@ private fun MainScreen( Scaffold( modifier = Modifier.fillMaxSize(), topBar = { - AnimatedVisibility( - visible = isTopNavigationScreen, - enter = fadeIn(), - exit = fadeOut(), - ) { - WSTopBar( - title = "", - navigation = { - Image( - modifier = Modifier - .padding(top = 8.dp, bottom = 8.dp, start = 16.dp) - .size(width = 112.dp, height = 44.dp), - painter = painterResource(id = R.drawable.logo), - contentDescription = stringResource( - id = com.bff.wespot.message.R.string.wespot_logo, - ), - ) - }, - action = { - IconButton( - modifier = Modifier.padding(top = 10.dp, bottom = 10.dp, end = 4.dp), - onClick = { - navController.navigateToNavGraph(AppNavGraphs.notification) - }, - ) { - Icon( - painter = painterResource(id = R.drawable.notification), + AnimatedContent( + targetState = isTopNavigationScreen, + transitionSpec = { + fadeIn(animationSpec = tween()) togetherWith fadeOut(animationSpec = tween()) + }, + label = stringResource(com.bff.wespot.R.string.bottom_bar_animated_content_label), + ) { targetState -> + if (targetState) { + WSTopBar( + title = "", + navigation = { + Image( + modifier = Modifier + .padding(top = 8.dp, bottom = 8.dp, start = 16.dp) + .size(width = 112.dp, height = 44.dp), + painter = painterResource(id = R.drawable.logo), contentDescription = stringResource( - id = com.bff.wespot.message.R.string.notification_icon, + id = com.bff.wespot.message.R.string.wespot_logo, ), ) - } - }, - ) + }, + action = { + IconButton( + modifier = Modifier.padding(top = 10.dp, bottom = 10.dp, end = 4.dp), + onClick = { + navController.navigateToNavGraph(AppNavGraphs.notification) + }, + ) { + Icon( + painter = painterResource(id = R.drawable.notification), + contentDescription = stringResource( + id = com.bff.wespot.message.R.string.notification_icon, + ), + ) + } + }, + ) + } } }, bottomBar = { - AnimatedVisibility( - visible = isBottomNavigationScreen, - enter = fadeIn(), - exit = fadeOut(), - ) { - val currentSelectedItem by navController.currentScreenAsState() - BottomNavigationTab( - selectedNavigation = currentSelectedItem, - onNavigationSelected = { selected -> - navController.navigateToNavGraph(selected) - }, - modifier = Modifier.fillMaxWidth(), - ) + AnimatedContent( + targetState = isBottomNavigationScreen, + transitionSpec = { + fadeIn(animationSpec = tween()) togetherWith fadeOut(animationSpec = tween()) + }, + label = stringResource(com.bff.wespot.R.string.top_bar_animated_content_label) + ) { targetState -> + if (targetState) { + val currentSelectedItem by navController.currentScreenAsState() + BottomNavigationTab( + selectedNavigation = currentSelectedItem, + onNavigationSelected = { selected -> + navController.navigateToNavGraph(selected) + }, + modifier = Modifier.fillMaxWidth(), + ) + } } }, ) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1d6e43448..8f6d97717 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,3 +1,5 @@ WeSpot + Top Bar Animated content + bottom bar animated content label \ No newline at end of file