fixed icon fn definition

Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
Andrey Shovkoplyas 2018-07-25 15:53:29 +03:00
parent 9a02bca975
commit b9cbb28663
No known key found for this signature in database
GPG Key ID: EAAB7C8622D860A4
1 changed files with 167 additions and 163 deletions

View File

@ -27,8 +27,9 @@
(def defs (get-class "Defs"))
(def circle (get-class "Circle")))
(def icons
(if platform/desktop?
(def icons {:icons/discover (js/require "./resources/icons/bottom/discover_gray.svg")
{:icons/discover (js/require "./resources/icons/bottom/discover_gray.svg")
:icons/contacts (js/require "./resources/icons/bottom/contacts_gray.svg")
:icons/home (js/require "./resources/icons/bottom/home_gray.svg")
:icons/home-active (js/require "./resources/icons/bottom/home_blue.svg")
@ -88,8 +89,8 @@
:icons/camera (js/require "./resources/icons/camera.svg")
:icons/check (js/require "./resources/icons/check.svg")
:icons/dots (js/require "./resources/icons/dots.svg")
:icons/warning (js/require "./resources/icons/warning.svg")})
(def icons {:icons/discover (components.svg/slurp-svg "./resources/icons/bottom/discover_gray.svg")
:icons/warning (js/require "./resources/icons/warning.svg")}
{:icons/discover (components.svg/slurp-svg "./resources/icons/bottom/discover_gray.svg")
:icons/contacts (components.svg/slurp-svg "./resources/icons/bottom/contacts_gray.svg")
:icons/home (components.svg/slurp-svg "./resources/icons/bottom/home_gray.svg")
:icons/home-active (components.svg/slurp-svg "./resources/icons/bottom/home_blue.svg")
@ -156,23 +157,20 @@
(if platform/ios? :icons/dots-horizontal :icons/dots-vertical)
n))
(if platform/desktop?
(do (def default-viewbox {:width 24 :height 24})
(defn icon
([name] (icon name nil))
([name {:keys [color container-style style accessibility-label width height]
(defn desktop-icon
[name {:keys [color container-style style accessibility-label width height]
:or {accessibility-label :icon}}]
(let [icon-style (if width
(let [default-viewbox {:width 24 :height 24}
icon-style (if width
(assoc default-viewbox :width width :height height)
default-viewbox)]
[react/view {:style container-style
:accessibility-label accessibility-label}
[react/image {:source (get icons (normalize-property-name name))
:style (merge icon-style style)}]]))))
(do (defn icon
([name] (icon name nil))
([name {:keys [color container-style style accessibility-label width height]
:style (merge icon-style style)}]]))
(defn mobile-icon
[name {:keys [color container-style style accessibility-label width height]
:or {accessibility-label :icon}}]
^{:key name}
[react/view {:style container-style
@ -196,4 +194,10 @@
(if width
(update icon-vec 1 assoc :width width :height height)
icon-vec))
(throw (js/Error. (str "Unknown icon: " name))))]))))
(throw (js/Error. (str "Unknown icon: " name))))])
(defn icon
([name] (icon name nil))
([name options]
(let [icon-fn (if platform/desktop? desktop-icon mobile-icon)]
[icon-fn name options])))