2022-11-08 17:30:17 +00:00
|
|
|
(ns react-native.safe-area
|
2023-10-16 22:03:18 +00:00
|
|
|
(:require
|
|
|
|
["react-native-static-safe-area-insets" :default StaticSafeAreaInsets]
|
|
|
|
[oops.core :as oops]
|
|
|
|
[react-native.navigation :as navigation]
|
|
|
|
[react-native.platform :as platform]))
|
2022-11-08 17:30:17 +00:00
|
|
|
|
2023-04-25 13:13:14 +00:00
|
|
|
(defn- get-static-top
|
|
|
|
[]
|
|
|
|
(oops/oget StaticSafeAreaInsets "safeAreaInsetsTop"))
|
2022-11-08 17:30:17 +00:00
|
|
|
|
2023-04-25 13:13:14 +00:00
|
|
|
(defn- get-static-bottom
|
|
|
|
[]
|
2023-07-04 23:08:47 +00:00
|
|
|
(some-> StaticSafeAreaInsets
|
|
|
|
(oops/oget "safeAreaInsetsBottom")))
|
2023-01-16 16:20:10 +00:00
|
|
|
|
2023-04-25 13:13:14 +00:00
|
|
|
(defn get-top
|
|
|
|
[]
|
|
|
|
(if platform/ios?
|
|
|
|
(get-static-top)
|
|
|
|
(navigation/status-bar-height)))
|
|
|
|
|
|
|
|
(defn get-bottom
|
|
|
|
[]
|
2023-07-04 23:08:47 +00:00
|
|
|
(if-let [bottom (and platform/ios? (get-static-bottom))]
|
|
|
|
bottom
|
2023-04-25 13:13:14 +00:00
|
|
|
0))
|
2023-03-14 04:24:14 +00:00
|
|
|
|
2023-04-25 13:13:14 +00:00
|
|
|
(defn get-insets
|
2023-03-14 04:24:14 +00:00
|
|
|
[]
|
2023-04-25 13:13:14 +00:00
|
|
|
{:top (get-top)
|
|
|
|
:bottom (get-bottom)})
|