mori-atsushi / katalog

A UI Catalog Library made with Jetpack Compose
https://mori-atsushi.github.io/katalog
Apache License 2.0
159 stars 6 forks source link

Please consider ditching the material dependency from the manifest! #111

Open zoltish opened 2 years ago

zoltish commented 2 years ago

What happened?

The library declares android:theme="@style/Theme.MaterialComponents.DayNight.NoActionBar" in its manifest.

Unfortunately this breaks things for projects like mine that dont depend on material at all. Please consider ditching it, if thats viable for you too! :)

mori-atsushi commented 2 years ago

Thanks for your report!

What specific problems do you encounter? Android Theme in Preview can be replaced with an extension.

dependencies {
    implementation("jp.co.cyberagent.katalog:katalog:`LATEST_VERSION`")
    implementation("jp.co.cyberagent.katalog:katalog-androidview:`LATEST_VERSION`")
    implementation("jp.co.cyberagent.katalog:katalog-ext-androidtheme:`LATEST_VERSION`")
}
registerKatalog(
    title = "Android Sample",
    extensions = listOf(
        AndroidThemeExt(R.style.MyTheme) // add this line
    )
) {
    view("Text View") {
        TextView(context).apply {
            text = "Hello, World"
        }
    }
}

Details

yshrsmz commented 2 years ago

Actually, there's a PR for this specific issue; #110

zoltish commented 2 years ago

@Mori-Atsushi Thank you, that works :)

While on the topic, I saw that appcompat would replace material - is it possible to make both optional? My application is entirely written in compose and Im able to trim the aab/apk size quite massively by removing these libraries. My activity just extends ComponentActivity.

mori-atsushi commented 2 years ago

This is a debug tool, so if you care about app size, it's best not to include it in your production code. You can use it only in debug build or an independent application.