Simplified TripleVerticalSplitPane
This commit is contained in:
parent
d06e746c6c
commit
3a72a9d0cf
@ -13,6 +13,7 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.input.key.onKeyEvent
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.jetpackduba.gitnuro.AppConstants
|
||||
import com.jetpackduba.gitnuro.LocalTabScope
|
||||
@ -22,7 +23,7 @@ import com.jetpackduba.gitnuro.git.rebase.RebaseInteractiveState
|
||||
import com.jetpackduba.gitnuro.keybindings.KeybindingOption
|
||||
import com.jetpackduba.gitnuro.keybindings.matchesBinding
|
||||
import com.jetpackduba.gitnuro.ui.components.SecondaryButton
|
||||
import com.jetpackduba.gitnuro.ui.components.TripleVerticalSplit
|
||||
import com.jetpackduba.gitnuro.ui.components.TripleVerticalSplitPanel
|
||||
import com.jetpackduba.gitnuro.ui.components.gitnuroDynamicViewModel
|
||||
import com.jetpackduba.gitnuro.ui.dialogs.*
|
||||
import com.jetpackduba.gitnuro.ui.diff.Diff
|
||||
@ -249,13 +250,15 @@ fun MainContentView(
|
||||
blameState: BlameState,
|
||||
) {
|
||||
val rebaseInteractiveState by tabViewModel.rebaseInteractiveState.collectAsState()
|
||||
val density = LocalDensity.current.density
|
||||
|
||||
TripleVerticalSplit(
|
||||
var firstWidth by remember { mutableStateOf(180f) }
|
||||
var thirdWidth by remember { mutableStateOf(360f) }
|
||||
|
||||
TripleVerticalSplitPanel(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
initialFirstWidth = 220f,
|
||||
minFirstWidth = 150f,
|
||||
initialThirdWidth = 360f,
|
||||
minThirdWidth = 180f,
|
||||
firstWidth = firstWidth,
|
||||
thirdWidth = thirdWidth,
|
||||
first = {
|
||||
SidePanel()
|
||||
},
|
||||
@ -362,11 +365,19 @@ fun MainContentView(
|
||||
}
|
||||
}
|
||||
},
|
||||
onFirstSizeChanged = {
|
||||
onFirstSizeDrag = {
|
||||
val newWidth = firstWidth + it / density
|
||||
|
||||
if (newWidth > 150) {
|
||||
firstWidth = newWidth
|
||||
}
|
||||
},
|
||||
onThirdSizeChanged = {
|
||||
onThirdSizeDrag = {
|
||||
val newWidth = thirdWidth - it / density
|
||||
|
||||
if (newWidth > 150) {
|
||||
thirdWidth = newWidth
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
@ -8,33 +8,29 @@ import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.ExperimentalComposeUiApi
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.input.pointer.pointerHoverIcon
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.layout.onGloballyPositioned
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.jetpackduba.gitnuro.ui.resizePointerIconEast
|
||||
|
||||
@OptIn(ExperimentalComposeUiApi::class)
|
||||
@Composable
|
||||
fun TripleVerticalSplit(
|
||||
fun TripleVerticalSplitPanel(
|
||||
modifier: Modifier = Modifier,
|
||||
first: @Composable () -> Unit,
|
||||
second: @Composable () -> Unit,
|
||||
third: @Composable () -> Unit,
|
||||
initialFirstWidth: Float,
|
||||
minFirstWidth: Float,
|
||||
initialThirdWidth: Float,
|
||||
minThirdWidth: Float,
|
||||
onFirstSizeChanged: (Float) -> Unit,
|
||||
onThirdSizeChanged: (Float) -> Unit,
|
||||
firstWidth: Float,
|
||||
thirdWidth: Float,
|
||||
onFirstSizeDrag: (Float) -> Unit,
|
||||
onThirdSizeDrag: (Float) -> Unit,
|
||||
) {
|
||||
val density = LocalDensity.current.density
|
||||
var firstWidth by remember { mutableStateOf(initialFirstWidth) }
|
||||
var thirdWidth by remember { mutableStateOf(initialThirdWidth) }
|
||||
|
||||
Row(
|
||||
modifier = modifier
|
||||
) {
|
||||
Box(modifier = Modifier.width((firstWidth).dp)) {
|
||||
Box(modifier = Modifier.width(firstWidth.dp)) {
|
||||
first()
|
||||
}
|
||||
|
||||
@ -44,12 +40,7 @@ fun TripleVerticalSplit(
|
||||
.width(8.dp)
|
||||
.draggable(
|
||||
state = rememberDraggableState {
|
||||
val newWidth = firstWidth + it / density
|
||||
|
||||
if (newWidth > minFirstWidth) {
|
||||
firstWidth = newWidth
|
||||
onFirstSizeChanged(firstWidth)
|
||||
}
|
||||
onFirstSizeDrag(it)
|
||||
},
|
||||
orientation = Orientation.Horizontal
|
||||
)
|
||||
@ -66,12 +57,7 @@ fun TripleVerticalSplit(
|
||||
.width(8.dp)
|
||||
.draggable(
|
||||
rememberDraggableState {
|
||||
val newWidth = thirdWidth - it / density
|
||||
|
||||
if(newWidth > minThirdWidth) {
|
||||
thirdWidth = newWidth
|
||||
onThirdSizeChanged(thirdWidth)
|
||||
}
|
||||
onThirdSizeDrag(it)
|
||||
}, Orientation.Horizontal
|
||||
)
|
||||
.pointerHoverIcon(resizePointerIconEast)
|
Loading…
Reference in New Issue
Block a user