Site icon Android Tutorial Online

Animated wavy slider component as a light library for jetpack compose

Animated wavy slider component as a light library for jetpack compose

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

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 = WaveAnimationOptions(
        reverseDirection = false,
        flatlineOnDrag = true,
        animateWave = true,
        reverseFlatline = false
    ),
    thumb = { DiamondThumb() },
    colors = WaveSliderDefaults.colors(
        thumbColor = MaterialTheme.colorScheme.secondary,
        activeTrackColor = MaterialTheme.colorScheme.secondary,
        inactiveTrackColor = MaterialTheme.colorScheme.secondaryContainer
    ),
    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.

GitHub

View Github

Exit mobile version