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