parent
8de3be1f6f
commit
a24cdd293e
|
@ -1,4 +1,5 @@
|
||||||
(ns syng-im.discovery.screen
|
(ns syng-im.discovery.screen
|
||||||
|
(:require-macros [syng-im.utils.views :refer [defview]])
|
||||||
(:require
|
(:require
|
||||||
[re-frame.core :refer [dispatch subscribe]]
|
[re-frame.core :refer [dispatch subscribe]]
|
||||||
[syng-im.components.react :refer [view
|
[syng-im.components.react :refer [view
|
||||||
|
@ -29,25 +30,23 @@
|
||||||
(defn toogle-search [current-value]
|
(defn toogle-search [current-value]
|
||||||
(dispatch [:set ::show-search (not current-value)]))
|
(dispatch [:set ::show-search (not current-value)]))
|
||||||
|
|
||||||
(defn discovery []
|
(defview discovery []
|
||||||
[]
|
[show-search [:get ::show-search]]
|
||||||
(let [show-search (subscribe [:get ::show-search])]
|
[view st/discovery-container
|
||||||
(fn []
|
[toolbar
|
||||||
[view st/discovery-container
|
{:style st/discovery-toolbar
|
||||||
[toolbar
|
:nav-action {:image {:source {:uri :icon_hamburger}
|
||||||
{:style st/discovery-toolbar
|
:style st/hamburger-icon}
|
||||||
:nav-action {:image {:source {:uri :icon_hamburger}
|
:handler #(dispatch [:create-fake-discovery!])}
|
||||||
:style st/hamburger-icon}
|
:title "Add Participants"
|
||||||
:handler #(dispatch [:create-fake-discovery!])}
|
:content [title-content show-search]
|
||||||
:title "Add Participants"
|
:action {:image {:source {:uri :icon_search}
|
||||||
:content [title-content @show-search]
|
:style st/search-icon}
|
||||||
:action {:image {:source {:uri :icon_search}
|
:handler #(toogle-search show-search)}}]
|
||||||
:style st/search-icon}
|
[scroll-view {:style {}}
|
||||||
:handler #(toogle-search @show-search)}}]
|
[view st/section-spacing
|
||||||
[scroll-view {:style {}}
|
[text {:style st/discovery-subtitle} "Popular tags"]]
|
||||||
[view st/section-spacing
|
[popular]
|
||||||
[text {:style st/discovery-subtitle} "Popular tags"]]
|
[view st/section-spacing
|
||||||
[popular]
|
[text {:style st/discovery-subtitle} "Recent"]]
|
||||||
[view st/section-spacing
|
[discovery-recent]]])
|
||||||
[text {:style st/discovery-subtitle} "Recent"]]
|
|
||||||
[discovery-recent]]])))
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
(ns syng-im.discovery.views.popular
|
(ns syng-im.discovery.views.popular
|
||||||
|
(:require-macros [syng-im.utils.views :refer [defview]])
|
||||||
(:require
|
(:require
|
||||||
[re-frame.core :refer [subscribe]]
|
[re-frame.core :refer [subscribe]]
|
||||||
[syng-im.utils.logging :as log]
|
[syng-im.utils.logging :as log]
|
||||||
|
@ -11,12 +12,11 @@
|
||||||
(defn page-width []
|
(defn page-width []
|
||||||
(.-width (.get (.. js/React -Dimensions) "window")))
|
(.-width (.get (.. js/React -Dimensions) "window")))
|
||||||
|
|
||||||
(defn popular []
|
(defview popular []
|
||||||
(let [popular-tags (subscribe [:get-popular-tags 3])]
|
[popular-tags [:get-popular-tags 3]]
|
||||||
(log/debug "Got popular tags: " @popular-tags)
|
(if (pos? (count popular-tags))
|
||||||
(if (pos? (count @popular-tags))
|
[carousel {:pageStyle st/carousel-page-style
|
||||||
[carousel {:pageStyle st/carousel-page-style
|
:sneak 20}
|
||||||
:sneak 20}
|
(for [{:keys [name count]} popular-tags]
|
||||||
(for [{:keys [name count]} @popular-tags]
|
[discovery-popular-list name count])]
|
||||||
[discovery-popular-list name count])]
|
[text "None"]))
|
||||||
[text "None"])))
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
(ns syng-im.discovery.views.popular-list
|
(ns syng-im.discovery.views.popular-list
|
||||||
|
(:require-macros [syng-im.utils.views :refer [defview]])
|
||||||
(:require
|
(:require
|
||||||
[re-frame.core :refer [subscribe dispatch]]
|
[re-frame.core :refer [subscribe dispatch]]
|
||||||
[syng-im.components.react :refer [view
|
[syng-im.components.react :refer [view
|
||||||
|
@ -17,18 +18,17 @@
|
||||||
(list-item [view {:style st/row-separator
|
(list-item [view {:style st/row-separator
|
||||||
:key row-id}]))
|
:key row-id}]))
|
||||||
|
|
||||||
(defn discovery-popular-list [tag count]
|
(defview discovery-popular-list [tag count]
|
||||||
(let [discoveries (subscribe [:get-discoveries-by-tag tag 3])]
|
[discoveries [:get-discoveries-by-tag tag 3]]
|
||||||
(fn [tag count]
|
[view st/popular-list-container
|
||||||
[view st/popular-list-container
|
[view st/row
|
||||||
[view st/row
|
[view st/tag-name-container
|
||||||
[view st/tag-name-container
|
[touchable-highlight {:onPress #(dispatch [:show-discovery-tag tag])}
|
||||||
[touchable-highlight {:onPress #(dispatch [:show-discovery-tag tag])}
|
[text {:style st/tag-name} (str " #" (name tag))]]]
|
||||||
[text {:style st/tag-name} (str " #" (name tag))]]]
|
[view st/tag-count-container
|
||||||
[view st/tag-count-container
|
[text {:style st/tag-count} count]]]
|
||||||
[text {:style st/tag-count} count]]]
|
[list-view {:dataSource (to-datasource discoveries)
|
||||||
[list-view {:dataSource (to-datasource @discoveries)
|
:enableEmptySections true
|
||||||
:enableEmptySections true
|
:renderRow render-row
|
||||||
:renderRow render-row
|
:renderSeparator render-separator
|
||||||
:renderSeparator render-separator
|
:style st/popular-list}]])
|
||||||
:style st/popular-list}]])))
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
(ns syng-im.discovery.views.popular-list-item
|
(ns syng-im.discovery.views.popular-list-item
|
||||||
;syng-im.discovery.views.popular-list-item
|
|
||||||
(:require [syng-im.components.react :refer [view text image]]
|
(:require [syng-im.components.react :refer [view text image]]
|
||||||
[syng-im.discovery.styles :as st]
|
[syng-im.discovery.styles :as st]
|
||||||
[reagent.core :as r]))
|
[reagent.core :as r]))
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
(ns syng-im.discovery.views.recent
|
(ns syng-im.discovery.views.recent
|
||||||
|
(:require-macros [syng-im.utils.views :refer [defview]])
|
||||||
(:require
|
(:require
|
||||||
[re-frame.core :refer [subscribe]]
|
[re-frame.core :refer [subscribe]]
|
||||||
[syng-im.components.react :refer [view list-view list-item]]
|
[syng-im.components.react :refer [view list-view list-item]]
|
||||||
|
@ -14,11 +15,9 @@
|
||||||
(list-item [view {:style st/row-separator
|
(list-item [view {:style st/row-separator
|
||||||
:key row-id}]))
|
:key row-id}]))
|
||||||
|
|
||||||
(defn discovery-recent []
|
(defview discovery-recent []
|
||||||
(let [discoveries (subscribe [:get :discoveries])]
|
[discoveries [:get :discoveries]]
|
||||||
(fn []
|
[list-view {:dataSource (to-datasource discoveries)
|
||||||
;; todo fetch more on :onEndReached
|
:renderRow render-row
|
||||||
[list-view {:dataSource (to-datasource @discoveries)
|
:renderSeparator render-separator
|
||||||
:renderRow render-row
|
:style st/recent-list}])
|
||||||
:renderSeparator render-separator
|
|
||||||
:style st/recent-list}])))
|
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
(ns syng-im.utils.views)
|
||||||
|
|
||||||
|
(defn prepare-subs [subs]
|
||||||
|
(let [pairs (map (fn [[form sub]]
|
||||||
|
{:form form
|
||||||
|
:sub sub
|
||||||
|
:sym (gensym)})
|
||||||
|
(partition 2 subs))]
|
||||||
|
[(mapcat (fn [{:keys [sym sub]}]
|
||||||
|
[sym `(re-frame.core/subscribe ~sub)])
|
||||||
|
pairs)
|
||||||
|
(mapcat (fn [{:keys [sym form]}]
|
||||||
|
[form `(deref ~sym)])
|
||||||
|
pairs)]))
|
||||||
|
|
||||||
|
(defmacro defview
|
||||||
|
[n params & rest]
|
||||||
|
(let [[subs body] (if (= 1 (count rest))
|
||||||
|
[nil (first rest)]
|
||||||
|
rest)
|
||||||
|
[subs-bindings vars-bindings] (prepare-subs subs)]
|
||||||
|
`(defn ~n ~params
|
||||||
|
(let [~@subs-bindings]
|
||||||
|
(fn ~params
|
||||||
|
(let [~@vars-bindings]
|
||||||
|
~body))))))
|
||||||
|
|
Loading…
Reference in New Issue