• Stars
    star
    547
  • Rank 81,254 (Top 2 %)
  • Language
    Kotlin
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🍭 The usual Snackbar, but elegant

Light

Build Status Download

The usual Snackbar, but elegant. Inspired by Toasty.

Screenshots

success Info warning
Success Info Warning
Error Normal Custom
Error Normal Custom

Download

Gradle

Add the code below to your root build.gradle file (NOT your module build.gradle file, check here for an example).

allprojects {
    repositories {
        jcenter()
    }
}

Add the code below to your module's build.gradle file:

dependencies {
	implementation 'io.github.tonnyl:light:latest_version'
}

Maven

<dependency>
  <groupId>io.github.tonnyl</groupId>
  <artifactId>light</artifactId>
  <version>latest_version</version>
  <type>pom</type>
</dependency>

Usage

Each method always returns a Snackbar object, so you can customize the Snackbar much more. DO NOT FORGET TO CALL THE show() METHOD!

  • To display a success Snackbar:
// Kotlin
import io.github.tonnyl.light.success

success(fab, "Success", Snackbar.LENGTH_SHORT)
	.setAction("Action", {
		Toast.makeText(this@MainActivity, "Hello, Light!", Toast.LENGTH_SHORT).show()
	})
	.show()
// Java
Light.success(fab, "Success", Snackbar.LENGTH_SHORT)
	.setAction("Action", v ->
		Toast.makeText(SettingsActivity.this, "Hello, Light!", Toast.LENGTH_SHORT).show())
	.show());
  • To display an info Snackbar:
// Kotlin
import io.github.tonnyl.light.info

info(fab, "Info", Snackbar.LENGTH_SHORT).show()
// Java
Light.info(fab, "Info", Snackbar.LENGTH_SHORT).show());
  • To display a warning Snackbar:
// Kotlin
import io.github.tonnyl.light.warning

warning(fab, "Warning", Snackbar.LENGTH_SHORT).show()
// Java
Light.warning(fab, "Warning", Snackbar.LENGTH_SHORT).show());
  • To display an error Snackbar:
// Kotlin
import io.github.tonnyl.light.error

error(fab, "Error", Snackbar.LENGTH_SHORT).show()
// Java
Light.error(fab, "Error", Snackbar.LENGTH_SHORT).show());
  • To display the usual Snackbar:
// Kotlin
import io.github.tonnyl.light.normal

normal(fab, "Normal", Snackbar.LENGTH_SHORT).show()
// Java
Light.normal(fab, "Normal", Snackbar.LENGTH_SHORT).show();
  • You can also create your own Snackbar in custom-designed style:
// Kotlin
import io.github.tonnyl.light.make

make(
	fab, // // The view to find a parent from.
	"Awesome Snackbar", // The message to show.
	Snackbar.LENGTH_INDEFINITE, // How long to display the message.
	R.drawable.ic_album_white_24dp, // The left icon of message to show.
	R.color.color_cyan, // The background color of Snackbar.
	android.R.color.white, // The color of text to show.
	R.drawable.ic_done_all_white_24dp,
	R.color.colorAccent) // The left icon of action text.
	.setAction("Done all", {
		// Do whatever you want to do.
		Toast.makeText(this@MainActivity, "Hello, Light!", Toast.LENGTH_SHORT).show()
	})
	.show()
// Java
Light.make(
	fab,
	"Awesome Snackbar",
	Snackbar.LENGTH_SHORT,
	R.drawable.ic_album_white_24dp,
	R.color.color_cyan,
	android.R.color.white,
	R.drawable.ic_done_all_white_24dp,
	R.color.colorAccent)
	.setAction("Done all", v ->
		Toast.makeText(SettingsActivity.this, "Hello, Light!", Toast.LENGTH_SHORT).show())
	.show());

Extra

You can pass formatted text to Light!

Pull Request

Have some new ideas or find a bug? Do not hesitate to open an issue and make a pull request.

License

Light is under an MIT license. See the LICENSE file for more info.

More Repositories

1

Awesome_APIs

:octocat: A collection of APIs
11,690
star
2

PaperPlane

📚 PaperPlane - An Android reading app, including articles from Zhihu Daily, Guokr Handpick and Douban Moment.
Kotlin
1,140
star
3

Espresso

🚚 Espresso is an express delivery tracking app designed with Material Design style, built on MVP(Model-View-Presenter) architecture with RxJava2, Retrofit2, Realm database and ZXing
Java
1,087
star
4

Spark

🎨 An Android library to create gradient animation like Instagram&Spotify
Kotlin
671
star
5

Mango

🏀 An Android app for dribbble.com
Kotlin
655
star
6

WhatsNew

🎉 WhatsNew automatically displays a short description of the new features when users update your app
Kotlin
475
star
7

Charles

[WIP]✨ Charles is a local multi-media selector for Android
Kotlin
429
star
8

FanfouHandpick

📖 A Fanfou Handpick Client Developed by Kotlin
Kotlin
227
star
9

Zhihu_Zhuanlan_APIs

知乎专栏API分析
190
star
10

Windary

🎓 My solutions to LeetCode problems written in Go, Java, JavaScript, Kotlin, Python, Rust & Swift.
Swift
189
star
11

Translator

📘 Translator-A translation app based on Android platform
Java
67
star
12

Reader

📚 MVP + Volley + Gson, 内容包含了糗事百科,煎蛋,和内涵段子
Java
58
star
13

Latticify

[DEPRECATED]💬 An Android app for Slack.
Kotlin
42
star
14

awesome-courses-of-chinese-university

中国大学课程资料
30
star
15

GaussianBlur

Android Gaussian Blur using RenderScript
Java
26
star
16

wukong

A command-line tool for browsing GitHub trending written by Rust. [DEPRECATED]
Rust
24
star
17

Packman

A mobile application made for managing GitLab CI/CD jobs, demonstrating how to implement some latest technologies in mobile software development.
Kotlin
16
star
18

Dash

Design patterns in Kotlin and Swift.
Swift
12
star
19

Telecode

Country&Region&Telecode data in Chinese&English
11
star
20

CircleProgressBar

A circel progress bar library on Android
Java
6
star
21

WaterPal

🥛 WaterPal - Remind you to drink water at regular time.
Java
5
star
22

toolman

A collection of tools
Shell
5
star
23

Moka-Feedback

Moka is a mobile app for GitHub.
4
star
24

cathem

Dart
4
star
25

MyPythonLearnProject

My Project of Learning Python
Python
3
star
26

TDate

Calculate the date in a way that is similar to Windows system
C++
2
star
27

TonnyL

1
star
28

ActionsFlow

1
star