Skip to content

Commit

Permalink
[ADD/#1] 컴포저블 함수화 및 프리뷰 실습
Browse files Browse the repository at this point in the history
  • Loading branch information
b1urrrr committed Nov 30, 2023
1 parent 83f62bd commit fa3406a
Showing 1 changed file with 30 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.ocomwan.myapplication.ui.theme.MyApplicationTheme

Expand All @@ -20,20 +24,33 @@ class MainActivity : ComponentActivity() {
super.onCreate(savedInstanceState)
setContent {
MyApplicationTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background,
) {
Column(
modifier = Modifier
.padding(16.dp),
) {
Text("Hello")
Text("World")
}
}
practiceColumn()
}
}
}

@Composable
fun practiceColumn() {
Surface(
color = MaterialTheme.colorScheme.background,
) {
Column(
modifier = Modifier
.fillMaxSize()
.background(color = Color.Blue)
.padding(16.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.SpaceBetween,
) {
Text("Hello")
Text("World")
}
}
}

@Preview(showBackground = true)
@Composable
fun defaultPreview() {
practiceColumn()
}
}

0 comments on commit fa3406a

Please sign in to comment.