Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

수료 제출합니다. #110

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,61 @@ import com.example.happybirthday.ui.theme.HappyBirthdayTheme
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent { }
setContent {

}
}
}

// 7. 텍스트 정렬 및 패딩 추가
@Composable
fun BirthdayGreetingWithText(message: String, from: String) {
// Create a column so that texts don't overlap
Column { }
Column {
Text(
text = message,
fontSize = 36.sp,
modifier = Modifier
.fillMaxWidth()
.wrapContentWidth(Alignment.CenterHorizontally)
.padding(start = 16.dp, top = 16.dp)
)
Text(
text = from,
fontSize = 24.sp,
modifier = Modifier
.fillMaxWidth()
.wrapContentWidth(Alignment.CenterHorizontally)
.padding(start = 16.dp, end = 16.dp)
)

}
}

// 5. Box 레이아웃 추
@Composable
fun BirthdayGreetingWithImage(message: String, from: String) { }
fun BirthdayGreetingWithImage(message: String, from: String) {
val image = painterResource(R.drawable.androidparty)
Image(
painter = image,
contentDescription = null,
modifier = Modifier
.fillMaxHeight()
.fillMaxWidth(),
contentScale = ContentScale.Crop
)
BirthdayGreetingWithText(message = message, from = from)
}

// 4. 이미지 컴포저블 추가
@Preview(showBackground = false)
@Preview(showBackground = true)
@Composable
private fun BirthdayCardPreview() { }
private fun BirthdayCardPreview() {
HappyBirthdayTheme {
BirthdayGreetingWithImage(
stringResource(R.string.happy_birthday_text),
stringResource(R.string.signature_text)
)
}
}

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@
-->
<resources>
<string name="app_name">Happy Birthday</string>
<string name="happy_birthday_text">Happy Birthday Sam!</string>
<string name="signature_text">- from Namju</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,25 @@ import com.example.composearticle.ui.theme.ComposeArticleTheme
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent { }
setContent {
ComposeArticleTheme {
Surface(color = MaterialTheme.colors.background) {
ComposeArticleApp()
}
}
}
}
}

@Composable
fun ComposeArticleApp() { }
fun ComposeArticleApp() {
ArticleCard(
title = stringResource(R.string.title_jetpack_compose_tutorial),
shortDescription = stringResource(R.string.compose_short_desc),
longDescription = stringResource(R.string.compose_long_desc),
imagePainter = painterResource(id = R.drawable.bg_compose_background)
)
}

@Composable
private fun ArticleCard(
Expand All @@ -39,10 +52,39 @@ private fun ArticleCard(
imagePainter: Painter,
modifier: Modifier = Modifier,
) {
Column() { }
Column {
Image(
painter = imagePainter,
contentDescription = null
)
Text(
text = title,
fontSize = 24.sp,
modifier = Modifier.padding(16.dp)
)
Text(
text = shortDescription,
textAlign = TextAlign.Justify,
modifier = Modifier.padding(
start = 16.dp,
end = 16.dp
)
)
Text(
text = longDescription,
textAlign = TextAlign.Justify,
modifier = Modifier.padding(16.dp)
)
}
}


@Preview(showBackground = true)
@Composable
fun DefaultPreview() { }
fun DefaultPreview() {
ComposeArticleTheme() {
Surface {
ComposeArticleApp()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,47 @@ import com.example.composequadrant.ui.theme.ComposeQuadrantTheme
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent { }
setContent {
ComposeQuadrantTheme {
Surface(color = MaterialTheme.colors.background) {
ComposeQuadrantApp()
}
}
}
}
}

@Composable
fun ComposeQuadrantApp() {
Column() {
Row() { }
Row() { }
Column(Modifier.fillMaxWidth()) {
Row(Modifier.weight(1f)) {
ComposableInfoCard(
title = stringResource(R.string.first_title),
description = stringResource(R.string.first_description),
backgroundColor = Color.Green,
modifier = Modifier.weight(1f)
)
ComposableInfoCard(
title = stringResource(R.string.second_title),
description = stringResource(R.string.second_description),
backgroundColor = Color.Yellow,
modifier = Modifier.weight(1f)
)
}
Row(Modifier.weight(1f)) {
ComposableInfoCard(
title = stringResource(R.string.third_title),
description = stringResource(R.string.third_description),
backgroundColor = Color.Cyan,
modifier = Modifier.weight(1f)
)
ComposableInfoCard(
title = stringResource(R.string.fourth_title),
description = stringResource(R.string.fourth_description),
backgroundColor = Color.LightGray,
modifier = Modifier.weight(1f)
)
}
}
}

Expand All @@ -41,10 +73,33 @@ private fun ComposableInfoCard(
backgroundColor: Color,
modifier: Modifier = Modifier
) {
Column( ) { }
Column(
modifier = modifier
.fillMaxSize()
.background(backgroundColor)
.padding(16.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
Text(
text = title,
fontWeight = FontWeight.Bold,
modifier = Modifier.padding(bottom = 16.dp)
)
Text(
text = description,
textAlign = TextAlign.Justify
)
}
}


@Preview(showBackground = true)
@Composable
fun DefaultPreview() { }
fun DefaultPreview() {
ComposeQuadrantTheme {
Surface {
ComposeQuadrantApp()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,43 @@ import com.example.taskcompleted.ui.theme.TaskCompletedTheme
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent { }
setContent {
TaskCompletedTheme() {
Surface {
TaskCompletedScreen()
}
}
}
}
}

@Composable
fun TaskCompletedScreen() {
Column( ) { }
Column(
modifier = Modifier
.fillMaxWidth()
.fillMaxHeight(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
val image = painterResource(R.drawable.ic_task_completed)
Image(painter = image, contentDescription = null)
Text(
text = stringResource(R.string.all_task_completed),
fontWeight = FontWeight.Bold,
modifier = Modifier.padding(top = 24.dp, bottom = 8.dp)
)
Text(
text = stringResource(R.string.nice_work),
fontSize = 16.sp
)
}
}

@Preview(showBackground = true)
@Composable
fun DefaultPreview() { }
fun DefaultPreview() {
Surface {
TaskCompletedScreen()
}
}
15 changes: 15 additions & 0 deletions Unit2/Pathway2/DiceRoller/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
1 change: 1 addition & 0 deletions Unit2/Pathway2/DiceRoller/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
63 changes: 63 additions & 0 deletions Unit2/Pathway2/DiceRoller/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}

android {
namespace 'com.example.diceroller'
compileSdk 32

defaultConfig {
applicationId "com.example.diceroller"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.1.1'
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}

dependencies {

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.3.1'
implementation "androidx.compose.ui:ui:$compose_ui_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version"
implementation 'androidx.compose.material:material:1.1.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_ui_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_ui_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_ui_version"
}
21 changes: 21 additions & 0 deletions Unit2/Pathway2/DiceRoller/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Loading