clean js/window first attempt

This commit is contained in:
Roman Volosovskyi 2016-05-27 19:44:06 +03:00
parent ab36ec7df7
commit 7694ad9e87
9 changed files with 19 additions and 47 deletions

View File

@ -1,7 +1,7 @@
(ns status-im.components.action-button
(:require [reagent.core :as r]))
(set! js/window.ActionButton (js/require "react-native-action-button"))
(def class (js/require "react-native-action-button"))
(def action-button (r/adapt-react-class (.-default js/ActionButton)))
(def action-button-item (r/adapt-react-class (.. js/ActionButton -default -Item)))
(def action-button (r/adapt-react-class (.-default class)))
(def action-button-item (r/adapt-react-class (.. class -default -Item)))

View File

@ -1,6 +1,4 @@
(ns status-im.components.icons.ionicons
(:require [reagent.core :as r]))
(set! js/window.Ionicons (js/require "react-native-vector-icons/Ionicons"))
(def icon (r/adapt-react-class js/Ionicons))
(def icon (r/adapt-react-class (js/require "react-native-vector-icons/Ionicons")))

View File

@ -1,8 +1,7 @@
(ns status-im.components.invertible-scroll-view)
(set! js/window.InvertibleScrollView (js/require "react-native-invertible-scroll-view"))
(def class (js/require "react-native-invertible-scroll-view"))
(defn invertible-scroll-view [props]
(js/React.createElement js/InvertibleScrollView
(clj->js (merge {:inverted true} props))))
(js/React.createElement class (clj->js (merge {:inverted true} props))))

View File

@ -1,7 +1,5 @@
(ns status-im.components.item-checkbox
(:require [reagent.core :as r]))
(set! js/window.ItemCheckbox (js/require "react-native-circle-checkbox"))
(def item-checkbox (r/adapt-react-class js/ItemCheckbox))
(def item-checkbox (r/adapt-react-class (js/require "react-native-circle-checkbox")))

View File

@ -1,9 +0,0 @@
(ns status-im.components.realm
(:require [reagent.core :as r]))
(set! js/window.RealmReactNative (js/require "realm/react-native"))
(def list-view-class (r/adapt-react-class (.-ListView js/RealmReactNative)))
(defn list-view [props]
[list-view-class (merge {:enableEmptySections true} props)])

View File

@ -12,9 +12,7 @@
color-purple
text1-color
text2-color
toolbar-background1]]
[status-im.components.realm :refer [list-view]]
[reagent.core :as r]))
toolbar-background1]]))
(defn toolbar [{:keys [title nav-action hide-nav? action custom-action
background-color custom-content style]}]

View File

@ -2,22 +2,11 @@
(:require
[status-im.translations.en :as en]))
(set! js/window.I18n (js/require "react-native-i18n"))
(set! (.-fallbacks js/I18n) true)
(set! (.-defaultSeparator js/I18n) "/")
(def i18n (js/require "react-native-i18n"))
(set! (.-fallbacks i18n) true)
(set! (.-defaultSeparator i18n) "/")
(set! (.-translations js.I18n) (clj->js {:en en/translations}))
(set! (.-translations i18n) (clj->js {:en en/translations}))
(defn label [path & options]
(.t js/I18n (name path) (clj->js options)))
(comment
(defn deep-merge [& maps]
(if (every? map? maps)
(apply merge-with deep-merge maps)
(last maps)))
(defn add-translations [new-translations]
(let [translations (.-translations js/I18n)]
(set! (.-translations js/I18n) (clj->js (deep-merge (js->clj translations) new-translations)))))
)
(.t i18n (name path) (clj->js options)))

View File

@ -3,7 +3,7 @@
[clojure.string :as s])
(:import goog.crypt.Sha256))
(set! js/window.RnRandomBytes (js/require "react-native-randombytes"))
(def random-bytes (js/require "react-native-randombytes"))
(def sha-256 (Sha256.))
@ -19,7 +19,7 @@
(byteArrayToHex (.digest sha-256)))
(defn gen-random-bytes [length cb]
(.randomBytes js/window.RnRandomBytes length (fn [& [err buf]]
(.randomBytes random-bytes length (fn [& [err buf]]
(if err
(cb {:error err})
(cb {:buffer buf})))))

View File

@ -1,6 +1,5 @@
(ns status-im.utils.listview
(:require-macros [natal-shell.data-source :refer [data-source]])
(:require [status-im.components.realm]))
(:require-macros [natal-shell.data-source :refer [data-source]]))
(defn clone-with-rows [ds rows]
(.cloneWithRows ds (reduce (fn [ac el] (.push ac el) ac)