This file contains hidden or 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
val scale = remember { | |
Animatable(0f) | |
} | |
LaunchedEffect(key1 = true, block = { | |
scale.animateTo(targetValue = 1f, | |
animationSpec = tween( | |
durationMillis = 2000, | |
)) | |
delay(2000L) |
This file contains hidden or 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
Box( | |
modifier = Modifier | |
.background(color = Purple700) | |
.fillMaxSize(), | |
contentAlignment = Alignment.Center | |
) { | |
Column(modifier = Modifier, | |
horizontalAlignment = Alignment.CenterHorizontally, | |
verticalArrangement = Arrangement.Center) { | |
Image(painter = painterResource(id = R.drawable.love), |
This file contains hidden or 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
@Composable | |
fun Content( | |
title: String, | |
onTitleChange: (String) -> Unit, | |
onResetClicked: () -> Unit, | |
) { | |
Column( | |
modifier = Modifier | |
.fillMaxSize() | |
.background(MaterialTheme.colors.background) |
This file contains hidden or 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
private val viewModel = AppViewModel() | |
@Composable | |
fun MainContent(viewModel: AppViewModel) { | |
val title by viewModel.titleInputFlow.collectAsState() | |
Content(title = title, onTitleChange = { | |
viewModel.setTitle(it) | |
}, onResetClicked = { viewModel.resetTitle() }) | |
} |
This file contains hidden or 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
class AppViewModel : ViewModel() { | |
private val _titleInputFlow = MutableStateFlow<String>("") | |
val titleInputFlow: StateFlow<String> get() = _titleInputFlow | |
fun setTitle(title: String) { | |
_titleInputFlow.value = title | |
} | |
fun resetTitle() { | |
_titleInputFlow.value = "" |
This file contains hidden or 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
@Composable | |
fun MainScreen() { | |
val navController = rememberNavController() | |
Scaffold( | |
bottomBar = { | |
BottomAppBar { | |
CustomBottomNavigation(navController = navController) | |
} | |
} | |
) { |
This file contains hidden or 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
@Composable | |
fun RowScope.BottomItem( | |
screen: BottomNavigationItem, | |
currentDestination: NavDestination?, | |
navController: NavHostController, | |
) { | |
//RowScope.BottomNavigationItem | |
BottomNavigationItem( | |
icon = { Icon(painterResource(id = screen.icon), contentDescription = screen.title) }, | |
selected = currentDestination?.hierarchy?.any { |