Milan Jurkulak преди 3 години
родител
ревизия
b2753a5bb5
променени са 1 файла, в които са добавени 14 реда и са изтрити 4 реда
  1. 14 4
      tvlib/src/main/kotlin/org/mjdev/tvlib/ui/components/gallery/Gallery.kt

+ 14 - 4
tvlib/src/main/kotlin/org/mjdev/tvlib/ui/components/gallery/Gallery.kt

@@ -131,6 +131,7 @@ fun Gallery(
         }
     },
     listState: TvLazyListState = rememberTvLazyListState(),
+    imageScaleType: MutableState<ContentScale> = remember { mutableStateOf(ContentScale.Fit) },
     customOverlay: @Composable (item: Any?) -> Unit = {}
 ) {
     val initialized = remember { mutableStateOf(false) }
@@ -153,15 +154,24 @@ fun Gallery(
                     ImageAny(
                         src = imageFromItem(currentItemIndex.intValue),
                         contentDescription = null,
-                        contentScale = ContentScale.Fit,
+                        contentScale = imageScaleType.value,
                         modifier = Modifier
                             .fillMaxSize()
                             .focusable()
                             .focusRequester(focusRequester)
                             .pointerInput(Unit) {
-                                detectTapGestures {
-                                    infoVisible.toggle()
-                                }
+                                detectTapGestures(
+                                    onDoubleTap = {
+                                        imageScaleType.value = when (imageScaleType.value) {
+                                            ContentScale.Fit -> ContentScale.Crop
+                                            ContentScale.Crop -> ContentScale.Fit
+                                            else -> ContentScale.Fit
+                                        }
+                                    },
+                                    onTap = {
+                                        infoVisible.toggle()
+                                    }
+                                )
                             }
                             .pointerInput(Unit) {
                                 detectSwipe(