Side panel now is a single big list with local branches and stashes expanded by default
This commit is contained in:
parent
64764c556d
commit
6599f2f861
@ -38,16 +38,6 @@ fun Remotes(
|
|||||||
var showEditRemotesDialog by remember { mutableStateOf(false) }
|
var showEditRemotesDialog by remember { mutableStateOf(false) }
|
||||||
val isExpanded by remotesViewModel.isExpanded.collectAsState()
|
val isExpanded by remotesViewModel.isExpanded.collectAsState()
|
||||||
|
|
||||||
val itemsCount = remember(remotes) {
|
|
||||||
val allBranches = remotes.filter { remoteView ->
|
|
||||||
remoteView.isExpanded // Only include in the branches count the nodes expanded
|
|
||||||
}.map { remoteView ->
|
|
||||||
remoteView.remoteInfo.branchesList
|
|
||||||
}.flatten()
|
|
||||||
|
|
||||||
allBranches.count() + remotes.count()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (showEditRemotesDialog) {
|
if (showEditRemotesDialog) {
|
||||||
EditRemotesDialog(
|
EditRemotesDialog(
|
||||||
remotesViewModel = remotesViewModel,
|
remotesViewModel = remotesViewModel,
|
||||||
@ -61,7 +51,6 @@ fun Remotes(
|
|||||||
title = "Remotes",
|
title = "Remotes",
|
||||||
icon = painterResource("cloud.svg"),
|
icon = painterResource("cloud.svg"),
|
||||||
items = remotes,
|
items = remotes,
|
||||||
itemsCountForMaxHeight = itemsCount,
|
|
||||||
isExpanded = isExpanded,
|
isExpanded = isExpanded,
|
||||||
onExpand = { remotesViewModel.onExpand() },
|
onExpand = { remotesViewModel.onExpand() },
|
||||||
contextItems = {
|
contextItems = {
|
||||||
|
@ -17,6 +17,7 @@ import androidx.compose.ui.unit.sp
|
|||||||
import app.extensions.handMouseClickable
|
import app.extensions.handMouseClickable
|
||||||
import app.git.DiffEntryType
|
import app.git.DiffEntryType
|
||||||
import app.theme.*
|
import app.theme.*
|
||||||
|
import app.ui.components.ScrollableColumn
|
||||||
import app.ui.dialogs.AuthorDialog
|
import app.ui.dialogs.AuthorDialog
|
||||||
import app.ui.dialogs.NewBranchDialog
|
import app.ui.dialogs.NewBranchDialog
|
||||||
import app.ui.dialogs.StashWithMessageDialog
|
import app.ui.dialogs.StashWithMessageDialog
|
||||||
@ -176,10 +177,7 @@ fun MainContentView(
|
|||||||
Row {
|
Row {
|
||||||
HorizontalSplitPane {
|
HorizontalSplitPane {
|
||||||
first(minSize = 250.dp) {
|
first(minSize = 250.dp) {
|
||||||
Column(
|
ScrollableColumn(modifier = Modifier.fillMaxHeight( )) {
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxHeight()
|
|
||||||
) {
|
|
||||||
Branches(
|
Branches(
|
||||||
branchesViewModel = tabViewModel.branchesViewModel,
|
branchesViewModel = tabViewModel.branchesViewModel,
|
||||||
)
|
)
|
||||||
|
43
src/main/kotlin/app/ui/components/ScrollableColumn.kt
Normal file
43
src/main/kotlin/app/ui/components/ScrollableColumn.kt
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package app.ui.components
|
||||||
|
|
||||||
|
import androidx.compose.foundation.*
|
||||||
|
import androidx.compose.foundation.layout.*
|
||||||
|
import androidx.compose.material.MaterialTheme
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import app.theme.scrollbarHover
|
||||||
|
import app.theme.scrollbarNormal
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ScrollableColumn(
|
||||||
|
modifier: Modifier,
|
||||||
|
state: ScrollState = rememberScrollState(0),
|
||||||
|
content: @Composable ColumnScope.() -> Unit
|
||||||
|
) {
|
||||||
|
|
||||||
|
Box(
|
||||||
|
modifier = modifier,
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
content = content,
|
||||||
|
modifier = Modifier
|
||||||
|
.verticalScroll(state)
|
||||||
|
)
|
||||||
|
|
||||||
|
VerticalScrollbar(
|
||||||
|
modifier = Modifier
|
||||||
|
.align(Alignment.CenterEnd)
|
||||||
|
.fillMaxHeight()
|
||||||
|
.padding(end = 2.dp),
|
||||||
|
style = LocalScrollbarStyle.current.copy(
|
||||||
|
unhoverColor = MaterialTheme.colors.scrollbarNormal,
|
||||||
|
hoverColor = MaterialTheme.colors.scrollbarHover,
|
||||||
|
),
|
||||||
|
adapter = rememberScrollbarAdapter(
|
||||||
|
scrollState = state
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,7 @@ import androidx.compose.foundation.ContextMenuArea
|
|||||||
import androidx.compose.foundation.ContextMenuItem
|
import androidx.compose.foundation.ContextMenuItem
|
||||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.heightIn
|
import androidx.compose.foundation.layout.heightIn
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
@ -23,13 +24,10 @@ fun <T> SideMenuPanel(
|
|||||||
items: List<T>,
|
items: List<T>,
|
||||||
isExpanded: Boolean = false,
|
isExpanded: Boolean = false,
|
||||||
onExpand: () -> Unit,
|
onExpand: () -> Unit,
|
||||||
itemsCountForMaxHeight: Int = items.count(),
|
|
||||||
itemContent: @Composable (T) -> Unit,
|
itemContent: @Composable (T) -> Unit,
|
||||||
headerHoverIcon: @Composable (() -> Unit)? = null,
|
headerHoverIcon: @Composable (() -> Unit)? = null,
|
||||||
contextItems: () -> List<ContextMenuItem> = { emptyList() },
|
contextItems: () -> List<ContextMenuItem> = { emptyList() },
|
||||||
) {
|
) {
|
||||||
val maxHeight = remember(items) { maxSidePanelHeight(itemsCountForMaxHeight) }
|
|
||||||
|
|
||||||
VerticalExpandable(
|
VerticalExpandable(
|
||||||
isExpanded = isExpanded,
|
isExpanded = isExpanded,
|
||||||
onExpand = onExpand,
|
onExpand = onExpand,
|
||||||
@ -46,13 +44,12 @@ fun <T> SideMenuPanel(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
ScrollableLazyColumn(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.heightIn(max = maxHeight.dp)
|
|
||||||
.background(MaterialTheme.colors.background)
|
.background(MaterialTheme.colors.background)
|
||||||
) {
|
) {
|
||||||
items(items) { item ->
|
for (item in items) {
|
||||||
itemContent(item)
|
itemContent(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ class BranchesViewModel @Inject constructor(
|
|||||||
private val remoteOperationsManager: RemoteOperationsManager,
|
private val remoteOperationsManager: RemoteOperationsManager,
|
||||||
private val tabState: TabState,
|
private val tabState: TabState,
|
||||||
private val appPreferences: AppPreferences,
|
private val appPreferences: AppPreferences,
|
||||||
) : ExpandableViewModel() {
|
) : ExpandableViewModel(true) {
|
||||||
private val _branches = MutableStateFlow<List<Ref>>(listOf())
|
private val _branches = MutableStateFlow<List<Ref>>(listOf())
|
||||||
val branches: StateFlow<List<Ref>>
|
val branches: StateFlow<List<Ref>>
|
||||||
get() = _branches
|
get() = _branches
|
||||||
|
@ -3,8 +3,8 @@ package app.viewmodels
|
|||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
|
|
||||||
abstract class ExpandableViewModel {
|
abstract class ExpandableViewModel(expandedDefault: Boolean = false) {
|
||||||
private val _isExpanded = MutableStateFlow(true)
|
private val _isExpanded = MutableStateFlow(expandedDefault)
|
||||||
val isExpanded: StateFlow<Boolean> = _isExpanded
|
val isExpanded: StateFlow<Boolean> = _isExpanded
|
||||||
|
|
||||||
fun onExpand() {
|
fun onExpand() {
|
||||||
|
@ -13,7 +13,7 @@ import javax.inject.Inject
|
|||||||
class StashesViewModel @Inject constructor(
|
class StashesViewModel @Inject constructor(
|
||||||
private val stashManager: StashManager,
|
private val stashManager: StashManager,
|
||||||
private val tabState: TabState,
|
private val tabState: TabState,
|
||||||
) : ExpandableViewModel() {
|
) : ExpandableViewModel(true) {
|
||||||
private val _stashStatus = MutableStateFlow<StashStatus>(StashStatus.Loaded(listOf()))
|
private val _stashStatus = MutableStateFlow<StashStatus>(StashStatus.Loaded(listOf()))
|
||||||
val stashStatus: StateFlow<StashStatus>
|
val stashStatus: StateFlow<StashStatus>
|
||||||
get() = _stashStatus
|
get() = _stashStatus
|
||||||
|
Loading…
Reference in New Issue
Block a user