status-react/src/react_native/safe_area.cljs

33 lines
689 B
Plaintext
Raw Normal View History

2022-11-08 17:30:17 +00:00
(ns react-native.safe-area
(: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
[]
(some-> StaticSafeAreaInsets
(oops/oget "safeAreaInsetsBottom")))
2023-04-25 13:13:14 +00:00
(defn get-top
[]
(if platform/ios?
(get-static-top)
(navigation/status-bar-height)))
(defn get-bottom
[]
(if-let [bottom (and platform/ios? (get-static-bottom))]
bottom
2023-04-25 13:13:14 +00:00
0))
2023-04-25 13:13:14 +00:00
(defn get-insets
[]
2023-04-25 13:13:14 +00:00
{:top (get-top)
:bottom (get-bottom)})