From dd5c433687dee1c9d028a2a385fd0cdc57bb3d58 Mon Sep 17 00:00:00 2001 From: Goran Jovic Date: Mon, 18 Sep 2017 16:09:59 +0200 Subject: [PATCH] fix #1977 - discover recent statuses and statuses per popular hashtags --- src/status_im/android/platform.cljs | 7 +- src/status_im/translations/en.cljs | 6 +- .../ui/screens/discover/components/views.cljs | 81 +++++++++ src/status_im/ui/screens/discover/db.cljs | 2 +- .../discover/popular_hashtags/views.cljs | 27 +++ .../discover/recent_statuses/views.cljs | 27 +++ .../discover/search_results/views.cljs | 44 +++++ src/status_im/ui/screens/discover/styles.cljs | 80 ++++++--- src/status_im/ui/screens/discover/subs.cljs | 10 +- src/status_im/ui/screens/discover/views.cljs | 154 ++++++++++-------- .../discover/views/discover_list_item.cljs | 52 ------ .../screens/discover/views/popular_list.cljs | 36 ---- .../discover/views/search_results.cljs | 60 ------- src/status_im/ui/screens/views.cljs | 10 +- 14 files changed, 346 insertions(+), 250 deletions(-) create mode 100644 src/status_im/ui/screens/discover/components/views.cljs create mode 100644 src/status_im/ui/screens/discover/popular_hashtags/views.cljs create mode 100644 src/status_im/ui/screens/discover/recent_statuses/views.cljs create mode 100644 src/status_im/ui/screens/discover/search_results/views.cljs delete mode 100644 src/status_im/ui/screens/discover/views/discover_list_item.cljs delete mode 100644 src/status_im/ui/screens/discover/views/popular_list.cljs delete mode 100644 src/status_im/ui/screens/discover/views/search_results.cljs diff --git a/src/status_im/android/platform.cljs b/src/status_im/android/platform.cljs index 49b9b894cb..5f3488f5b1 100644 --- a/src/status_im/android/platform.cljs +++ b/src/status_im/android/platform.cljs @@ -37,17 +37,16 @@ :border-top-width 0.5}} :discover {:subtitle {:color styles/color-gray2 :font-size 14} - :popular {:border-radius 1 + :popular {:border-radius 4 :margin-top 2 :margin-bottom 4 - :margin-right 2 - :elevation 2} + :margin-right 2} :tag {:flex-direction "column" :background-color "#7099e619" :border-radius 5 :padding 4} :item {:status-text {:line-height 22 - :font-size 14}}} + :font-size 16}}} :contacts {:show-all-text-font :medium} :bottom-gradient {:height 3} :input-label {:left 4} diff --git a/src/status_im/translations/en.cljs b/src/status_im/translations/en.cljs index f27bcdb75b..694a6fd938 100644 --- a/src/status_im/translations/en.cljs +++ b/src/status_im/translations/en.cljs @@ -159,10 +159,12 @@ :discover "Discover" :none "None" :search-tags "Type your search tags here" - :popular-tags "Popular tags" - :recent "Recent" + :popular-tags "Popular hashtags" + :recent "Recent statuses" :no-statuses-discovered "No statuses discovered" :no-statuses-found "No statuses found" + :chat "Chat" + :all "All" ;;settings :settings "Settings" diff --git a/src/status_im/ui/screens/discover/components/views.cljs b/src/status_im/ui/screens/discover/components/views.cljs new file mode 100644 index 0000000000..ed4f580a05 --- /dev/null +++ b/src/status_im/ui/screens/discover/components/views.cljs @@ -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])]]))) diff --git a/src/status_im/ui/screens/discover/db.cljs b/src/status_im/ui/screens/discover/db.cljs index 831a79fbe8..fce6007238 100644 --- a/src/status_im/ui/screens/discover/db.cljs +++ b/src/status_im/ui/screens/discover/db.cljs @@ -3,7 +3,7 @@ ;; {id (string) descovery (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/current-tag (s/nilable map?)) (s/def :discoveries/request-discoveries-timer (s/nilable int?)) diff --git a/src/status_im/ui/screens/discover/popular_hashtags/views.cljs b/src/status_im/ui/screens/discover/popular_hashtags/views.cljs new file mode 100644 index 0000000000..459e66f7ab --- /dev/null +++ b/src/status_im/ui/screens/discover/popular_hashtags/views.cljs @@ -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}]))]]]])) diff --git a/src/status_im/ui/screens/discover/recent_statuses/views.cljs b/src/status_im/ui/screens/discover/recent_statuses/views.cljs new file mode 100644 index 0000000000..f0ad7a450d --- /dev/null +++ b/src/status_im/ui/screens/discover/recent_statuses/views.cljs @@ -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}]))]]]]))) diff --git a/src/status_im/ui/screens/discover/search_results/views.cljs b/src/status_im/ui/screens/discover/search_results/views.cljs new file mode 100644 index 0000000000..246397a774 --- /dev/null +++ b/src/status_im/ui/screens/discover/search_results/views.cljs @@ -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}])]))) diff --git a/src/status_im/ui/screens/discover/styles.cljs b/src/status_im/ui/screens/discover/styles.cljs index b5d3ecd9fd..32de598b94 100644 --- a/src/status_im/ui/screens/discover/styles.cljs +++ b/src/status_im/ui/screens/discover/styles.cljs @@ -26,8 +26,10 @@ :align-items :center :justify-content :center}) -(def section-spacing - {:padding 16}) +(def title + {:padding 16 + :flex-direction :row + :justify-content :space-between}) ;; Popular @@ -37,7 +39,7 @@ (def carousel-page-style {}) -(def tag-name +(def tag-button {:color color-blue :font-size 14 :padding-right 5 @@ -45,6 +47,13 @@ :align-items :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 {:color "#838c93" :font-size 12 @@ -61,8 +70,10 @@ :padding-right 9}) (def separator - {:background-color "rgb(200, 199, 204)" - :height 0.5}) + {:background-color "rgb(238, 241, 245)" + :height 2 + :margin-top 2 + :margin-bottom 2}) ;; Popular list item @@ -70,28 +81,44 @@ {:flex 1 :background-color :white :padding-top 18 - :padding-left 16}) + :padding-left 16 + }) (def popular-list-item - {:flex-direction :row + {:flex-direction "column" :padding-bottom 16 + :margin-right 10 :top 1}) -(def popular-list-item-name - {:color "black" - :font-size 15 - :padding-bottom 4}) +(def popular-list-item-second-row + {:flex 1 + :flex-direction :row + :align-items :center + :justify-content :space-between + :margin-bottom 5 + :padding-top 25}) (def popular-list-item-name-container - {:flex 0.8 - :flex-direction "column" - :padding-top 16}) + {:flex 0.3 + :flex-direction :row + :justify-content :flex-start}) + +(def popular-list-item-name + {:margin-left 7 + :color "black" + :font-size 12}) (def popular-list-item-avatar-container - {:flex 0.2 - :flex-direction "column" - :align-items :center - :padding-top 16}) + {:flex-direction "column"}) + +(def popular-list-chat-action + {: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 @@ -118,7 +145,7 @@ :justifyContent "center"}) (def tag-title-container - {:flex 1 + {:flex 0.2 :alignItems "center" :justifyContent "center" :flex-direction "row"}) @@ -147,3 +174,18 @@ (def search-icon {:width 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}) \ No newline at end of file diff --git a/src/status_im/ui/screens/discover/subs.cljs b/src/status_im/ui/screens/discover/subs.cljs index 870ce90a09..9d3d5fd7af 100644 --- a/src/status_im/ui/screens/discover/subs.cljs +++ b/src/status_im/ui/screens/discover/subs.cljs @@ -18,10 +18,10 @@ (defn- get-discoveries-by-tags [discoveries current-tag tags] (let [tags' (or tags [current-tag])] - (filter #(every? (->> (:tags %) - (map :name) - (into (hash-set))) - tags') + (filter #(some (->> (:tags %) + (map :name) + (into (hash-set))) + tags') (vals discoveries)))) (reg-sub :get-popular-discoveries @@ -37,7 +37,7 @@ (reg-sub :get-recent-discoveries (fn [db] - (vals (:discoveries db)))) + (sort-by :created-at > (vals (:discoveries db))))) (reg-sub :get-popular-tags (fn [db [_ limit]] diff --git a/src/status_im/ui/screens/discover/views.cljs b/src/status_im/ui/screens/discover/views.cljs index 6def129ce8..83ead15de8 100644 --- a/src/status_im/ui/screens/discover/views.cljs +++ b/src/status_im/ui/screens/discover/views.cljs @@ -1,95 +1,113 @@ (ns status-im.ui.screens.discover.views (:require-macros [status-im.utils.views :refer [defview letsubs]]) (:require - [re-frame.core :refer [dispatch subscribe]] - [clojure.string :as str] - [status-im.components.react :refer [view - scroll-view - text - text-input]] - [status-im.components.icons.vector-icons :as vi] - [status-im.components.toolbar-new.view :refer [toolbar-with-search]] - [status-im.components.toolbar-new.actions :as act] - [status-im.components.drawer.view :as drawer] - [status-im.components.carousel.carousel :refer [carousel]] - [status-im.ui.screens.discover.views.popular-list :refer [discover-popular-list]] - [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])) + [re-frame.core :as re-frame] + [clojure.string :as str] + [status-im.components.react :as react] + [status-im.components.icons.vector-icons :as vi] + [status-im.components.toolbar-new.view :as toolbar] + [status-im.components.toolbar-new.actions :as act] + [status-im.components.drawer.view :as drawer] + [status-im.components.carousel.carousel :as carousel] + [status-im.ui.screens.discover.components.views :as components] + [status-im.utils.platform :as platform] + [status-im.i18n :as i18n] + [status-im.ui.screens.discover.styles :as styles] + [status-im.ui.screens.contacts.styles :as contacts-st])) (defn get-hashtags [status] (let [hashtags (map #(str/lower-case (str/replace % #"#" "")) (re-seq #"[^ !?,;:.]+" status))] (or hashtags []))) (defn toolbar-view [show-search? search-text] - [toolbar-with-search + [toolbar/toolbar-with-search {:show-search? show-search? :search-text search-text :search-key :discover - :title (label :t/discover) - :search-placeholder (label :t/search-tags) + :title (i18n/label :t/discover) + :search-placeholder (i18n/label :t/search-tags) :nav-action (act/hamburger drawer/open-drawer!) :on-search-submit (fn [text] (when-not (str/blank? text) (let [hashtags (get-hashtags text)] - (dispatch [:set :discover-search-tags hashtags]) - (dispatch [:navigate-to :discover-search-results]))))}]) + ;TODO (goranjovic) - refactor double dispatch to a single call + (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]] - [view st/popular-container - [title :t/popular-tags false] - (if (pos? (count popular-tags)) - [carousel {:pageStyle st/carousel-page-style - :gap 8 - :sneak 16 - :count (count popular-tags)} + [react/view styles/popular-container + ;TODO (goranjovic) - refactor double dispatch to a single call + [components/title :t/popular-tags :t/all #(do (re-frame/dispatch [:set :discover-search-tags (map :name popular-tags)]) + (re-frame/dispatch [:navigate-to :discover-all-hashtags]))] + (if (seq popular-tags) + [carousel/carousel {:pageStyle styles/carousel-page-style + :gap 8 + :sneak 16 + :count (count popular-tags)} (for [{:keys [name]} popular-tags] - [discover-popular-list {:tag name - :contacts contacts - :current-account current-account}])] - [text (label :t/none)])])) + [top-status-for-popular-hashtag {:tag name + :contacts contacts + :current-account current-account}])] + [react/text (i18n/label :t/none)])])) -(defview discover-recent [{:keys [current-account]}] - (letsubs [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 message}] discoveries] - ^{:key (str "message-recent-" message-id)} - [discover-list-item {:message message - :show-separator? (not= (inc i) (count discoveries)) - :current-account current-account}]))]]))) + +(defn empty-discoveries [] + [react/view contacts-st/empty-contact-groups + ;; todo change the icon + [vi/icon :icons/group-big {:style contacts-st/empty-contacts-icon}] + [react/text {:style contacts-st/empty-contacts-text} + (i18n/label :t/no-statuses-discovered)]]) + +(defn recent-statuses-preview [current-account discoveries] + [react/view styles/recent-statuses-preview-container + [components/title :t/recent :t/all #(re-frame/dispatch [:navigate-to :discover-all-recent])] + (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?] - (letsubs [show-search [:get-in [:toolbar-search :show]] - search-text [:get-in [:toolbar-search :text]] - contacts [:get-contacts] + (letsubs [show-search [:get-in [:toolbar-search :show]] + search-text [:get-in [:toolbar-search :text]] + contacts [:get-contacts] current-account [:get-current-account] - discoveries [:get-recent-discoveries] - tabs-hidden? [:tabs-hidden?]] - [view st/discover-container + discoveries [:get-recent-discoveries]] + [react/view styles/discover-container [toolbar-view (and current-view? (= show-search :discover)) search-text] (if discoveries - [scroll-view st/list-container - [discover-popular {:contacts contacts - :current-account current-account}] - [discover-recent {:current-account current-account}]] - [view contacts-st/empty-contact-groups - ;; 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)]])])) + [react/scroll-view styles/list-container + [recent-statuses-preview current-account discoveries] + [popular-hashtags-preview {:contacts contacts + :current-account current-account}]] + [empty-discoveries])])) diff --git a/src/status_im/ui/screens/discover/views/discover_list_item.cljs b/src/status_im/ui/screens/discover/views/discover_list_item.cljs deleted file mode 100644 index d9c0fff2e7..0000000000 --- a/src/status_im/ui/screens/discover/views/discover_list_item.cljs +++ /dev/null @@ -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])]))) diff --git a/src/status_im/ui/screens/discover/views/popular_list.cljs b/src/status_im/ui/screens/discover/views/popular_list.cljs deleted file mode 100644 index 44c6fa8383..0000000000 --- a/src/status_im/ui/screens/discover/views/popular_list.cljs +++ /dev/null @@ -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}]))])) diff --git a/src/status_im/ui/screens/discover/views/search_results.cljs b/src/status_im/ui/screens/discover/views/search_results.cljs deleted file mode 100644 index 02acc872fd..0000000000 --- a/src/status_im/ui/screens/discover/views/search_results.cljs +++ /dev/null @@ -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}])]))) diff --git a/src/status_im/ui/screens/views.cljs b/src/status_im/ui/screens/views.cljs index 5400beffe7..c126cc7dd8 100644 --- a/src/status_im/ui/screens/views.cljs +++ b/src/status_im/ui/screens/views.cljs @@ -19,8 +19,6 @@ [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.discover.views.search-results :refer [discover-search-results]] - [status-im.ui.screens.qr-scanner.views :refer [qr-scanner]] [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.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.add-rpc.views :refer [add-rpc-url]] [status-im.ui.screens.network-settings.network-details.views :refer [network-details]] @@ -77,7 +79,6 @@ :wallet-request-transaction request-transaction :wallet-transactions wallet-transactions/transactions :wallet-transaction-details wallet-transactions/transaction-details - :discover-search-results discover-search-results :new-chat new-chat :new-group new-group :edit-contact-group edit-contact-group @@ -96,6 +97,9 @@ :profile profile :my-profile 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 :accounts accounts :login login