2022-11-08 17:30:17 +00:00
|
|
|
(ns react-native.safe-area
|
2022-12-20 14:45:37 +00:00
|
|
|
(:require ["react-native-safe-area-context" :as safe-area-context :refer
|
|
|
|
(SafeAreaProvider SafeAreaInsetsContext)]
|
2022-11-08 17:30:17 +00:00
|
|
|
[reagent.core :as reagent]))
|
|
|
|
|
|
|
|
(def ^:private consumer-raw (reagent/adapt-react-class (.-Consumer ^js SafeAreaInsetsContext)))
|
|
|
|
|
2022-12-20 14:45:37 +00:00
|
|
|
(defn consumer
|
|
|
|
[component]
|
2022-11-08 17:30:17 +00:00
|
|
|
[consumer-raw
|
2022-12-16 13:45:00 +00:00
|
|
|
(fn [^js insets]
|
2022-11-08 17:30:17 +00:00
|
|
|
(reagent/as-element
|
|
|
|
[component (js->clj insets :keywordize-keys true)]))])
|
2022-11-14 18:16:55 +00:00
|
|
|
|
|
|
|
(def safe-area-provider (reagent/adapt-react-class SafeAreaProvider))
|
|
|
|
(def safe-area-consumer consumer-raw)
|