Close others menu before loading new song
This commit is contained in:
parent
dd0e4a5e53
commit
0b0f0e48a6
2 changed files with 35 additions and 17 deletions
|
|
@ -52,14 +52,12 @@ fun MainScreenWithDrawer(
|
||||||
val currentActivePath = Solfa.currentFile
|
val currentActivePath = Solfa.currentFile
|
||||||
var textInput = sharedScreenModel.searchTitle.collectAsState().value
|
var textInput = sharedScreenModel.searchTitle.collectAsState().value
|
||||||
|
|
||||||
var isSearchActive by remember { mutableStateOf(false) }
|
val isSearchActive by sharedScreenModel.showSearchMenu.collectAsState()
|
||||||
val focusRequester = remember { FocusRequester() }
|
val focusRequester = remember { FocusRequester() }
|
||||||
|
|
||||||
var isExpanded by remember { mutableStateOf(false) }
|
val isExpanded by sharedScreenModel.expandedFAB.collectAsState()
|
||||||
|
val showMidiCtrl by sharedScreenModel.showMidiCtrl.collectAsState()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var isPlayMid by remember { mutableStateOf(false) }
|
|
||||||
val isPlay by sharedScreenModel.isPlay.collectAsState()
|
val isPlay by sharedScreenModel.isPlay.collectAsState()
|
||||||
val isPos by sharedScreenModel.isPos.collectAsState()
|
val isPos by sharedScreenModel.isPos.collectAsState()
|
||||||
var isDragging = sharedScreenModel.isDragging
|
var isDragging = sharedScreenModel.isDragging
|
||||||
|
|
@ -153,14 +151,14 @@ LaunchedEffect(isPlay, isPos) {
|
||||||
verticalArrangement = Arrangement.spacedBy(7.dp)
|
verticalArrangement = Arrangement.spacedBy(7.dp)
|
||||||
) {
|
) {
|
||||||
AnimatedVisibility(
|
AnimatedVisibility(
|
||||||
visible = isExpanded and !isPlayMid,
|
visible = isExpanded and !showMidiCtrl,
|
||||||
enter = fadeIn() + scaleIn() + slideInVertically { it / 2 },
|
enter = fadeIn() + scaleIn() + slideInVertically { it / 2 },
|
||||||
exit = fadeOut() + scaleOut() + slideOutVertically { it / 2 }
|
exit = fadeOut() + scaleOut() + slideOutVertically { it / 2 }
|
||||||
) {
|
) {
|
||||||
FloatingActionButton(
|
FloatingActionButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
sharedScreenModel.toggleQRCodeVisibility()
|
sharedScreenModel.toggleQRCodeVisibility()
|
||||||
isExpanded = false
|
sharedScreenModel.setExpandedFAB(false)
|
||||||
}, modifier = Modifier.alpha(0.45f)
|
}, modifier = Modifier.alpha(0.45f)
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
|
|
@ -173,7 +171,7 @@ LaunchedEffect(isPlay, isPos) {
|
||||||
|
|
||||||
|
|
||||||
AnimatedVisibility(
|
AnimatedVisibility(
|
||||||
visible = isExpanded and !isPlayMid,
|
visible = isExpanded and !showMidiCtrl,
|
||||||
enter = fadeIn() + scaleIn() + slideInVertically { it / 2 },
|
enter = fadeIn() + scaleIn() + slideInVertically { it / 2 },
|
||||||
exit = fadeOut() + scaleOut() + slideOutVertically { it / 2 }
|
exit = fadeOut() + scaleOut() + slideOutVertically { it / 2 }
|
||||||
) {
|
) {
|
||||||
|
|
@ -195,20 +193,20 @@ LaunchedEffect(isPlay, isPos) {
|
||||||
) {
|
) {
|
||||||
FloatingActionButton(
|
FloatingActionButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
isPlayMid = !isPlayMid
|
sharedScreenModel.setMidiCtrl(!showMidiCtrl)
|
||||||
}, modifier = Modifier.alpha(0.45f)
|
}, modifier = Modifier.alpha(0.45f)
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = if(isPlayMid) Icons.Filled.StopCircle else Icons.Filled.PlayCircle,
|
imageVector = if(showMidiCtrl) Icons.Filled.StopCircle else Icons.Filled.PlayCircle,
|
||||||
contentDescription = "Jouer",
|
contentDescription = "Jouer",
|
||||||
tint = Color.Blue
|
tint = Color.Blue
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isPlayMid) {
|
if (!showMidiCtrl) {
|
||||||
FloatingActionButton(
|
FloatingActionButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
isExpanded = !isExpanded
|
sharedScreenModel.setExpandedFAB(!isExpanded)
|
||||||
refreshTrigeer++
|
refreshTrigeer++
|
||||||
sharedScreenModel.loadNewSong("$midiFile")
|
sharedScreenModel.loadNewSong("$midiFile")
|
||||||
}, modifier = Modifier.alpha(0.45f)
|
}, modifier = Modifier.alpha(0.45f)
|
||||||
|
|
@ -221,7 +219,7 @@ LaunchedEffect(isPlay, isPos) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AnimatedVisibility(
|
AnimatedVisibility(
|
||||||
visible = isPlayMid,
|
visible = showMidiCtrl,
|
||||||
enter = fadeIn() + scaleIn() + slideInVertically { it / 2 },
|
enter = fadeIn() + scaleIn() + slideInVertically { it / 2 },
|
||||||
exit = fadeOut() + scaleOut() + slideOutVertically { it / 2 }
|
exit = fadeOut() + scaleOut() + slideOutVertically { it / 2 }
|
||||||
) {
|
) {
|
||||||
|
|
@ -292,9 +290,6 @@ LaunchedEffect(isPlay, isPos) {
|
||||||
sharedScreenModel.updateSearchTxt("")
|
sharedScreenModel.updateSearchTxt("")
|
||||||
sharedScreenModel.reset()
|
sharedScreenModel.reset()
|
||||||
solfaScreenModel.loadFromFile(item.path)
|
solfaScreenModel.loadFromFile(item.path)
|
||||||
isSearchActive = false
|
|
||||||
isPlayMid = false
|
|
||||||
isExpanded = false
|
|
||||||
sharedScreenModel.stopMidi()
|
sharedScreenModel.stopMidi()
|
||||||
sharedScreenModel.seekTo(0f)
|
sharedScreenModel.seekTo(0f)
|
||||||
})
|
})
|
||||||
|
|
@ -355,7 +350,7 @@ LaunchedEffect(isPlay, isPos) {
|
||||||
) {
|
) {
|
||||||
IconButton(
|
IconButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
isSearchActive = !isSearchActive
|
sharedScreenModel.showSearchMenu(!isSearchActive)
|
||||||
sharedScreenModel.updateSearchTxt("")
|
sharedScreenModel.updateSearchTxt("")
|
||||||
textInput = ""
|
textInput = ""
|
||||||
}, modifier = Modifier.size(56.dp).alpha(0.45f).background(
|
}, modifier = Modifier.size(56.dp).alpha(0.45f).background(
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,24 @@ class SharedScreenModel(private val fileRepository: FileRepository) : ScreenMode
|
||||||
fun updateSearchTxt(searchValue: String) {
|
fun updateSearchTxt(searchValue: String) {
|
||||||
_searchTitle.value = searchValue
|
_searchTitle.value = searchValue
|
||||||
}
|
}
|
||||||
|
private val _showMidiCtrl = MutableStateFlow<Boolean>(false)
|
||||||
|
val showMidiCtrl: StateFlow<Boolean> = _showMidiCtrl.asStateFlow()
|
||||||
|
fun setMidiCtrl(value: Boolean) {
|
||||||
|
_showMidiCtrl.value = value
|
||||||
|
}
|
||||||
|
|
||||||
|
private val _expandedFAB = MutableStateFlow<Boolean>(false)
|
||||||
|
val expandedFAB: StateFlow<Boolean> = _expandedFAB.asStateFlow()
|
||||||
|
|
||||||
|
fun setExpandedFAB(value: Boolean) {
|
||||||
|
_expandedFAB.value = value
|
||||||
|
}
|
||||||
|
|
||||||
|
private val _showSearchMenu = MutableStateFlow<Boolean>(false)
|
||||||
|
val showSearchMenu: StateFlow<Boolean> = _showSearchMenu.asStateFlow()
|
||||||
|
fun showSearchMenu(value: Boolean) {
|
||||||
|
_showSearchMenu.value = value
|
||||||
|
}
|
||||||
|
|
||||||
private var _mediaPlayer by mutableStateOf<FMediaPlayer?>(null)
|
private var _mediaPlayer by mutableStateOf<FMediaPlayer?>(null)
|
||||||
val mediaPlayer: FMediaPlayer? get() = _mediaPlayer
|
val mediaPlayer: FMediaPlayer? get() = _mediaPlayer
|
||||||
|
|
@ -369,6 +387,11 @@ class SharedScreenModel(private val fileRepository: FileRepository) : ScreenMode
|
||||||
}
|
}
|
||||||
|
|
||||||
fun reset() {
|
fun reset() {
|
||||||
|
// Close other menus
|
||||||
|
_showMidiCtrl.value = false
|
||||||
|
_expandedFAB.value = false
|
||||||
|
_showSearchMenu.value = false
|
||||||
|
updateSearchTxt("")
|
||||||
tempTimeUnitObjectList.clear()
|
tempTimeUnitObjectList.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue