Site icon Android Tutorial Online

Android Compose Expandable/Foldable Box Library

Android Compose Expandable/Foldable Box Library

GroovinCollapsingToolBar

 This library offers a Box Composable that can be expanded/reduced through up/down swipe gestures.

MusicPlayer SampleArticle Page Sample

Including in your project

Gradle

Add below codes to settings.gradle.

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        maven { url "https://jitpack.io" }
    }
}

for old gradle version, Add below codes to your project‘s build.gradle.

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

And add a dependency code to your module‘s build.gradle file.

dependencies {
    implementation 'com.github.gaiuszzang:GroovinExpandableBox:x.x.x'
}

Usage

ExpandableBox

ExpandableBox is Expandable Layout based on Box through up/down swipe gestures.

ExpandableBox(
    modifier = modifier,
    swipeableState = rememberSwipeableState(initialValue = ExpandableBoxState.FOLD),
    isDownDirection = true,
    isHideable = false,
    foldHeight = 200.dp
) {
    Content(...)   //Contents Composable
}

There are 4 arguments to be aware of use.

SwipeableState

ExpandableBox needs SwipeableState<ExpandableBoxState> instance for store and use its status.

val swipeableState = rememberSwipeableState(initialValue = ExpandableBoxState.FOLD)

One of the values below must be set as the initial value.

ExpandableBoxScope

ExpandableBoxScope provides a scope with attributes for the content of ExpandableBox.

also, ExpandableBoxScope inheriting BoxScope, it can be used the same as BoxScope.

License

Copyright 2023 gaiuszzang (Mincheol Shin)

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.

GitHub

View Github

Exit mobile version