Skip to content

Commit 0726afc

Browse files
Add left action to gallery picker
1 parent efe1d58 commit 0726afc

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

gallery-picker/src/main/kotlin/run/nabla/gallerypicker/picker/GalleryHeader.kt

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,46 @@ fun GalleryHeader(
2828
title: String = DEFAULT_HEADER_TITLE,
2929
titleSize: Int = DEFAULT_HEADER_TITLE_SIZE,
3030
titleColor: Long = Color.White.value.toLong(),
31-
actionIcon: ImageVector = Icons.Default.Close,
31+
rightActionIcon: ImageVector = Icons.Default.Close,
32+
leftActionIcon: ImageVector = Icons.Default.Close,
3233
paddingVertical: Int = DEFAULT_HEADER_PADDING_VERTICAL,
3334
paddingHorizontal: Int = DEFAULT_HEADER_PADDING_HORIZONTAL,
35+
verticalAlignment: Alignment.Vertical = Alignment.CenterVertically,
36+
onRightActionClick: (() -> Unit)? = null,
3437
onLeftActionClick: (() -> Unit)? = null
3538
) {
3639
if (title.isEmpty()) return
3740
Row(
3841
modifier = modifier
3942
.fillMaxWidth()
4043
.padding(vertical = paddingVertical.dp, horizontal = paddingHorizontal.dp),
41-
verticalAlignment = Alignment.CenterVertically
44+
verticalAlignment = verticalAlignment
4245
) {
46+
onLeftActionClick?.let {
47+
Icon(
48+
modifier = Modifier.clickable {
49+
onLeftActionClick()
50+
},
51+
imageVector = leftActionIcon,
52+
contentDescription = "",
53+
tint = Color(titleColor.toULong())
54+
)
55+
}
4356
Text(
44-
modifier = Modifier.weight(1f),
57+
modifier = Modifier
58+
.weight(1f)
59+
.padding(horizontal = 10.dp),
4560
text = title,
4661
color = Color(titleColor.toULong()),
4762
fontSize = titleSize.sp,
4863
fontWeight = FontWeight.Bold
4964
)
50-
onLeftActionClick?.let {
65+
onRightActionClick?.let {
5166
Icon(
5267
modifier = Modifier.clickable {
53-
onLeftActionClick()
68+
onRightActionClick()
5469
},
55-
imageVector = actionIcon,
70+
imageVector = rightActionIcon,
5671
contentDescription = "",
5772
tint = Color(titleColor.toULong())
5873
)

gallery-picker/src/main/kotlin/run/nabla/gallerypicker/picker/GalleryPicker.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ fun GalleryPicker(
3939
state: GalleryPickerState = rememberGalleryPickerState(),
4040
permissionState: RequestPermissionState = rememberRequestPermissionState(),
4141
backgroundColor: Color = Color.Black,
42-
header: @Composable () -> Unit = { GalleryHeader() },
42+
header: @Composable () -> Unit = {
43+
GalleryHeader(
44+
onLeftActionClick = {}
45+
)
46+
},
4347
onImageSelected: (Uri) -> Unit,
4448
) {
4549
val context = LocalContext.current

0 commit comments

Comments
 (0)