Improve ux by back btn to hide ui before exit - Android
This commit is contained in:
parent
b8b9eda836
commit
88b734cdc2
3 changed files with 21 additions and 12 deletions
|
|
@ -56,7 +56,6 @@ object ScreenSolfa : Screen {
|
||||||
var showContextualMenu = false
|
var showContextualMenu = false
|
||||||
var viewportHeight by remember { mutableStateOf(0) }
|
var viewportHeight by remember { mutableStateOf(0) }
|
||||||
|
|
||||||
var isScanning by remember { mutableStateOf(false) }
|
|
||||||
var qrCodeResult by remember { mutableStateOf("Aucun code scanné") }
|
var qrCodeResult by remember { mutableStateOf("Aucun code scanné") }
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
DeepLinkHandler.onSongReceived = { content, filePath ->
|
DeepLinkHandler.onSongReceived = { content, filePath ->
|
||||||
|
|
@ -88,9 +87,6 @@ object ScreenSolfa : Screen {
|
||||||
solfaScreenModel,
|
solfaScreenModel,
|
||||||
sharedScreenModel,
|
sharedScreenModel,
|
||||||
qrCodeResult = qrCodeResult,
|
qrCodeResult = qrCodeResult,
|
||||||
onScannerButtonClick = {
|
|
||||||
isScanning = true
|
|
||||||
},
|
|
||||||
solfaScrollState = scrollState
|
solfaScrollState = scrollState
|
||||||
) { paddingValues ->
|
) { paddingValues ->
|
||||||
Box(
|
Box(
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,8 @@ import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
|
import cafe.adriel.voyager.core.annotation.InternalVoyagerApi
|
||||||
|
import cafe.adriel.voyager.navigator.internal.BackHandler
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
@ -53,13 +55,13 @@ import mg.dot.feufaro.solfa.Transpose
|
||||||
import mg.dot.feufaro.viewmodel.SolfaScreenModel
|
import mg.dot.feufaro.viewmodel.SolfaScreenModel
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
|
||||||
|
@OptIn(ExperimentalMaterial3Api::class, InternalVoyagerApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun MainScreenWithDrawer(
|
fun MainScreenWithDrawer(
|
||||||
solfaScreenModel: SolfaScreenModel,
|
solfaScreenModel: SolfaScreenModel,
|
||||||
sharedScreenModel: SharedScreenModel,
|
sharedScreenModel: SharedScreenModel,
|
||||||
qrCodeResult: String,
|
qrCodeResult: String,
|
||||||
onScannerButtonClick: () -> Unit,
|
|
||||||
solfaScrollState: ScrollState,
|
solfaScrollState: ScrollState,
|
||||||
content: @Composable (PaddingValues) -> Unit,
|
content: @Composable (PaddingValues) -> Unit,
|
||||||
) {
|
) {
|
||||||
|
|
@ -199,6 +201,22 @@ fun MainScreenWithDrawer(
|
||||||
val density = LocalDensity.current
|
val density = LocalDensity.current
|
||||||
var keyboardHeightDp by remember { mutableStateOf(0.dp) }
|
var keyboardHeightDp by remember { mutableStateOf(0.dp) }
|
||||||
|
|
||||||
|
BackHandler(enabled = isSearchActive) {
|
||||||
|
sharedScreenModel.showSearchMenu(false)
|
||||||
|
}
|
||||||
|
BackHandler(enabled = showMidiCtrl) {
|
||||||
|
sharedScreenModel.setMidiCtrl(false)
|
||||||
|
}
|
||||||
|
BackHandler(enabled = isQrVisible) {
|
||||||
|
sharedScreenModel.toggleQRCodeVisibility()
|
||||||
|
}
|
||||||
|
BackHandler(enabled = (!showMidiCtrl && isExpanded)) {
|
||||||
|
sharedScreenModel.setExpandedFAB(!isExpanded)
|
||||||
|
}
|
||||||
|
BackHandler(enabled = drawerState.isOpen) {
|
||||||
|
scope.launch { drawerState.close() }
|
||||||
|
}
|
||||||
|
|
||||||
ModalNavigationDrawer(drawerState = drawerState, drawerContent = {
|
ModalNavigationDrawer(drawerState = drawerState, drawerContent = {
|
||||||
SimpleDrawerContent(
|
SimpleDrawerContent(
|
||||||
items,
|
items,
|
||||||
|
|
@ -207,10 +225,6 @@ fun MainScreenWithDrawer(
|
||||||
currentActivePath,
|
currentActivePath,
|
||||||
drawerState,
|
drawerState,
|
||||||
scope,
|
scope,
|
||||||
onScannerButtonClick = {
|
|
||||||
scope.launch { drawerState.close() }
|
|
||||||
onScannerButtonClick()
|
|
||||||
},
|
|
||||||
onSongSelected = { newSong ->
|
onSongSelected = { newSong ->
|
||||||
sharedScreenModel.loadNewSong("$midiFile")
|
sharedScreenModel.loadNewSong("$midiFile")
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,6 @@ fun SimpleDrawerContent(
|
||||||
activePath: String = Solfa.currentFile,
|
activePath: String = Solfa.currentFile,
|
||||||
drawerState: DrawerState,
|
drawerState: DrawerState,
|
||||||
scope: CoroutineScope,
|
scope: CoroutineScope,
|
||||||
onScannerButtonClick: () -> Unit,
|
|
||||||
onSongSelected: (String) -> Unit,
|
onSongSelected: (String) -> Unit,
|
||||||
onSettingsCheck: () -> Unit,
|
onSettingsCheck: () -> Unit,
|
||||||
onAboutCheck: () -> Unit,
|
onAboutCheck: () -> Unit,
|
||||||
|
|
@ -195,7 +194,7 @@ fun SimpleDrawerContent(
|
||||||
|
|
||||||
stickyHeader {
|
stickyHeader {
|
||||||
DrawerHeaderSticky(
|
DrawerHeaderSticky(
|
||||||
title = "Personnel",
|
title = "Fichiers locaux",
|
||||||
icon = Icons.Default.LibraryMusic,
|
icon = Icons.Default.LibraryMusic,
|
||||||
isExpanded = externalExpanded,
|
isExpanded = externalExpanded,
|
||||||
onToggle = { externalExpanded = !externalExpanded },
|
onToggle = { externalExpanded = !externalExpanded },
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue