Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/skydoves/DoubleLift

🦋 Expands and collapses a layout horizontally and vertically sequentially.
https://github.com/skydoves/DoubleLift

android android-library android-ui collapse doublelift expand expandable kotlin skydoves

Last synced: about 2 months ago
JSON representation

🦋 Expands and collapses a layout horizontally and vertically sequentially.

Awesome Lists containing this project

README

        

# DoubleLift


License
API
Build Status
Build Status
Javadoc


🦋 Expands and collapses a layout horizontally and vertically sequentially.

Inspired by "Viewing Labels" from the Trello.




## Including in your project
[![Maven Central](https://img.shields.io/maven-central/v/com.github.skydoves/doublelift.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.github.skydoves%22%20AND%20a:%22doublelift%22)
[![Jitpack](https://jitpack.io/v/skydoves/DoubleLift.svg)](https://jitpack.io/#skydoves/DoubleLift)
### Gradle
Add below codes to your **root** `build.gradle` file (not your module build.gradle file).
```gradle
allprojects {
repositories {
mavenCentral()
}
}
```
And add a dependency code to your **module**'s `build.gradle` file.
```gradle
dependencies {
implementation "com.github.skydoves:doublelift:1.0.4"
}
```

## Usage
Add following XML namespace inside your XML layout file.

```gradle
xmlns:app="http://schemas.android.com/apk/res-auto"
```

### DoubleLiftLayout
Here is a basic example of implementing `DoubleLiftLayout`.

```gradle



// something complicated views or layouts

```

### Create using builder class
We can create an instance of `DoubleLiftLayout` using the `DoubleLiftLayout.Builder` class.
#### Java
```java
DoubleLiftLayout doubleLiftLayout = new DoubleLiftLayout.Builder(context)
.setFoldedWidth(200)
.setFoldedHeight(100)
.setCornerRadius(6)
.setLiftHorizontalDuration(400)
.setLiftVerticalDuration(200)
.setOnExpandListener(new OnExpandListener() {
@Override public void onExpand(boolean isExpanded) {
toast("expanded: " + isExpanded);
}
}).build();
```

#### Kotlin
```kotlin
val myDoubleLiftLayout = DoubleLiftLayout.Builder(context)
.setFoldedWidth(200)
.setFoldedHeight(100)
.setCornerRadius(6)
.setLiftHorizontalDuration(400)
.setLiftVerticalDuration(200)
.setOnExpandListener { toast("expanded: $it") }
.build()
```
Or we can create using the kotlin-dsl.
```kotlin
val myDoubleLiftLayout = doubleLiftLayout(this) {
setFoldedWidth(200)
setFoldedHeight(100)
setCornerRadius(6)
setLiftHorizontalDuration(400)
setLiftVerticalDuration(200)
setOnExpandListener { toast("expanded: $it") }
}
```

### Expand and Collapse
We can expand and collapse using the below methods.
```kotlin
doubleLiftLayout.expand(); // expand the width and height size sequentially.
doubleLiftLayout.collapse(); // collapse the width and height size sequentially.
```

or we can do something after expanded using lambda in Kotlin.

```kotlin
doubleLiftLayout.expand { toast("expanded!") }
doubleLiftLayout.collapse { toast("collapsed!") }
```

### OnExpandListener
We can listen to the `DoubleLiftLayout` is expanded or collapsed.
#### Java
```java
.setOnExpandListener(new OnExpandListener() {
@Override public void onExpand(boolean isExpanded) {
toast("expanded: " + isExpanded);
}
}
```
#### Kotlin
```kotlin
doubleLiftLayout.onExpandListener = object : OnExpandListener {
override fun onExpand(isExpanded: Boolean) {
toast("Expanded : $it")
}
}

// or we can listen using a lambda expression.
doubleLiftLayout.setOnExpandListener {
if (it) {
toast("expanded")
} else {
toast("collapse")
}
}
```

### LiftAnimation
We can customize the expanding and collapsing animation.

```kotlin
LiftAnimation.NORMAL
LiftAnimation.ACCELERATE
LiftAnimation.BOUNCE
```

NORMAL | ACCELERATE | BOUNCE
| :---------------: | :---------------: | :---------------: |
| | |

## DoubleLiftLayout Attributes
Attributes | Type | Default | Description
--- | --- | --- | ---
foldedWidth | Dimension | 0 | sets the width size when collapsed.
foldedHeight | Dimension | 0 | ets the height size when collapsed.
horizontalDuration | Long | 500L | sets the duration of horizontal lifting.
verticalDuration | Long | 300L | sets the duration of vertical lifting.
cornerRadius | Dimension | 4dp | sets the corner radius.
autoExpand | Boolean | false | invkoe expand() method initially or not.
startOrientation | LiftStartOrientation | LiftStartOrientation.HORIZONTAL | sets the starting orientation of the lifting.
animation | LiftAnimation | LiftAnimation.NORMAL | sets the lifting animation when expanding and collapsing

## Find this library useful? :heart:
Support it by joining __[stargazers](https://github.com/skydoves/DoubleLift/stargazers)__ for this repository. :star:

And __[follow](https://github.com/skydoves)__ me for my next creations! 🤩

# License
```xml
Copyright 2019 skydoves (Jaewoong Eum)

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.
```