Coder Social home page Coder Social logo

galaxygoldfish / waveslider Goto Github PK

View Code? Open in Web Editor NEW
95.0 3.0 9.0 22.17 MB

๐ŸŒŠ Animated wavy slider component for jetpack compose

License: Apache License 2.0

Kotlin 100.00%
android compose kotlin material-3 slider android-library material-you

waveslider's Introduction


๐ŸŒŠ Animated wavy slider component as a light library for jetpack compose, similar to the slider present in the Android 13 media player notification

  • Customizable
  • Lightweight
  • Easy to use

Implementation

  1. Make sure you have JitPack added as a repository in your root-level build.gradle file
allprojects {
    repositories {
        ..
        maven { url 'https://jitpack.io' }
    }
}
  1. Add the dependency in your :app level build.gradle
dependencies {
      ..
      implementation 'com.github.galaxygoldfish:waveslider:VERSION'
 }

Demo

View the full documentation here, and download the latest demo app here

var sliderValue by remember { mutableStateOf(0.4F) }

WaveSlider(
    value = sliderValue,
    onValueChange = { sliderValue = it },
    animationOptions = WaveSliderDefaults.animationOptions(
        reverseDirection = false,
        flatlineOnDrag = true,
        animateWave = true,
        reverseFlatline = false
    ),
    thumb = { DiamondThumb() },
    colors = WaveSliderDefaults.colors(
        thumbColor = MaterialTheme.colorScheme.secondary,
        activeTrackColor = MaterialTheme.colorScheme.secondary
    ),
    amplitude = 15F,
    frequency = 0.07F,
    modifier = Modifier.padding(
        horizontal = 20.dp, 
        vertical = 50.dp
    )
)



License

Copyright 2023 Sebastian Hriscu

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.

waveslider's People

Contributors

galaxygoldfish avatar t8rin 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

Watchers

 avatar  avatar  avatar

waveslider's Issues

ValueRange

Is it possible to add value range parameter to the slider? I've tried, but this causes buggy beahavior, wave fully brokes after that(

Bug with frequency

I've tested some frequency values, and every value except predefined 0.07 caused laggy animation, it starts running and then breaks and starts again, In other words infinity running effect became broken :(

Crash

Screenshot_20230601-200121_Image Resizer.png

I have no idea, why this happens, maybe that's because i use newer compose version...

Stepped slider

Is it possible to add steps like this?

ResizedImage_Screenshot_20230531-160806_Image Resizer_2023-05-31_16-08-29_3289.png

Maybe only when the slider is flattened, or make them invisible, while animation is running

`FATAL EXCEPTION: main` in Compose Version `1.6.8`

Description

I'm working on a Music Streaming App and this library has been incredibly helpful. However, an update to a transitive dependency upgraded my Compose version from 1.5.1 to the latest 1.6.8 (as of July 23, 2024). It appears that Google has made some Slider components private in this version. Can you help me find a workaround for this issue? The proposed fix in #7 doesn't seem to work.

My Implementation

WaveSlider(
    modifier = Modifier.height(12.dp),
    value = seekPosition,   // state hoisted in a ViewModel
    onValueChange = { value ->
        onSeekPlayBack(value)
    },
    waveOptions = WaveSliderDefaults.waveOptions(
        amplitude = 12F,
        frequency = 0.07F
    ),
    thumb = { PillThumb() },
    animationOptions = WaveSliderDefaults.animationOptions(
        reverseDirection = false,
        flatlineOnDrag = true,
        animateWave = animateWave,
        reverseFlatline = false
    ),
    colors = WaveSliderDefaults.colors(
        inactiveTrackColor = MaterialTheme.colorScheme.inverseOnSurface
    )
)

Error

FATAL EXCEPTION: main
Process: com.android.swingmusic, PID: 10067
java.lang.NoSuchMethodError: No static method
Slider(FLkotlin/jvm/functions/Function1;Landroidx/compose/ui/Modifier;ZLkotlin/ranges/ClosedFloatingPointRange;Lkotlin/jvm/functions/Function0;Landroidx/compose/material3/SliderColors;Landroidx/compose/foundation/interaction/MutableInteractionSource;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;ILandroidx/compose/runtime/Composer;III)V
in class Landroidx/compose/material3/SliderKt; or its super classes (declaration of
'androidx.compose.material3.SliderKt' appears in
/data/app/~~hsIXHYVNljfimgOBwNYmUw==/com.android.swingmusic-CvbzKCHUiz6oiMzGcnFxbQ==/base.apk!classes23.dex)
at com.galaxygoldfish.waveslider.WaveSliderKt.WaveSlider(WaveSlider.kt:110)

Height of waves

Is it possible to add parameter, which will represent the height of the waves, while animation running?

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.