Skip to content

Commit

Permalink
08/04/2024.
Browse files Browse the repository at this point in the history
  • Loading branch information
youndon committed Apr 8, 2024
1 parent 279f774 commit 9c843cb
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ data class AddScreen(
}
) {
// recording dialog visibility.
if (recordDialogState.value) {
RecorderScreen(id = id, dialogState = recordDialogState)
}
// if (recordDialogState.value) {
// RecorderScreen(id = id/*, dialogState = recordDialogState*/)
// }

// reminding dialog visibility.
if (remindingDialogState.value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import cafe.adriel.voyager.navigator.LocalNavigator
import city.zouitel.note.ui.ColorsRow
import city.zouitel.note.model.Data
import city.zouitel.recoder.ui.RecorderScreen
import city.zouitel.systemDesign.CommonRow
import city.zouitel.systemDesign.Cons.FOCUS_NAVIGATION
import city.zouitel.systemDesign.Cons.KEY_CLICK
Expand Down Expand Up @@ -64,6 +66,7 @@ fun AddEditBottomBar(
) {
val context = LocalContext.current
val haptic = LocalHapticFeedback.current
val navigator = LocalNavigator.current

val showOptionsMenu = remember { mutableStateOf(false) }
val thereIsSoundEffect = remember(dataStoreVM, dataStoreVM::getSound).collectAsState()
Expand All @@ -84,7 +87,8 @@ fun AddEditBottomBar(
rememberMultiplePermissionsState(
permissions = listOf()
) {
recordDialogState.value = true
// recordDialogState.value = true
navigator?.push(RecorderScreen(note.uid))
}
}
val showRationalDialog = remember { mutableStateOf(false) }
Expand Down Expand Up @@ -156,7 +160,8 @@ fun AddEditBottomBar(
permissionState.launchMultiplePermissionRequest()
}
} else {
remindingDialogState.value = true
// remindingDialogState.value = true
navigator?.push(RecorderScreen(note.uid))
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package city.zouitel.note.ui.bottom_bar

import android.Manifest.permission
import android.annotation.SuppressLint
import android.health.connect.datatypes.Record
import android.net.Uri
import android.widget.Toast
import androidx.activity.compose.ManagedActivityResultLauncher
Expand Down Expand Up @@ -31,6 +32,7 @@ import cafe.adriel.voyager.navigator.LocalNavigator
import cafe.adriel.voyager.navigator.currentOrThrow
import city.zouitel.audios.media.AudioListViewModel
import city.zouitel.note.model.Data
import city.zouitel.recoder.ui.RecorderScreen
import city.zouitel.systemDesign.Cons.DRAW_ROUTE
import city.zouitel.systemDesign.Cons.KEY_CLICK
import city.zouitel.systemDesign.Cons.KEY_STANDARD
Expand Down Expand Up @@ -84,7 +86,8 @@ internal fun Plus(
)
) {
if (it.getValue(permission.RECORD_AUDIO)) {
recordDialogState.value = true
// recordDialogState.value = true
navigator.push(RecorderScreen(note.uid))
}
}

Expand Down Expand Up @@ -152,7 +155,8 @@ internal fun Plus(
permissionState.launchMultiplePermissionRequest()
}
} else {
recordDialogState.value = true
// recordDialogState.value = true
navigator.push(RecorderScreen(id = note.uid))
}
isShow.value = false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ data class EditScreen(
}
) {
// recording dialog visibility.
if (recordDialogState.value) {
RecorderScreen(id = id, dialogState = recordDialogState)
}
// if (recordDialogState.value) {
// RecorderScreen(id = id, dialogState = recordDialogState)
// }

// reminding dialog visibility.
if (remindingDialogState.value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import cafe.adriel.voyager.navigator.LocalNavigator
import city.zouitel.recoder.viewmodel.RecorderScreenModel
import city.zouitel.systemDesign.CommonRow
import city.zouitel.systemDesign.Icons.MIC_ICON_36
import city.zouitel.systemDesign.Icons.PAUSE_CIRCLE_FILLED_ICON_36
Expand All @@ -25,17 +27,20 @@ import city.zouitel.systemDesign.Icons.STOP_CIRCLE_ICON_36
fun RecordController(
isRecording: MutableState<Boolean>,
isPause: MutableState<Boolean>,
dialogState: MutableState<Boolean>,
mediaRecorder:MediaRecorder,
// dialogState: MutableState<Boolean>,
mediaRecorder: MediaRecorder,
recorderScreenModel: RecorderScreenModel,
seconds: String,
minutes: String,
hours: String,
onStart: () -> Unit = {},
onPause: () -> Unit = {},
onStop: () -> Unit = {},
) {
val navigator = LocalNavigator.current

Column(
Modifier,
Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Expand Down Expand Up @@ -91,9 +96,11 @@ fun RecordController(
mediaRecorder.stop()
mediaRecorder.reset()
mediaRecorder.release()
recorderScreenModel.stop()
isRecording.value = false
dialogState.value = false
// dialogState.value = false
onStop()
navigator?.pop()
},
tint = Color.Red
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import city.zouitel.systemDesign.Cons.REC_DIR
import city.zouitel.systemDesign.Cons.MP3
import java.io.File

data class RecorderScreen(val id: String, val dialogState: MutableState<Boolean>): Screen {
data class RecorderScreen(val id: String/*, val dialogState: MutableState<Boolean>*/): Screen {
@Composable
override fun Content() {
val context = LocalContext.current
Expand All @@ -33,32 +33,47 @@ data class RecorderScreen(val id: String, val dialogState: MutableState<Boolean>
record.start()
}

AlertDialog(
onDismissRequest = {
runCatching {
record.stop()
record.reset()
record.release()
recorderModel.stop()
}
dialogState.value = false
},
confirmButton = {},
text = {
RecordController(
isRecording = isRecording,
isPause = isPause,
dialogState = dialogState,
mediaRecorder = record,
seconds = recorderModel.seconds,
minutes = recorderModel.minutes,
hours = recorderModel.hours,
onStart = { recorderModel.start() },
onPause = { recorderModel.pause() },
onStop = { recorderModel.stop() }
)
}
// TODO: optimization!
RecordController(
isRecording = isRecording,
isPause = isPause,
// dialogState = dialogState,
mediaRecorder = record,
recorderScreenModel = recorderModel,
seconds = recorderModel.seconds,
minutes = recorderModel.minutes,
hours = recorderModel.hours,
onStart = { recorderModel.start() },
onPause = { recorderModel.pause() },
onStop = { recorderModel.stop() }
)

// AlertDialog(
// onDismissRequest = {
// runCatching {
// record.stop()
// record.reset()
// record.release()
// recorderModel.stop()
// }
// dialogState.value = false
// },
// confirmButton = {},
// text = {
// RecordController(
// isRecording = isRecording,
// isPause = isPause,
// dialogState = dialogState,
// mediaRecorder = record,
// seconds = recorderModel.seconds,
// minutes = recorderModel.minutes,
// hours = recorderModel.hours,
// onStart = { recorderModel.start() },
// onPause = { recorderModel.pause() },
// onStop = { recorderModel.stop() }
// )
// }
// )
}
}

0 comments on commit 9c843cb

Please sign in to comment.