Skip to content

Commit

Permalink
개인 프로젝트 MetaAsset 에서 진행한 1장을 이곳으로 옮겼습니다
Browse files Browse the repository at this point in the history
  • Loading branch information
winter-love-dev committed Dec 4, 2021
1 parent 3824a3d commit 77a1d30
Showing 1 changed file with 27 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import androidx.compose.material.IconButton
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.Icons.Filled
import androidx.compose.material.icons.filled.ExpandLess
import androidx.compose.material.icons.filled.ExpandMore
Expand Down Expand Up @@ -66,7 +67,8 @@ class MainActivity : ComponentActivity() {
}

@Composable
private fun MyApp() {
fun MyApp() {

var shouldShowOnboarding by rememberSaveable { mutableStateOf(true) }

if (shouldShowOnboarding) {
Expand All @@ -77,18 +79,18 @@ private fun MyApp() {
}

@Composable
private fun OnboardingScreen(onContinueClicked: () -> Unit) {
fun OnboardingScreen(onContinueClicked: () -> Unit) {
Surface {
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
) {
Text("Welcome to the Basics Codelab!")
Button(
modifier = Modifier.padding(vertical = 24.dp),
onClick = onContinueClicked
) {
) {
Text("Continue")
}
}
Expand All @@ -97,6 +99,7 @@ private fun OnboardingScreen(onContinueClicked: () -> Unit) {

@Composable
private fun Greetings(names: List<String> = List(1000) { "$it" } ) {
// val expanded by remember { mutableStateOf(false) }
LazyColumn(modifier = Modifier.padding(vertical = 4.dp)) {
items(items = names) { name ->
Greeting(name = name)
Expand All @@ -109,64 +112,70 @@ private fun Greeting(name: String) {
Card(
backgroundColor = MaterialTheme.colors.primary,
modifier = Modifier.padding(vertical = 4.dp, horizontal = 8.dp)
) {
) {
CardContent(name)
}
}

@Composable
private fun CardContent(name: String) {
var expanded by remember { mutableStateOf(false) }

Row(
modifier = Modifier
.padding(12.dp)
.animateContentSize(
animationSpec = spring(
dampingRatio = Spring.DampingRatioMediumBouncy,
stiffness = Spring.StiffnessLow
)
)
) {
)
)
) {
Column(
modifier = Modifier
.weight(1f)
.padding(12.dp)
) {
) {
Text(text = "Hello, ")
Text(
text = name,
style = MaterialTheme.typography.h4.copy(
fontWeight = FontWeight.ExtraBold
)
)
)
if (expanded) {
Text(
text = ("Composem ipsum color sit lazy, " +
"padding theme elit, sed do bouncy. ").repeat(4),
)
"padding theme elit, sed do bouncy. ").repeat(4),
)
}
}
IconButton(onClick = { expanded = !expanded }) {
Icon(
imageVector = if (expanded) Filled.ExpandLess else Filled.ExpandMore,
imageVector = if (expanded) Icons.Filled.ExpandLess else Icons.Filled.ExpandMore,
contentDescription = if (expanded) {
stringResource(R.string.show_less)
} else {
stringResource(R.string.show_more)
}

)
})
}
}
}

@Preview(showBackground = true, widthDp = 320, heightDp = 320)
@Composable
fun OnboardingPreview() {
BasicsCodelabTheme {
OnboardingScreen(onContinueClicked = {})
}
}


@Preview(
showBackground = true,
widthDp = 320,
uiMode = UI_MODE_NIGHT_YES,
name = "DefaultPreviewDark"
)
)
@Preview(showBackground = true, widthDp = 320)
@Composable
fun DefaultPreview() {
Expand All @@ -175,10 +184,3 @@ fun DefaultPreview() {
}
}

@Preview(showBackground = true, widthDp = 320, heightDp = 320)
@Composable
fun OnboardingPreview() {
BasicsCodelabTheme {
OnboardingScreen(onContinueClicked = {})
}
}

0 comments on commit 77a1d30

Please sign in to comment.