Skip to content

ambishiva/Snack-Bar-Reusable-Component

Repository files navigation

Snack Bar Wrapper

This library can be used/intergrate in a project as a wrapper for alert messages so that if required to change snackbar to any other lib then can be changed easily without affecting or changes on UI layer.

 

Dev can use this lib as a bridge between Google snackbar and their application. Flexible to adobt new changes from Snackbar library so that core dev team should focus on delivering the things instead of thinking about library updation or learn/adopt new changes.

 

How to use

 

Snack Bar Message
Alert.with(context, "Snack bar message").show()

 

Change background color
Alert.with(this, "Snackbar with red background")
            .backgroundColor(android.R.color.holo_red_dark).show()

 

Change text color
Alert.with(this, "Snackbar with red text color")
            .textColor(android.R.color.holo_red_dark).show()

 

Change snack bar duration
Alert.with(this, "Snackbar with 20 seconds")
            .textColor(android.R.color.holo_red_dark)
            .duration(20000).show()

 

Snack bar with font
 val hindiFont = Typeface.createFromAsset(assets, "hind_font.ttf")
        val snackBarBuilder = Alert.with(this, "Snackbar with hindi font")
            .textColor(android.R.color.holo_red_dark)
            .font(hindiFont).show()

 

Snack bar with error view
Alert.with(this, "Snackbar Error Message")
            .textColor(R.color.white)
            .error().show()

 

Snack bar with success view
Alert.with(this, "Snackbar success Message")
            .textColor(R.color.white)
            .success().show()