Google launches Jetpack Compose, an open-source, Kotlin-based UI development toolkit – TechCrunch
Google today announced the first preview of Jetpack Compose, a new open-source UI toolkit for Kotlin developers who want to use a reactive programming model similar to React Native and Vue.js. Jetpack Compose is an unbundled toolkit that is part of Google’s overall Android Jetpack set of software co…
Backup

Jetpack Compose 如果成功開發推出 Stable Release,相信整個 Android Ecosystem 會變天!

睇咗少少 Demo,Kotlin ONLY 冇懸念,因為 DSL 部份主要用上 Kotlin Builder DSL、Named Parameters,如果 Android 仲停留係 Java <= 11 喺冇可能創造到咁簡潔嘅 DSL Abstraction。

同 Anko 有咩唔同?

  1. Anko 主要用黎取代 XML Layout
  2. 喺 Anko 做 Custom View 一樣都要同平時一樣咁寫只不過原本份 XML 可以用埋 Kotlin 寫

有做開 Android 嘅朋友可以參考/玩下 Flutter,相信將來成隻 App UI 嘅 Code 會同 Flutter 嗰種起法幾似。

Examples

以呢個 UI 做例子
class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            NewsStory()
        }
    }
}

@Composable
fun NewsStory() {
  val image = +imageResource(R.drawable.header)
      Column(
        modifier = Spacing(16.dp)
      ) {
          Container(modifier = Height(180.dp) wraps Expanded) {
              DrawImage(image)
          }

          HeightSpacer(16.dp)

          Text("A day in Shark Fin Cove")
          Text("Davenport, California")
          Text("December 2018")
      }
}

@Preview
@Composable
fun DefaultPreview() {
  NewsStory()
}
  
Official Tutorial

Android Development 的突破

要取代舊有 XML 嗰套 UI Builder,所需要嘅氣力唔喺一般 Library 可以相提並論,無論係 Pre Annotation Processing、Add Core UI Builder、Runtime reconciliation⋯⋯真係只有 Google 有咁嘅人力物力財力先做到。

希望 Apple 都會喺 iOS 發功

阿 Gap 相信 Kotlin ONLY 嘅 Tools 會越來越多,大家開始咗寫 Kotlin 未?

當年阿 Gap 喺 Kotlin 未正式成為 Android First Class Support 嘅時候已經力推用 Kotlin 寫 Android...

[長文慎入] 斷斷續續寫咗成個月,好多人問 Kotlin 有乜好,好多文都覆蓋唔哂阿 Gap 心目中覺得好嘅野,索性自己寫出黎介紹番: ◆ 六大原因:點解要揀 Kotlin? ◆ 七大重點進步(vs Java):Kotlin...

Posted by Gap撈Tech on Saturday, 8 April 2017

Official Doc:
https://developer.android.com/jetpack/compose