Skip to content

Commit

Permalink
ui: if it's bookmark folder, don't show open tab function in context …
Browse files Browse the repository at this point in the history
…menu
  • Loading branch information
plateaukao committed Nov 16, 2024
1 parent 2abca12 commit 19d6620
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class BookmarkContextMenuDlgFragment(
composeView.setContent {
MyTheme {
BookmarkContextMenuScreen(
title = bookmark.title,
bookmark = bookmark,
allowEdit = allowEdit,
onClicked = { onClicked(it); dismiss() })
}
Expand Down Expand Up @@ -76,18 +76,18 @@ class BookmarkContextMenuDlgFragment(

@Composable
fun BookmarkContextMenuScreen(
title: String,
bookmark: Bookmark,
allowEdit: Boolean = true,
onClicked: (ContextMenuItemType) -> Unit,
) {
Column(
modifier = Modifier
.wrapContentHeight()
.width(320.dp),
.width(if (bookmark.isDirectory) 200.dp else 320.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(
text = title,
text = bookmark.title,
Modifier.padding(4.dp),
color = MaterialTheme.colors.onBackground,
overflow = TextOverflow.Ellipsis,
Expand All @@ -99,14 +99,16 @@ fun BookmarkContextMenuScreen(
.width(IntrinsicSize.Max)
.horizontalScroll(rememberScrollState()),
) {
ContextMenuItem(R.string.main_menu_new_tabOpen, true, Icons.Outlined.Tab) {
onClicked(ContextMenuItemType.NewTabForeground)
}
ContextMenuItem(R.string.main_menu_new_tab, true, Icons.Outlined.TabUnselected) {
onClicked(ContextMenuItemType.NewTabBackground)
}
ContextMenuItem(R.string.split_screen, true, Icons.Outlined.ViewStream) {
onClicked(ContextMenuItemType.SplitScreen)
if (!bookmark.isDirectory) {
ContextMenuItem(R.string.main_menu_new_tabOpen, true, Icons.Outlined.Tab) {
onClicked(ContextMenuItemType.NewTabForeground)
}
ContextMenuItem(R.string.main_menu_new_tab, true, Icons.Outlined.TabUnselected) {
onClicked(ContextMenuItemType.NewTabBackground)
}
ContextMenuItem(R.string.split_screen, true, Icons.Outlined.ViewStream) {
onClicked(ContextMenuItemType.SplitScreen)
}
}
if (allowEdit) {
ContextMenuItem(R.string.menu_edit, true, Icons.Outlined.Edit) { onClicked(ContextMenuItemType.Edit) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,26 +312,26 @@ fun BookmarkList(
shouldShowDragHandle = shouldShowDragHandle,
dragModifier = Modifier.draggableHandle(),
modifier = Modifier.then(
if (shouldShowDragHandle) {
Modifier
.longPressDraggableHandle()
.clickable(
interactionSource = interactionSource,
indication = null,
) { onBookmarkClick(bookmark) }
} else {
Modifier.pointerInput(Unit) {
detectTapGestures(
onTap = { offset -> onBookmarkClick(bookmark) },
onLongPress = { offset ->
longClickPosition.value = offset
onBookmarkLongClick(bookmark, offset.toScreenPoint(boxPosition.value))
}
)
if (shouldShowDragHandle) {
Modifier
.longPressDraggableHandle()
.clickable(
interactionSource = interactionSource,
indication = null,
) { onBookmarkClick(bookmark) }
} else {
Modifier.pointerInput(Unit) {
detectTapGestures(
onTap = { offset -> onBookmarkClick(bookmark) },
onLongPress = { offset ->
longClickPosition.value = offset
onBookmarkLongClick(bookmark, offset.toScreenPoint(boxPosition.value))
}
)
}
.onGloballyPositioned { boxPosition.value = it.positionOnScreen() }
}
.onGloballyPositioned { boxPosition.value = it.positionOnScreen() }
}
),
),
iconClick = {
if (!bookmark.isDirectory) onBookmarkIconClick(bookmark)
else onBookmarkClick(bookmark)
Expand Down

0 comments on commit 19d6620

Please sign in to comment.