Skip to content

Commit 2cc2a55

Browse files
authored
TimelineEditor.kt
1 parent 47da132 commit 2cc2a55

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed
Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1-
package com.subpilot.ui
1+
package com.geekneuron.subpilot.ui
22

3-
@Composable fun TimelineEditor(...) { ... }
3+
import androidx.compose.foundation.layout.*
4+
import androidx.compose.material3.*
5+
import androidx.compose.runtime.Composable
6+
import androidx.compose.runtime.MutableState
7+
import androidx.compose.ui.Modifier
8+
import androidx.compose.ui.unit.dp
9+
10+
@Composable
11+
fun TimelineEditor(
12+
label: String,
13+
timeMs: MutableState<Long>,
14+
onTimeChanged: (Long) -> Unit
15+
) {
16+
Column(modifier = Modifier.padding(8.dp)) {
17+
Text(text = label, style = MaterialTheme.typography.labelMedium)
18+
Slider(
19+
value = timeMs.value.toFloat(),
20+
onValueChange = { onTimeChanged(it.toLong()) },
21+
valueRange = 0f..600000f, // 0 to 10 minutes
22+
modifier = Modifier.fillMaxWidth()
23+
)
24+
Text(text = formatTime(timeMs.value), style = MaterialTheme.typography.bodySmall)
25+
}
26+
}
27+
28+
private fun formatTime(ms: Long): String {
29+
val totalSec = ms / 1000
30+
val min = totalSec / 60
31+
val sec = totalSec % 60
32+
return String.format("%02d:%02d", min, sec)
33+
}

0 commit comments

Comments
 (0)