Giter Site home page Giter Site logo

light's Introduction

Light

Build Status

The usual Snackbar, but elegant. Inspired by Toasty.

Screenshots

Success Info Warning
Error Normal Custom

Download

Gradle

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

allprojects {
    repositories {
        jcenter()
    }
}

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

dependencies {
	// Other dependencies here.
	compile 'io.github.tonnyl:light:1.0.0'
}

Maven

<dependency>
  <groupId>io.github.tonnyl</groupId>
  <artifactId>light</artifactId>
  <version>1.0.0</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:
Light.success(fab, "Success", Light.LENGTH_SHORT)
        .setAction("Action", new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // Do anything you want to do
                Toast.makeText(MainActivity.this, "Hello, Light!", Toast.LENGTH_SHORT).show();
            }
        })
        .show();

// or call

Light.make(fab, "Success", Light.TYPE_SUCCESS, Light.LENGTH_SHORT).show();
  • To display an info Snackbar:
Light.info(fab, "Info", Light.LENGTH_SHORT).show();

// or call
Light.make(fab, "Info", Light.TYPE_INFO, Light.LENGTH_SHORT).show();
  • To display a warning Snackbar:
Light.warning(fab, "Warning", Light.LENGTH_SHORT).show();

// or call
Light.make(fab, "Warning", Light.TYPE_WARNING, Light.LENGTH_SHORT).show();
  • To display an error Snackbar:
Light.error(fab, "Error", Light.LENGTH_SHORT).show();

// or call
Light.make(fab, "Error", Light.TYPE_ERROR, Light.LENGTH_SHORT).show();
  • To display the usual Snackbar:
Light.normal(fab, "Normal", Light.LENGTH_SHORT).show();

// or call
Light.make(fab, "Normal", Light.TYPE_NORMAL, Light.LENGTH_SHORT).show();
  • You can also create your own Snackbar in custom-designed style:
Light.make(
        fab, // The view to find a parent from.
        "Awesome Snackbar", // The text to show.
        R.drawable.ic_album_white_24dp, // The left icon of text to show.
        R.color.color_cyan, // The background color of Snackbar.
        android.R.color.white, // The color of text to show.
        Light.LENGTH_INDEFINITE, // How long to display the message.
        R.drawable.ic_done_all_white_24dp, // The left icon of action text.
        R.color.colorAccent) // The color of action text.
        .setAction("Done all", new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // Do whatever you want to do.
                Toast.makeText(MainActivity.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

Copyright 2017 lizhaotailang

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.

light's People

Contributors

tonnyl avatar

Watchers

Alp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.