Skip to content

Commit a1cc489

Browse files
committed
Move long press menu drag handle to its own composable
1 parent 62a400b commit a1cc489

1 file changed

Lines changed: 29 additions & 25 deletions

File tree

app/src/main/java/org/schabi/newpipe/ui/components/menu/LongPressMenu.kt

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -115,31 +115,7 @@ fun LongPressMenu(
115115
ModalBottomSheet(
116116
onDismissRequest,
117117
sheetState = sheetState,
118-
dragHandle = {
119-
Box(
120-
modifier = Modifier.fillMaxWidth()
121-
) {
122-
BottomSheetDefaults.DragHandle(
123-
modifier = Modifier.align(Alignment.Center)
124-
)
125-
IconButton(
126-
onClick = onEditActions,
127-
modifier = Modifier.align(Alignment.CenterEnd)
128-
) {
129-
// show a small button here, it's not an important button and it shouldn't
130-
// capture the user attention
131-
Icon(
132-
imageVector = Icons.Default.Settings,
133-
contentDescription = stringResource(R.string.edit),
134-
// same color and height as the DragHandle
135-
tint = MaterialTheme.colorScheme.onSurfaceVariant,
136-
modifier = Modifier
137-
.padding(2.dp)
138-
.size(16.dp),
139-
)
140-
}
141-
}
142-
},
118+
dragHandle = { LongPressMenuDragHandle(onEditActions) },
143119
) {
144120
BoxWithConstraints(
145121
modifier = Modifier
@@ -202,6 +178,34 @@ fun LongPressMenu(
202178
}
203179
}
204180

181+
@Preview
182+
@Composable
183+
fun LongPressMenuDragHandle(onEditActions: () -> Unit = {}) {
184+
Box(
185+
modifier = Modifier.fillMaxWidth()
186+
) {
187+
BottomSheetDefaults.DragHandle(
188+
modifier = Modifier.align(Alignment.Center)
189+
)
190+
IconButton(
191+
onClick = onEditActions,
192+
modifier = Modifier.align(Alignment.CenterEnd)
193+
) {
194+
// show a small button here, it's not an important button and it shouldn't
195+
// capture the user attention
196+
Icon(
197+
imageVector = Icons.Default.Settings,
198+
contentDescription = stringResource(R.string.edit),
199+
// same color and height as the DragHandle
200+
tint = MaterialTheme.colorScheme.onSurfaceVariant,
201+
modifier = Modifier
202+
.padding(2.dp)
203+
.size(16.dp),
204+
)
205+
}
206+
}
207+
}
208+
205209
@Composable
206210
fun LongPressMenuHeader(
207211
item: LongPressable,

0 commit comments

Comments
 (0)