Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use wavy slider #149

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
},
)
}
}