{"id":45788,"date":"2021-11-24T15:14:03","date_gmt":"2021-11-24T06:14:03","guid":{"rendered":"https:\/\/www.charlezz.com\/?p=45788"},"modified":"2021-11-24T15:14:04","modified_gmt":"2021-11-24T06:14:04","slug":"migrating-to-jetpack-compose-%ed%85%8c%eb%a7%88-%ec%83%81%ed%98%b8%ec%9a%b4%ec%9a%a9","status":"publish","type":"post","link":"https:\/\/charlezz.com\/?p=45788","title":{"rendered":"Migrating to Jetpack Compose &#8211; \ud14c\ub9c8 \uc0c1\ud638\uc6b4\uc6a9"},"content":{"rendered":"\n<p>\ucef4\ud3ec\uc988\ub85c \ub9c8\uc774\uadf8\ub808\uc774\uc158\ub41c \uc2dd\ubb3c \uc138\ubd80 \uc815\ubcf4\uc758 \ud14d\uc2a4\ud2b8 \ucf58\ud150\uce20\uac00 \uc788\ub2e4. \uadf8\ub7ec\ub098 \ucef4\ud3ec\uc988\uac00 \uc62c\ubc14\ub978 \ud14c\ub9c8 \uc0c9\uc0c1\uc744 \uc0ac\uc6a9\ud558\uc9c0 \uc54a\ub294\ub2e4\ub294 \uac83\uc744 \ub208\uce58\ucc4c \uc218 \uc788\ub2e4. \ub179\uc0c9\uc744 \uc0ac\uc6a9\ud574\uc57c \ud560 \ub54c \uc2dd\ubb3c \uc774\ub984\uc5d0 \ubcf4\ub77c\uc0c9\uc744 \uc0ac\uc6a9\ud55c\ub2e4.<\/p>\n\n\n\n<p>\uc774 \ucd08\uae30 \ub9c8\uc774\uadf8\ub808\uc774\uc158 \ub2e8\uacc4\uc5d0\uc11c, \ucef4\ud3ec\uc988\uc5d0\uc11c \ucc98\uc74c\ubd80\ud130 Material \ud14c\ub9c8\ub97c \ub2e4\uc2dc \uc791\uc131\ud558\ub294 \ub300\uc2e0 View \uc2dc\uc2a4\ud15c\uc5d0\uc11c \uc0ac\uc6a9 \uac00\ub2a5\ud55c \ud14c\ub9c8\ub97c \uc0c1\uc18d\ud558\uae30\ub97c \uc6d0\ud560 \uc218 \uc788\ub2e4. Material \ud14c\ub9c8\ub294 \ucef4\ud3ec\uc988\uc640 \ud568\uaed8 \uc81c\uacf5\ub418\ub294 \ubaa8\ub4e0 Material \ub514\uc790\uc778 \ucef4\ud3ec\ub10c\ud2b8\uc640 \uc644\ubcbd\ud558\uac8c \uc791\ub3d9\ud55c\ub2e4. <\/p>\n\n\n\n<p>\ucef4\ud3ec\uc988\uc5d0\uc11c View \uc2dc\uc2a4\ud15c MDC \ud14c\ub9c8\ub97c \uc7ac\uc0ac\uc6a9\ud558\ub824\uba74, compose-theme-adapter\ub97c \uc0ac\uc6a9\ud560 \uc218 \uc788\ub2e4. MdcTheme \ud568\uc218\ub294 \ud638\uc2a4\ud2b8 \ucee8\ud14d\uc2a4\ud2b8\uc758 MDC \ud14c\ub9c8\ub97c \uc790\ub3d9\uc73c\ub85c \uc77d\uace0, \ub77c\uc774\ud2b8 \ud14c\ub9c8\uc640 \ub2e4\ud06c \ud14c\ub9c8 \ubaa8\ub450\uc5d0 \ub300\ud574 \uc6b0\ub9ac\ub97c \ub300\uc2e0\ud558\uc5ec MaterialTheme\uc5d0 \uc804\ub2ec\ud55c\ub2e4. \uc774 \ucf54\ub4dc\ub7a9\uc758 \ud14c\ub9c8 \uc0c9\uc0c1\ub9cc \ud544\uc694\ud558\ub354\ub77c\ub3c4, \ub77c\uc774\ube0c\ub7ec\ub9ac\ub294 View \uc2dc\uc2a4\ud15c\uc758 \ubaa8\uc591\uacfc \ud0c0\uc774\ud3ec\uadf8\ub798\ud53c\ub3c4 \uc77d\uc5b4\uc628\ub2e4. (Mdc\ub294 Material Desgin Component\uc758 \uc57d\uc790)<\/p>\n\n\n\n<p>\ub77c\uc774\ube0c\ub7ec\ub9ac\ub294 \uc774\ubbf8 \ub2e4\uc74c\uacfc \uac19\uc774 app\/build.gradle \ud30c\uc77c\uc5d0 \ud3ec\ud568\ub418\uc5b4 \uc788\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>...<br>dependencies {<br>&nbsp; &nbsp; ...<br>&nbsp; &nbsp; implementation \"com.google.android.material:compose-theme-adapter:$rootProject.composeVersion\"<br>&nbsp; &nbsp; ...<br>}<\/code><\/pre>\n\n\n\n<p>\uc774\ub97c \uc0ac\uc6a9\ud558\ub824\uba74 MdcTheme\uc5d0 \ub300\ud55c MaterialTheme \uc0ac\uc6a9\uc744 \uad50\uccb4\ud574\uc57c \ud55c\ub2e4. \uc608\ub97c \ub4e4\uc5b4 PlantDetailFragment\uc5d0\uc11c \ub2e4\uc74c\uacfc \uac19\uc774 \ucf54\ub4dc\ub97c \ubcc0\uacbd\ud560 \uc218 \uc788\ub2e4. <\/p>\n\n\n\n<h4 class=\"wp-block-heading\">PlantDetailFragment.kt<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>class PlantDetailFragment : Fragment() {<br>&nbsp; &nbsp; ...<br>&nbsp; &nbsp; composeView.apply {<br>&nbsp; &nbsp; &nbsp; &nbsp; ...<br>&nbsp; &nbsp; &nbsp; &nbsp; setContent {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MdcTheme {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PlantDetailDescription(plantDetailViewModel)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; }<br>}<\/code><\/pre>\n\n\n\n<p>PlantDetailDescription.kt \ud30c\uc77c\uc758 \ubaa8\ub4e0 \ucef4\ud3ec\uc800\ube14 \ubbf8\ub9ac\ubcf4\uae30\ub294 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">PlantDetailDescription.kt<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>@Preview<br>@Composable<br>private fun PlantDetailContentPreview() {<br>&nbsp; &nbsp; val plant = Plant(\"id\", \"Apple\", \"HTML&lt;br&gt;&lt;br&gt;description\", 3, 30, \"\")<br>&nbsp; &nbsp; MdcTheme {<br>&nbsp; &nbsp; &nbsp; &nbsp; PlantDetailContent(plant)<br>&nbsp; &nbsp; }<br>}<br><br>@Preview<br>@Composable<br>private fun PlantNamePreview() {<br>&nbsp; &nbsp; MdcTheme {<br>&nbsp; &nbsp; &nbsp; &nbsp; PlantName(\"Apple\")<br>&nbsp; &nbsp; }<br>}<br><br>@Preview<br>@Composable<br>private fun PlantWateringPreview() {<br>&nbsp; &nbsp; MdcTheme {<br>&nbsp; &nbsp; &nbsp; &nbsp; PlantWatering(7)<br>&nbsp; &nbsp; }<br>}<br><br>@Preview<br>@Composable<br>private fun PlantDescriptionPreview() {<br>&nbsp; &nbsp; MdcTheme {<br>&nbsp; &nbsp; &nbsp; &nbsp; PlantDescription(\"HTML&lt;br&gt;&lt;br&gt;description\")<br>&nbsp; &nbsp; }<br>}<\/code><\/pre>\n\n\n\n<p>\ubbf8\ub9ac\ubcf4\uae30\uc5d0\uc11c \ubcfc \uc218 \uc788\ub4ef\uc774 MdcTheme\ub294 styles.xml \ud30c\uc77c\uc758 \ud14c\ub9c8\uc5d0\uc11c \uc0c9\uc0c1\uc744 \uc120\ud0dd\ud558\uace0 \uc788\ub2e4.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/developer.android.com\/codelabs\/jetpack-compose-migration\/img\/44dc929c9b63137d.png\" alt=\"44dc929c9b63137d.png\"\/><\/figure><\/div>\n\n\n\n<p>\uc0c8 \ud568\uc218\ub97c \ub9cc\ub4e4\uace0 \ubbf8\ub9ac\ubcf4\uae30\uc758 uiMode\uc5d0 Configuration.UI_MODE_NIGHT_YES\ub97c \uc804\ub2ec\ud558\uc5ec \uc5b4\ub450\uc6b4 \ud14c\ub9c8\uc758 UI\ub97c \ubbf8\ub9ac \ubcfc \uc218\ub3c4 \uc788\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)<br>@Composable<br>private fun PlantDetailContentDarkPreview() {<br>&nbsp; &nbsp; val plant = Plant(\"id\", \"Apple\", \"HTML&lt;br&gt;&lt;br&gt;description\", 3, 30, \"\")<br>&nbsp; &nbsp; MdcTheme {<br>&nbsp; &nbsp; &nbsp; &nbsp; PlantDetailContent(plant)<br>&nbsp; &nbsp; }<br>}<\/code><\/pre>\n\n\n\n<p>\ub098\uc774\ud2b8 \ubaa8\ub4dc\uac00 \uc801\uc6a9\ub41c \ubbf8\ub9ac\ubcf4\uae30\ub85c \ubcf4\uba74 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/developer.android.com\/codelabs\/jetpack-compose-migration\/img\/8b676db6b0793855.png\" alt=\"8b676db6b0793855.png\"\/><\/figure><\/div>\n\n\n\n<p>\uc571\uc744 \uc2e4\ud589\ud558\uba74 \ub77c\uc774\ud2b8 \ud14c\ub9c8\uc640 \ub2e4\ud06c \ud14c\ub9c8 \ubaa8\ub450\uc5d0\uc11c \ub9c8\uc774\uadf8\ub808\uc774\uc158 \uc804\uacfc \uc815\ud655\ud788 \ub3d9\uc77c\ud558\uac8c \uc791\ub3d9\ud55c\ub2e4.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/developer.android.com\/codelabs\/jetpack-compose-migration\/img\/2b95ea2dee5ed3ae.gif\" alt=\"2b95ea2dee5ed3ae.gif\" width=\"393\" height=\"803\"\/><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\ucef4\ud3ec\uc988\ub85c \ub9c8\uc774\uadf8\ub808\uc774\uc158\ub41c \uc2dd\ubb3c \uc138\ubd80 \uc815\ubcf4\uc758 \ud14d\uc2a4\ud2b8 \ucf58\ud150\uce20\uac00 \uc788\ub2e4. \uadf8\ub7ec\ub098 \ucef4\ud3ec\uc988\uac00 \uc62c\ubc14\ub978 \ud14c\ub9c8 \uc0c9\uc0c1\uc744 \uc0ac\uc6a9\ud558\uc9c0 \uc54a\ub294\ub2e4\ub294 \uac83\uc744 \ub208\uce58\ucc4c \uc218 \uc788\ub2e4. \ub179\uc0c9\uc744 \uc0ac\uc6a9\ud574\uc57c \ud560 \ub54c \uc2dd\ubb3c \uc774\ub984\uc5d0 \ubcf4\ub77c\uc0c9\uc744 \uc0ac\uc6a9\ud55c\ub2e4. \uc774 \ucd08\uae30 \ub9c8\uc774\uadf8\ub808\uc774\uc158 \ub2e8\uacc4\uc5d0\uc11c, \ucef4\ud3ec\uc988\uc5d0\uc11c \ucc98\uc74c\ubd80\ud130 Material \ud14c\ub9c8\ub97c \ub2e4\uc2dc \uc791\uc131\ud558\ub294 \ub300\uc2e0 View \uc2dc\uc2a4\ud15c\uc5d0\uc11c \uc0ac\uc6a9 \uac00\ub2a5\ud55c \ud14c\ub9c8\ub97c \uc0c1\uc18d\ud558\uae30\ub97c \uc6d0\ud560 \uc218 \uc788\ub2e4. Material \ud14c\ub9c8\ub294 \ucef4\ud3ec\uc988\uc640 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"inline_featured_image":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[38],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/45788"}],"collection":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=45788"}],"version-history":[{"count":1,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/45788\/revisions"}],"predecessor-version":[{"id":45789,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/45788\/revisions\/45789"}],"wp:attachment":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=45788"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=45788"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=45788"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}