icerockdev / moko-errors

Automated exceptions handler for mobile (android & ios) Kotlin Multiplatform development.
https://moko.icerock.dev/
Apache License 2.0
52 stars 6 forks source link

SnackbarErrorPresenter shows snackbar under navigation bar #26

Closed sham0688 closed 2 years ago

sham0688 commented 3 years ago

image

sham0688 commented 3 years ago

add custom container id:

<resources>
    <item name="snackbar_container" type="id"/>
</resources>
actual class ExSnackBarErrorPresenter : ErrorPresenter<StringDesc> {

    override fun show(throwable: Throwable, activity: FragmentActivity, data: StringDesc) {
        val rootView = activity.findViewById<View>(R.id.snackbar_container)
            ?: ...
        if (rootView != null) {
            Snackbar.make(
                rootView,
                ... ,
            ).show()
        }
    }
}

use in fragment layout

<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@id/snackbar_container"
    ... />