{"id":13428837,"url":"https://github.com/TonnyL/Light","last_synced_at":"2025-03-16T02:30:28.309Z","repository":{"id":37270299,"uuid":"90392225","full_name":"TonnyL/Light","owner":"TonnyL","description":"🍭 The usual Snackbar, but elegant","archived":false,"fork":false,"pushed_at":"2018-07-14T03:15:23.000Z","size":471,"stargazers_count":548,"open_issues_count":6,"forks_count":33,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-14T22:06:06.116Z","etag":null,"topics":["android","kotlin","kotlin-android","kotlin-library","material-components","material-design","snackbar","ui-components"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TonnyL.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-05T15:47:01.000Z","updated_at":"2024-11-04T06:01:18.000Z","dependencies_parsed_at":"2022-09-04T16:01:54.706Z","dependency_job_id":null,"html_url":"https://github.com/TonnyL/Light","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TonnyL%2FLight","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TonnyL%2FLight/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TonnyL%2FLight/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TonnyL%2FLight/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TonnyL","download_url":"https://codeload.github.com/TonnyL/Light/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243652705,"owners_count":20325610,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","kotlin","kotlin-android","kotlin-library","material-components","material-design","snackbar","ui-components"],"created_at":"2024-07-31T01:01:06.380Z","updated_at":"2025-03-16T02:30:27.982Z","avatar_url":"https://github.com/TonnyL.png","language":"Kotlin","funding_links":[],"categories":["Libraries","开源库","Snackbar","Kotlin"],"sub_categories":["UI"],"readme":"# Light\n[![Build Status](https://travis-ci.org/TonnyL/Light.svg?branch=master)](https://travis-ci.org/TonnyL/Light)\n[ ![Download](https://api.bintray.com/packages/tonnyl/maven/light/images/download.svg) ](https://bintray.com/tonnyl/maven/light/_latestVersion)\n\n\u003cdiv align=\"center\"\u003e\n\t\u003cimg src=\"./images/ic_launcher.png\" width=\"128\"\u003e\n\u003c/div\u003e\n\nThe usual Snackbar, but elegant. Inspired by [Toasty](https://github.com/GrenderG/Toasty).\n\n## Screenshots\n\n|     success     |      Info       |     warning     |\n| :-------------: | :-------------: | :-------------: |\n| ![Success](./images/success.png)  | ![Info](./images/info.png)       | ![Warning](./images/warning.png) |\n\n|      Error      |     Normal      |      Custom     |\n| :-------------: | :-------------: | :-------------: |\n| ![Error](./images/error.png)      | ![Normal](./images/normal.png)   | ![Custom](./images/custom.png)   |\n\n## Download\n\n### Gradle\n\nAdd the code below to your **root** `build.gradle` file (`NOT` your module `build.gradle` file, check [here](./build.gradle) for an example).\n\n```gradle\nallprojects {\n    repositories {\n        jcenter()\n    }\n}\n```\n\nAdd the code below to your **module**'s `build.gradle` file:\n\n```gradle\ndependencies {\n\timplementation 'io.github.tonnyl:light:latest_version'\n}\n```\n\n### Maven\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eio.github.tonnyl\u003c/groupId\u003e\n  \u003cartifactId\u003elight\u003c/artifactId\u003e\n  \u003cversion\u003elatest_version\u003c/version\u003e\n  \u003ctype\u003epom\u003c/type\u003e\n\u003c/dependency\u003e\n```\n\n## Usage\n\nEach method always returns a `Snackbar` object, so you can customize the Snackbar much more. **DO NOT FORGET TO CALL THE `show()` METHOD!**\n\n+ To display a success Snackbar:\n\n```Kotlin\n// Kotlin\nimport io.github.tonnyl.light.success\n\nsuccess(fab, \"Success\", Snackbar.LENGTH_SHORT)\n\t.setAction(\"Action\", {\n\t\tToast.makeText(this@MainActivity, \"Hello, Light!\", Toast.LENGTH_SHORT).show()\n\t})\n\t.show()\n```\n\n```Java\n// Java\nLight.success(fab, \"Success\", Snackbar.LENGTH_SHORT)\n\t.setAction(\"Action\", v -\u003e\n\t\tToast.makeText(SettingsActivity.this, \"Hello, Light!\", Toast.LENGTH_SHORT).show())\n\t.show());\n```\n\n+ To display an info Snackbar:\n\n```Kotlin\n// Kotlin\nimport io.github.tonnyl.light.info\n\ninfo(fab, \"Info\", Snackbar.LENGTH_SHORT).show()\n```\n\n```Java\n// Java\nLight.info(fab, \"Info\", Snackbar.LENGTH_SHORT).show());\n```\n\n+ To display a warning Snackbar:\n\n```Kotlin\n// Kotlin\nimport io.github.tonnyl.light.warning\n\nwarning(fab, \"Warning\", Snackbar.LENGTH_SHORT).show()\n```\n\n```Java\n// Java\nLight.warning(fab, \"Warning\", Snackbar.LENGTH_SHORT).show());\n```\n\n+ To display an error Snackbar:\n\n```Kotlin\n// Kotlin\nimport io.github.tonnyl.light.error\n\nerror(fab, \"Error\", Snackbar.LENGTH_SHORT).show()\n```\n\n```Java\n// Java\nLight.error(fab, \"Error\", Snackbar.LENGTH_SHORT).show());\n```\n\n+ To display the usual Snackbar:\n\n```Kotlin\n// Kotlin\nimport io.github.tonnyl.light.normal\n\nnormal(fab, \"Normal\", Snackbar.LENGTH_SHORT).show()\n```\n\n```Java\n// Java\nLight.normal(fab, \"Normal\", Snackbar.LENGTH_SHORT).show();\n```\n\n+ You can also create your own Snackbar in custom-designed style:\n\n```Kotlin\n// Kotlin\nimport io.github.tonnyl.light.make\n\nmake(\n\tfab, // // The view to find a parent from.\n\t\"Awesome Snackbar\", // The message to show.\n\tSnackbar.LENGTH_INDEFINITE, // How long to display the message.\n\tR.drawable.ic_album_white_24dp, // The left icon of message to show.\n\tR.color.color_cyan, // The background color of Snackbar.\n\tandroid.R.color.white, // The color of text to show.\n\tR.drawable.ic_done_all_white_24dp,\n\tR.color.colorAccent) // The left icon of action text.\n\t.setAction(\"Done all\", {\n\t\t// Do whatever you want to do.\n\t\tToast.makeText(this@MainActivity, \"Hello, Light!\", Toast.LENGTH_SHORT).show()\n\t})\n\t.show()\n```\n\n```Java\n// Java\nLight.make(\n\tfab,\n\t\"Awesome Snackbar\",\n\tSnackbar.LENGTH_SHORT,\n\tR.drawable.ic_album_white_24dp,\n\tR.color.color_cyan,\n\tandroid.R.color.white,\n\tR.drawable.ic_done_all_white_24dp,\n\tR.color.colorAccent)\n\t.setAction(\"Done all\", v -\u003e\n\t\tToast.makeText(SettingsActivity.this, \"Hello, Light!\", Toast.LENGTH_SHORT).show())\n\t.show());\n```\n\n## Extra\n\n[You can pass formatted text to Light!](./app/src/main/java/io/github/tonnyl/sample/MainActivity.kt#L70-L79)\n\n## Pull Request\n\nHave some new ideas or find a bug? Do not hesitate to open an `issue` and make a `pull request`.\n\n## License\n\n**Light** is under an **MIT** license. See the [LICENSE](LICENSE) file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTonnyL%2FLight","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTonnyL%2FLight","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTonnyL%2FLight/lists"}