Errors now include the stacktrace
This commit is contained in:
parent
d9bd6fc905
commit
ed86583f58
9 changed files with 89 additions and 16 deletions
|
@ -28,7 +28,7 @@ import com.jetpackduba.gitnuro.extensions.handMouseClickable
|
|||
import com.jetpackduba.gitnuro.extensions.handOnHover
|
||||
import com.jetpackduba.gitnuro.extensions.ignoreKeyEvents
|
||||
import com.jetpackduba.gitnuro.git.remote_operations.PullType
|
||||
import com.jetpackduba.gitnuro.ui.components.InstantTooltip
|
||||
import com.jetpackduba.gitnuro.ui.components.tooltip.InstantTooltip
|
||||
import com.jetpackduba.gitnuro.ui.components.gitnuroViewModel
|
||||
import com.jetpackduba.gitnuro.ui.context_menu.*
|
||||
import com.jetpackduba.gitnuro.viewmodels.MenuViewModel
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.jetpackduba.gitnuro.extensions.isValid
|
|||
import com.jetpackduba.gitnuro.extensions.simpleName
|
||||
import com.jetpackduba.gitnuro.theme.onBackgroundSecondary
|
||||
import com.jetpackduba.gitnuro.ui.components.*
|
||||
import com.jetpackduba.gitnuro.ui.components.tooltip.DelayedTooltip
|
||||
import com.jetpackduba.gitnuro.ui.context_menu.*
|
||||
import com.jetpackduba.gitnuro.ui.dialogs.AddSubmodulesDialog
|
||||
import com.jetpackduba.gitnuro.ui.dialogs.EditRemotesDialog
|
||||
|
@ -597,7 +598,7 @@ private fun Submodule(
|
|||
},
|
||||
) {
|
||||
val stateName = submodule.second.type.toString()
|
||||
Tooltip(stateName) {
|
||||
DelayedTooltip(stateName) {
|
||||
Text(
|
||||
text = stateName.first().toString(),
|
||||
color = MaterialTheme.colors.onBackgroundSecondary,
|
||||
|
|
|
@ -31,6 +31,8 @@ import com.jetpackduba.gitnuro.extensions.handMouseClickable
|
|||
import com.jetpackduba.gitnuro.extensions.handOnHover
|
||||
import com.jetpackduba.gitnuro.extensions.onMiddleMouseButtonClick
|
||||
import com.jetpackduba.gitnuro.managers.AppStateManager
|
||||
import com.jetpackduba.gitnuro.ui.components.tooltip.DelayedTooltip
|
||||
import com.jetpackduba.gitnuro.ui.components.tooltip.InstantTooltip
|
||||
import com.jetpackduba.gitnuro.ui.drag_sorting.HorizontalDraggableItem
|
||||
import com.jetpackduba.gitnuro.ui.drag_sorting.horizontalDragContainer
|
||||
import com.jetpackduba.gitnuro.ui.drag_sorting.rememberHorizontalDragDropState
|
||||
|
@ -80,7 +82,7 @@ fun RepositoriesTabPanel(
|
|||
|
||||
Column {
|
||||
if (canBeScrolled) {
|
||||
Tooltip(
|
||||
DelayedTooltip(
|
||||
"\"Shift + Mouse wheel\" to scroll"
|
||||
) {
|
||||
HorizontalScrollbar(
|
||||
|
|
|
@ -15,6 +15,7 @@ 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 com.jetpackduba.gitnuro.ui.components.tooltip.DelayedTooltip
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
|
@ -37,7 +38,7 @@ fun TooltipText(
|
|||
style: TextStyle = LocalTextStyle.current,
|
||||
tooltipTitle: String,
|
||||
) {
|
||||
Tooltip(
|
||||
DelayedTooltip(
|
||||
text = tooltipTitle,
|
||||
) {
|
||||
Text(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.jetpackduba.gitnuro.ui.components
|
||||
package com.jetpackduba.gitnuro.ui.components.tooltip
|
||||
|
||||
import androidx.compose.foundation.BorderStroke
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
|
@ -15,7 +15,7 @@ import com.jetpackduba.gitnuro.theme.onBackgroundSecondary
|
|||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun Tooltip(text: String?, modifier: Modifier = Modifier, content: @Composable () -> Unit) {
|
||||
fun DelayedTooltip(text: String?, modifier: Modifier = Modifier, content: @Composable () -> Unit) {
|
||||
TooltipArea(
|
||||
modifier = modifier,
|
||||
tooltip = {
|
|
@ -1,4 +1,4 @@
|
|||
package com.jetpackduba.gitnuro.ui.components
|
||||
package com.jetpackduba.gitnuro.ui.components.tooltip
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
|
@ -6,7 +6,6 @@ import androidx.compose.foundation.hoverable
|
|||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.interaction.collectIsHoveredAsState
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
|
@ -104,7 +103,6 @@ fun InstantTooltip(
|
|||
modifier = Modifier.padding(8.dp)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,25 +1,35 @@
|
|||
package com.jetpackduba.gitnuro.ui.dialogs
|
||||
|
||||
import androidx.compose.foundation.*
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.Icon
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.material.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.ClipboardManager
|
||||
import androidx.compose.ui.platform.LocalClipboardManager
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.jetpackduba.gitnuro.AppIcons
|
||||
import com.jetpackduba.gitnuro.extensions.handOnHover
|
||||
import com.jetpackduba.gitnuro.managers.Error
|
||||
import com.jetpackduba.gitnuro.theme.secondarySurface
|
||||
import com.jetpackduba.gitnuro.ui.components.PrimaryButton
|
||||
import com.jetpackduba.gitnuro.ui.components.tooltip.InstantTooltip
|
||||
import kotlinx.coroutines.delay
|
||||
|
||||
@Composable
|
||||
fun ErrorDialog(
|
||||
error: Error,
|
||||
onAccept: () -> Unit,
|
||||
) {
|
||||
val horizontalScroll = rememberScrollState()
|
||||
val verticalScroll = rememberScrollState()
|
||||
val clipboard = LocalClipboardManager.current
|
||||
|
||||
MaterialDialog {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
|
@ -52,6 +62,61 @@ fun ErrorDialog(
|
|||
style = MaterialTheme.typography.body2,
|
||||
)
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.padding(top = 24.dp)
|
||||
.height(400.dp)
|
||||
.fillMaxWidth()
|
||||
) {
|
||||
OutlinedTextField(
|
||||
value = error.exception.stackTraceToString(),
|
||||
onValueChange = {},
|
||||
readOnly = true,
|
||||
colors = TextFieldDefaults.outlinedTextFieldColors(backgroundColor = MaterialTheme.colors.secondarySurface),
|
||||
textStyle = MaterialTheme.typography.body2,
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.horizontalScroll(horizontalScroll)
|
||||
.verticalScroll(verticalScroll),
|
||||
)
|
||||
|
||||
HorizontalScrollbar(
|
||||
rememberScrollbarAdapter(horizontalScroll),
|
||||
modifier = Modifier
|
||||
.align(Alignment.BottomCenter)
|
||||
.fillMaxWidth()
|
||||
)
|
||||
|
||||
VerticalScrollbar(
|
||||
rememberScrollbarAdapter(verticalScroll),
|
||||
modifier = Modifier
|
||||
.align(Alignment.CenterEnd)
|
||||
.fillMaxHeight()
|
||||
)
|
||||
|
||||
InstantTooltip(
|
||||
"Copy error",
|
||||
modifier = Modifier
|
||||
.align(Alignment.BottomEnd)
|
||||
.padding(end = 16.dp, bottom = 16.dp)
|
||||
) {
|
||||
IconButton(
|
||||
onClick = {
|
||||
copyMessageError(clipboard, error.exception)
|
||||
},
|
||||
modifier = Modifier
|
||||
.size(24.dp)
|
||||
.handOnHover()
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(AppIcons.COPY),
|
||||
contentDescription = "Copy stacktrace",
|
||||
tint = MaterialTheme.colors.onSurface,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.align(Alignment.End)
|
||||
|
@ -64,4 +129,8 @@ fun ErrorDialog(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun copyMessageError(clipboard: ClipboardManager, ex: Exception) {
|
||||
clipboard.setText(AnnotatedString(ex.stackTraceToString()))
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ import com.jetpackduba.gitnuro.theme.*
|
|||
import com.jetpackduba.gitnuro.ui.components.PrimaryButton
|
||||
import com.jetpackduba.gitnuro.ui.components.ScrollableLazyColumn
|
||||
import com.jetpackduba.gitnuro.ui.components.SecondaryButton
|
||||
import com.jetpackduba.gitnuro.ui.components.Tooltip
|
||||
import com.jetpackduba.gitnuro.ui.components.tooltip.DelayedTooltip
|
||||
import com.jetpackduba.gitnuro.ui.context_menu.ContextMenu
|
||||
import com.jetpackduba.gitnuro.ui.context_menu.ContextMenuElement
|
||||
import com.jetpackduba.gitnuro.ui.context_menu.CustomTextContextMenu
|
||||
|
@ -945,7 +945,7 @@ fun StateIcon(
|
|||
isToggled: Boolean,
|
||||
onClick: () -> Unit,
|
||||
) {
|
||||
Tooltip(tooltip) {
|
||||
DelayedTooltip(tooltip) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.clip(RoundedCornerShape(4.dp))
|
||||
|
|
|
@ -46,6 +46,8 @@ import com.jetpackduba.gitnuro.keybindings.matchesBinding
|
|||
import com.jetpackduba.gitnuro.theme.*
|
||||
import com.jetpackduba.gitnuro.ui.SelectedItem
|
||||
import com.jetpackduba.gitnuro.ui.components.*
|
||||
import com.jetpackduba.gitnuro.ui.components.tooltip.InstantTooltip
|
||||
import com.jetpackduba.gitnuro.ui.components.tooltip.InstantTooltipPosition
|
||||
import com.jetpackduba.gitnuro.ui.context_menu.*
|
||||
import com.jetpackduba.gitnuro.ui.dialogs.NewBranchDialog
|
||||
import com.jetpackduba.gitnuro.ui.dialogs.NewTagDialog
|
||||
|
|
Loading…
Reference in a new issue