Android native BottomSheet on steroids 💪
Switch branches/tags
Clone or download
Latest commit b76c0eb Oct 31, 2018

README.md

Super Bottom Sheet

Android native bottom sheet on steroids 💪

Build Status jitpack api Android Arsenal

Summary

This library allows you to show bottom sheets in your app with the bonus of animating the status bar color and the top rounded corners as you scroll.

It has been written 100% in Kotlin. ❤️

Download

This library is available in jitpack, so you need to add this repository to your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Add the dependency:

dependencies {
    implementation 'com.github.andrefrsousa:SuperBottomSheet:1.3.0'
}

Sample Project

We have a sample project in Kotlin that demonstrates the lib usage here.

Usage

It is recommended to check the sample project to get a complete understanding of all the features offered by the library.
In order to create a bottom sheet in your project you just need to extend SuperBottomSheetFragment.

Example:

class MySheetFragment : SuperBottomSheetFragment() {

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        super.onCreateView(inflater, container, savedInstanceState)
        return inflater.inflate(R.layout.fragment_demo_sheet, container, false)
    }
}

Customization

The are a group of general properties that you can define. These properties will be applied to all the SuperBottomSheet in your project.

// The amount of DIM that will be applied to the background from 0 to 1.
<attr name="superBottomSheet_dim" format="float"/>  

// Sheet background color
<attr name="superBottomSheet_backgroundColor" format="color"/>

// To corner radius to be applied. 0 if you want none.
<attr name="superBottomSheet_cornerRadius" format="dimension"/>  

// Enable or disable the status bar animation. Default is true.
<attr name="superBottomSheet_animateStatusBar" format="boolean"/>

// Enable or disable the radius animation. Default is true.
<attr name="superBottomSheet_animateCornerRadius" format="boolean"/>

// Default if false. Enalbe it if you want to skip collapse state
<attr name="superBottomSheet_alwaysExpanded" format="boolean"/>

// Default if true
<attr name="superBottomSheet_cancelableOnTouchOutside" format="boolean"/>

// Default if true
<attr name="superBottomSheet_cancelable" format="boolean"/>

// Status bar color. The default uses the colorDark attribute value.  
<attr name="superBottomSheet_statusBarColor" format="color"/>  

// The height of the bottom sheet when it is collapsed 
<attr name="superBottomSheet_peekHeight" format="dimension"/>

If you want to change the properties of a single bottom sheet you can override these methods:

fun getPeekHeight(): Int {
    // Your code goes here
}

fun getDim(): Float {
    // Your code goes here
}

fun getBackgroundColor(): Int {
   // Your code goes here
}

fun getStatusBarColor(): Int {
    // Your code goes here
}

fun getCornerRadius(): Float {
    // Your code goes here
}

fun isSheetAlwaysExpanded(): Boolean {
    // Your code goes here
}

fun isSheetCancelableOnTouchOutside(): Boolean {
    // Your code goes here
}

fun isSheetCancelable(): Boolean {
    // Your code goes here
}

fun animateCornerRadius(): Boolean {
    // Your code goes here
}

fun animateStatusBar(): Boolean {
    // Your code goes here
}

Project Maintained By

André Sousa

Design-focused Engineer | Front-end Developer | Open-Source Enthusiast | Android | Husband | Foodie

License

The MIT License (MIT)  
  
Copyright (c) 2018 André Sousa  
  
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.