Changed commited and uncommited changes to use new design
This commit is contained in:
parent
317947cee7
commit
b394d9f33b
@ -33,6 +33,7 @@ import androidx.compose.ui.graphics.toComposeImageBitmap
|
|||||||
import app.ui.components.ScrollableLazyColumn
|
import app.ui.components.ScrollableLazyColumn
|
||||||
import app.git.GitManager
|
import app.git.GitManager
|
||||||
import app.theme.headerText
|
import app.theme.headerText
|
||||||
|
import org.eclipse.jgit.lib.PersonIdent
|
||||||
import org.jetbrains.skia.Image.Companion.makeFromEncoded
|
import org.jetbrains.skia.Image.Companion.makeFromEncoded
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ -48,115 +49,116 @@ fun CommitChanges(
|
|||||||
|
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize(),
|
||||||
.background(MaterialTheme.colors.background),
|
|
||||||
) {
|
) {
|
||||||
|
val scroll = rememberScrollState(0)
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth(),
|
.fillMaxWidth()
|
||||||
|
.padding(8.dp),
|
||||||
) {
|
) {
|
||||||
val scroll = rememberScrollState(0)
|
SelectionContainer {
|
||||||
Card(
|
Text(
|
||||||
modifier = Modifier
|
text = commit.fullMessage,
|
||||||
.padding(8.dp)
|
fontSize = 14.sp,
|
||||||
.fillMaxWidth()
|
modifier = Modifier
|
||||||
) {
|
.fillMaxWidth()
|
||||||
Column {
|
.background(MaterialTheme.colors.background)
|
||||||
SelectionContainer {
|
.height(120.dp)
|
||||||
Text(
|
.padding(8.dp)
|
||||||
text = commit.fullMessage,
|
.verticalScroll(scroll),
|
||||||
fontSize = 14.sp,
|
)
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.height(120.dp)
|
|
||||||
.padding(8.dp)
|
|
||||||
.verticalScroll(scroll),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
Divider(modifier = Modifier.fillMaxWidth())
|
|
||||||
|
|
||||||
Row(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.height(72.dp),
|
|
||||||
verticalAlignment = Alignment.CenterVertically
|
|
||||||
) {
|
|
||||||
val url = "https://www.gravatar.com/avatar/${commit.authorIdent.emailAddress.md5}"
|
|
||||||
Image(
|
|
||||||
bitmap = rememberNetworkImage(url),
|
|
||||||
modifier = Modifier
|
|
||||||
.padding(horizontal = 16.dp)
|
|
||||||
.height(40.dp)
|
|
||||||
.clip(CircleShape),
|
|
||||||
contentDescription = null,
|
|
||||||
)
|
|
||||||
|
|
||||||
Column(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxSize(),
|
|
||||||
verticalArrangement = Arrangement.Center
|
|
||||||
) {
|
|
||||||
Row {
|
|
||||||
Text(
|
|
||||||
text = commit.authorIdent.name,
|
|
||||||
color = MaterialTheme.colors.primaryTextColor,
|
|
||||||
maxLines = 1,
|
|
||||||
fontSize = 14.sp,
|
|
||||||
)
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.weight(1f, fill = true))
|
|
||||||
val date = remember(commit) {
|
|
||||||
commit.authorIdent.`when`.toSmartSystemString()
|
|
||||||
}
|
|
||||||
|
|
||||||
Text(
|
|
||||||
text = date,
|
|
||||||
color = MaterialTheme.colors.secondaryTextColor,
|
|
||||||
maxLines = 1,
|
|
||||||
modifier = Modifier.padding(horizontal = 16.dp),
|
|
||||||
fontSize = 12.sp,
|
|
||||||
)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Text(
|
|
||||||
text = commit.authorIdent.emailAddress,
|
|
||||||
color = MaterialTheme.colors.secondaryTextColor,
|
|
||||||
maxLines = 1,
|
|
||||||
fontSize = 12.sp,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Divider(modifier = Modifier.fillMaxWidth())
|
||||||
|
|
||||||
|
Author(commit.authorIdent)
|
||||||
}
|
}
|
||||||
|
|
||||||
Card(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.weight(1f, fill = true)
|
.weight(1f, fill = true)
|
||||||
.padding(horizontal = 8.dp, vertical = 8.dp)
|
.padding(horizontal = 8.dp, vertical = 8.dp)
|
||||||
|
.background(MaterialTheme.colors.background)
|
||||||
) {
|
) {
|
||||||
Column {
|
Text(
|
||||||
|
modifier = Modifier
|
||||||
|
.background(MaterialTheme.colors.headerBackground)
|
||||||
|
.padding(vertical = 8.dp)
|
||||||
|
.fillMaxWidth(),
|
||||||
|
text = "Files changed",
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
textAlign = TextAlign.Center,
|
||||||
|
color = MaterialTheme.colors.headerText,
|
||||||
|
maxLines = 1,
|
||||||
|
fontSize = 14.sp,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
CommitLogChanges(diff, onDiffSelected = onDiffSelected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun Author(authorIdent: PersonIdent?) {
|
||||||
|
if(authorIdent == null)
|
||||||
|
return
|
||||||
|
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(72.dp)
|
||||||
|
.background(MaterialTheme.colors.background),
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
val url = "https://www.gravatar.com/avatar/${authorIdent.emailAddress.md5}"
|
||||||
|
Image(
|
||||||
|
bitmap = rememberNetworkImage(url),
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(horizontal = 16.dp)
|
||||||
|
.height(40.dp)
|
||||||
|
.clip(CircleShape),
|
||||||
|
contentDescription = null,
|
||||||
|
)
|
||||||
|
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize(),
|
||||||
|
verticalArrangement = Arrangement.Center
|
||||||
|
) {
|
||||||
|
Row {
|
||||||
Text(
|
Text(
|
||||||
modifier = Modifier
|
text = authorIdent.name,
|
||||||
.background(MaterialTheme.colors.headerBackground)
|
color = MaterialTheme.colors.primaryTextColor,
|
||||||
.padding(vertical = 8.dp)
|
|
||||||
.fillMaxWidth(),
|
|
||||||
text = "Files changed",
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
textAlign = TextAlign.Center,
|
|
||||||
color = MaterialTheme.colors.headerText,
|
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
fontSize = 14.sp,
|
fontSize = 14.sp,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.weight(1f, fill = true))
|
||||||
|
val date = remember(authorIdent) {
|
||||||
|
authorIdent.`when`.toSmartSystemString()
|
||||||
|
}
|
||||||
|
|
||||||
|
Text(
|
||||||
|
text = date,
|
||||||
|
color = MaterialTheme.colors.secondaryTextColor,
|
||||||
|
maxLines = 1,
|
||||||
|
modifier = Modifier.padding(horizontal = 16.dp),
|
||||||
|
fontSize = 12.sp,
|
||||||
|
)
|
||||||
|
|
||||||
CommitLogChanges(diff, onDiffSelected = onDiffSelected)
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
Text(
|
||||||
|
text = authorIdent.emailAddress,
|
||||||
|
color = MaterialTheme.colors.secondaryTextColor,
|
||||||
|
maxLines = 1,
|
||||||
|
fontSize = 12.sp,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,11 +9,13 @@ import androidx.compose.animation.fadeOut
|
|||||||
import androidx.compose.foundation.*
|
import androidx.compose.foundation.*
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.lazy.itemsIndexed
|
import androidx.compose.foundation.lazy.itemsIndexed
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.*
|
import androidx.compose.material.*
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.ExperimentalComposeUiApi
|
import androidx.compose.ui.ExperimentalComposeUiApi
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.RectangleShape
|
import androidx.compose.ui.graphics.RectangleShape
|
||||||
import androidx.compose.ui.input.pointer.pointerMoveFilter
|
import androidx.compose.ui.input.pointer.pointerMoveFilter
|
||||||
@ -127,7 +129,7 @@ fun UncommitedChanges(
|
|||||||
value = commitMessage,
|
value = commitMessage,
|
||||||
onValueChange = { commitMessage = it },
|
onValueChange = { commitMessage = it },
|
||||||
label = { Text("Write your commit message here", fontSize = 14.sp) },
|
label = { Text("Write your commit message here", fontSize = 14.sp) },
|
||||||
colors = TextFieldDefaults.textFieldColors(backgroundColor = MaterialTheme.colors.surface),
|
colors = TextFieldDefaults.textFieldColors(backgroundColor = MaterialTheme.colors.background),
|
||||||
textStyle = TextStyle.Default.copy(fontSize = 14.sp)
|
textStyle = TextStyle.Default.copy(fontSize = 14.sp)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -166,63 +168,65 @@ private fun EntriesList(
|
|||||||
onAllAction: () -> Unit,
|
onAllAction: () -> Unit,
|
||||||
allActionTitle: String,
|
allActionTitle: String,
|
||||||
) {
|
) {
|
||||||
|
Column(
|
||||||
Card(
|
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
) {
|
) {
|
||||||
Column {
|
Box {
|
||||||
Box {
|
Text(
|
||||||
|
modifier = Modifier
|
||||||
|
.background(color = MaterialTheme.colors.headerBackground)
|
||||||
|
.padding(vertical = 8.dp)
|
||||||
|
.fillMaxWidth(),
|
||||||
|
text = title,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
textAlign = TextAlign.Center,
|
||||||
|
color = MaterialTheme.colors.headerText,
|
||||||
|
fontSize = 14.sp,
|
||||||
|
maxLines = 1,
|
||||||
|
)
|
||||||
|
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(horizontal = 16.dp)
|
||||||
|
.align(Alignment.CenterEnd)
|
||||||
|
.clip(RoundedCornerShape(5.dp))
|
||||||
|
.background(actionColor)
|
||||||
|
.clickable { onAllAction() },
|
||||||
|
) {
|
||||||
Text(
|
Text(
|
||||||
modifier = Modifier
|
text = allActionTitle,
|
||||||
.background(color = MaterialTheme.colors.headerBackground)
|
fontSize = 12.sp,
|
||||||
.padding(vertical = 8.dp)
|
color = MaterialTheme.colors.contentColorFor(actionColor),
|
||||||
.fillMaxWidth(),
|
modifier = Modifier.padding(vertical = 4.dp, horizontal = 16.dp)
|
||||||
text = title,
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
textAlign = TextAlign.Center,
|
|
||||||
color = MaterialTheme.colors.headerText,
|
|
||||||
fontSize = 14.sp,
|
|
||||||
maxLines = 1,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
Button(
|
|
||||||
onClick = onAllAction,
|
|
||||||
modifier = Modifier
|
|
||||||
.padding(horizontal = 16.dp)
|
|
||||||
.align(Alignment.CenterEnd),
|
|
||||||
elevation = ButtonDefaults.elevation(0.dp, 0.dp, 0.dp),
|
|
||||||
colors = ButtonDefaults.buttonColors(backgroundColor = actionColor)
|
|
||||||
) {
|
|
||||||
Text(allActionTitle, fontSize = 10.sp)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollableLazyColumn(
|
}
|
||||||
modifier = Modifier.fillMaxSize(),
|
|
||||||
) {
|
|
||||||
itemsIndexed(diffEntries) { index, diffEntry ->
|
|
||||||
FileEntry(
|
|
||||||
diffEntry = diffEntry,
|
|
||||||
actionTitle = actionTitle,
|
|
||||||
actionColor = actionColor,
|
|
||||||
onClick = {
|
|
||||||
onDiffEntrySelected(diffEntry)
|
|
||||||
},
|
|
||||||
onButtonClick = {
|
|
||||||
onDiffEntryOptionSelected(diffEntry)
|
|
||||||
},
|
|
||||||
onReset = {
|
|
||||||
onReset(diffEntry)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
if (index < diffEntries.size - 1) {
|
ScrollableLazyColumn(
|
||||||
Divider(modifier = Modifier.fillMaxWidth())
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.background(MaterialTheme.colors.background),
|
||||||
|
) {
|
||||||
|
itemsIndexed(diffEntries) { index, diffEntry ->
|
||||||
|
FileEntry(
|
||||||
|
diffEntry = diffEntry,
|
||||||
|
actionTitle = actionTitle,
|
||||||
|
actionColor = actionColor,
|
||||||
|
onClick = {
|
||||||
|
onDiffEntrySelected(diffEntry)
|
||||||
|
},
|
||||||
|
onButtonClick = {
|
||||||
|
onDiffEntryOptionSelected(diffEntry)
|
||||||
|
},
|
||||||
|
onReset = {
|
||||||
|
onReset(diffEntry)
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
if (index < diffEntries.size - 1) {
|
||||||
|
Divider(modifier = Modifier.fillMaxWidth())
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user