diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/ui/Menu.kt b/src/main/kotlin/com/jetpackduba/gitnuro/ui/Menu.kt index c00b8bb..d49816d 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/ui/Menu.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/ui/Menu.kt @@ -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 diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/ui/SidePanel.kt b/src/main/kotlin/com/jetpackduba/gitnuro/ui/SidePanel.kt index 923f6d5..a8f81be 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/ui/SidePanel.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/ui/SidePanel.kt @@ -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, diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/ui/components/RepositoriesTabPanel.kt b/src/main/kotlin/com/jetpackduba/gitnuro/ui/components/RepositoriesTabPanel.kt index 31d28d2..d5acf35 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/ui/components/RepositoriesTabPanel.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/ui/components/RepositoriesTabPanel.kt @@ -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( diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/ui/components/TooltipText.kt b/src/main/kotlin/com/jetpackduba/gitnuro/ui/components/TooltipText.kt index 093d1e2..16b0d07 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/ui/components/TooltipText.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/ui/components/TooltipText.kt @@ -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( diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/ui/components/Tooltip.kt b/src/main/kotlin/com/jetpackduba/gitnuro/ui/components/tooltip/DelayedTooltip.kt similarity index 89% rename from src/main/kotlin/com/jetpackduba/gitnuro/ui/components/Tooltip.kt rename to src/main/kotlin/com/jetpackduba/gitnuro/ui/components/tooltip/DelayedTooltip.kt index 2c6bd1d..233bd77 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/ui/components/Tooltip.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/ui/components/tooltip/DelayedTooltip.kt @@ -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 = { diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/ui/components/InstantTooltip.kt b/src/main/kotlin/com/jetpackduba/gitnuro/ui/components/tooltip/InstantTooltip.kt similarity index 98% rename from src/main/kotlin/com/jetpackduba/gitnuro/ui/components/InstantTooltip.kt rename to src/main/kotlin/com/jetpackduba/gitnuro/ui/components/tooltip/InstantTooltip.kt index 3fc2368..1f98fed 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/ui/components/InstantTooltip.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/ui/components/tooltip/InstantTooltip.kt @@ -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) ) } - } } } diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/ui/dialogs/ErrorDialog.kt b/src/main/kotlin/com/jetpackduba/gitnuro/ui/dialogs/ErrorDialog.kt index d58b1f0..6db57b8 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/ui/dialogs/ErrorDialog.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/ui/dialogs/ErrorDialog.kt @@ -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( } } } -} \ No newline at end of file +} + +fun copyMessageError(clipboard: ClipboardManager, ex: Exception) { + clipboard.setText(AnnotatedString(ex.stackTraceToString())) +} diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/ui/diff/Diff.kt b/src/main/kotlin/com/jetpackduba/gitnuro/ui/diff/Diff.kt index fa1cabc..7eeafd6 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/ui/diff/Diff.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/ui/diff/Diff.kt @@ -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)) diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/ui/log/Log.kt b/src/main/kotlin/com/jetpackduba/gitnuro/ui/log/Log.kt index 4246e7c..103d3a9 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/ui/log/Log.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/ui/log/Log.kt @@ -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