Skip to content

Commit

Permalink
Refactor to handle onPause, onResume requests and the icon visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
zwarm committed Jun 17, 2024
1 parent 408bb1a commit 5d56725
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ import androidx.compose.material.ContentAlpha
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
Expand All @@ -37,9 +35,9 @@ import org.wordpress.android.ui.compose.theme.AppTheme
@OptIn(ExperimentalAnimationApi::class)
@Suppress("DEPRECATION")
@Composable
fun MicToStopIcon(model: RecordingPanelUIModel) {
fun MicToStopIcon(model: RecordingPanelUIModel, isRecording: Boolean) {
val isEnabled = model.isEnabled
var isMic by remember { mutableStateOf(true) }
val isMic by rememberUpdatedState(newValue = !isRecording)
val isLight = !isSystemInDarkTheme()

val circleColor by animateColorAsState(
Expand Down Expand Up @@ -73,11 +71,9 @@ fun MicToStopIcon(model: RecordingPanelUIModel) {
} else {
model.onStopTap?.invoke()
}
// isMic = !isMic
} else {
model.onRequestPermission?.invoke()
}
isMic = !isMic
}
)
) {
Expand Down Expand Up @@ -128,7 +124,8 @@ fun ExistingLayoutPreview() {
hasPermission = true,
onRequestPermission = {},
actionLabel = R.string.voice_to_content_base_header_label, isEnabled = false
)
),
isRecording = true
)
}
}

0 comments on commit 5d56725

Please sign in to comment.