11package com.bitchat.android.ui.media
22
33import android.media.MediaPlayer
4- import androidx.compose.foundation.border
5- import androidx.compose.foundation.isSystemInDarkTheme
4+ import androidx.compose.foundation.background
5+ import androidx.compose.foundation.clickable
66import androidx.compose.foundation.layout.*
7- import androidx.compose.foundation.shape.RoundedCornerShape
7+ import androidx.compose.foundation.shape.CircleShape
88import androidx.compose.material.icons.Icons
99import androidx.compose.material.icons.filled.Pause
1010import androidx.compose.material.icons.filled.PlayArrow
1111import androidx.compose.material3.FilledTonalIconButton
1212import androidx.compose.material3.Icon
13- import androidx.compose.material3.IconButtonDefaults
1413import androidx.compose.material3.MaterialTheme
1514import androidx.compose.material3.Text
1615import androidx.compose.runtime.*
@@ -34,8 +33,6 @@ fun VoiceNotePlayer(
3433 var durationMs by remember { mutableStateOf(0 ) }
3534 val player = remember { MediaPlayer () }
3635
37- val borderOpacity = if (isSystemInDarkTheme()) 0.3f else 0.2f
38-
3936 // Seek function - position is a fraction from 0.0 to 1.0
4037 val seekTo: (Float ) -> Unit = { position ->
4138 if (isPrepared && durationMs > 0 ) {
@@ -89,34 +86,20 @@ fun VoiceNotePlayer(
8986 DisposableEffect (Unit ) { onDispose { try { player.release() } catch (_: Exception ) {} } }
9087
9188 Row (
92- modifier = Modifier .fillMaxWidth()
93- .border(
94- color = MaterialTheme .colorScheme.primary.copy(alpha = borderOpacity),
95- width = 1.0 .dp,
96- shape = RoundedCornerShape (14 .dp)
97- )
98- .padding(12 .dp),
89+ modifier = Modifier .fillMaxWidth(),
9990 verticalAlignment = Alignment .CenterVertically ,
100- horizontalArrangement = Arrangement .spacedBy(8 .dp),
91+ horizontalArrangement = Arrangement .spacedBy(8 .dp)
10192 ) {
10293 // Disable play/pause while showing send progress override (optional UX choice)
10394 val controlsEnabled = isPrepared && ! isError && progressOverride == null
104- FilledTonalIconButton (
105- onClick = { if (controlsEnabled) isPlaying = ! isPlaying },
106- enabled = controlsEnabled,
107- modifier = Modifier .size(28 .dp),
108- colors = IconButtonDefaults .filledTonalIconButtonColors(
109- containerColor = MaterialTheme .colorScheme.primary,
110- contentColor = MaterialTheme .colorScheme.onPrimary
111- ),
112- ) {
95+ FilledTonalIconButton (onClick = { if (controlsEnabled) isPlaying = ! isPlaying }, enabled = controlsEnabled, modifier = Modifier .size(28 .dp)) {
11396 Icon (
11497 imageVector = if (isPlaying) Icons .Filled .Pause else Icons .Filled .PlayArrow ,
11598 contentDescription = if (isPlaying) " Pause" else " Play"
11699 )
117100 }
118-
119- WaveformPreview (
101+ val progressBarColor = progressColor ? : MaterialTheme .colorScheme.primary
102+ com.bitchat.android.ui.media. WaveformPreview (
120103 modifier = Modifier
121104 .height(24 .dp)
122105 .weight(1f )
@@ -127,12 +110,7 @@ fun VoiceNotePlayer(
127110 onSeek = seekTo
128111 )
129112 val durText = if (durationMs > 0 ) String .format(" %02d:%02d" , (durationMs / 1000 ) / 60 , (durationMs / 1000 ) % 60 ) else " --:--"
130- Text (
131- color = MaterialTheme .colorScheme.tertiary,
132- text = durText,
133- fontFamily = FontFamily .Monospace ,
134- fontSize = 12 .sp,
135- )
113+ Text (text = durText, fontFamily = FontFamily .Monospace , fontSize = 12 .sp)
136114 }
137115}
138116
0 commit comments