Suhuf is an android library that is used to build bottom sheets in an elegant way.

Overview

Suhuf

Suhuf is an android library that is used to build bottom sheets in an elegant way.

Download

Add it in your root gradle build.gradle at the end of repositories

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

And add this to your application gradle build.gradle

dependencies {
    implementation "com.github.rahmatrasyidi.suhuf:ui:$latestVersion"
}

If you want to get Jetpack Compose support add this to your application gradle build.gradle

dependencies {
    implementation "com.github.rahmatrasyidi:suhuf:$latestVersion"
}

Usage

For full examples, you can refer to the samples app.

You can override basic sheet behaviour like identifier, peekHeight, isCancellable, isDraggable.

class SampleSheet : Suhuf(R.layout.sheet_sample) {
    override val identifier: String get() = IDENTIFIER // set identifier to be pass to SheetResult
    override val isCancellable: Boolean get() = true 
    override val isDraggable: Boolean get() = true
    override val peekHeight: PeekHeight get() = PeekHeight.HEIGHT_FULL // set height of sheet
}

For the PeekHeight it is only allowed to set HEIGHT_FULL, HEIGHT_65 & HEIGHT_AUTO. You can override Suhuf theme like this:

override fun getTheme(): Int = R.style.BottomSheetDialogTheme

You can show and put arguments like this:

    val bundle = Bundle().apply {
      putString(SampleSheet.KEY_MESSAGE, "Message from arguments!")
    }
    val sheet = SampleSheet().apply {
       arguments = bundle
    }
    sheet.show(this)     

and get Suhuf arguments like this:

class SampleSheet : Suhuf(R.layout.sheet_sample) {
  override fun extractArguments(bundle: Bundle?) {
    super.extractArguments(bundle)
    val message = bundle?.getString(KEY_MESSAGE).orEmpty()
    showToast(message)
  }
}

Suhuf only allowed to call inside Activity or Fragment.

Passing Result

You can pass Suhuf result back to Fragment or Activity like this:

class SampleSheet : Suhuf(R.layout.sheet_sample) {

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    super.onViewCreated(view, savedInstanceState)
    val btnPositive = view.findViewById<Button>(R.id.btnPositive)
    btnPositive.setPositiveButtonClicked()

    val btnNegative = view.findViewById<Button>(R.id.btnNegative)
    val bundle = Bundle().apply {
      putString(KEY_MESSAGE, "Message from bundle!")
    }
    btnNegative.setNegativeButtonClicked(bundle)
  }
}

or just call dismissAndSendResult from your view listener.

Receive Result

For the result you need to implement SheetResult like this:

{ result.data?.getString(SampleSheet.KEY_MESSAGE).orEmpty() } else -> "Result cancel from $identifier" } showToast(message) } } ">
class SampleActivity : AppCompatActivity(), SheetActions {
...

override fun onSheetResult(identifier: String, result: SheetResult) {
        if (identifier == SampleSheet.IDENTIFIER) {
            val message = when {
                result.isResultPositive() -> "Result positive from $identifier"
                result.isResultNegative() -> {
                    result.data?.getString(SampleSheet.KEY_MESSAGE).orEmpty()
                }
                else -> "Result cancel from $identifier"
            }
            showToast(message)
        }
    }

Jetpack Compose

class SampleComposeSheet : SuhufCompose() {

    override val identifier: String get() = IDENTIFIER
    override val isCancellable: Boolean get() = true
    override val isDraggable: Boolean get() = true
    override val peekHeight: PeekHeight get() = PeekHeight.HEIGHT_FULL

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        setContent {
            Row(
                modifier = Modifier.fillMaxWidth(),
                horizontalArrangement = Arrangement.Center
            ) {
                BasicText(
                    text = "Hello world",
                    modifier = Modifier.padding(vertical = Dp(24f)),
                    style = TextStyle(color = Color.Blue, fontSize = 36.sp)
                )
            }
        }
    }
}

License

Copyright (c) 2021 Rahmat Rasyidi.

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.
You might also like...
An Android library that allows you to easily create applications with slide-in menus. You may use it in your Android apps provided that you cite this project and include the license in your app. Thanks!

SlidingMenu (Play Store Demo) SlidingMenu is an Open Source Android library that allows developers to easily create applications with sliding menus li

Android-NewPopupMenu 3.9 0.0 Java  is an android library to create popup menu with GoogleMusic app-like style.
Android-NewPopupMenu 3.9 0.0 Java is an android library to create popup menu with GoogleMusic app-like style.

Android-NewPopupMenu Android-NewPopupMenu is an android library to create popup menu with GoogleMusic app-like style. Requirements Tested with APIv4 H

BottomSheet-Android - A simple customizable BottomSheet Library for Android Kotlin

BottomSheet-Android A simple customizable BottomSheet Library for Android Kotlin

Android library that provides the floating action button to sheet transition from Google's Material Design.
Android library that provides the floating action button to sheet transition from Google's Material Design.

MaterialSheetFab Library that implements the floating action button to sheet transition from Google's Material Design documentation. It can be used wi

Simple library which enable you to add a drawer(slide-out) navigation to your android application
Simple library which enable you to add a drawer(slide-out) navigation to your android application

SimpleSideDrawer is an android library to add a drawer navigation into your android application. This library has high affinity with other libraries l

Android Library for a DrawerLayout similar to the one in Google Apps
Android Library for a DrawerLayout similar to the one in Google Apps

GoogleNavigationDrawerMenu This project aims to let you use a ListView menu similar to the one in the new Google Apps (Keep, Play Music...) without ha

An Android Library that allows users to pull down a menu and select different actions. It can be implemented inside ScrollView, GridView, ListView.
An Android Library that allows users to pull down a menu and select different actions. It can be implemented inside ScrollView, GridView, ListView.

AndroidPullMenu AndroidPullMenu is an Open Source Android library that allows developers to easily create applications with pull menu. The aim of this

An Android library for managing multiple stacks of fragments
An Android library for managing multiple stacks of fragments

FragNav Android library for managing multiple stacks of fragments (e.g., Bottom Navigation , Navigation Drawer). This library does NOT include the UI

A floating menu library for Android.
A floating menu library for Android.

Hover Hover is a floating menu implementation for Android. Goals The goals of Hover are to: Provide an easy-to-use, out-of-the-box floating menu imple

Releases(v1.0.0)
Owner
Rahmat Rasyidi Hakim
I am passionate about mobile app development.
Rahmat Rasyidi Hakim
Bottom Navigation widget component inspired by the Google Material Design Guidelines at https://www.google.com/design/spec/components/bottom-navigation.html

Material Bottom Navigation Library Lightweight Bottom Navigation library component inspired by the Google Material Design Guidelines at https://www.go

Alessandro Crugnola 1.4k Dec 18, 2022
Spotify like android material bottom navigation bar library.

SuperBottomBar About Spotify like android material bottom navigation bar library. GIF Design Credits All design and inspiration credits belongs to Spo

Ertugrul 73 Dec 10, 2022
🚀 A very customizable library that allows you to present menu items (from menu resource and/or other sources) to users as a bottom sheet.

SlidingUpMenu A library that allows you to present menu items (from menu resource and/or other sources) to users as a bottom sheet. Gradle Dependency

Rasheed Sulayman 26 Jul 17, 2022
Spinner with bottom sheet dialog for Android

This is a small library for spinner view with displaying options in bottom sheet dialog. This view doesn't improve or extend the default android Spinner. The library doesn't support any other types of showing menu, only bottom sheet dialog.

Oleg Nestyuk 23 Oct 19, 2022
You can create awesome menus with bottom sheet experience in a few lines

You can create awesome menus with bottom sheet experience in a few lines

Mazen Rashed 19 Nov 1, 2022
Bottom Sheet fragment with a sticky header and a content recycler view

Sticky Header Bottom Sheet A simple library to create a Bottom Sheet with a sticky header and a content recycler view. The bottom sheet expands on scr

Kshitij Kumar 12 Sep 21, 2022
Neat library, that provides a simple way to implement guillotine-styled animation

Guillotine animation Neat library, that provides a simple way to implement guillotine-styled animation Check this [project on Dribbble] (https://dribb

Yalantis 2.7k Jan 3, 2023
A new way to implement navigation in your app 🏎

ExpandableBottomBar A new way to improve navigation in your app Its really easy integrate to your project take it, faster, faster Important: library w

Alexander Dadukin 692 Dec 29, 2022
:fire: The powerful and easiest way to implement modern material popup menu.

PowerMenu ?? The powerful and easiest way to implement modern material popup menu. PowerMenu can be fully customized and used for popup dialogs. Downl

Jaewoong Eum 1k Dec 29, 2022