Changed log to use the new design

This commit is contained in:
Abdelilah El Aissaoui 2021-11-26 05:32:14 +01:00
parent b394d9f33b
commit a89317305e

View file

@ -1,10 +1,7 @@
package app.ui package app.ui
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
@ -33,67 +30,68 @@ fun Diff(gitManager: GitManager, diffEntryType: DiffEntryType, onCloseDiffView:
text = gitManager.diffFormat(diffEntryType) text = gitManager.diffFormat(diffEntryType)
} }
Column(
Card(
modifier = Modifier modifier = Modifier
.padding(8.dp) .padding(8.dp)
.background(MaterialTheme.colors.surface) .background(MaterialTheme.colors.background)
.fillMaxSize() .fillMaxSize()
) { ) {
Column { OutlinedButton(
OutlinedButton( modifier = Modifier
.padding(vertical = 16.dp, horizontal = 16.dp)
.align(Alignment.End),
onClick = onCloseDiffView,
colors = ButtonDefaults.buttonColors(
backgroundColor = MaterialTheme.colors.background,
contentColor = MaterialTheme.colors.primary,
)
) {
Text("Close diff")
}
SelectionContainer {
ScrollableLazyColumn(
modifier = Modifier modifier = Modifier
.padding(vertical = 16.dp, horizontal = 16.dp) .fillMaxSize()
.align(Alignment.End), .padding(16.dp)
onClick = onCloseDiffView,
) { ) {
Text("Close diff") items(text) { line ->
} val isHunkLine = line.startsWith("@@")
SelectionContainer {
ScrollableLazyColumn(
modifier = Modifier
.fillMaxSize()
.padding(16.dp)
) {
items(text) { line ->
val isHunkLine = line.startsWith("@@") && line.endsWith("@@")
val backgroundColor = when { val backgroundColor = when {
line.startsWith("+") -> { line.startsWith("+") -> {
Color(0x77a9d49b) Color(0x77a9d49b)
} }
line.startsWith("-") -> { line.startsWith("-") -> {
Color(0x77dea2a2) Color(0x77dea2a2)
} }
isHunkLine -> { isHunkLine -> {
MaterialTheme.colors.background MaterialTheme.colors.surface
} }
else -> { else -> {
MaterialTheme.colors.surface MaterialTheme.colors.background
}
} }
val paddingTop = if (isHunkLine)
32.dp
else
0.dp
Text(
text = line,
modifier = Modifier
.padding(top = paddingTop)
.background(backgroundColor)
.fillMaxWidth(),
color = MaterialTheme.colors.primaryTextColor,
maxLines = 1,
fontFamily = FontFamily.Monospace,
fontSize = 14.sp,
)
} }
val paddingTop = if (isHunkLine)
32.dp
else
0.dp
Text(
text = line,
modifier = Modifier
.padding(top = paddingTop)
.background(backgroundColor)
.fillMaxWidth(),
color = MaterialTheme.colors.primaryTextColor,
maxLines = 1,
fontFamily = FontFamily.Monospace,
fontSize = 14.sp,
)
} }
} }
} }
} }
} }