From cf9dab19c95cbe648c3d2224d5c4adcc5f06a88a Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Thu, 20 Oct 2016 18:14:15 +0300 Subject: [PATCH] empty discover screen Former-commit-id: 15f66cc0e3dbd27b1cc8d94193e31e2fbc245665 --- src/status_im/discovery/screen.cljs | 56 ++++++++++++++----- src/status_im/discovery/views/popular.cljs | 23 -------- .../discovery/views/popular_list.cljs | 4 -- src/status_im/discovery/views/recent.cljs | 19 ------- src/status_im/translations/en.cljs | 1 + 5 files changed, 42 insertions(+), 61 deletions(-) delete mode 100644 src/status_im/discovery/views/popular.cljs delete mode 100644 src/status_im/discovery/views/recent.cljs diff --git a/src/status_im/discovery/screen.cljs b/src/status_im/discovery/screen.cljs index d5bf5d6d84..09a8f96f3f 100644 --- a/src/status_im/discovery/screen.cljs +++ b/src/status_im/discovery/screen.cljs @@ -6,14 +6,17 @@ [status-im.components.react :refer [view scroll-view text - text-input]] + text-input + icon]] [status-im.components.toolbar.view :refer [toolbar]] [status-im.components.drawer.view :refer [open-drawer]] - [status-im.discovery.views.popular :refer [discovery-popular]] - [status-im.discovery.views.recent :refer [discovery-recent]] [status-im.discovery.styles :as st] [status-im.components.tabs.bottom-gradient :refer [bottom-gradient]] - [status-im.i18n :refer [label]])) + [status-im.i18n :refer [label]] + [status-im.components.carousel.carousel :refer [carousel]] + [status-im.discovery.views.popular-list :refer [discovery-popular-list]] + [status-im.discovery.views.discovery-list-item :refer [discovery-list-item]] + [status-im.contacts.styles :as contacts-styles])) (defn get-hashtags [status] (let [hashtags (map #(str/lower-case (str/replace % #"#" "")) (re-seq #"[^ !?,;:.]+" status))] @@ -49,23 +52,46 @@ :style st/search-icon} :handler #(toogle-search show-search?)}]}]) +(defn title [label-kw] + [view st/section-spacing + [text {:style st/discovery-subtitle + :font :medium} + (label label-kw)]]) + +(defview discovery-popular [{:keys [contacts]}] + [popular-tags [:get-popular-tags 10]] + (if (seq popular-tags) + [view + [title :t/popular-tags] + (if (pos? (count popular-tags)) + [carousel {:pageStyle st/carousel-page-style} + (for [{:keys [name count]} popular-tags] + [discovery-popular-list {:tag name + :count count + :contacts contacts}])] + [text (label :t/none)])] + [view contacts-styles/empty-contact-groups + ;; todo change icon + [icon :group_big contacts-styles/empty-contacts-icon] + [text {:style contacts-styles/empty-contacts-text} + (label :t/no-statuses-discovered)]])) + +(defview discovery-recent [{:keys [contacts]}] + [discoveries [:get :discoveries]] + (when (seq discoveries) + [view + [title :t/recent] + [view st/recent-list + (for [{:keys [message-id] :as discovery} discoveries] + ^{:key (str "message-" message-id)} + [discovery-list-item discovery])]])) + (defview discovery [] [show-search? [:get ::show-search?] contacts [:get :contacts]] [view st/discovery-container [discovery-toolbar show-search?] [scroll-view st/scroll-view-container - - [view st/section-spacing - [text {:style st/discovery-subtitle - :font :medium} - (label :t/popular-tags)]] [discovery-popular {:contacts contacts}] - - [view st/section-spacing - [text {:style st/discovery-subtitle - :font :medium} - (label :t/recent)]] [discovery-recent {:contacts contacts}]] - [bottom-gradient]]) diff --git a/src/status_im/discovery/views/popular.cljs b/src/status_im/discovery/views/popular.cljs deleted file mode 100644 index b78ee07459..0000000000 --- a/src/status_im/discovery/views/popular.cljs +++ /dev/null @@ -1,23 +0,0 @@ -(ns status-im.discovery.views.popular - (:require-macros [status-im.utils.views :refer [defview]]) - (:require - [re-frame.core :refer [subscribe]] - [status-im.components.react :refer [text]] - [status-im.components.carousel.carousel :refer [carousel]] - [status-im.discovery.styles :as st] - [status-im.discovery.views.popular-list :refer [discovery-popular-list]] - [status-im.i18n :refer [label]] - [status-im.components.react :as r])) - -(defn page-width [] - (.-width (.get (.. r/react-native -Dimensions) "window"))) - -(defview discovery-popular [{:keys [contacts]}] - [popular-tags [:get-popular-tags 10]] - (if (pos? (count popular-tags)) - [carousel {:pageStyle st/carousel-page-style} - (for [{:keys [name count]} popular-tags] - [discovery-popular-list {:tag name - :count count - :contacts contacts}])] - [text (label :t/none)])) diff --git a/src/status_im/discovery/views/popular_list.cljs b/src/status_im/discovery/views/popular_list.cljs index 8888de7134..f8a7dd2bb4 100644 --- a/src/status_im/discovery/views/popular_list.cljs +++ b/src/status_im/discovery/views/popular_list.cljs @@ -11,10 +11,6 @@ [status-im.utils.listview :refer [to-datasource]] [status-im.discovery.views.discovery-list-item :refer [discovery-list-item]])) -(defn render-separator [_ row-id _] - (list-item [view {:style st/row-separator - :key row-id}])) - (defview discovery-popular-list [{:keys [tag count contacts]}] [discoveries [:get-discoveries-by-tags [tag] 3]] [view st/popular-list-container diff --git a/src/status_im/discovery/views/recent.cljs b/src/status_im/discovery/views/recent.cljs deleted file mode 100644 index 66b629d988..0000000000 --- a/src/status_im/discovery/views/recent.cljs +++ /dev/null @@ -1,19 +0,0 @@ -(ns status-im.discovery.views.recent - (:require-macros [status-im.utils.views :refer [defview]]) - (:require - [re-frame.core :refer [subscribe]] - [status-im.components.react :refer [view list-view list-item]] - [status-im.utils.listview :refer [to-datasource]] - [status-im.discovery.styles :as st] - [status-im.discovery.views.discovery-list-item :refer [discovery-list-item]])) - -(defn render-separator [_ row-id _] - (list-item [view {:style st/row-separator - :key row-id}])) - -(defview discovery-recent [{:keys [contacts]}] - [discoveries [:get :discoveries]] - [view st/recent-list - (for [{:keys [message-id] :as discovery} discoveries] - ^{:key (str "message-" message-id)} - [discovery-list-item discovery])]) diff --git a/src/status_im/translations/en.cljs b/src/status_im/translations/en.cljs index e502cbc852..d1791a508a 100644 --- a/src/status_im/translations/en.cljs +++ b/src/status_im/translations/en.cljs @@ -100,6 +100,7 @@ :search-tags "Type your search tags here" :popular-tags "Popular tags" :recent "Recent" + :no-statuses-discovered "No statuses discovered" ;settings :settings "Settings"