js/window

This commit is contained in:
Roman Volosovskyi 2016-05-29 10:30:46 +03:00
parent 7694ad9e87
commit 043d28c44d
7 changed files with 41 additions and 34 deletions

View File

@ -60,4 +60,5 @@
(dispatch [:init-console-chat])
(dispatch [:init-chat])
(init-back-button-handler!)
(.registerComponent app-registry "StatusIm" #(r/reactify-component app-root)))
;(.registerComponent app-registry "StatusIm" #(r/reactify-component app-root))
)

View File

@ -5,11 +5,12 @@
touchable-without-feedback
text]]
[status-im.components.carousel.styles :as st]
[status-im.utils.logging :as log]))
[status-im.utils.logging :as log]
[status-im.components.react :as r]))
(defn window-page-width []
(.-width (.get (.. js/React -Dimensions) "window")))
(.-width (.get (.. r/react -Dimensions) "window")))
(def defaults {:gap 10
:sneak 10

View File

@ -12,7 +12,8 @@
touchable-opacity]]
[status-im.resources :as res]
[status-im.components.drawer.styles :as st]
[status-im.i18n :refer [label]]))
[status-im.i18n :refer [label]]
[status-im.components.react :refer [react]]))
(defonce drawer-atom (atom))
@ -72,7 +73,7 @@
(defn drawer-view [items]
[drawer-layout-android {:drawerWidth 260
:drawerPosition js/React.DrawerLayoutAndroid.positions.Left
:drawerPosition react.DrawerLayoutAndroid.positions.Left
:render-navigation-view #(r/as-element [drawer-menu])
:ref (fn [drawer]
(reset! drawer-atom drawer))}

View File

@ -1,7 +1,8 @@
(ns status-im.components.invertible-scroll-view)
(ns status-im.components.invertible-scroll-view
(:require [reagent.core :as r]))
(def class (js/require "react-native-invertible-scroll-view"))
(defn invertible-scroll-view [props]
(js/React.createElement class (clj->js (merge {:inverted true} props))))
(r/create-element class (clj->js (merge {:inverted true} props))))

View File

@ -2,25 +2,28 @@
(:require [reagent.core :as r]
[status-im.components.styles :as st]))
(set! js/window.React (js/require "react-native"))
(when (exists? js/window)
(set! js/window.React (js/require "react-native")))
(def app-registry (.-AppRegistry js/React))
(def navigator (r/adapt-react-class (.-Navigator js/React)))
(def text (r/adapt-react-class (.-Text js/React)))
(def view (r/adapt-react-class (.-View js/React)))
(def image (r/adapt-react-class (.-Image js/React)))
(def touchable-highlight-class (r/adapt-react-class (.-TouchableHighlight js/React)))
(def react (js/require "react-native"))
(def app-registry (.-AppRegistry react))
(def navigator (r/adapt-react-class (.-Navigator react)))
(def text (r/adapt-react-class (.-Text react)))
(def view (r/adapt-react-class (.-View react)))
(def image (r/adapt-react-class (.-Image react)))
(def touchable-highlight-class (r/adapt-react-class (.-TouchableHighlight react)))
(defn touchable-highlight [props content]
[touchable-highlight-class
(merge {:underlay-color :transparent} props)
content])
(def toolbar-android (r/adapt-react-class (.-ToolbarAndroid js/React)))
(def list-view-class (r/adapt-react-class (.-ListView js/React)))
(def toolbar-android (r/adapt-react-class (.-ToolbarAndroid react)))
(def list-view-class (r/adapt-react-class (.-ListView react)))
(defn list-view [props]
[list-view-class (merge {:enableEmptySections true} props)])
(def scroll-view (r/adapt-react-class (.-ScrollView js/React)))
(def touchable-without-feedback (r/adapt-react-class (.-TouchableWithoutFeedback js/React)))
(def text-input-class (r/adapt-react-class (.-TextInput js/React)))
(def scroll-view (r/adapt-react-class (.-ScrollView react)))
(def touchable-without-feedback (r/adapt-react-class (.-TouchableWithoutFeedback react)))
(def text-input-class (r/adapt-react-class (.-TextInput react)))
(defn text-input [props text]
[text-input-class (merge
{:underlineColorAndroid :transparent
@ -28,11 +31,11 @@
:placeholder "Type"}
props)
text])
(def drawer-layout-android (r/adapt-react-class (.-DrawerLayoutAndroid js/React)))
(def touchable-opacity (r/adapt-react-class (.-TouchableOpacity js/React)))
(def modal (r/adapt-react-class (.-Modal js/React)))
(def picker (r/adapt-react-class (.-Picker js/React)))
(def picker-item (r/adapt-react-class (.-Item (.-Picker js/React))))
(def drawer-layout-android (r/adapt-react-class (.-DrawerLayoutAndroid react)))
(def touchable-opacity (r/adapt-react-class (.-TouchableOpacity react)))
(def modal (r/adapt-react-class (.-Modal react)))
(def picker (r/adapt-react-class (.-Picker react)))
(def picker-item (r/adapt-react-class (.-Item (.-Picker react))))
(defn icon
@ -44,13 +47,13 @@
;(def react-linear-gradient (.-default (js/require "react-native-linear-gradient")))
;(def linear-gradient (r/adapt-react-class react-linear-gradient))
(set! js/window.LinearGradient (js/require "react-native-linear-gradient"))
(def linear-gradient-class (js/require "react-native-linear-gradient"))
(defn linear-gradient [props]
(js/React.createElement js/LinearGradient
(r/creacteElement linear-gradient-class
(clj->js (merge {:inverted true} props))))
(def platform (.. js/React -Platform -OS))
(def platform (.. react -Platform -OS))
(def android? (= platform "android"))

View File

@ -2,16 +2,16 @@
(:require-macros [status-im.utils.views :refer [defview]])
(:require
[re-frame.core :refer [subscribe]]
[status-im.utils.logging :as log]
[status-im.components.react :refer [android?
text]]
[status-im.components.carousel.carousel :refer [carousel]]
[status-im.discovery.styles :as st]
[status-im.discovery.views.popular-list :refer [discovery-popular-list]]
[status-im.i18n :refer [label]]))
[status-im.i18n :refer [label]]
[status-im.components.react :as r]))
(defn page-width []
(.-width (.get (.. js/React -Dimensions) "window")))
(.-width (.get (.. r/react -Dimensions) "window")))
(defview popular []
[popular-tags [:get-popular-tags 3]]

View File

@ -5,8 +5,6 @@
[status-im.utils.types :refer [to-string]])
(:refer-clojure :exclude [exists?]))
(set! js/window.Realm (js/require "realm"))
(def opts {:schema [{:name :contacts
:primaryKey :whisper-identity
:properties {:phone-number {:type "string"
@ -70,7 +68,9 @@
:objectType "tag"}
:last-updated "date"}}]})
(def realm (js/Realm. (clj->js opts)))
(def realm-class (js/require "realm"))
(def realm (realm-class. (clj->js opts)))
(def schema-by-name (->> (:schema opts)
(mapv (fn [{:keys [name] :as schema}]