Giter Club home page Giter Club logo

bottomsheetdialog-compose's Introduction

Jetpack Compose BottomSheetDialog library that allows you to use BottomsheetDialog like Dialog's interface.

Also, it supports to set navigation bar color when BottomSheetDialog has shown.

API As Seen In - jetc.dev Newsletter Issue #123

Preview

Get Started

Gradle

Compose Library
Compose 1.3.x Maven Central
Compose 1.4.x Maven Central
Compose 1.5.x Maven Central
Compose 1.6.x Maven Central
Compose 1.7.x Maven Central
// module's build.gradle
dependencies {
    implementation "com.holix.android:bottomsheetdialog-compose:{version}"
}

Usage

You can use BottomSheetDialog composable like Dialog composable! It is super simple ๐Ÿ˜Ž

@Composable
fun YourComposable() {
    var show by remember {
        mutableStateOf(false)
    }
    if (show) {
        BottomSheetDialog(
            onDismissRequest = {
                show = false
            },
            properties = BottomSheetDialogProperties(
                ...
            )
        ) {
            // content
            Surface {
                ...
            }
        }
    }
}

BottomSheetDialogProperties

name default value type
dismissOnBackPress true Boolean
dismissOnClickOutside true Boolean
dismissWithAnimation false Boolean
enableEdgeToEdge false Boolean
navigationBarProperties NavigationBarProperties() NavigationBarProperties
behaviorProperties BottomSheetBehaviorProperties() BottomSheetBehaviorProperties

NavigationBarProperties

inspired by accompanist's SystemUiController

name default value type
color Color.Unspecified Color
darkIcons color.luminance() > 0.5f Boolean
navigationBarContrastEnforced true Boolean
transformColorForLightContent { original -> Color(0f, 0f, 0f, 0.3f).compositeOver(original) } (Color) -> Color

BottomSheetBehaviorProperties

BottomSheetBehavior official docs

name default value type
state State.Collapsed State
maxWidth Size.NotSet Size
maxHeight Size.NotSet Size
isDraggable true Boolean
expandedOffset 0 Integer
halfExpandedRatio 0.5F Float
isHideable true Boolean
peekHeight PeekHeight.Auto PeekHeight
isFitToContents true Boolean
skipCollapsed false Boolean
isGestureInsetBottomIgnored false Boolean

Additional Information

License

Designed and developed by 2022 holixfactory

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.

bottomsheetdialog-compose's People

Contributors

pbk20191 avatar workspace avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

bottomsheetdialog-compose's Issues

BottomSheetDialog์˜ content์— ์Šคํฌ๋กค ์—†๋Š” Column์„ ์‚ฌ์šฉํ•˜๋ฉด ๋“œ๋ž˜๊ทธ๊ฐ€ ์•ˆ๋˜๋Š” ๋ฌธ์ œ.

BottomSheetDialog`์˜ content์— ์Šคํฌ๋กค ์—†๋Š” Column์„ ์‚ฌ์šฉํ•˜๋ฉด ๋“œ๋ž˜๊ทธ๊ฐ€ ์•ˆ๋˜๋Š” ๋ฌธ์ œ๊ฐ€ ์žˆ๋Š” ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

Modifier.verticalScroll(scrollState)๋ฅผ ์ถ”๊ฐ€ํ•˜๋ฉด ์ •์ƒ์ ์œผ๋กœ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค.

์ด๊ฒŒ ๋ฒ„๊ทธ์ธ์ง€ ์˜๋„ํ•˜์‹  ๋ถ€๋ถ„์ธ์ง€ ๋ชจ๋ฅด๊ฒ ์–ด์„œ ์ด์Šˆ๋กœ ๋‚จ๊น๋‹ˆ๋‹ค.

    BottomSheetDialog() {
        Column(
            modifier = Modifier
                .fillMaxWidth()
                .background(Color.White)
                .verticalScroll(scrollState)  // ์ด ๋ถ€๋ถ„์„ ์ถ”๊ฐ€ํ•˜๋ฉด ์ •์ƒ์ ์œผ๋กœ ๋“œ๋ž˜๊ทธ ๋จ.
        ) {
             // children..
       }
    }
2023-01-03.6.00.03.mov

Display Scroll Issue

I want to make the content a scroll view with isDraggable set to false.

Column(
modifier = modifier
.clip(RoundedCornerShape(topStart = 20.dp, topEnd = 20.dp))
.background(color = "#ffffff".color)
.padding(start = 24.dp, top = 30.dp, end = 24.dp, bottom = 24.dp)
.verticalScroll(rememberScrollState())
)

Even if you configure it in that format, it will not scroll.

Is there a way to do this without specifying maxheight?

v1.2.0 ์ดํ›„ ํ‚ค๋ณด๋“œ ๊ด€๋ จ ์ด์Šˆ.

v1.2.0 ์ดํ›„๋กœ ํ‚ค๋ณด๋“œ ๋™์ž‘์ด ์ด์ƒํ•ด์ง„ ๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค.

BottomSheetDialog ๋‚ด๋ถ€์— TextField๊ฐ€ ์žˆ์œผ๋ฉด ํ‚ค๋ณด๋“œ๊ฐ€ ๋‚˜ํƒ€๋‚˜์ง€ ์•Š๊ณ ,
ํŒ์—…์ด ๋‹ซํžˆ๋ฉด ๊ทธ๋•Œ์„œ์•ผ ํ‚ค๋ณด๋“œ๊ฐ€ ์˜ฌ๋ผ์˜ต๋‹ˆ๋‹ค.

์•„๋ž˜ ์˜์ƒ์€ ์ƒ˜ํ”Œ ์ฝ”๋“œ์—์„œ TextField๋งŒ ์ถ”๊ฐ€ํ•ด์„œ ํ…Œ์ŠคํŠธํ–ˆ์Šต๋‹ˆ๋‹ค.

untitled.webm

Crash on Android 5 and 6 (API 22, 23)

First of all, thanks for the library! I'm trying to solve the same problem and this library looks like exactly what I need.

The problem is that the library doesn't work in Android with API levels 22 and 23. The app from your repository crashes on Android with these API versions.

Here is the stack trace:

Process: su.ati.common.sample, PID: 23247
android.util.AndroidRuntimeException: requestFeature() must be called before adding content
	at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:302)
	at com.holix.android.bottomsheetdialog.compose.BottomSheetDialogWrapper.<init>(BottomSheetDialog.kt:391)
	at com.holix.android.bottomsheetdialog.compose.BottomSheetDialogKt.BottomSheetDialog(BottomSheetDialog.kt:274)
	at su.ati.common.sample.compose.components.BottomSheetDialogDemoFragment.ScreenUi(BottomSheetDialogDemoFragment.kt:62)
	at su.ati.common.sample.compose.components.BottomSheetDialogDemoFragment.access$ScreenUi(BottomSheetDialogDemoFragment.kt:32)
	at su.ati.common.sample.compose.components.BottomSheetDialogDemoFragment$ScreenUi$2.invoke(BottomSheetDialogDemoFragment.kt)
	at su.ati.common.sample.compose.components.BottomSheetDialogDemoFragment$ScreenUi$2.invoke(BottomSheetDialogDemoFragment.kt)
	at androidx.compose.runtime.RecomposeScopeImpl.compose(RecomposeScopeImpl.kt:145)
	at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2375)
	at androidx.compose.runtime.ComposerImpl.skipCurrentGroup(Composer.kt:2643)
	at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3260)
	at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3238)
	at androidx.compose.runtime.SnapshotStateKt__DerivedStateKt.observeDerivedStateRecalculations(DerivedState.kt:341)
	at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations(Unknown Source)
	at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3238)
	at androidx.compose.runtime.ComposerImpl.recompose$runtime_release(Composer.kt:3203)
	at androidx.compose.runtime.CompositionImpl.recompose(Composition.kt:771)
	at androidx.compose.runtime.Recomposer.performRecompose(Recomposer.kt:1031)
	at androidx.compose.runtime.Recomposer.access$performRecompose(Recomposer.kt:125)
	at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:534)
	at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:503)
	at androidx.compose.ui.platform.AndroidUiFrameClock$withFrameNanos$2$callback$1.doFrame(AndroidUiFrameClock.android.kt:34)
	at androidx.compose.ui.platform.AndroidUiDispatcher.performFrameDispatch(AndroidUiDispatcher.android.kt:109)
	at androidx.compose.ui.platform.AndroidUiDispatcher.access$performFrameDispatch(AndroidUiDispatcher.android.kt:41)
	at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.doFrame(AndroidUiDispatcher.android.kt:69)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:765)
	at android.view.Choreographer.doCallbacks(Choreographer.java:580)
	at android.view.Choreographer.doFrame(Choreographer.java:549)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
	at android.os.Handler.handleCallback(Handler.java:739)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:135)
	at android.app.ActivityThread.main(ActivityThread.java:5254)
	at java.lang.reflect.Method.invoke(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:372)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

๋ฒ„ํŠผ ํด๋ฆญ์‹œ bottomDialog ํ˜ธ์ถœํ•˜๋Š”๋ฐ ์—๋Ÿฌ ๊ด€๋ จ ์ด์Šˆ

bottomDialog๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด ํ•ด๋‹น ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ syncํ•˜์—ฌ ์‚ฌ์šฉ์ค‘์— ์žˆ์Šต๋‹ˆ๋‹ค.

TodoList๋ฅผ ๋งŒ๋“œ๋Š” ์ค‘์ธ๋ฐ, LazyColumn์˜ Item์„ ํด๋ฆญ์‹œ ํ•ด๋‹น BottomDialog ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์Šคํฌ๋ฆฐ์— ๋„์šธ๋ ค๊ณ  ํ•˜๋Š”๋ฐ ํด๋ฆญํ•˜๋ฉด ์•ฑ์ด ํŠ•๊ธฐ๋ฉฐ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.

compose๋ฅผ 1.3.2 ๋ฒ„์ „์„ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์–ด์„œ, README์— ์„ค๋ช…๋๋“ฏ์ด 1.1.1 ๋ฒ„์ „์œผ๋กœ ์‚ฌ์šฉ์ค‘์ธ๋ฐ๋„ ํ•ด๊ฒฐ์ด ์•ˆ๋ผ์„œ ์งˆ๋ฌธํ•ฉ๋‹ˆ๋‹ค ใ… ใ… 

์—๋Ÿฌ
image
image

gradle

buildscript {
    ext {
//        compose_version = '1.1.0-beta01'
        compose_version = '1.3.2'
    }
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.3.1' apply false
    id 'com.android.library' version '7.3.1' apply false
    id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}

android {
    compileSdk 33

    defaultConfig {
        applicationId "com.example.todo_android"
        minSdk 21
        targetSdk 33
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion compose_version
    }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation 'androidx.compose.material3:material3:1.1.0-alpha04'
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
    implementation 'androidx.activity:activity-compose:1.3.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.4'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
    debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
    debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"

    // Custom BottomSheet
    implementation "com.holix.android:bottomsheetdialog-compose:1.1.1"
}

Support edge to edge

consider this :
`
BottomSheetDialog(
edgeToEdge
){
Box(modifier = Modifier.navigationBarPadding()) {
content()
}

}
`

Compose Version 1.4

ํ˜น์‹œ compose 1.4์—์„œ๋„ ๊ธฐ๋Šฅ ์ž‘๋™์ด ์ž˜ ๋˜๋‚˜์š”??
ํ…Œ์ŠคํŠธํ•ด๋ดค์„๋•Œ crash๊ฐ€ ๋ฐœ์ƒํ•˜๋Š” ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

onDismissRequest is called twice when bottom sheet is dismissed by swiping down

Hi, I really like you library and I'm trying to integrate it with my own Compose Navigation lib. I've noticed that swiping down causes the current BottomSheetDialog to call onDismissRequest twice, which breaks some logic for me. In all other cases this callback is always called once.

Could you maybe fix this issue and make it be called only once on swipe down? The current behaviour is very much unexpected and error-prone.

Part of bottomSheet hiding behind keyboard

Hi, There was a ๏ฟฝissue while using library.
If there is an input in the bottomSheet and the keyboard is raised due to focus on the input, the button fixed at the bottom is hidden behind the keyboard.

The activity is set to adjustResize . I checked to see if there is a way to solve this, but I'm not sure. If this function is not supported, could you add a function to raise the area of โ€‹โ€‹the bottomSheet as much as the keyboard area? Thank you.

Navigation area display issues

On the Galaxy Z Flip, it's displayed on the navigation area
In the Galaxy S23 Ultra, it is displayed from the navigation area.
Is there a reason?

I use 1.2.2 SDK version

Darker dim behind the sheet

Hi there.
Awesome library, a needed one in Compose especially with Compose material3.
I want to use this BottomSheetDialog with some padding around it(looks like an AlertDialog) but there is some weird dark shadow behind the sheet.
Is there any way to eliminate these darker dims?
Screenshot_1667809965

Screenshot_1667811183

Add expand property to BottomSheet library

hello. I'm using your library very well.
While using the library, I found that there is no expand function.
So, when I want a bottomSheet that covers the entire screen, I have to open the bottomSheet twice by swiping.

Can you fix this by adding a property for expand? If this property is added, the usability of the library will be better.
(By the way, your library is really cool)

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.