react-native-unistyles 2.8.0-beta.3 → 2.8.0-beta.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,13 +10,13 @@ import kotlin.math.max
10
10
 
11
11
  class Platform(private val reactApplicationContext: ReactApplicationContext) {
12
12
  private val displayMetrics: DisplayMetrics = reactApplicationContext.resources.displayMetrics
13
- private val density: Float = reactApplicationContext.resources.displayMetrics.density
14
13
  private var insetsCompat: InsetsCompat = InsetsCompat.getDefaults()
15
14
 
16
15
  var defaultNavigationBarColor: Int? = null
17
16
  var defaultStatusBarColor: Int? = null
18
17
 
19
18
  fun getScreenDimensions(): Dimensions {
19
+ val density = reactApplicationContext.resources.displayMetrics.density
20
20
  val screenWidth = (displayMetrics.widthPixels / density).toInt()
21
21
  val screenHeight = (displayMetrics.heightPixels / density).toInt()
22
22
 
@@ -36,12 +36,14 @@ class Platform(private val reactApplicationContext: ReactApplicationContext) {
36
36
  }
37
37
 
38
38
  fun getStatusBarDimensions(): Dimensions {
39
+ val density = reactApplicationContext.resources.displayMetrics.density
39
40
  val screenWidth = (displayMetrics.widthPixels / density).toInt()
40
41
 
41
42
  return Dimensions(screenWidth, getStatusBarHeight())
42
43
  }
43
44
 
44
45
  fun getNavigationBarDimensions(): Dimensions {
46
+ val density = reactApplicationContext.resources.displayMetrics.density
45
47
  val screenWidth = (displayMetrics.widthPixels / density).toInt()
46
48
 
47
49
  return Dimensions(screenWidth, getNavigationBarHeight())
@@ -84,6 +86,7 @@ class Platform(private val reactApplicationContext: ReactApplicationContext) {
84
86
  }
85
87
 
86
88
  fun getInsets(): Insets {
89
+ val density = reactApplicationContext.resources.displayMetrics.density
87
90
  val top = max(this.insetsCompat.cutout.top, this.insetsCompat.statusBar.top)
88
91
  val bottom = this.insetsCompat.navigationBar.bottom
89
92
  val left = this.insetsCompat.statusBar.left
@@ -98,10 +101,14 @@ class Platform(private val reactApplicationContext: ReactApplicationContext) {
98
101
  }
99
102
 
100
103
  private fun getStatusBarHeight(): Int {
104
+ val density = reactApplicationContext.resources.displayMetrics.density
105
+
101
106
  return (this.insetsCompat.statusBar.top / density).toInt()
102
107
  }
103
108
 
104
109
  private fun getNavigationBarHeight(): Int {
110
+ val density = reactApplicationContext.resources.displayMetrics.density
111
+
105
112
  return (this.insetsCompat.navigationBar.bottom / density).toInt()
106
113
  }
107
114
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "2.8.0-beta.3",
3
+ "version": "2.8.0-beta.4",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "jest",