fix #1977 - discover recent statuses and statuses per popular hashtags

This commit is contained in:
Goran Jovic 2017-09-18 16:09:59 +02:00 committed by Roman Volosovskyi
parent a7950af335
commit dd5c433687
14 changed files with 346 additions and 250 deletions

View File

@ -37,17 +37,16 @@
:border-top-width 0.5}} :border-top-width 0.5}}
:discover {:subtitle {:color styles/color-gray2 :discover {:subtitle {:color styles/color-gray2
:font-size 14} :font-size 14}
:popular {:border-radius 1 :popular {:border-radius 4
:margin-top 2 :margin-top 2
:margin-bottom 4 :margin-bottom 4
:margin-right 2 :margin-right 2}
:elevation 2}
:tag {:flex-direction "column" :tag {:flex-direction "column"
:background-color "#7099e619" :background-color "#7099e619"
:border-radius 5 :border-radius 5
:padding 4} :padding 4}
:item {:status-text {:line-height 22 :item {:status-text {:line-height 22
:font-size 14}}} :font-size 16}}}
:contacts {:show-all-text-font :medium} :contacts {:show-all-text-font :medium}
:bottom-gradient {:height 3} :bottom-gradient {:height 3}
:input-label {:left 4} :input-label {:left 4}

View File

@ -159,10 +159,12 @@
:discover "Discover" :discover "Discover"
:none "None" :none "None"
:search-tags "Type your search tags here" :search-tags "Type your search tags here"
:popular-tags "Popular tags" :popular-tags "Popular hashtags"
:recent "Recent" :recent "Recent statuses"
:no-statuses-discovered "No statuses discovered" :no-statuses-discovered "No statuses discovered"
:no-statuses-found "No statuses found" :no-statuses-found "No statuses found"
:chat "Chat"
:all "All"
;;settings ;;settings
:settings "Settings" :settings "Settings"

View File

@ -0,0 +1,81 @@
(ns status-im.ui.screens.discover.components.views
(:require-macros [status-im.utils.views :refer [defview letsubs]])
(:require [re-frame.core :as re-frame]
[clojure.string :as str]
[status-im.components.react :as react]
[status-im.ui.screens.discover.styles :as st]
[status-im.components.status-view.view :as view]
[status-im.utils.gfycat.core :as gfycat]
[status-im.utils.identicon :as identicon]
[status-im.components.chat-icon.screen :as ci]
[status-im.utils.platform :as platform]
[status-im.components.icons.vector-icons :as vi]
[status-im.i18n :as i18n]))
(defn title [label-kw action-kw action-fn]
[react/view st/title
[react/text {:style (get-in platform/platform-specific [:component-styles :discover :subtitle])
:uppercase? (get-in platform/platform-specific [:discover :uppercase-subtitles?])
:font :medium}
(i18n/label label-kw)]
[react/touchable-highlight {:on-press action-fn}
[react/view {} [react/text {:style st/title-action-text} (i18n/label action-kw)]]]])
(defn tags-menu [tags]
[react/view st/tag-title-container
(for [tag (take 3 tags)]
^{:key (str "tag-" tag)}
[react/touchable-highlight {:on-press #(do (re-frame/dispatch [:set :discover-search-tags [tag]])
(re-frame/dispatch [:navigate-to :discover-search-results]))}
[react/view (merge (get-in platform/platform-specific [:component-styles :discover :tag])
{:margin-left 2 :margin-right 2})
[react/text {:style st/tag-title
:font :default}
(str " #" tag)]]])])
(defn display-name [me? account-name contact-name name whisper-id]
(cond
me? account-name ;status by current user
(not (str/blank? contact-name)) contact-name ; what's the
(not (str/blank? name)) name ;difference
:else (gfycat/generate-gfy whisper-id)))
(defn display-image [me? account-photo-path contact-photo-path photo-path whisper-id]
(cond
me? account-photo-path
(not (str/blank? contact-photo-path)) contact-photo-path
(not (str/blank? photo-path)) photo-path
:else (identicon/identicon whisper-id)))
(defview discover-list-item [{:keys [message show-separator? current-account]}]
(letsubs [{contact-name :name
contact-photo-path :photo-path} [:get-in [:contacts/contacts (:whisper-id message)]]]
(let [{:keys [name photo-path whisper-id message-id status]} message
{account-photo-path :photo-path
account-address :public-key
account-name :name} current-account
me? (= account-address whisper-id)
item-style (get-in platform/platform-specific [:component-styles :discover :item])]
[react/view
[react/view st/popular-list-item
[view/status-view {:id message-id
:style (:status-text item-style)
:status status}]
[react/view st/popular-list-item-second-row
[react/view st/popular-list-item-name-container
[react/view (merge st/popular-list-item-avatar-container
(:icon item-style))
[ci/chat-icon
(display-image me? account-photo-path contact-photo-path photo-path whisper-id)
{:size 20}]]
[react/text {:style st/popular-list-item-name
:font :medium
:number-of-lines 1}
(display-name me? account-name contact-name name whisper-id)]]
(when-not me?
[react/touchable-highlight {:on-press #(re-frame/dispatch [:start-chat whisper-id])}
[react/view st/popular-list-chat-action
[vi/icon :icons/chats {:color "rgb(110, 0, 228)"}]
[react/text {:style st/popular-list-chat-action-text} (i18n/label :t/chat)]]])]
(when show-separator?
[react/view st/separator])]])))

View File

@ -3,7 +3,7 @@
;; {id (string) descovery (map)} ;; {id (string) descovery (map)}
(s/def :discoveries/discoveries (s/nilable map?)) (s/def :discoveries/discoveries (s/nilable map?))
(s/def :discoveries/discover-search-tags (s/nilable seq?)) (s/def :discoveries/discover-search-tags (s/nilable sequential?))
(s/def :discoveries/tags (s/nilable vector?)) (s/def :discoveries/tags (s/nilable vector?))
(s/def :discoveries/current-tag (s/nilable map?)) (s/def :discoveries/current-tag (s/nilable map?))
(s/def :discoveries/request-discoveries-timer (s/nilable int?)) (s/def :discoveries/request-discoveries-timer (s/nilable int?))

View File

@ -0,0 +1,27 @@
(ns status-im.ui.screens.discover.popular-hashtags.views
(:require-macros [status-im.utils.views :refer [defview letsubs]])
(:require
[status-im.components.react :as react]
[status-im.ui.screens.discover.styles :as st]
[status-im.utils.listview :refer [to-datasource]]
[status-im.ui.screens.discover.components.views :as components]
[status-im.components.toolbar-new.view :as toolbar]))
(defview discover-all-hashtags []
(letsubs [current-account [:get-current-account]
popular-tags [:get-popular-tags 10]
{:keys [discoveries]} [:get-popular-discoveries 10]] ;uses the tags passed via :discover-search-tags state
[react/view st/discover-container
[toolbar/toolbar2 {}
toolbar/default-nav-back
[react/view {} [react/text {} "All hashtags"]]]
[components/tags-menu (map :name popular-tags)]
[react/scroll-view st/list-container
[react/view st/recent-container
[react/view st/recent-list
(let [discoveries (map-indexed vector discoveries)]
(for [[i {:keys [message-id] :as message}] discoveries]
^{:key (str "message-hashtag-" message-id)}
[components/discover-list-item {:message message
:show-separator? (not= (inc i) (count discoveries))
:current-account current-account}]))]]]]))

View File

@ -0,0 +1,27 @@
(ns status-im.ui.screens.discover.recent-statuses.views
(:require-macros [status-im.utils.views :refer [defview letsubs]])
(:require
[status-im.components.react :as react]
[status-im.ui.screens.discover.styles :as st]
[status-im.utils.listview :refer [to-datasource]]
[status-im.ui.screens.discover.components.views :as components]
[status-im.components.toolbar-new.view :as toolbar]))
(defview discover-all-recent []
(letsubs [discoveries [:get-recent-discoveries]
tabs-hidden? [:tabs-hidden?]
current-account [:get-current-account]]
(when (seq discoveries)
[react/view st/discover-container
[toolbar/toolbar2 {}
toolbar/default-nav-back
[react/view {} [react/text {} "All recent"]]]
[react/scroll-view (st/list-container tabs-hidden?)
[react/view st/recent-container
[react/view st/recent-list
(let [discoveries (map-indexed vector discoveries)]
(for [[i {:keys [message-id] :as message}] discoveries]
^{:key (str "message-recent-" message-id)}
[components/discover-list-item {:message message
:show-separator? (not= (inc i) (count discoveries))
:current-account current-account}]))]]]])))

View File

@ -0,0 +1,44 @@
(ns status-im.ui.screens.discover.search-results.views
(:require-macros [status-im.utils.views :refer [defview letsubs]])
(:require [status-im.utils.listview :refer [to-datasource]]
[status-im.components.status-bar :as status-bar]
[status-im.components.react :as react]
[status-im.components.icons.vector-icons :as vi]
[status-im.components.toolbar.view :refer [toolbar]]
[status-im.ui.screens.discover.components.views :as components]
[status-im.i18n :as i18n]
[status-im.ui.screens.discover.styles :as styles]
[status-im.ui.screens.contacts.styles :as contacts-styles]
[status-im.components.toolbar-new.view :as toolbar]))
(defn render-separator [_ row-id _]
(react/list-item [react/view {:style styles/row-separator
:key row-id}]))
(defview discover-search-results []
(letsubs [{:keys [discoveries total]} [:get-popular-discoveries 250]
tags [:get :discover-search-tags]
current-account [:get-current-account]]
(let [datasource (to-datasource discoveries)]
[react/view styles/discover-tag-container
[status-bar/status-bar]
[toolbar/toolbar2 {}
toolbar/default-nav-back
[react/view {:flex-direction :row
:justify-content :flex-start}
[react/text {} (str "#" (first tags) " " total)]]]
(if (empty? discoveries)
[react/view styles/empty-view
[vi/icon :icons/group-big {:style contacts-styles/empty-contacts-icon}]
[react/text {:style contacts-styles/empty-contacts-text}
(i18n/label :t/no-statuses-found)]]
;TODO (goranjovic) replace this with status-im.components.list.views
;as per https://github.com/status-im/status-react/issues/1840
[react/list-view {:dataSource datasource
:renderRow (fn [row _ _]
(react/list-item [components/discover-list-item
{:message row
:current-account current-account}]))
:renderSeparator render-separator
:style styles/recent-list}])])))

View File

@ -26,8 +26,10 @@
:align-items :center :align-items :center
:justify-content :center}) :justify-content :center})
(def section-spacing (def title
{:padding 16}) {:padding 16
:flex-direction :row
:justify-content :space-between})
;; Popular ;; Popular
@ -37,7 +39,7 @@
(def carousel-page-style (def carousel-page-style
{}) {})
(def tag-name (def tag-button
{:color color-blue {:color color-blue
:font-size 14 :font-size 14
:padding-right 5 :padding-right 5
@ -45,6 +47,13 @@
:align-items :center :align-items :center
:justify-content :center}) :justify-content :center})
(def tag-name
{:color color-blue
:background-color :white
:font-size 14
:align-items :center
:justify-content :center})
(def tag-count (def tag-count
{:color "#838c93" {:color "#838c93"
:font-size 12 :font-size 12
@ -61,8 +70,10 @@
:padding-right 9}) :padding-right 9})
(def separator (def separator
{:background-color "rgb(200, 199, 204)" {:background-color "rgb(238, 241, 245)"
:height 0.5}) :height 2
:margin-top 2
:margin-bottom 2})
;; Popular list item ;; Popular list item
@ -70,28 +81,44 @@
{:flex 1 {:flex 1
:background-color :white :background-color :white
:padding-top 18 :padding-top 18
:padding-left 16}) :padding-left 16
})
(def popular-list-item (def popular-list-item
{:flex-direction :row {:flex-direction "column"
:padding-bottom 16 :padding-bottom 16
:margin-right 10
:top 1}) :top 1})
(def popular-list-item-name (def popular-list-item-second-row
{:color "black" {:flex 1
:font-size 15 :flex-direction :row
:padding-bottom 4}) :align-items :center
:justify-content :space-between
:margin-bottom 5
:padding-top 25})
(def popular-list-item-name-container (def popular-list-item-name-container
{:flex 0.8 {:flex 0.3
:flex-direction "column" :flex-direction :row
:padding-top 16}) :justify-content :flex-start})
(def popular-list-item-name
{:margin-left 7
:color "black"
:font-size 12})
(def popular-list-item-avatar-container (def popular-list-item-avatar-container
{:flex 0.2 {:flex-direction "column"})
:flex-direction "column"
:align-items :center (def popular-list-chat-action
:padding-top 16}) {:background-color "rgb(220, 214, 251)"
:flex-direction :row
:border-radius 5
:padding 4})
(def popular-list-chat-action-text
{:color "rgb(110, 0, 228)"})
;; discover_recent ;; discover_recent
@ -118,7 +145,7 @@
:justifyContent "center"}) :justifyContent "center"})
(def tag-title-container (def tag-title-container
{:flex 1 {:flex 0.2
:alignItems "center" :alignItems "center"
:justifyContent "center" :justifyContent "center"
:flex-direction "row"}) :flex-direction "row"})
@ -147,3 +174,18 @@
(def search-icon (def search-icon
{:width 17 {:width 17
:height 17}) :height 17})
(def title-action-text
{:color "rgb(110, 0, 228)"})
(def recent-statuses-preview-container
{:background-color toolbar-background2})
(def recent-statuses-preview-content
{:border-radius 4
:padding-top 18
:padding-left 16
:margin-top 2
:margin-bottom 4
:margin-right 2
:background-color :white})

View File

@ -18,10 +18,10 @@
(defn- get-discoveries-by-tags [discoveries current-tag tags] (defn- get-discoveries-by-tags [discoveries current-tag tags]
(let [tags' (or tags [current-tag])] (let [tags' (or tags [current-tag])]
(filter #(every? (->> (:tags %) (filter #(some (->> (:tags %)
(map :name) (map :name)
(into (hash-set))) (into (hash-set)))
tags') tags')
(vals discoveries)))) (vals discoveries))))
(reg-sub :get-popular-discoveries (reg-sub :get-popular-discoveries
@ -37,7 +37,7 @@
(reg-sub :get-recent-discoveries (reg-sub :get-recent-discoveries
(fn [db] (fn [db]
(vals (:discoveries db)))) (sort-by :created-at > (vals (:discoveries db)))))
(reg-sub :get-popular-tags (reg-sub :get-popular-tags
(fn [db [_ limit]] (fn [db [_ limit]]

View File

@ -1,95 +1,113 @@
(ns status-im.ui.screens.discover.views (ns status-im.ui.screens.discover.views
(:require-macros [status-im.utils.views :refer [defview letsubs]]) (:require-macros [status-im.utils.views :refer [defview letsubs]])
(:require (:require
[re-frame.core :refer [dispatch subscribe]] [re-frame.core :as re-frame]
[clojure.string :as str] [clojure.string :as str]
[status-im.components.react :refer [view [status-im.components.react :as react]
scroll-view [status-im.components.icons.vector-icons :as vi]
text [status-im.components.toolbar-new.view :as toolbar]
text-input]] [status-im.components.toolbar-new.actions :as act]
[status-im.components.icons.vector-icons :as vi] [status-im.components.drawer.view :as drawer]
[status-im.components.toolbar-new.view :refer [toolbar-with-search]] [status-im.components.carousel.carousel :as carousel]
[status-im.components.toolbar-new.actions :as act] [status-im.ui.screens.discover.components.views :as components]
[status-im.components.drawer.view :as drawer] [status-im.utils.platform :as platform]
[status-im.components.carousel.carousel :refer [carousel]] [status-im.i18n :as i18n]
[status-im.ui.screens.discover.views.popular-list :refer [discover-popular-list]] [status-im.ui.screens.discover.styles :as styles]
[status-im.ui.screens.discover.views.discover-list-item :refer [discover-list-item]] [status-im.ui.screens.contacts.styles :as contacts-st]))
[status-im.utils.platform :refer [platform-specific]]
[status-im.i18n :refer [label]]
[status-im.ui.screens.discover.styles :as st]
[status-im.ui.screens.contacts.styles :as contacts-st]))
(defn get-hashtags [status] (defn get-hashtags [status]
(let [hashtags (map #(str/lower-case (str/replace % #"#" "")) (re-seq #"[^ !?,;:.]+" status))] (let [hashtags (map #(str/lower-case (str/replace % #"#" "")) (re-seq #"[^ !?,;:.]+" status))]
(or hashtags []))) (or hashtags [])))
(defn toolbar-view [show-search? search-text] (defn toolbar-view [show-search? search-text]
[toolbar-with-search [toolbar/toolbar-with-search
{:show-search? show-search? {:show-search? show-search?
:search-text search-text :search-text search-text
:search-key :discover :search-key :discover
:title (label :t/discover) :title (i18n/label :t/discover)
:search-placeholder (label :t/search-tags) :search-placeholder (i18n/label :t/search-tags)
:nav-action (act/hamburger drawer/open-drawer!) :nav-action (act/hamburger drawer/open-drawer!)
:on-search-submit (fn [text] :on-search-submit (fn [text]
(when-not (str/blank? text) (when-not (str/blank? text)
(let [hashtags (get-hashtags text)] (let [hashtags (get-hashtags text)]
(dispatch [:set :discover-search-tags hashtags]) ;TODO (goranjovic) - refactor double dispatch to a single call
(dispatch [:navigate-to :discover-search-results]))))}]) (re-frame/dispatch [:set :discover-search-tags hashtags])
(re-frame/dispatch [:navigate-to :discover-search-results]))))}])
(defn title [label-kw spacing?]
[view st/section-spacing
[text {:style (merge (get-in platform-specific [:component-styles :discover :subtitle])
(when spacing? {:margin-top 16}))
:uppercase? (get-in platform-specific [:discover :uppercase-subtitles?])
:font :medium}
(label label-kw)]])
(defview discover-popular [{:keys [contacts current-account]}] (defview top-status-for-popular-hashtag [{:keys [tag current-account]}]
(letsubs [discoveries [:get-popular-discoveries 1 [tag]]]
[react/view (merge styles/popular-list-container
(get-in platform/platform-specific [:component-styles :discover :popular]))
[react/view styles/row
[react/view {}
;TODO (goranjovic) - refactor double dispatch to a single call
[react/touchable-highlight {:on-press #(do (re-frame/dispatch [:set :discover-search-tags [tag]])
(re-frame/dispatch [:navigate-to :discover-search-results]))}
[react/view {}
[react/text {:style styles/tag-name
:font :medium}
(str " #" (name tag))]]]]
[react/view styles/tag-count-container
[react/text {:style styles/tag-count
:font :default}
(:total discoveries)]]]
[components/discover-list-item {:message (first (:discoveries discoveries))
:show-separator? false
:current-account current-account}]]))
(defview popular-hashtags-preview [{:keys [contacts current-account]}]
(letsubs [popular-tags [:get-popular-tags 10]] (letsubs [popular-tags [:get-popular-tags 10]]
[view st/popular-container [react/view styles/popular-container
[title :t/popular-tags false] ;TODO (goranjovic) - refactor double dispatch to a single call
(if (pos? (count popular-tags)) [components/title :t/popular-tags :t/all #(do (re-frame/dispatch [:set :discover-search-tags (map :name popular-tags)])
[carousel {:pageStyle st/carousel-page-style (re-frame/dispatch [:navigate-to :discover-all-hashtags]))]
:gap 8 (if (seq popular-tags)
:sneak 16 [carousel/carousel {:pageStyle styles/carousel-page-style
:count (count popular-tags)} :gap 8
:sneak 16
:count (count popular-tags)}
(for [{:keys [name]} popular-tags] (for [{:keys [name]} popular-tags]
[discover-popular-list {:tag name [top-status-for-popular-hashtag {:tag name
:contacts contacts :contacts contacts
:current-account current-account}])] :current-account current-account}])]
[text (label :t/none)])])) [react/text (i18n/label :t/none)])]))
(defview discover-recent [{:keys [current-account]}]
(letsubs [discoveries [:get-recent-discoveries]] (defn empty-discoveries []
(when (seq discoveries) [react/view contacts-st/empty-contact-groups
[view st/recent-container ;; todo change the icon
[title :t/recent true] [vi/icon :icons/group-big {:style contacts-st/empty-contacts-icon}]
[view st/recent-list [react/text {:style contacts-st/empty-contacts-text}
(let [discoveries (map-indexed vector discoveries)] (i18n/label :t/no-statuses-discovered)]])
(for [[i {:keys [message-id] :as message}] discoveries]
^{:key (str "message-recent-" message-id)} (defn recent-statuses-preview [current-account discoveries]
[discover-list-item {:message message [react/view styles/recent-statuses-preview-container
:show-separator? (not= (inc i) (count discoveries)) [components/title :t/recent :t/all #(re-frame/dispatch [:navigate-to :discover-all-recent])]
:current-account current-account}]))]]))) (if (seq discoveries)
[carousel/carousel {:pageStyle styles/carousel-page-style
:gap 8
:sneak 16
:count (count discoveries)}
(for [discovery discoveries]
[react/view styles/recent-statuses-preview-content
[components/discover-list-item {:message discovery
:show-separator? false
:current-account current-account}]])]
[react/text (i18n/label :t/none)])])
(defview discover [current-view?] (defview discover [current-view?]
(letsubs [show-search [:get-in [:toolbar-search :show]] (letsubs [show-search [:get-in [:toolbar-search :show]]
search-text [:get-in [:toolbar-search :text]] search-text [:get-in [:toolbar-search :text]]
contacts [:get-contacts] contacts [:get-contacts]
current-account [:get-current-account] current-account [:get-current-account]
discoveries [:get-recent-discoveries] discoveries [:get-recent-discoveries]]
tabs-hidden? [:tabs-hidden?]] [react/view styles/discover-container
[view st/discover-container
[toolbar-view (and current-view? [toolbar-view (and current-view?
(= show-search :discover)) search-text] (= show-search :discover)) search-text]
(if discoveries (if discoveries
[scroll-view st/list-container [react/scroll-view styles/list-container
[discover-popular {:contacts contacts [recent-statuses-preview current-account discoveries]
:current-account current-account}] [popular-hashtags-preview {:contacts contacts
[discover-recent {:current-account current-account}]] :current-account current-account}]]
[view contacts-st/empty-contact-groups [empty-discoveries])]))
;; todo change icon
[vi/icon :icons/group-big {:style contacts-st/empty-contacts-icon}]
[text {:style contacts-st/empty-contacts-text}
(label :t/no-statuses-discovered)]])]))

View File

@ -1,52 +0,0 @@
(ns status-im.ui.screens.discover.views.discover-list-item
(:require-macros [status-im.utils.views :refer [defview letsubs]])
(:require [re-frame.core :refer [subscribe dispatch]]
[clojure.string :as str]
[status-im.components.react :refer [view text image touchable-highlight]]
[status-im.ui.screens.discover.styles :as st]
[status-im.components.status-view.view :refer [status-view]]
[status-im.utils.gfycat.core :refer [generate-gfy]]
[status-im.utils.identicon :refer [identicon]]
[status-im.components.chat-icon.screen :as ci]
[status-im.utils.platform :refer [platform-specific]]))
(defview discover-list-item [{{:keys [name
photo-path
whisper-id
message-id
status]
:as message} :message
show-separator? :show-separator?
{account-photo-path :photo-path
account-address :public-key
account-name :name
:as current-account} :current-account}]
(letsubs [{contact-name :name
contact-photo-path :photo-path} [:get-in [:contacts/contacts whisper-id]]]
(let [item-style (get-in platform-specific [:component-styles :discover :item])]
[view
[view st/popular-list-item
[view st/popular-list-item-name-container
[text {:style st/popular-list-item-name
: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))]
[status-view {:id message-id
:style (:status-text item-style)
:status status}]]
[view (merge st/popular-list-item-avatar-container
(:icon item-style))
[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))
{:size 36}]]]]]
(when show-separator?
[view st/separator])])))

View File

@ -1,36 +0,0 @@
(ns status-im.ui.screens.discover.views.popular-list
(:require-macros [status-im.utils.views :refer [defview letsubs]])
(:require
[re-frame.core :refer [subscribe dispatch]]
[status-im.components.react :refer [view
list-view
list-item
touchable-highlight
text]]
[status-im.ui.screens.discover.styles :as st]
[status-im.utils.listview :refer [to-datasource]]
[status-im.ui.screens.discover.views.discover-list-item :refer [discover-list-item]]
[status-im.utils.platform :refer [platform-specific]]))
(defview discover-popular-list [{:keys [tag contacts current-account]}]
(letsubs [discoveries [:get-popular-discoveries 3 [tag]]]
[view (merge st/popular-list-container
(get-in platform-specific [:component-styles :discover :popular]))
[view st/row
[view (get-in platform-specific [:component-styles :discover :tag])
[touchable-highlight {:on-press #(do (dispatch [:set :discover-search-tags [tag]])
(dispatch [:navigate-to :discover-search-results]))}
[view
[text {:style st/tag-name
:font :medium}
(str " #" (name tag))]]]]
[view st/tag-count-container
[text {:style st/tag-count
:font :default}
(:total discoveries)]]]
(let [discoveries (map-indexed vector (:discoveries discoveries))]
(for [[i {:keys [message-id] :as discover}] discoveries]
^{:key (str "message-popular-" message-id)}
[discover-list-item {:message discover
:show-separator? (not= (inc i) (count discoveries))
:current-account current-account}]))]))

View File

@ -1,60 +0,0 @@
(ns status-im.ui.screens.discover.views.search-results
(:require-macros [status-im.utils.views :refer [defview letsubs]])
(:require [re-frame.core :refer [subscribe dispatch]]
[status-im.utils.listview :refer [to-datasource]]
[status-im.components.status-bar :refer [status-bar]]
[status-im.components.react :refer [view
text
list-view
list-item
scroll-view]]
[status-im.components.icons.vector-icons :as vi]
[status-im.components.toolbar.view :refer [toolbar]]
[status-im.components.toolbar.actions :as act]
[status-im.ui.screens.discover.views.discover-list-item :refer [discover-list-item]]
[status-im.utils.platform :refer [platform-specific]]
[status-im.i18n :refer [label]]
[status-im.ui.screens.discover.styles :as st]
[status-im.ui.screens.contacts.styles :as contacts-st]))
(defn render-separator [_ row-id _]
(list-item [view {:style st/row-separator
:key row-id}]))
(defn title-content [tags]
[scroll-view {:horizontal true
:bounces false
:flex 1
:contentContainerStyle st/tag-title-scroll}
[view st/tag-title-container
(for [tag (take 3 tags)]
^{:key (str "tag-" tag)}
[view (merge (get-in platform-specific [:component-styles :discover :tag])
{:margin-left 2 :margin-right 2})
[text {:style st/tag-title
:font :default}
(str " #" tag)]])]])
(defview discover-search-results []
(letsubs [discoveries [:get-popular-discoveries 250]
tags [:get :discover-search-tags]
current-account [:get-current-account]]
(let [discoveries (:discoveries discoveries)
datasource (to-datasource discoveries)]
[view st/discover-tag-container
[status-bar]
[toolbar {:nav-action (act/back #(dispatch [:navigate-back]))
:custom-content (title-content tags)
:style st/discover-tag-toolbar}]
(if (empty? discoveries)
[view st/empty-view
[vi/icon :icons/group-big {:style contacts-st/empty-contacts-icon}]
[text {:style contacts-st/empty-contacts-text}
(label :t/no-statuses-found)]]
[list-view {:dataSource datasource
:renderRow (fn [row _ _]
(list-item [discover-list-item
{:message row
:current-account current-account}]))
:renderSeparator render-separator
:style st/recent-list}])])))

View File

@ -19,8 +19,6 @@
[status-im.ui.screens.contacts.contact-list-modal.views :refer [contact-list-modal]] [status-im.ui.screens.contacts.contact-list-modal.views :refer [contact-list-modal]]
[status-im.ui.screens.contacts.new-contact.views :refer [new-contact]] [status-im.ui.screens.contacts.new-contact.views :refer [new-contact]]
[status-im.ui.screens.discover.views.search-results :refer [discover-search-results]]
[status-im.ui.screens.qr-scanner.views :refer [qr-scanner]] [status-im.ui.screens.qr-scanner.views :refer [qr-scanner]]
[status-im.transactions.screens.confirmation-success :refer [confirmation-success]] [status-im.transactions.screens.confirmation-success :refer [confirmation-success]]
@ -50,6 +48,10 @@
[status-im.ui.screens.wallet.send.transaction-sent.views :refer [transaction-sent]] [status-im.ui.screens.wallet.send.transaction-sent.views :refer [transaction-sent]]
[status-im.components.status-bar :as status-bar] [status-im.components.status-bar :as status-bar]
[status-im.ui.screens.discover.search-results.views :as discover-search]
[status-im.ui.screens.discover.recent-statuses.views :as discover-recent]
[status-im.ui.screens.discover.popular-hashtags.views :as discover-popular]
[status-im.ui.screens.network-settings.views :refer [network-settings]] [status-im.ui.screens.network-settings.views :refer [network-settings]]
[status-im.ui.screens.network-settings.add-rpc.views :refer [add-rpc-url]] [status-im.ui.screens.network-settings.add-rpc.views :refer [add-rpc-url]]
[status-im.ui.screens.network-settings.network-details.views :refer [network-details]] [status-im.ui.screens.network-settings.network-details.views :refer [network-details]]
@ -77,7 +79,6 @@
:wallet-request-transaction request-transaction :wallet-request-transaction request-transaction
:wallet-transactions wallet-transactions/transactions :wallet-transactions wallet-transactions/transactions
:wallet-transaction-details wallet-transactions/transaction-details :wallet-transaction-details wallet-transactions/transaction-details
:discover-search-results discover-search-results
:new-chat new-chat :new-chat new-chat
:new-group new-group :new-group new-group
:edit-contact-group edit-contact-group :edit-contact-group edit-contact-group
@ -96,6 +97,9 @@
:profile profile :profile profile
:my-profile my-profile :my-profile my-profile
:edit-my-profile edit-my-profile :edit-my-profile edit-my-profile
:discover-all-recent discover-recent/discover-all-recent
:discover-all-hashtags discover-popular/discover-all-hashtags
:discover-search-results discover-search/discover-search-results
:profile-photo-capture profile-photo-capture :profile-photo-capture profile-photo-capture
:accounts accounts :accounts accounts
:login login :login login