Added scroll to all lists
This commit is contained in:
parent
2f77127119
commit
0d7c42b1bf
@ -17,6 +17,7 @@ import androidx.compose.ui.text.style.TextAlign
|
|||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
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 components.ScrollableLazyColumn
|
||||||
import extensions.simpleName
|
import extensions.simpleName
|
||||||
import org.eclipse.jgit.lib.Ref
|
import org.eclipse.jgit.lib.Ref
|
||||||
import theme.headerBackground
|
import theme.headerBackground
|
||||||
@ -46,7 +47,7 @@ fun Branches(gitManager: GitManager) {
|
|||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
)
|
)
|
||||||
|
|
||||||
LazyColumn(modifier = Modifier.weight(5f)) {
|
ScrollableLazyColumn(modifier = Modifier.weight(5f)) {
|
||||||
itemsIndexed(branches) { _, branch ->
|
itemsIndexed(branches) { _, branch ->
|
||||||
BranchRow(
|
BranchRow(
|
||||||
branch = branch,
|
branch = branch,
|
||||||
|
@ -28,6 +28,7 @@ import java.net.HttpURLConnection
|
|||||||
import java.net.URL
|
import java.net.URL
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
|
import components.ScrollableLazyColumn
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun CommitChanges(
|
fun CommitChanges(
|
||||||
@ -183,7 +184,7 @@ fun rememberNetworkImage(url: String): ImageBitmap {
|
|||||||
fun CommitLogChanges(diffEntries: List<DiffEntry>, onDiffSelected: (DiffEntry) -> Unit) {
|
fun CommitLogChanges(diffEntries: List<DiffEntry>, onDiffSelected: (DiffEntry) -> Unit) {
|
||||||
val selectedIndex = remember(diffEntries) { mutableStateOf(-1) }
|
val selectedIndex = remember(diffEntries) { mutableStateOf(-1) }
|
||||||
|
|
||||||
LazyColumn(
|
ScrollableLazyColumn(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
) {
|
) {
|
||||||
|
@ -19,6 +19,7 @@ import androidx.compose.ui.graphics.Color
|
|||||||
import androidx.compose.ui.text.font.FontFamily
|
import androidx.compose.ui.text.font.FontFamily
|
||||||
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 components.ScrollableLazyColumn
|
||||||
import theme.primaryTextColor
|
import theme.primaryTextColor
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ -46,7 +47,7 @@ fun Diff(gitManager: GitManager, diffEntryType: DiffEntryType, onCloseDiffView:
|
|||||||
Text("Close diff")
|
Text("Close diff")
|
||||||
}
|
}
|
||||||
SelectionContainer {
|
SelectionContainer {
|
||||||
LazyColumn(
|
ScrollableLazyColumn(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.padding(16.dp)
|
.padding(16.dp)
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
|
import androidx.compose.foundation.VerticalScrollbar
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.itemsIndexed
|
import androidx.compose.foundation.lazy.itemsIndexed
|
||||||
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
|
import androidx.compose.foundation.rememberScrollbarAdapter
|
||||||
import androidx.compose.material.Card
|
import androidx.compose.material.Card
|
||||||
import androidx.compose.material.Divider
|
import androidx.compose.material.Divider
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material.MaterialTheme
|
||||||
@ -14,6 +17,7 @@ import androidx.compose.ui.text.font.FontStyle
|
|||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
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 components.ScrollableLazyColumn
|
||||||
import extensions.toSmartSystemString
|
import extensions.toSmartSystemString
|
||||||
import git.LogStatus
|
import git.LogStatus
|
||||||
import org.eclipse.jgit.revwalk.RevCommit
|
import org.eclipse.jgit.revwalk.RevCommit
|
||||||
@ -37,6 +41,7 @@ fun Log(
|
|||||||
} else
|
} else
|
||||||
listOf()
|
listOf()
|
||||||
|
|
||||||
|
|
||||||
Card(
|
Card(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(8.dp)
|
.padding(8.dp)
|
||||||
@ -45,10 +50,10 @@ fun Log(
|
|||||||
) {
|
) {
|
||||||
val hasUncommitedChanges by gitManager.hasUncommitedChanges.collectAsState()
|
val hasUncommitedChanges by gitManager.hasUncommitedChanges.collectAsState()
|
||||||
|
|
||||||
LazyColumn(
|
ScrollableLazyColumn(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.background(MaterialTheme.colors.surface)
|
.background(MaterialTheme.colors.surface)
|
||||||
.fillMaxSize()
|
.fillMaxSize(),
|
||||||
) {
|
) {
|
||||||
|
|
||||||
if (hasUncommitedChanges)
|
if (hasUncommitedChanges)
|
||||||
|
@ -16,6 +16,7 @@ import androidx.compose.ui.text.style.TextAlign
|
|||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
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 components.ScrollableLazyColumn
|
||||||
import git.StashStatus
|
import git.StashStatus
|
||||||
import org.eclipse.jgit.revwalk.RevCommit
|
import org.eclipse.jgit.revwalk.RevCommit
|
||||||
import theme.headerBackground
|
import theme.headerBackground
|
||||||
@ -50,7 +51,7 @@ fun Stashes(gitManager: GitManager) {
|
|||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
)
|
)
|
||||||
|
|
||||||
LazyColumn(modifier = Modifier.weight(5f)) {
|
ScrollableLazyColumn(modifier = Modifier.weight(5f)) {
|
||||||
items(items = stashList) { stash ->
|
items(items = stashList) { stash ->
|
||||||
StashRow(
|
StashRow(
|
||||||
stash = stash,
|
stash = stash,
|
||||||
|
@ -8,6 +8,7 @@ import androidx.compose.foundation.*
|
|||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.itemsIndexed
|
import androidx.compose.foundation.lazy.itemsIndexed
|
||||||
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.*
|
import androidx.compose.material.*
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
@ -29,6 +30,7 @@ import androidx.compose.ui.text.style.TextAlign
|
|||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
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 components.ScrollableLazyColumn
|
||||||
import extensions.filePath
|
import extensions.filePath
|
||||||
import extensions.icon
|
import extensions.icon
|
||||||
import extensions.iconColor
|
import extensions.iconColor
|
||||||
@ -157,6 +159,7 @@ private fun EntriesList(
|
|||||||
onDiffEntryOptionSelected: (DiffEntry) -> Unit,
|
onDiffEntryOptionSelected: (DiffEntry) -> Unit,
|
||||||
onReset: (DiffEntry) -> Unit,
|
onReset: (DiffEntry) -> Unit,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
Card(
|
Card(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
) {
|
) {
|
||||||
@ -174,7 +177,9 @@ private fun EntriesList(
|
|||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
)
|
)
|
||||||
|
|
||||||
LazyColumn(modifier = Modifier.weight(5f)) {
|
ScrollableLazyColumn(
|
||||||
|
modifier = Modifier.fillMaxSize(),
|
||||||
|
) {
|
||||||
itemsIndexed(diffEntries) { index, diffEntry ->
|
itemsIndexed(diffEntries) { index, diffEntry ->
|
||||||
FileEntry(
|
FileEntry(
|
||||||
diffEntry = diffEntry,
|
diffEntry = diffEntry,
|
||||||
@ -194,7 +199,9 @@ private fun EntriesList(
|
|||||||
if (index < diffEntries.size - 1) {
|
if (index < diffEntries.size - 1) {
|
||||||
Divider(modifier = Modifier.fillMaxWidth())
|
Divider(modifier = Modifier.fillMaxWidth())
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
35
src/main/kotlin/components/ScrollableLazyColumn.kt
Normal file
35
src/main/kotlin/components/ScrollableLazyColumn.kt
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
package components
|
||||||
|
|
||||||
|
import androidx.compose.foundation.VerticalScrollbar
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.fillMaxHeight
|
||||||
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
|
import androidx.compose.foundation.lazy.LazyListScope
|
||||||
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
|
import androidx.compose.foundation.rememberScrollbarAdapter
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ScrollableLazyColumn(
|
||||||
|
modifier: Modifier,
|
||||||
|
content: LazyListScope.() -> Unit
|
||||||
|
) {
|
||||||
|
val state = rememberLazyListState()
|
||||||
|
|
||||||
|
Box(
|
||||||
|
modifier = modifier,
|
||||||
|
) {
|
||||||
|
LazyColumn(
|
||||||
|
state = state,
|
||||||
|
content = content
|
||||||
|
)
|
||||||
|
VerticalScrollbar(
|
||||||
|
modifier = Modifier.align(Alignment.CenterEnd).fillMaxHeight(),
|
||||||
|
adapter = rememberScrollbarAdapter(
|
||||||
|
scrollState = state
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user