Put FloawRow list stanzas list 75% width & Change verse on drag left/right
This commit is contained in:
parent
373eed0b0e
commit
47350c6286
1 changed files with 35 additions and 1 deletions
|
|
@ -2,6 +2,7 @@ package mg.dot.feufaro
|
||||||
|
|
||||||
import SharedScreenModel
|
import SharedScreenModel
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.gestures.detectHorizontalDragGestures
|
||||||
import androidx.compose.foundation.gestures.detectTapGestures
|
import androidx.compose.foundation.gestures.detectTapGestures
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
|
|
@ -52,6 +53,7 @@ object ScreenSolfa : Screen {
|
||||||
val tuoList by sharedScreenModel.tuoList.collectAsState()
|
val tuoList by sharedScreenModel.tuoList.collectAsState()
|
||||||
val measure by sharedScreenModel.measure.collectAsState()
|
val measure by sharedScreenModel.measure.collectAsState()
|
||||||
val stanza by sharedScreenModel.stanza.collectAsState()
|
val stanza by sharedScreenModel.stanza.collectAsState()
|
||||||
|
val nbStanzas: Int by sharedScreenModel.nbStanzas.collectAsState()
|
||||||
val gridTUOData = remember(tuoList, measure, stanza) { GridTUOData(measure, tuoList, stanza) }
|
val gridTUOData = remember(tuoList, measure, stanza) { GridTUOData(measure, tuoList, stanza) }
|
||||||
val coroutineScope = rememberCoroutineScope()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
val scrollState = rememberScrollState()
|
val scrollState = rememberScrollState()
|
||||||
|
|
@ -147,6 +149,38 @@ object ScreenSolfa : Screen {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
.pointerInput(stanza, nbStanzas) {
|
||||||
|
var totalDragX = 0f
|
||||||
|
detectHorizontalDragGestures(
|
||||||
|
onDragStart = { totalDragX = 0f },
|
||||||
|
onDragEnd = {
|
||||||
|
val currentStanza = stanza.toString().toIntOrNull() ?: 1
|
||||||
|
val threshold = 70f
|
||||||
|
|
||||||
|
if (totalDragX < -threshold) {
|
||||||
|
// Droite -> Gauche
|
||||||
|
if (currentStanza < nbStanzas) {
|
||||||
|
sharedScreenModel.setStanza(currentStanza + 1)
|
||||||
|
coroutineScope.launch {
|
||||||
|
scrollState.animateScrollTo(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (totalDragX > threshold) {
|
||||||
|
// Gauche -> Droite
|
||||||
|
if (currentStanza > 1) {
|
||||||
|
sharedScreenModel.setStanza(currentStanza - 1)
|
||||||
|
coroutineScope.launch {
|
||||||
|
scrollState.animateScrollTo(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onHorizontalDrag = { change, dragAmount ->
|
||||||
|
change.consume()
|
||||||
|
totalDragX += dragAmount
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
.onGloballyPositioned { coordinates ->
|
.onGloballyPositioned { coordinates ->
|
||||||
viewportHeight = coordinates.size.height
|
viewportHeight = coordinates.size.height
|
||||||
},
|
},
|
||||||
|
|
@ -253,7 +287,7 @@ object ScreenSolfa : Screen {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FlowRow(
|
FlowRow(
|
||||||
modifier = Modifier.fillMaxWidth()
|
modifier = Modifier.fillMaxWidth(0.75f)
|
||||||
//.windowInsetsPadding(WindowInsets.safeDrawing)
|
//.windowInsetsPadding(WindowInsets.safeDrawing)
|
||||||
.padding(start = 8.dp, end = 8.dp, top = 8.dp),
|
.padding(start = 8.dp, end = 8.dp, top = 8.dp),
|
||||||
horizontalArrangement = Arrangement.spacedBy(16.dp),
|
horizontalArrangement = Arrangement.spacedBy(16.dp),
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue