Changed author info to show commit id instead of mail
E-mail is shown as a tooltip of the username
This commit is contained in:
parent
2a8794d62d
commit
3c3b044c80
@ -11,7 +11,6 @@ import androidx.compose.ui.Alignment
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.graphics.ImageBitmap
|
import androidx.compose.ui.graphics.ImageBitmap
|
||||||
import androidx.compose.ui.graphics.asImageBitmap
|
|
||||||
import androidx.compose.ui.res.useResource
|
import androidx.compose.ui.res.useResource
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
@ -35,6 +34,7 @@ import app.git.GitManager
|
|||||||
import app.images.ImagesCache
|
import app.images.ImagesCache
|
||||||
import app.images.InMemoryImagesCache
|
import app.images.InMemoryImagesCache
|
||||||
import app.theme.headerText
|
import app.theme.headerText
|
||||||
|
import app.ui.components.TooltipText
|
||||||
import org.eclipse.jgit.lib.PersonIdent
|
import org.eclipse.jgit.lib.PersonIdent
|
||||||
import org.jetbrains.skia.Image.Companion.makeFromEncoded
|
import org.jetbrains.skia.Image.Companion.makeFromEncoded
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ fun CommitChanges(
|
|||||||
|
|
||||||
Divider(modifier = Modifier.fillMaxWidth())
|
Divider(modifier = Modifier.fillMaxWidth())
|
||||||
|
|
||||||
Author(commit.authorIdent)
|
Author(commit)
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
@ -105,9 +105,8 @@ fun CommitChanges(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Author(authorIdent: PersonIdent?) {
|
fun Author(commit: RevCommit) {
|
||||||
if(authorIdent == null)
|
val authorIdent = commit.authorIdent
|
||||||
return
|
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@ -132,14 +131,16 @@ fun Author(authorIdent: PersonIdent?) {
|
|||||||
verticalArrangement = Arrangement.Center
|
verticalArrangement = Arrangement.Center
|
||||||
) {
|
) {
|
||||||
Row {
|
Row {
|
||||||
Text(
|
TooltipText(
|
||||||
text = authorIdent.name,
|
text = authorIdent.name,
|
||||||
color = MaterialTheme.colors.primaryTextColor,
|
color = MaterialTheme.colors.primaryTextColor,
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
fontSize = 14.sp,
|
fontSize = 14.sp,
|
||||||
|
tooltipTitle = authorIdent.emailAddress,
|
||||||
)
|
)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.weight(1f, fill = true))
|
Spacer(modifier = Modifier.weight(1f, fill = true))
|
||||||
|
|
||||||
val date = remember(authorIdent) {
|
val date = remember(authorIdent) {
|
||||||
authorIdent.`when`.toSmartSystemString()
|
authorIdent.`when`.toSmartSystemString()
|
||||||
}
|
}
|
||||||
@ -155,7 +156,7 @@ fun Author(authorIdent: PersonIdent?) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = authorIdent.emailAddress,
|
text = commit.id.abbreviate(7).name(),
|
||||||
color = MaterialTheme.colors.secondaryTextColor,
|
color = MaterialTheme.colors.secondaryTextColor,
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
fontSize = 12.sp,
|
fontSize = 12.sp,
|
||||||
|
77
src/main/kotlin/app/ui/components/TooltipText.kt
Normal file
77
src/main/kotlin/app/ui/components/TooltipText.kt
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
package app.ui.components
|
||||||
|
|
||||||
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||||
|
import androidx.compose.foundation.TooltipArea
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.material.Card
|
||||||
|
import androidx.compose.material.LocalTextStyle
|
||||||
|
import androidx.compose.material.MaterialTheme
|
||||||
|
import androidx.compose.material.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.text.TextLayoutResult
|
||||||
|
import androidx.compose.ui.text.TextStyle
|
||||||
|
import androidx.compose.ui.text.font.FontFamily
|
||||||
|
import androidx.compose.ui.text.font.FontStyle
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
|
import androidx.compose.ui.text.style.TextDecoration
|
||||||
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
|
import androidx.compose.ui.unit.TextUnit
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
|
||||||
|
@OptIn(ExperimentalFoundationApi::class)
|
||||||
|
@Composable
|
||||||
|
fun TooltipText(
|
||||||
|
text: String,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
color: Color = Color.Unspecified,
|
||||||
|
fontSize: TextUnit = TextUnit.Unspecified,
|
||||||
|
fontStyle: FontStyle? = null,
|
||||||
|
fontWeight: FontWeight? = null,
|
||||||
|
fontFamily: FontFamily? = null,
|
||||||
|
letterSpacing: TextUnit = TextUnit.Unspecified,
|
||||||
|
textDecoration: TextDecoration? = null,
|
||||||
|
textAlign: TextAlign? = null,
|
||||||
|
lineHeight: TextUnit = TextUnit.Unspecified,
|
||||||
|
overflow: TextOverflow = TextOverflow.Clip,
|
||||||
|
softWrap: Boolean = true,
|
||||||
|
maxLines: Int = Int.MAX_VALUE,
|
||||||
|
onTextLayout: (TextLayoutResult) -> Unit = {},
|
||||||
|
style: TextStyle = LocalTextStyle.current,
|
||||||
|
tooltipTitle: String,
|
||||||
|
) {
|
||||||
|
TooltipArea(
|
||||||
|
tooltip = {
|
||||||
|
Card (
|
||||||
|
backgroundColor = MaterialTheme.colors.background,
|
||||||
|
elevation = 10.dp,
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = tooltipTitle,
|
||||||
|
modifier = Modifier.padding(10.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = text,
|
||||||
|
modifier = modifier,
|
||||||
|
color = color,
|
||||||
|
fontSize = fontSize,
|
||||||
|
fontStyle = fontStyle,
|
||||||
|
fontWeight = fontWeight,
|
||||||
|
fontFamily = fontFamily,
|
||||||
|
letterSpacing = letterSpacing,
|
||||||
|
textDecoration = textDecoration,
|
||||||
|
textAlign = textAlign,
|
||||||
|
lineHeight = lineHeight,
|
||||||
|
overflow = overflow,
|
||||||
|
softWrap = softWrap,
|
||||||
|
maxLines = maxLines,
|
||||||
|
style = style,
|
||||||
|
onTextLayout = onTextLayout,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user