Aliases in discovery (#477)

This commit is contained in:
Alexander Pantyukhov 2016-11-21 23:48:42 +03:00
parent 3efb8a7bb8
commit e0313ef9c6
4 changed files with 32 additions and 14 deletions

View File

@ -61,7 +61,7 @@
:font :medium}
(label label-kw)]])
(defview discovery-popular [{:keys [contacts]}]
(defview discovery-popular [{:keys [contacts current-account]}]
[popular-tags [:get-popular-tags 10]]
[view st/popular-container
[title :t/popular-tags false]
@ -71,30 +71,35 @@
:sneak (if (> (count popular-tags) 1) 16 8)}
(for [{:keys [name]} popular-tags]
[discovery-popular-list {:tag name
:contacts contacts}])]
:contacts contacts
:current-account current-account}])]
[text (label :t/none)])])
(defview discovery-recent [{:keys [contacts]}]
(defview discovery-recent [{:keys [current-account]}]
[discoveries [:get-recent-discoveries]]
(when (seq discoveries)
[view st/recent-container
[title :t/recent true]
[view st/recent-list
(let [discoveries (map-indexed vector discoveries)]
(for [[i {:keys [message-id] :as discovery}] discoveries]
(for [[i {:keys [message-id] :as message}] discoveries]
^{:key (str "message-" message-id)}
[discovery-list-item discovery (not= (inc i) (count discoveries))]))]]))
[discovery-list-item {:message message
:show-separator? (not= (inc i) (count discoveries))
:current-account current-account}]))]]))
(defview discovery []
[show-search? [:get ::show-search?]
contacts [:get :contacts]
current-account [:get-current-account]
discoveries [:get-recent-discoveries]]
[view st/discovery-container
[discovery-toolbar show-search?]
(if discoveries
[scroll-view st/scroll-view-container
[discovery-popular {:contacts contacts}]
[discovery-recent {:contacts contacts}]]
[discovery-popular {:contacts contacts
:current-account current-account}]
[discovery-recent {:current-account current-account}]]
[view contacts-styles/empty-contact-groups
;; todo change icon
[icon :group_big contacts-styles/empty-contacts-icon]

View File

@ -37,7 +37,8 @@
(defview discovery-search-results []
[discoveries [:get-popular-discoveries 250]
tags [:get :discovery-search-tags]]
tags [:get :discovery-search-tags]
current-account [:get-current-account]]
(let [discoveries (:discoveries discoveries)
datasource (to-datasource discoveries)]
[view st/discovery-tag-container
@ -55,6 +56,7 @@
(label :t/no-statuses-found)]]
[list-view {:dataSource datasource
:renderRow (fn [row _ _]
(list-item [discovery-list-item row]))
(list-item [discovery-list-item {:message row
:current-account current-account}]))
:renderSeparator render-separator
:style st/recent-list}])]))

View File

@ -26,8 +26,15 @@
^{:key (str "item-" message-id "-" i)}
(str status " ")))])
(defview discovery-list-item [{:keys [name photo-path whisper-id] :as message}
show-separator?]
(defview discovery-list-item [{{:keys [name
photo-path
whisper-id]
:as message} :message
show-separator? :show-separator?
{account-photo-path :photo-path
account-address :public-key
account-name :name
:as current-account} :current-account}]
[{contact-name :name
contact-photo-path :photo-path} [:get-in [:contacts whisper-id]]]
(let [item-style (get-in platform-specific [:component-styles :discovery :item])]
@ -38,6 +45,7 @@
:font :medium
:number-of-lines 1}
(cond
(= account-address whisper-id) account-name
(not (str/blank? contact-name)) contact-name
(not (str/blank? name)) name
:else (generate-gfy))]
@ -47,6 +55,7 @@
[touchable-highlight {:on-press #(dispatch [:start-chat whisper-id])}
[view
[ci/chat-icon (cond
(= account-address whisper-id) account-photo-path
(not (str/blank? contact-photo-path)) contact-photo-path
(not (str/blank? photo-path)) photo-path
:else (identicon whisper-id))

View File

@ -12,7 +12,7 @@
[status-im.discovery.views.discovery-list-item :refer [discovery-list-item]]
[status-im.utils.platform :refer [platform-specific]]))
(defview discovery-popular-list [{:keys [tag contacts]}]
(defview discovery-popular-list [{:keys [tag contacts current-account]}]
[discoveries [:get-popular-discoveries 3 [tag]]]
[view (merge st/popular-list-container
(get-in platform-specific [:component-styles :discovery :popular]))
@ -31,4 +31,6 @@
(let [discoveries (map-indexed vector (:discoveries discoveries))]
(for [[i {:keys [message-id] :as discovery}] discoveries]
^{:key (str "message-" message-id)}
[discovery-list-item discovery (not= (inc i) (count discoveries))]))])
[discovery-list-item {:message discovery
:show-separator? (not= (inc i) (count discoveries))
:current-account current-account}]))])