status-react/src/react_native/safe_area.cljs

16 lines
508 B
Plaintext
Raw Normal View History

2022-11-08 17:30:17 +00:00
(ns react-native.safe-area
(: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)))
(def provider (reagent/adapt-react-class SafeAreaProvider))
(defn consumer
[component]
2022-11-08 17:30:17 +00:00
[consumer-raw
(fn [^js insets]
2022-11-08 17:30:17 +00:00
(reagent/as-element
[component (js->clj insets :keywordize-keys true)]))])