Migration from 0.3.1 to 0.6.0
osipxd opened this issue · 2 comments
osipxd commented
Just created functions with annotation @Deprecated
and replaceWith
expressions to make migration easier in simple cases.
@file:Suppress("PackageDirectoryMismatch", "unused")
package dev.chrisbanes.insetter
import android.view.View
@Deprecated(
level = DeprecationLevel.ERROR,
message = "Use applyInsetter instead",
replaceWith = ReplaceWith(
"this.applyInsetter { type(statusBars = top, navigationBars = bottom) { padding() } }",
"dev.chrisbanes.insetter.applyInsetter"
)
)
fun View.applySystemWindowInsetsToPadding(top: Boolean = false, bottom: Boolean = false) {
error("should not be used")
}
@Deprecated(
level = DeprecationLevel.ERROR,
message = "Use applyInsetter instead",
replaceWith = ReplaceWith(
"this.applyInsetter { type(statusBars = top, navigationBars = bottom) { margin() } }",
"dev.chrisbanes.insetter.applyInsetter"
)
)
fun View.applySystemWindowInsetsToMargin(top: Boolean = false, bottom: Boolean = false) {
error("should not be used")
}
object Insetter {
@Deprecated(
level = DeprecationLevel.ERROR,
message = "Use WindowCompat.setDecorFitsSystemWindows() instead",
replaceWith = ReplaceWith(
"WindowCompat.setDecorFitsSystemWindows(window, !enabled)",
"androidx.core.view.WindowCompat"
)
)
fun setEdgeToEdgeSystemUiFlags(view: View, enabled: Boolean = true) {
error("should not be used")
}
}
osipxd commented
For example:
// Before
view.applySystemWindowInsetsToPadding(top = true)
// After replace
view.applyInsetter { type(statusBars = true) { padding() } }
// Before
view.applySystemWindowInsetsToMargin(top = true, bottom = true)
// After replace
view.applyInsetter { type(statusBars = true, navigationBars = true) { margin() } }
It is not the exact equivalent, but the migration gets easier.
chrisbanes commented
Feel free to submit a PR and we'll get them merged 👍