Giter Site home page Giter Site logo

bottomlistsheet's Introduction

๐Ÿ—ณ BottomListSheet

API Download

A quick and easy way to implement a selectable list (single/multiple) via Bottom Sheet Dialog Fragment.

Instalation

Add it via gradle

    dependencies {
        // ...
        implementation 'com.kishannareshpal:bottomlistsheet:<version>'
        // ...
    }

Using it

    /* 
        List of items you want to show
        The items should be:
            - Item(text: String, iconRes: Int? = null) 
    */
    val dataList = listOf<Item>(
        Item("Maputo", R.drawable.maputo),
        Item("Inhambane", R.drawable.inhambane),
        Item("Beira", R.drawable.beira),
        Item("Nampula", R.drawable.nampula)
    ) 


    BottomListSheet()
        .title("Filter")
        .subtitle("By specific cities")
        .items(dataList)
        .onItemSelected { position ->
            Log.d(TAG, "You have clicked item at position: $position -> ${data[position]}")
        }
        .onConfirm { button, selectedItems ->
            Log.d(TAG, "You have selected ${selectedItems.size} items!")
        }
        .preselectItems(listOf(1, 2));
        .show(supportFragmentManager) // or if in a fragment, use activity?.supportfragmentManager

        
        // .dismiss() // use to dismiss the sheet at any time
        
        // Available properties:
        .isMultipleSelection // to get or set multiple selection mode
        .selectedItemsPositions // to get the list of selected items positions

Available Methods

Method Default value Description
Title title null Set the title
Subtitle subtitle null Set the subtitle
Selectable items items [] An array list of items Item(string, int)
Show as dark mode isNightMode false Use this option to show the bottom sheet as dark mode
On item clicked onItemSelected null The block of code to run whenever a single item in the list is tapped. Providing you with the position
On confirm button clicked onConfirm null The block of code to run when the confirm button is tapped. Providing you with the selectedItemsList
On close button clicked onClose null The block of code to run when the close button is tapped.
Preselected items preselectedItems null The list of the items position, which you want to be selected by default when the sheet is set to multiple selection.
Clear all selected items clearAllSelection n/a Use to clear all selected items when the sheet is set to be multiple selected.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

Copyright 2020 Kishan Jadav

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.

bottomlistsheet's People

Contributors

kishannareshpal avatar

Stargazers

TEST avatar

Watchers

James Cloos avatar  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.