mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-18 23:05:26 +02:00
fix: Fix sheets coming and leaving
This commit is contained in:
parent
39895bcd40
commit
101f8d46e9
@ -24,6 +24,7 @@ import androidx.compose.runtime.Composable
|
|||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.runtime.saveable.rememberSaveable
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
@ -41,6 +42,7 @@ import app.myzel394.alibi.ui.components.atoms.MessageBox
|
|||||||
import app.myzel394.alibi.ui.components.atoms.MessageType
|
import app.myzel394.alibi.ui.components.atoms.MessageType
|
||||||
import app.myzel394.alibi.ui.models.AudioRecorderModel
|
import app.myzel394.alibi.ui.models.AudioRecorderModel
|
||||||
import app.myzel394.alibi.ui.utils.MicrophoneInfo
|
import app.myzel394.alibi.ui.utils.MicrophoneInfo
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
@ -73,11 +75,17 @@ fun MicrophoneSelection(
|
|||||||
visibleMicrophones
|
visibleMicrophones
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val scope = rememberCoroutineScope()
|
||||||
|
fun hideSheet() {
|
||||||
|
scope.launch {
|
||||||
|
sheetState.hide()
|
||||||
|
showSelection = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (showSelection) {
|
if (showSelection) {
|
||||||
ModalBottomSheet(
|
ModalBottomSheet(
|
||||||
onDismissRequest = {
|
onDismissRequest = ::hideSheet,
|
||||||
showSelection = false
|
|
||||||
},
|
|
||||||
sheetState = sheetState,
|
sheetState = sheetState,
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
@ -114,7 +122,7 @@ fun MicrophoneSelection(
|
|||||||
selectedAsFallback = isTryingToReconnect,
|
selectedAsFallback = isTryingToReconnect,
|
||||||
onSelect = {
|
onSelect = {
|
||||||
audioRecorder.changeMicrophone(null)
|
audioRecorder.changeMicrophone(null)
|
||||||
showSelection = false
|
hideSheet()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -128,7 +136,7 @@ fun MicrophoneSelection(
|
|||||||
disabled = isTryingToReconnect && microphone == audioRecorder.selectedMicrophone,
|
disabled = isTryingToReconnect && microphone == audioRecorder.selectedMicrophone,
|
||||||
onSelect = {
|
onSelect = {
|
||||||
audioRecorder.changeMicrophone(microphone)
|
audioRecorder.changeMicrophone(microphone)
|
||||||
showSelection = false
|
hideSheet()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -165,7 +173,7 @@ fun MicrophoneSelection(
|
|||||||
selected = audioRecorder.selectedMicrophone == microphone,
|
selected = audioRecorder.selectedMicrophone == microphone,
|
||||||
onSelect = {
|
onSelect = {
|
||||||
audioRecorder.changeMicrophone(microphone)
|
audioRecorder.changeMicrophone(microphone)
|
||||||
showSelection = false
|
hideSheet()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -181,7 +189,10 @@ fun MicrophoneSelection(
|
|||||||
if (shownMicrophones.isNotEmpty() || (settings.audioRecorderSettings.showAllMicrophones && hiddenMicrophones.isNotEmpty())) {
|
if (shownMicrophones.isNotEmpty() || (settings.audioRecorderSettings.showAllMicrophones && hiddenMicrophones.isNotEmpty())) {
|
||||||
Button(
|
Button(
|
||||||
onClick = {
|
onClick = {
|
||||||
showSelection = true
|
scope.launch {
|
||||||
|
showSelection = true
|
||||||
|
sheetState.show()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
colors = ButtonDefaults.textButtonColors(),
|
colors = ButtonDefaults.textButtonColors(),
|
||||||
) {
|
) {
|
||||||
|
@ -34,7 +34,6 @@ import kotlinx.coroutines.launch
|
|||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun QuickMaxDurationSelector(
|
fun QuickMaxDurationSelector(
|
||||||
settings: AppSettings,
|
|
||||||
onDismiss: () -> Unit,
|
onDismiss: () -> Unit,
|
||||||
) {
|
) {
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
|
@ -156,7 +156,6 @@ fun StartRecording(
|
|||||||
|
|
||||||
if (showQuickMaxDurationSelector) {
|
if (showQuickMaxDurationSelector) {
|
||||||
QuickMaxDurationSelector(
|
QuickMaxDurationSelector(
|
||||||
settings = appSettings,
|
|
||||||
onDismiss = {
|
onDismiss = {
|
||||||
showQuickMaxDurationSelector = false
|
showQuickMaxDurationSelector = false
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user