Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Semper-Viventem/Material-backdrop
A simple solution for implementing Backdrop pattern for Android
https://github.com/Semper-Viventem/Material-backdrop
android android-app android-design android-design-pattern android-library android-sdk androidx backdrop bintray design-patterns foreground jetpack kotlin-library library material material-backdrop material-components material-design patterns ui-components
Last synced: about 2 months ago
JSON representation
A simple solution for implementing Backdrop pattern for Android
- Host: GitHub
- URL: https://github.com/Semper-Viventem/Material-backdrop
- Owner: Semper-Viventem
- License: mit
- Created: 2018-07-19T18:07:39.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-12-20T09:35:48.000Z (about 5 years ago)
- Last Synced: 2024-08-02T00:23:39.935Z (5 months ago)
- Topics: android, android-app, android-design, android-design-pattern, android-library, android-sdk, androidx, backdrop, bintray, design-patterns, foreground, jetpack, kotlin-library, library, material, material-backdrop, material-components, material-design, patterns, ui-components
- Language: Kotlin
- Homepage:
- Size: 3.32 MB
- Stars: 219
- Watchers: 5
- Forks: 20
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-material-design - Material-backdrop) - Implemented new material component Backdrop for android (Android / Components)
README
# Backdrop
[ ![Download](https://api.bintray.com/packages/semper-viventem/maven/backdrop/images/download.svg) ](https://bintray.com/semper-viventem/maven/backdrop/_latestVersion)[![](https://jitpack.io/v/Semper-Viventem/BackdropView.svg)](https://jitpack.io/#Semper-Viventem/BackdropView)
## What is it?
This library makes it easy to implement a [Backdrop](https://material.io/design/components/backdrop.html) pattern with a CoordinatorLayout
## Download
**JCenter (Recommended):**
```groovy
dependencies {
implementation 'ru.semper-viventem.backdrop:backdrop:0.1.7'
}
```**JitPack:**
```groovy
repositories {
...
maven { url 'https://jitpack.io' }
}dependencies {
implementation 'com.github.Semper-Viventem:BackdropView:0.1.7'
}
```## How to use it?
You need to add front layout and back layout (with toolbar) to CoordinatorLayout.Add BackdropBehavior to your front layout:
**XML**
```xml
```
**Kotlin**
*I used this extension to search for behavior:*
```kotlin
fun > View.findBehavior(): T = layoutParams.run {
if (this !is CoordinatorLayout.LayoutParams) throw IllegalArgumentException("View's layout params should be CoordinatorLayout.LayoutParams")(layoutParams as CoordinatorLayout.LayoutParams).behavior as? T
?: throw IllegalArgumentException("Layout's behavior is not current behavior")
}
``````kotlin
...val backdropBehavior: BackdropBehavior = foregroundContainer.findBehavior() // find behavior
with(backdropBehavior) {
// Attach your back layout to behavior.
// BackDropBehavior will find the toolbar itself.
attachBackLayout(R.id.backLayout)
// Set navigation icons for toolbar
setClosedIcon(R.drawable.ic_menu)
setOpenedIcon(R.drawable.ic_close)
// Add listener
addOnDropListener(object : BackdropBehavior.OnDropListener {
override fun onDrop(dropState: BackdropBehavior.DropState, fromUser: Boolean) {
// TODO: handle listener
}
})
}...
```## License
```
MIT License
Copyright (c) 2018 Konstantin Kulikov ([email protected])
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```