Skip to content

eriffanani/Snacking2

Repository files navigation

Snacking

Styling your snackbar easily and quickly. This library can be used in both Java and Kotlin.

Installation

repositories

maven { url 'https://jitpack.io' }

dependencies

implementation 'com.github.eriffanani:Snacking2:1.1.3'

How To Use

Xml Layout

<CoordinatorLayout
    android:id="@+id/parentView"/>
    <ChildView/>
    <ExtendedFloatingActionButton
        android:id="@+id/fab"
        android:layout_gravity="bottom|end"/>
</CoordinatorLayout>

Activity / Fragment

val parentView: CoordinatorLayout = findViewById(R.id.parentView)
val fab: ExtendedFloatingActionButton = findViewById(R.id.fab)

Basic

Snacking.Builder(parentView, "Hello! this is basic message")
    .build().show()

With Icon

.icon(R.drawable.ic_info, R.color.teal_200)

With Action

.action("Dismiss", R.color.teal_200) { snackBar ->
    // TODO ACTION
}

Use Margin

.useMargin(true)

Corner Radius

.cornerRadius(R.dimen.snack_bar_corner_radius)

Corner Radius (Custom)

// Top Left, Top Right, Bottom Left, Bottom Right
.cornerRadius(R.dimen.snack_bar_corner_radius, 0, 0, R.dimen.snack_bar_corner_radius)

Border

.border(R.dimen.snack_bar_border_size, R.color.teal_700)

Background Color

.backgroundColor(R.color.purple_200)

Background Image

.background(R.mipmap.img_gradient)

Text Color

.textColor("#ffca28") / R.color.colorYellow

Font

.fontFamily(R.font.montserrat)

Anchor View

.anchorView(fab)

State

Snacking.State(parentView!!, Snacking.State.INFO)
    .message("This message is using state")
    .show()

Top Position

.position(Snacking.TOP)

Message max lines

.messageMaxLines(2)

Support for landscape

.landscapeStyle(Snacking.CENTER)

Licence

Copyright 2022 Mukhammad Erif Fanani

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

Android library that made customize snack bar message easily and quickly.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors