Jetpack compose をちょっと触ってみた / about jetpack compose

624c83486bfce5286adcb895a1da66a3?s=47 charcoJp
November 30, 2019

Jetpack compose をちょっと触ってみた / about jetpack compose

624c83486bfce5286adcb895a1da66a3?s=128

charcoJp

November 30, 2019
Tweet

Transcript

  1. +FUQBDLDPNQPTF Λͪΐͬͱ৮ͬͯΈͨ "OESPJEݚڀൃදձ  

  2. ࣗݾ঺հ w ୸ຊେथ!DIBSDP@KQ w BLJQQBגࣜձࣾ w "OESPJEΞϓϦ։ൃ w 'MVUUFSΞϓϦ։ൃ ࢝Ίͨ͹͔Γɻ

  3. None
  4. λʔήοτ w +FUQBDL$PNQPTFΛ஌Βͳ͍ਓ w +FUQBDL$PNQPTFͷ໊લ͚ͩ஌͍ͬͯΔਓ

  5. ࿩͢͜ͱ w +FUQBDL$PNQPTFͱ͸ w ಛ௃ w +FUQBDL$PNQPTF͕ඞཁʹͳͬͨཧ༝ w ؆୯ͳ+FUQBDL$PNQPTFͷίʔυղઆ w

    ιʔεΛݟͯΈΔʢ࣌ؒ༨ͬͨΒʣ w ॴײ
  6. +FUQBDL$PNQPTFͱ͸ w ωΠςΟϒ6*ॻͨ͘ΊͷπʔϧΩοτ w 4%,ະόϯυϧ w ,PUMJOલఏ w એݴత6* w

    3FBDU -JUIP 7VFKT 'MVUUFSʹ৮ൃ͞Εͨ w JO%FWFMPQFS1SFWJFX
  7. +FUQBDL$PNQPTFͱ͸ w ωΠςΟϒ6*ॻͨ͘ΊͷπʔϧΩοτ w 4%,ະόϯυϧ w ,PUMJOલఏ w એݴత6* w

    3FBDU -JUIP 7VFKT 'MVUUFSʹ৮ൃ͞Εͨ w JO%FWFMPQFS1SFWJFX
  8. +FUQBDL$PNQPTFͱ͸ w ωΠςΟϒ6*ॻͨ͘ΊͷπʔϧΩοτ w 4%,ະόϯυϧ w ,PUMJOલఏ w એݴత6* w

    3FBDU -JUIP 7VFKT 'MVUUFSʹ৮ൃ͞Εͨ w JO%FWFMPQFS1SFWJFX
  9. +FUQBDL$PNQPTFͱ͸ w ωΠςΟϒ6*ॻͨ͘ΊͷπʔϧΩοτ w 4%,ະόϯυϧ w ,PUMJOલఏ w એݴత6* w

    3FBDU -JUIP 7VFKT 'MVUUFSʹ৮ൃ͞Εͨ w JO%FWFMPQFS1SFWJFX
  10. એݴత6*ʁ

  11. ࡶʹݴ͏ͱ ॻ͍ͯ͋Δ௨Γʹ6*͕දࣔ͞ΕΔ ˞஌͕ࣝͳ͍ͷͰ৮Ε·ͤΜ

  12. +FUQBDL$PNQPTFͱ͸ w ωΠςΟϒ6*Λߏங͢ΔͨΊͷ࠷৽πʔϧΩοτ w 4%,ະόϯυϧ w ,PUMJOલఏ w એݴత6* w

    3FBDU -JUIP 7VFKT 'MVUUFSʹ৮ൃ͞Εͨ w JO%FWFMPQFS1SFWJFX
  13. // ఆٛ fun hoge(callback: () -> Unit) { print("Hoge!") callback()

    } fun main() { hoge() { print("ऴΘͬͨΑ") } hoge({ print("ऴΘͬͨΑ") }) } Ҿ਺ͷ ͷ֎ʹDBMMCBDLͷ ॲཧΛهड़ Ҿ਺ͷதʹهड़ Ҿ਺ͷؔ਺Λ֎ͩ͠ग़དྷΔ
  14. +FUQBDL$PNQPTFͱ͸ w ωΠςΟϒ6*Λߏங͢ΔͨΊͷ࠷৽πʔϧΩοτ w 4%,ະόϯυϧ w ,PUMJOલఏ w એݴత6* w

    3FBDU -JUIP 7VFKT 'MVUUFSʹ৮ൃ͞Εͨ w JO%FWFMPQFS1SFWJFX w "1*͕ະ׬੒Ͱมߋ͕༧ఆ͞Ε͍ͯΔͨΊɺ੡඼൛Ͱ࢖༻͠ ͳ͍͜ͱ w "OESPJE4UVEJP$BOBSZ
  15. +FUQBDL$PNQPTF͕ඞཁʹͳͬͨཧ༝ w $PNQPOFOU"1*Λ͔Βߏங͍ͨ͠ w ྺ࢙తܦҢͰBOESPJEWJFX഑Լͷ࣮૷͕ෳࡶ w ΧελϜ6*ίϯϙʔωϯτ࡞Δͷ͕େม w 'SBHNFOU $VTUPN7JFX$VTUPN7JFX(SPVQ

    w ͳͲͳͲɻ w Ҿ༻ݩ w IUUQTEFWFMPQFSBOESPJEDPNKFUQBDLDPNQPTF w IUUQTXXXZPVUVCFDPNXBUDI W7T4UZR-[YP
  16. +FUQBDL$PNQPTF͕ඞཁʹͳͬͨཧ༝ w $PNQPOFOU"1*Λ͔Βߏங͍ͨ͠ w ྺ࢙తܦҢͰBOESPJEWJFX഑Լͷ࣮૷͕ෳࡶ w ΧελϜ6*ίϯϙʔωϯτ࡞Δͷ͕େม w 'SBHNFOU $VTUPN7JFX$VTUPN7JFX(SPVQ

    w ͳͲͳͲɻ w Ҿ༻ݩ w IUUQTEFWFMPQFSBOESPJEDPNKFUQBDLDPNQPTF w IUUQTXXXZPVUVCFDPNXBUDI W7T4UZR-[YP
  17. ؆୯ͳ+FUQBDL$PNQPTFͷίʔυղઆ w "OESPJE4%,ͷ7JFX$PNQPTBCMF ߏ੒Մೳͳ  ؔ਺͠ɺͦͷؔ਺ͷπϦʔߏ଄ʹΑΓ6*͕ߏங͞ΕΔ w !$PNQPTBCMFBOOPUBUJPO w ؔ਺ʹ෇༩͢Δߏ੒Մೳͳؔ਺ͱͳΔ

    w 5FYU #VUUPOͳͲͷΑ͘࢖͏7JFXͱ'"#΍$BSEͳ Ͳͷ.BUFSJBM%FTJHOͰఆٛ͞Ε͍ͯΔ7JFX͸ݱঢ়Ͱ ΋͋Δఔ౓༻ҙ͞Ε͍ͯΔ
  18. 5FYU @Composable fun Text( text: String, modifier: Modifier = Modifier.None,

    style: TextStyle? = null, paragraphStyle: ParagraphStyle? = null, softWrap: Boolean = DefaultSoftWrap, overflow: TextOverflow = DefaultOverflow, // TODO(siyamed): remove suppress @SuppressLint("AutoBoxing") maxLines: Int? = DefaultMaxLines, selectionColor: Color = DefaultSelectionColor ) { Text( text = AnnotatedString(text), modifier = modifier, style = style, paragraphStyle = paragraphStyle, softWrap = softWrap, overflow = overflow, maxLines = maxLines, selectionColor = selectionColor ) }
  19. 5FYUར༻ class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?)

    { super.onCreate(savedInstanceState) setContent { Text( text = "Hello World!", style = TextStyle( color = Color.Blue, fontSize = 24.sp ) ) } } }
  20. -JTU7JFX w -JTU7JFX 3FDZDMFS7JFXʹ૬౰͢Δ$PNQPOFU͸ͳ͍ w ݱঢ়Ͱ͸ҎԼͷೋͭΛ૊Έ߹Θ࣮ͤͯݱ͢Δ͜ͱʹͳΔ w 7FSUJDBM4DSPMMFS4DSPMM7JFX w $PMVNO-JOFBS-BZPVU

    PSJFOUBUJPOWFSUJDBM
  21. -JTUදࣔ @Composable fun MinimumListExampleScreen() { VerticalScroller { Column { (0..20).map

    { ListItem( text = it.toString(), onClick = { } ) Divider() } } } }
  22. ιʔεΛݟͯΈΔ ʢ࣌ؒ༨ͬͨΒʣ

  23. ॴײ w طଘͷ࣮૷ํ๏ΑΓ͸Δ͔ʹָͰ௚ײతɻݸਓతʹ͸TUBCMFʹͳͬͨΒ࢖Θͳ ͍ͱ͍͏બ୒͸ͳ͍ w ۪௚ʹॻ͍͍ͯ͘ͱωετ͕ਂͯ͘Մಡੑ͕Լ͕Γͦ͏ w ϝιουநग़ͯ͠!$PNQPTBCMFΛ͢Ε͹ύʔπԽͰ͖ΔͷͰ໰୊ʹ͸ͳΒ ͳ͍ͱࢥ͏ɻͨͩTQBDFΠϯσϯτ͸ྲྀੴʹਏͦ͏ w

    'MVUUFSͰͷܦݧ શͯΛ,PUMJOͰ͔͚Δ͚ͩͰՁ஋͕͋Δ w +BWB,PUMJOMBZPVUYNMTFUUJOHTYNMͳͲ͸ݴޠʗॻ͖ํ͕ҧ͏ ͨΊ಄ͷ੾Γସ͕͑ൃੜ͢Δ͕ͦΕ͕ͳ͍ w એݴత6* w J04"OESPJEͱ΋ʹରԠ͢ΔϥΠϒϥϦΛ༻ҙͨ͠ϞόΠϧΞϓϦ։ൃ ऀͷඞमՊ໨ʹͳΔ w ৽͍͠ߟ͑ํͰ͋ΔͨΊɺҰ֮ͭ͑ͯ͠·͑͹ଞʹ஌ࣝΛྲྀ༻Ͱ͖Δ
  24. ͜ͷػձʹ+FUQBDL $PNQPTFΛ৮ͬͯΈͯ͸ ͍͔͕Ͱ͠ΐ͏͔ʂ

  25. ͓ΘΓ