Giter Site home page Giter Site logo

pratyushsingh07 / bumblecardswipe Goto Github PK

View Code? Open in Web Editor NEW
8.0 1.0 1.0 344 KB

Jetpack Compose Modifier that allows you to achieve bumble like swipe gesture

License: MIT License

Kotlin 100.00%
android bumble card-swipe jetpack-compose kotlin

bumblecardswipe's Introduction

BumbleCardSwipe

Jetpack Compose Modifier that allows you to achieve bumble like swipe gesture

Demo

WhatsApp.Video.2023-11-01.at.7.24.48.PM.mp4

How to enable swipe gesture

  • Follow the below steps to use the bumble like swipe gesture

1. Add dependency

Kotlin Scripts

  • Add the below to your app build.gradle :
  dependencies {
    .....
    implementation("com.github.PratyushSingh07:BumbleCardSwipe:1.0.0")\
  }
  • After you have done this make sure to add the below snippet to your settings.gradle:
  dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        mavenCentral()
        maven {
            setUrl("https://jitpack.io")
        }
    }
}

Groovy

  • Add the dependency to your app build.gradle:
  dependencies {
	        implementation 'com.github.PratyushSingh07:BumbleCardSwipe:Tag'
	}
  • Add below snippet in your root build.gradle at the end of repositories:
    dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

2. Usage

  • Add the Modifier.swipeableCard() into your @Composable function to enable Bumble like card gestures:
Box(
   modifier = Modifier
       .fillMaxSize()
       .swipeableCard(
           onSwipe = { direction ->
               println("The card was swiped towards $direction")
           }
       )
)
  • onSwipe is used when the card has been completely swiped off the screen
  • Modifier.swipeableCard() has another attribute besides onSwipe that allows user to enable a spring like effect in case the swipe was canceled
  • To enable it you need to use the below snippet:
 Box(
    modifier = Modifier
        .fillMaxSize()
        .swipeableCard(
            onSwipe = { direction ->
                println("The card was swiped towards $direction")
            },
            enableSpringEffect = true
        )
)
  • By default the spring effect is set to false hence you have to set it to true in case you want to use it
  • Under the hood spring effect uses spring(dampingRatio = Spring.DampingRatioMediumBouncy) to produce the spring effect

Developers

License

MIT License

Copyright (c) 2023 Pratyush Singh

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

bumblecardswipe's People

Contributors

aditya-gupta99 avatar pratyushsingh07 avatar princeraj-pr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

princeraj-pr

bumblecardswipe's Issues

Feat: Add full-screen UI

Add a full-screen UI(no status bar) bar and also, the navigation bar should be the same color as the background

Bug: Hint text not visible

In some devices, the hint text at the bottom is either not visible or only partially visible.

Screenshot_2023-12-17-15-30-32-11_6378d0b0aa0dce502ca8dfc42f89f329

Screenshot_2023-12-17-15-29-52-85_6378d0b0aa0dce502ca8dfc42f89f329

Device info for not visible:
Phone: Realme 6
Android version: 11

Device info for partially visible:
Phone: Realme X
Android version: 11

Multiple cards arent visible

If I have a deck of cards then I want them to overlapped on top of one another . Now after I swipe the 1st card the 2nd card should be visible and then the 3rd card and so on. But currently after I swipe the 1st card I dont see this expected behaviour

WhatsApp.Video.2023-10-28.at.3.26.43.PM.mp4

Add buttons to swipe left and right

Currently you have to drag the card to swipe it to either left or right direction. I would want this to happen in the case of buttons as well.
What i exactly want is to have 2 buttons . One of them will be to swipe the card left and the other one will be to swipe it to right.

Feat: Undo Card Swipe

Once the card has been completely swiped off the screen the user should be given the option to undo the swipe

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.