Coder Social home page Coder Social logo

groovinexpandablebox's Introduction

GroovinExpandableBox

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

MusicPlayer Sample Article Page Sample Map Sample
MusicPlayerSample ArticlePageSample MapSample

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,
    expandableBoxState = rememberExpandableBoxState(initialValue = ExpandableBoxStateValue.Fold),
    swipeDirection = ExpandableBoxSwipeDirection.SwipeUpToExpand,
    foldHeight = 100.dp,
    halfExpandHeight = 300.dp,
    nestedScrollEnabled = true
) {
    Content(...)   //Contents Composable
}

There are 6 arguments to be aware of use.

  • expandableBoxState : ExpandableBox needs ExpandableBoxState for store and use its status. See the section below for details.
  • swipeDirection : You can set the Swipe direction for expanding this. default = SwipeUpToExpand
  • foldHeight : Define the Minimized Height. Mandatory
  • halfExpandHeight : Define the Half Expanded Height If you want to use Half Expanded State. If not defined, half expanded state is not used. Optional
  • expandHeight : Define the Fully Expanded Height. The default is Dp.Unspecified, which sets it to the parent's maximum height. Optional
  • nestedScrollEnabled : You can enable nested scrolling to allowing seamless swipe gesture with scrollable composable like Column or LazyColumn. default = true

ExpandableBoxState

ExpandableBox needs ExpandableBoxState instance for store and use its status.

val expandableBoxState = rememberExpandableBoxState(initialValue = ExpandableBoxStateValue.Fold)

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

  • ExpandableBoxStateValue.Fold : Begin with Minimized state.
  • ExpandableBoxStateValue.HalfExpand : Begin with Half Expanded state. Note that halfExpandHeight parameter in ExpandableBox should be defined to specific value for use this.
  • ExpandableBoxStateValue.Expand : Begin with Fully Expanded state.

ExpandableBoxState exposes following parameters.

  • completedValue : Indicates that latest completion State : Fold, HalfExpand, Expand
  • progressValue : Indicates that current Progress State : Fold, Folding, HalfExpanding, Expanding, Expand
  • offset : Indicates that current height pixel. Note that Folding, HalfExpand State is only available when only Half Expand state is used.

ExpandableBoxScope

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

  • progress: Float : Progress value(0 ~ 1f) between Fold to Expand(in use Half Expand state case, Fold to HalfExpand, or HalfExpand to Expand).
  • completedState: ExpandableBoxStateValue : It is same with ExpandableBoxState.completedValue
  • progressState: ExpandableBoxStateValue : It is same with ExpandableBoxState.progressValue

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.

groovinexpandablebox's People

Contributors

gaiuszzang avatar

Stargazers

 avatar  avatar  avatar

Watchers

 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.