diff options
author | Samuel Newman <mozzius@protonmail.com> | 2024-10-15 21:57:28 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-15 21:57:28 +0300 |
commit | c3d0cc55d98fb32b25cd2164cfa1c399985e7c84 (patch) | |
tree | 6a06ca7ec00e6c7143002fa1762bc5e08f858d4e /modules | |
parent | fe5eb507ca693e4db9ca1317b522765a513fea8c (diff) | |
download | voidsky-c3d0cc55d98fb32b25cd2164cfa1c399985e7c84.tar.zst |
Edit profile dialog ALF refresh (#5633)
Diffstat (limited to 'modules')
-rw-r--r-- | modules/bottom-sheet/android/src/main/java/expo/modules/bottomsheet/BottomSheetView.kt | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/modules/bottom-sheet/android/src/main/java/expo/modules/bottomsheet/BottomSheetView.kt b/modules/bottom-sheet/android/src/main/java/expo/modules/bottomsheet/BottomSheetView.kt index cfc89f5b3..56b5b3f05 100644 --- a/modules/bottom-sheet/android/src/main/java/expo/modules/bottomsheet/BottomSheetView.kt +++ b/modules/bottom-sheet/android/src/main/java/expo/modules/bottomsheet/BottomSheetView.kt @@ -1,6 +1,7 @@ package expo.modules.bottomsheet import android.content.Context +import android.util.DisplayMetrics import android.view.View import android.view.ViewGroup import android.view.ViewStructure @@ -17,7 +18,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialog import expo.modules.kotlin.AppContext import expo.modules.kotlin.viewevent.EventDispatcher import expo.modules.kotlin.views.ExpoView -import java.util.ArrayList + class BottomSheetView( context: Context, @@ -58,17 +59,18 @@ class BottomSheetView( if (value < 0) { 0f } else { - value + dpToPx(value) } } var maxHeight = this.screenHeight set(value) { + val px = dpToPx(value) field = - if (value > this.screenHeight) { - this.screenHeight.toFloat() + if (px > this.screenHeight) { + this.screenHeight } else { - value + px } } @@ -175,7 +177,7 @@ class BottomSheetView( behavior.isDraggable = true behavior.isHideable = true - if (contentHeight > this.screenHeight) { + if (contentHeight >= this.screenHeight || this.minHeight >= this.screenHeight) { behavior.state = BottomSheetBehavior.STATE_EXPANDED this.selectedSnapPoint = 2 } else { @@ -332,4 +334,11 @@ class BottomSheetView( override fun addChildrenForAccessibility(outChildren: ArrayList<View>?) { } override fun dispatchPopulateAccessibilityEvent(event: AccessibilityEvent?): Boolean = false + + // https://stackoverflow.com/questions/11862391/getheight-px-or-dpi + fun dpToPx(dp: Float): Float { + val displayMetrics = context.resources.displayMetrics + val px = dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT) + return px + } } |