added discover tag screen
This commit is contained in:
parent
f402fc9b6e
commit
69df1ad3ef
|
@ -9,6 +9,7 @@
|
||||||
[syng-im.components.react :refer [navigator app-registry]]
|
[syng-im.components.react :refer [navigator app-registry]]
|
||||||
[syng-im.components.contact-list.contact-list :refer [contact-list]]
|
[syng-im.components.contact-list.contact-list :refer [contact-list]]
|
||||||
[syng-im.components.discovery.discovery :refer [discovery]]
|
[syng-im.components.discovery.discovery :refer [discovery]]
|
||||||
|
[syng-im.components.discovery.discovery-tag :refer [discovery-tag]]
|
||||||
[syng-im.components.chat :refer [chat]]
|
[syng-im.components.chat :refer [chat]]
|
||||||
[syng-im.components.sign-up :refer [sign-up-view]]
|
[syng-im.components.sign-up :refer [sign-up-view]]
|
||||||
[syng-im.components.sign-up-confirm :refer [sign-up-confirm-view]]
|
[syng-im.components.sign-up-confirm :refer [sign-up-confirm-view]]
|
||||||
|
@ -46,6 +47,7 @@
|
||||||
(init-back-button-handler! nav)
|
(init-back-button-handler! nav)
|
||||||
(case view-id
|
(case view-id
|
||||||
:discovery (r/as-element [discovery {:navigator nav}])
|
:discovery (r/as-element [discovery {:navigator nav}])
|
||||||
|
:discovery-tag (r/as-element [discovery-tag {:navigator nav}])
|
||||||
:add-participants (r/as-element [new-participants {:navigator nav}])
|
:add-participants (r/as-element [new-participants {:navigator nav}])
|
||||||
:remove-participants (r/as-element [remove-participants {:navigator nav}])
|
:remove-participants (r/as-element [remove-participants {:navigator nav}])
|
||||||
:chat-list (r/as-element [chats-list {:navigator nav}])
|
:chat-list (r/as-element [chats-list {:navigator nav}])
|
||||||
|
@ -53,7 +55,8 @@
|
||||||
:contact-list (r/as-element [contact-list {:navigator nav}])
|
:contact-list (r/as-element [contact-list {:navigator nav}])
|
||||||
:chat (r/as-element [chat {:navigator nav}])
|
:chat (r/as-element [chat {:navigator nav}])
|
||||||
:sign-up (r/as-element [sign-up-view {:navigator nav}])
|
:sign-up (r/as-element [sign-up-view {:navigator nav}])
|
||||||
:sign-up-confirm (r/as-element [sign-up-confirm-view {:navigator nav}])))))}])
|
:sign-up-confirm (r/as-element [sign-up-confirm-view {:navigator nav}])
|
||||||
|
(log/error "No matching route: " route nav)))))}])
|
||||||
|
|
||||||
(defn init []
|
(defn init []
|
||||||
(dispatch-sync [:initialize-db])
|
(dispatch-sync [:initialize-db])
|
||||||
|
|
|
@ -91,18 +91,14 @@
|
||||||
[text {:style {:color "#8f838c93"
|
[text {:style {:color "#8f838c93"
|
||||||
:fontFamily "sans-serif-medium"
|
:fontFamily "sans-serif-medium"
|
||||||
:fontSize 14}} "Popular tags"]]
|
:fontSize 14}} "Popular tags"]]
|
||||||
[discovery-popular]
|
[discovery-popular navigator]
|
||||||
[view {:style {:paddingLeft 30
|
[view {:style {:paddingLeft 30
|
||||||
:paddingTop 15
|
:paddingTop 15
|
||||||
:paddingBottom 15}}
|
:paddingBottom 15}}
|
||||||
[text {:style {:color "#8f838c93"
|
[text {:style {:color "#8f838c93"
|
||||||
:fontSize 14
|
:fontSize 14
|
||||||
:fontFamily "sans-serif-medium"}} "Recent"]]
|
:fontFamily "sans-serif-medium"}} "Recent"]]
|
||||||
[discovery-recent]
|
[discovery-recent]]])))
|
||||||
]
|
|
||||||
]
|
|
||||||
)
|
|
||||||
))
|
|
||||||
(comment
|
(comment
|
||||||
(def page-width (aget (natal-shell.dimensions/get "window") "width"))
|
(def page-width (aget (natal-shell.dimensions/get "window") "width"))
|
||||||
(def page-height (aget (natal-shell.dimensions/get "window") "height"))
|
(def page-height (aget (natal-shell.dimensions/get "window") "height"))
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
(defn page-width []
|
(defn page-width []
|
||||||
(.-width (.get (.. js/React -Dimensions) "window")))
|
(.-width (.get (.. js/React -Dimensions) "window")))
|
||||||
|
|
||||||
(defn discovery-popular []
|
(defn discovery-popular [navigator]
|
||||||
(let [popular-tags (subscribe [:get-popular-tags 3])]
|
(let [popular-tags (subscribe [:get-popular-tags 3])]
|
||||||
(log/debug "Got popular tags: " @popular-tags)
|
(log/debug "Got popular tags: " @popular-tags)
|
||||||
(if (> (count @popular-tags) 0)
|
(if (> (count @popular-tags) 0)
|
||||||
|
@ -24,8 +24,5 @@
|
||||||
:pageWidth (- (page-width) 60)
|
:pageWidth (- (page-width) 60)
|
||||||
:sneak 20}
|
:sneak 20}
|
||||||
(for [tag @popular-tags]
|
(for [tag @popular-tags]
|
||||||
(discovery-popular-list (.-name tag) (.-count tag)))]
|
(discovery-popular-list (.-name tag) (.-count tag) navigator))]
|
||||||
[text "None"]
|
[text "None"])))
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
|
@ -5,6 +5,7 @@
|
||||||
[syng-im.components.react :refer [android?
|
[syng-im.components.react :refer [android?
|
||||||
view
|
view
|
||||||
list-view
|
list-view
|
||||||
|
touchable-highlight
|
||||||
text
|
text
|
||||||
image]]
|
image]]
|
||||||
[reagent.core :as r]
|
[reagent.core :as r]
|
||||||
|
@ -25,7 +26,7 @@
|
||||||
:key rowID}])]
|
:key rowID}])]
|
||||||
elem))
|
elem))
|
||||||
|
|
||||||
(defn discovery-popular-list [tag count]
|
(defn discovery-popular-list [tag count navigator]
|
||||||
(let [discoveries (subscribe [:get-discoveries-by-tag tag 3])]
|
(let [discoveries (subscribe [:get-discoveries-by-tag tag 3])]
|
||||||
(log/debug "Got discoveries for tag (" tag "): " @discoveries)
|
(log/debug "Got discoveries for tag (" tag "): " @discoveries)
|
||||||
[view {:style {:flex 1
|
[view {:style {:flex 1
|
||||||
|
@ -37,17 +38,19 @@
|
||||||
:padding 0}}
|
:padding 0}}
|
||||||
[view {:style {
|
[view {:style {
|
||||||
:flexDirection "column"}}
|
:flexDirection "column"}}
|
||||||
[view {:style {:backgroundColor "#eef2f5"
|
[touchable-highlight {:onPress (fn [event]
|
||||||
|
(dispatch [:show-discovery-tag tag navigator :push]))}
|
||||||
|
[view {:style {:backgroundColor "#eef2f5"
|
||||||
:borderRadius 5
|
:borderRadius 5
|
||||||
:padding 4}}
|
:padding 4}}
|
||||||
[text {:style {:color "#7099e6"
|
[text {:style {:color "#7099e6"
|
||||||
:fontFamily "sans-serif-medium"
|
:fontFamily "sans-serif-medium"
|
||||||
:fontSize 14
|
:fontSize 14
|
||||||
:paddingRight 5
|
:paddingRight 5
|
||||||
:paddingBottom 2
|
:paddingBottom 2
|
||||||
:alignItems "center"
|
:alignItems "center"
|
||||||
:justifyContent "center"}}
|
:justifyContent "center"}}
|
||||||
(str " #" (name tag))]]]
|
(str " #" (name tag))]]]]
|
||||||
[view {:style {:flex 0.2
|
[view {:style {:flex 0.2
|
||||||
:alignItems "flex-end"
|
:alignItems "flex-end"
|
||||||
:paddingTop 10
|
:paddingTop 10
|
||||||
|
@ -61,6 +64,7 @@
|
||||||
:justifyContent "center"}}
|
:justifyContent "center"}}
|
||||||
count]]]
|
count]]]
|
||||||
[list-view {:dataSource (to-realm-datasource @discoveries)
|
[list-view {:dataSource (to-realm-datasource @discoveries)
|
||||||
|
:enableEmptySections true
|
||||||
:renderRow render-row
|
:renderRow render-row
|
||||||
:renderSeparator render-separator
|
:renderSeparator render-separator
|
||||||
:style {:backgroundColor "white"
|
:style {:backgroundColor "white"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
(ns syng-im.components.discovery.discovery-popular-list-item
|
(ns syng-im.components.discovery.discovery_popular_list_item
|
||||||
(:require
|
(:require
|
||||||
[syng-im.utils.logging :as log]
|
[syng-im.utils.logging :as log]
|
||||||
[syng-im.components.react :refer [android?
|
[syng-im.components.react :refer [android?
|
|
@ -1,4 +1,4 @@
|
||||||
(ns syng-im.components.discovery.discovery-recent
|
(ns syng-im.components.discovery.discovery_recent
|
||||||
(:require-macros
|
(:require-macros
|
||||||
[natal-shell.data-source :refer [data-source clone-with-rows]]
|
[natal-shell.data-source :refer [data-source clone-with-rows]]
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
view]]
|
view]]
|
||||||
[syng-im.components.realm :refer [list-view]]
|
[syng-im.components.realm :refer [list-view]]
|
||||||
[syng-im.utils.listview :refer [to-realm-datasource]]
|
[syng-im.utils.listview :refer [to-realm-datasource]]
|
||||||
[syng-im.components.discovery.discovery-popular-list-item :refer [discovery-popular-list-item]]
|
[syng-im.components.discovery.discovery_popular_list_item :refer [discovery-popular-list-item]]
|
||||||
[reagent.core :as r]))
|
[reagent.core :as r]))
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
:chats-updated-signal 0
|
:chats-updated-signal 0
|
||||||
:name "My Name"
|
:name "My Name"
|
||||||
:new-group #{}
|
:new-group #{}
|
||||||
:new-participants #{}})
|
:new-participants #{}
|
||||||
|
:current-tag nil})
|
||||||
|
|
||||||
|
|
||||||
(def protocol-initialized-path [:protocol-initialized])
|
(def protocol-initialized-path [:protocol-initialized])
|
||||||
|
@ -34,3 +35,5 @@
|
||||||
(def updated-discoveries-signal-path [:discovery-updated-signal])
|
(def updated-discoveries-signal-path [:discovery-updated-signal])
|
||||||
(defn updated-discovery-signal-path [whisper-id]
|
(defn updated-discovery-signal-path [whisper-id]
|
||||||
[:discoveries whisper-id :discovery-updated-signal])
|
[:discoveries whisper-id :discovery-updated-signal])
|
||||||
|
(def current-tag-path [:current-tag])
|
||||||
|
(def updated-current-tag-signal-path [:current-tag-updated-signal])
|
||||||
|
|
|
@ -2,7 +2,11 @@
|
||||||
(:require [re-frame.core :refer [register-handler after dispatch]]
|
(:require [re-frame.core :refer [register-handler after dispatch]]
|
||||||
[syng-im.utils.logging :as log]
|
[syng-im.utils.logging :as log]
|
||||||
[syng-im.protocol.api :as api]
|
[syng-im.protocol.api :as api]
|
||||||
|
[syng-im.navigation :refer [nav-push
|
||||||
|
nav-replace
|
||||||
|
nav-pop]]
|
||||||
[syng-im.models.discoveries :refer [save-discoveries
|
[syng-im.models.discoveries :refer [save-discoveries
|
||||||
|
set-current-tag
|
||||||
signal-discoveries-updated]]))
|
signal-discoveries-updated]]))
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,4 +34,11 @@
|
||||||
(let [name (:name db)]
|
(let [name (:name db)]
|
||||||
(log/debug "Status: " status ", Hashtags: " hashtags)
|
(log/debug "Status: " status ", Hashtags: " hashtags)
|
||||||
(api/broadcast-discover-status name status hashtags)
|
(api/broadcast-discover-status name status hashtags)
|
||||||
|
db)))
|
||||||
|
|
||||||
|
(register-handler :show-discovery-tag
|
||||||
|
(fn [db [action tag navigator nav-type]]
|
||||||
|
(log/debug action "setting current tag: " tag)
|
||||||
|
(let [db (set-current-tag db tag)]
|
||||||
|
(dispatch [:navigate-to navigator {:view-id :discovery-tag} nav-type])
|
||||||
db)))
|
db)))
|
|
@ -16,6 +16,17 @@
|
||||||
(defn discoveries-updated? [db]
|
(defn discoveries-updated? [db]
|
||||||
(get-in db db/updated-discoveries-signal-path))
|
(get-in db db/updated-discoveries-signal-path))
|
||||||
|
|
||||||
|
(defn current-tag-updated? [db]
|
||||||
|
(get-in db db/updated-current-tag-signal-path))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(defn current-tag [db]
|
||||||
|
(get-in db db/current-tag-path))
|
||||||
|
|
||||||
|
(defn set-current-tag [db tag]
|
||||||
|
(assoc-in db db/current-tag-path tag))
|
||||||
|
|
||||||
(defn get-tag [tag]
|
(defn get-tag [tag]
|
||||||
(log/debug "Getting tag: " tag)
|
(log/debug "Getting tag: " tag)
|
||||||
(-> (r/get-by-field :tag :name tag)
|
(-> (r/get-by-field :tag :name tag)
|
||||||
|
@ -100,10 +111,12 @@
|
||||||
(add-discoveries discoveries))
|
(add-discoveries discoveries))
|
||||||
|
|
||||||
(defn discoveries-by-tag [tag limit]
|
(defn discoveries-by-tag [tag limit]
|
||||||
(log/debug "Discoveries by tag: " tag)
|
(let [discoveries (-> (r/get-by-filter :discoveries (str "tags.name = '" tag "'"))
|
||||||
(-> (r/get-by-filter :discoveries (str "tags.name = '" tag "'"))
|
(r/sorted :last-updated :desc))]
|
||||||
(r/sorted :last-updated :desc)
|
(log/debug "Discoveries by tag: " tag)
|
||||||
(r/page 0 limit)))
|
(if (pos? limit)
|
||||||
|
(r/page discoveries 0 limit)
|
||||||
|
discoveries)))
|
||||||
|
|
||||||
(defn get-tag-popular [limit]
|
(defn get-tag-popular [limit]
|
||||||
(-> (r/get-all :tag)
|
(-> (r/get-all :tag)
|
||||||
|
|
|
@ -4,8 +4,10 @@
|
||||||
[syng-im.db :as db]
|
[syng-im.db :as db]
|
||||||
[syng-im.utils.logging :as log]
|
[syng-im.utils.logging :as log]
|
||||||
[syng-im.models.discoveries :refer [discovery-list
|
[syng-im.models.discoveries :refer [discovery-list
|
||||||
|
current-tag
|
||||||
get-tag-popular
|
get-tag-popular
|
||||||
discoveries-by-tag
|
discoveries-by-tag
|
||||||
|
current-tag-updated?
|
||||||
discoveries-updated?]]))
|
discoveries-updated?]]))
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,4 +36,13 @@
|
||||||
(log/debug "Getting tags limited: " limit)
|
(log/debug "Getting tags limited: " limit)
|
||||||
(reaction
|
(reaction
|
||||||
(let [_ @discoveries-updated]
|
(let [_ @discoveries-updated]
|
||||||
(get-tag-popular limit))))))
|
(get-tag-popular limit))))))
|
||||||
|
|
||||||
|
(register-sub :get-current-tag
|
||||||
|
(fn [db _]
|
||||||
|
(let [current-tag-updated (-> (current-tag-updated? @db)
|
||||||
|
(reaction))]
|
||||||
|
(reaction
|
||||||
|
(let [_ @current-tag-updated]
|
||||||
|
(current-tag @db))))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue