Android Weekly Notes #500 Android Weekly Issue #500

Android Weekly Issue #500

Screen templates — using Compose, SwiftUI & KMM

KMM下Compose和SwiftUI的跨平臺解決方案.

ViewModel和State是同一份. 但是UI模板代碼是各個平臺各一份.

Detect text overflow in Jetpack Compose

一個超出後顯示末尾badge count的compose實現.

Tiny things on big screens

在平板上顯示空間太大了怎麼辦?

有時候可能沒有master detail的需求.
不想展示很大的button, 也不想隔很遠的距離.

首先用BoxWithConstraints把內容居中, 並且設置最大寬度.

有劉海怎麼辦? 用WindowManager. 需要添加依賴.

Automatic screenshot testing for all your Compose @Previews

截圖測試:

@ShowkaseScreenshot(rootShowkaseClass = ShowkaseRoot::class)
abstract class ComposeTests : ShowkaseScreenshotTest {

    override fun onScreenshot(
        id: String,
        name: String,
        group: String,
        styleName: String?,
        screenshotType: ShowkaseScreenshotType,
        screenshotBitmap: Bitmap
    ) {
        val view = ImageView(InstrumentationRegistry.getInstrumentation().context)
        view.setImageBitmap(screenshotBitmap)
        ViewHelpers.setupView(view).setExactWidthPx(screenshotBitmap.width).setExactHeightPx(screenshotBitmap.height).layout()
        Screenshot.snap(view).setName("$group - $name").record()
    }
}

這個居然是把Compose轉爲View來測.

Things you should know about Coroutines. Part 4

協程的異常處理, 文章配圖不錯.

WorkManager multi-process for libraries

LeakCanary用了WorkManager.

Code

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章