2022-11-08 18:30:17 +01:00
|
|
|
(ns react-native.core
|
|
|
|
(:require [reagent.core :as reagent]
|
|
|
|
["react-native" :as react-native]
|
2022-11-28 10:24:31 +00:00
|
|
|
["@react-native-community/blur" :as blur]
|
2022-11-21 16:03:49 +04:00
|
|
|
[react-native.flat-list :as flat-list]
|
2022-12-05 14:22:06 +01:00
|
|
|
[react-native.section-list :as section-list]
|
|
|
|
[react-native.platform :as platform]))
|
2022-11-08 18:30:17 +01:00
|
|
|
|
2022-11-14 19:16:55 +01:00
|
|
|
(def app-state ^js (.-AppState ^js react-native))
|
2022-11-28 10:24:31 +00:00
|
|
|
(def blur-view (reagent/adapt-react-class (.-BlurView blur)))
|
2022-11-14 19:16:55 +01:00
|
|
|
|
2022-11-08 18:30:17 +01:00
|
|
|
(def view (reagent/adapt-react-class (.-View ^js react-native)))
|
|
|
|
(def scroll-view (reagent/adapt-react-class (.-ScrollView ^js react-native)))
|
|
|
|
(def image (reagent/adapt-react-class (.-Image ^js react-native)))
|
|
|
|
(def text (reagent/adapt-react-class (.-Text ^js react-native)))
|
2022-11-21 16:03:49 +04:00
|
|
|
(def text-input (reagent/adapt-react-class (.-TextInput ^js react-native)))
|
2022-11-08 18:30:17 +01:00
|
|
|
|
|
|
|
(def touchable-opacity (reagent/adapt-react-class (.-TouchableOpacity ^js react-native)))
|
|
|
|
(def touchable-highlight (reagent/adapt-react-class (.-TouchableHighlight ^js react-native)))
|
|
|
|
(def touchable-without-feedback (reagent/adapt-react-class (.-TouchableWithoutFeedback ^js react-native)))
|
|
|
|
|
|
|
|
(def flat-list flat-list/flat-list)
|
|
|
|
|
2022-11-21 16:03:49 +04:00
|
|
|
(def section-list section-list/section-list)
|
|
|
|
|
2022-11-10 09:10:43 +01:00
|
|
|
(def activity-indicator (reagent/adapt-react-class (.-ActivityIndicator ^js react-native)))
|
|
|
|
|
2022-11-08 18:30:17 +01:00
|
|
|
(def modal (reagent/adapt-react-class (.-Modal ^js react-native)))
|
|
|
|
|
|
|
|
(def keyboard ^js (.-Keyboard ^js react-native))
|
|
|
|
|
|
|
|
(def dismiss-keyboard! #(.dismiss keyboard))
|
|
|
|
|
|
|
|
(defn use-window-dimensions []
|
|
|
|
(let [window ^js (react-native/useWindowDimensions)]
|
|
|
|
{:font-scale (.-fontScale window)
|
|
|
|
:height (.-height window)
|
|
|
|
:scale (.-scale window)
|
2022-11-14 19:16:55 +01:00
|
|
|
:width (.-width window)}))
|
|
|
|
|
|
|
|
(defn hide-splash-screen []
|
|
|
|
(.hide ^js (-> react-native .-NativeModules .-SplashScreen)))
|
|
|
|
|
|
|
|
(defn alert [title message buttons options]
|
|
|
|
(.alert (.-Alert ^js react-native) title message (clj->js buttons) (clj->js options)))
|
|
|
|
|
|
|
|
(def appearance ^js (.-Appearance ^js react-native))
|
|
|
|
|
|
|
|
(defn get-color-scheme []
|
|
|
|
(.getColorScheme appearance))
|
|
|
|
|
|
|
|
(defn appearance-add-change-listener [handler]
|
|
|
|
(.addChangeListener appearance handler))
|
|
|
|
|
|
|
|
(defn get-window []
|
|
|
|
(js->clj (.get (.-Dimensions ^js react-native) "window") :keywordize-keys true))
|
2022-11-16 12:00:16 +01:00
|
|
|
|
|
|
|
(def status-bar (.-StatusBar ^js react-native))
|
2022-12-05 14:22:06 +01:00
|
|
|
|
|
|
|
(defn hw-back-add-listener [callback]
|
|
|
|
(.addEventListener (.-BackHandler ^js react-native) "hardwareBackPress" callback))
|
|
|
|
|
|
|
|
(defn hw-back-remove-listener [callback]
|
|
|
|
(.removeEventListener (.-BackHandler ^js react-native) "hardwareBackPress" callback))
|
|
|
|
|
|
|
|
(def keyboard-avoiding-view-class (reagent/adapt-react-class (.-KeyboardAvoidingView react-native)))
|
|
|
|
|
|
|
|
(defn keyboard-avoiding-view [props & children]
|
|
|
|
(into [keyboard-avoiding-view-class
|
|
|
|
(merge (when platform/ios? {:behavior :padding})
|
|
|
|
props)]
|
|
|
|
children))
|