Install Wavy Slider
mainTo use Wavy Slider in a standard project, add the following dependency to your build.gradle.kts file:
implementation("ir.mahozad.multiplatform:wavy-slider:2.2.0")repository·main·Indexed 42 days ago
https://github.com/mahozad/wavy-sliderA Compose Multiplatform library providing animated, wavy Material-style sliders and progress bars similar to Android 13 media controls. Supports Material 2 and Material 3 variants (WavySlider2 and WavySlider3) for Android, iOS, Desktop, and Web. Version 2.2.0 allows customization of wave length, height, velocity, and thickness.
To use Wavy Slider in a standard project, add the following dependency to your build.gradle.kts file:
implementation("ir.mahozad.multiplatform:wavy-slider:2.2.0")Use the apng2gif command-line tool to convert animated PNG (APNG) files into animated GIF format. The tool uses the Wu quantizer for true-color files to maintain quality.
Basic Syntax:
apng2gif <input_anim.png> [<output_anim.gif>] [options]
apng2gif anim.png [anim.gif] [-t tlevel] [-b bcolor]To disable the initial expansion/appearance animation when the component is composed, use the Compose snap() animation spec within the animationSpecs parameter. Ensure you import the correct SliderDefaults object for your Material version (M2 or M3).
animationSpecs = SliderDefaults.WaveAnimationSpecs.copy(waveAppearanceAnimationSpec = snap())Depending on your target platforms, you can add the library to your common source set or to specific targets.
If you target a subset of the library's supported platforms (Android, iOS, Desktop, Web), add it to your commonMain dependencies:
kotlin {
sourceSets {
commonMain.dependencies {
implementation("ir.mahozad.multiplatform:wavy-slider:2.2.0")
}
}
}If you have targets that are not supported by the library, add the dependency separately to each supported target:
kotlin {
val desktopMain /* OR jvmMain */ by getting {
dependencies {
implementation("ir.mahozad.multiplatform:wavy-slider:2.2.0")
}
}
androidMain.dependencies {
implementation("ir.mahozad.multiplatform:wavy-slider:2.2.0")
}
}kotlin {
sourceSets {
commonMain.dependencies {
implementation("ir.mahozad.multiplatform:wavy-slider:2.2.0")
// ...
}The WavySlider works similarly to the standard Material Slider. You can use either the Material 3 version (WavySlider3) or the Material 2 version (WavySlider2) by adjusting your imports.
value: The current slider value.onValueChange: Callback when the value changes.waveLength: The length of the wave. Setting this to 0.dp results in a regular flat Slider.waveHeight: The height of the wave. Setting this to 0.dp results in a regular flat Slider.waveVelocity: A Pair<Dp, WaveDirection> representing speed per second and direction (HEAD or TAIL).waveThickness: Thickness of the wave (defaults to 4.dp).trackThickness: Thickness of the track (defaults to a value based on the Material variant).incremental: Whether to gradually increase waveHeight.animationSpecs: Customize various animations of the wave using WaveAnimationSpecs.import ir.mahozad.multiplatform.wavyslider.material3.WavySlider as WavySlider3
import ir.mahozad.multiplatform.wavyslider.material.WavySlider as WavySlider2
import ir.mahozad.multiplatform.wavyslider.WaveDirection.*
@Composable
fun MyComposable() {
var fraction by remember { mutableStateOf(0.5f) }
WavySlider3( // OR WavySlider2. See the imports above that use "as ..."
value = fraction,
onValueChange = { fraction = it },
waveLength = 16.dp, // Setting this to 0.dp results in a Slider
waveHeight = 16.dp, // Setting this to 0.dp results in a Slider
waveVelocity = 15.dp to HEAD, // Speed per second and its direction
waveThickness = 4.dp, // Defaults to 4.dp irregardless of variant
trackThickness = 4.dp, // Defaults to a thickness based on variant
incremental = false, // Whether to gradually increase waveHeight
// animationSpecs = ... // Customize various animations of the wave
// Other options that are available in standard Material 2/3 Slider
)
}To create a wavy divider that is fixed and non-animated, pass a custom track to the WavySlider and set waveVelocity to 0.dp. You should also use snap() for the animation specs to prevent any movement.
WavySlider3(
value = 1f,
onValueChange = {},
thumb = {},
track = {
SliderDefaults.Track(
sliderState = it,
enabled = false,
colors = SliderDefaults.colors(disabledActiveTrackColor = Color.Magenta),
thumbTrackGapSize = 0.dp,
waveThickness = 1.dp,
waveVelocity = 0.dp to HEAD,
animationSpecs = WaveAnimationSpecs(
waveAppearanceAnimationSpec = snap(),
waveVelocityAnimationSpec = snap(),
waveHeightAnimationSpec = snap()
)
)
}
)You can control how transparency is handled during conversion using the -t and -b flags. Note that if you specify a background color with -b, the transparency threshold -t is ignored.
-t)Sets the alpha level threshold. Pixels with an alpha value less than this threshold will become fully transparent.
-t 128-b)Sets a solid background color that partially transparent pixels will be composed over. This effectively replaces transparency with a color.
255 0 0) or Hex strings (e.g., "#ff0000").-b 255 0 0 or -b "#ff0000"apng2gif anim.png [anim.gif] [-t tlevel] [-b bcolor]
Options:
-t 128
-b 255 0 0
-b "#ff0000"