Skip to content

Commit

Permalink
Merge pull request #149 from dokar3/wavy-slider
Browse files Browse the repository at this point in the history
Use wavy slider
  • Loading branch information
dokar3 authored Jul 9, 2024
2 parents 36c735d + 466dbb3 commit 841dd95
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ retrofit = "2.11.0"
sqldelight = "2.0.2"
coil = "2.6.0"
diskLruCache = "2.0.2"
wavySlider = "2.0.0-alpha"

[libraries]
core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "core-ktx" }
Expand Down Expand Up @@ -68,6 +69,8 @@ sqldelight-driver = { group = "app.cash.sqldelight", name = "android-driver", ve
coil = { group = "io.coil-kt", name = "coil-compose", version.ref = "coil" }
diskLruCache = { group = "com.jakewharton", name = "disklrucache", version.ref = "diskLruCache" }

wavySlider = { group = "ir.mahozad.multiplatform", name = "wavy-slider", version.ref = "wavySlider" }

[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
Expand Down
1 change: 1 addition & 0 deletions ui/home/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ dependencies {
implementation(libs.androidx.lifecycle.viewmodel.ktx)
implementation(libs.androidx.lifecycle.viewmodel.compose)
implementation(libs.sheets)
implementation(libs.wavySlider)

testImplementation(libs.junit)
androidTestImplementation(libs.androidx.test.ext.junit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Slider
import androidx.compose.material3.SliderDefaults
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand All @@ -17,7 +16,11 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import ir.mahozad.multiplatform.wavyslider.WaveDirection
import ir.mahozad.multiplatform.wavyslider.material3.WaveVelocity
import ir.mahozad.multiplatform.wavyslider.material3.WavySlider
import kotlinx.coroutines.delay
import kotlin.system.measureTimeMillis

Expand Down Expand Up @@ -83,14 +86,19 @@ internal fun PlayerProgressBar(
Text(maxTime, fontSize = 14.sp)
}

Slider(
WavySlider(
value = currProgress,
onValueChange = { onSeek((it * duration).toLong()) },
modifier = Modifier.fillMaxWidth(),
colors = SliderDefaults.colors(
thumbColor = MaterialTheme.colorScheme.primary,
activeTrackColor = MaterialTheme.colorScheme.secondary,
)
),
waveVelocity = if (isPlaying) {
SliderDefaults.WaveVelocity
} else {
0.dp to WaveDirection.HEAD
},
)
}
}

0 comments on commit 841dd95

Please sign in to comment.