Merge pull request #487 from status-im/bug/#478

Fixes for discover search input field (#478)
This commit is contained in:
Roman Volosovskyi 2016-11-27 15:59:45 +02:00 committed by GitHub
commit cfcce5f0f7
7 changed files with 27 additions and 24 deletions

View File

@ -103,7 +103,7 @@
:ref #(reset! main-swiper %)
:on-momentum-scroll-end (on-scroll-end swiped?)})
[chats-list]
[discovery]
[discovery (= @view-id :discovery)]
[contact-list]]
[tabs {:selected-view-id @view-id
:prev-view-id @prev-view-id

View File

@ -37,7 +37,7 @@
[text {:style st/toolbar-title-text
:font :toolbar-title}
title]])
[view (st/toolbar-actions-container (count actions) (or custom-content custom-action))
[view (st/toolbar-actions-container (count actions) custom-action)
(if actions
(for [{action-image :image
action-handler :handler} actions]

View File

@ -25,6 +25,7 @@
(defmethod nav/preload-data! :discovery
[db _]
(dispatch [:set :discovery-show-search? false])
(-> db
(assoc :tags (discoveries/get-all-tags))
(assoc :discoveries (->> (discoveries/get-all :desc)

View File

@ -17,7 +17,8 @@
[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]
[status-im.utils.platform :refer [platform-specific]]))
[status-im.utils.platform :refer [platform-specific]]
[reagent.core :as r]))
(defn get-hashtags [status]
(let [hashtags (map #(str/lower-case (str/replace % #"#" "")) (re-seq #"[^ !?,;:.]+" status))]
@ -26,21 +27,23 @@
(defn title-content [show-search?]
[view st/discovery-toolbar-content
(if show-search?
[text-input {:style st/discovery-search-input
:autoFocus true
:placeholder (label :t/search-tags)
:onSubmitEditing (fn [e]
(let [search (aget e "nativeEvent" "text")
hashtags (get-hashtags search)]
(dispatch [:set :discovery-search-tags hashtags])
(dispatch [:navigate-to :discovery-search-results])))}]
[text-input {:style st/discovery-search-input
:auto-focus true
:placeholder (label :t/search-tags)
:on-blur (fn [e]
(dispatch [:set :discovery-show-search? false]))
:on-submit-editing (fn [e]
(let [search (aget e "nativeEvent" "text")
hashtags (get-hashtags search)]
(dispatch [:set :discovery-search-tags hashtags])
(dispatch [:navigate-to :discovery-search-results])))}]
[view
[text {:style st/discovery-title
:font :toolbar-title}
(label :t/discovery)]])])
(defn toogle-search [current-value]
(dispatch [:set ::show-search? (not current-value)]))
(dispatch [:set :discovery-show-search? (not current-value)]))
(defn discovery-toolbar [show-search?]
[toolbar
@ -83,18 +86,18 @@
[view st/recent-list
(let [discoveries (map-indexed vector discoveries)]
(for [[i {:keys [message-id] :as message}] discoveries]
^{:key (str "message-" message-id)}
^{:key (str "message-recent-" message-id)}
[discovery-list-item {:message message
:show-separator? (not= (inc i) (count discoveries))
:current-account current-account}]))]]))
(defview discovery []
[show-search? [:get ::show-search?]
(defview discovery [current-view?]
[show-search? [:get :discovery-show-search?]
contacts [:get :contacts]
current-account [:get-current-account]
discoveries [:get-recent-discoveries]]
[view st/discovery-container
[discovery-toolbar show-search?]
[discovery-toolbar (and current-view? show-search?)]
(if discoveries
[scroll-view st/scroll-view-container
[discovery-popular {:contacts contacts

View File

@ -34,12 +34,11 @@
:elevation 0})
(def discovery-search-input
{:flex 1
:align-self "stretch"
:margin-left 18
:line-height 42
:font-size 14
:color "#7099e6"})
{:flex 1
:align-self "stretch"
:margin-left 18
:font-size 14
:color "#7099e6"})
(def discovery-title
{:color "#000000de"

View File

@ -30,7 +30,7 @@
(:total discoveries)]]]
(let [discoveries (map-indexed vector (:discoveries discoveries))]
(for [[i {:keys [message-id] :as discovery}] discoveries]
^{:key (str "message-" message-id)}
^{:key (str "message-popular-" message-id)}
[discovery-list-item {:message discovery
:show-separator? (not= (inc i) (count discoveries))
:current-account current-account}]))])

View File

@ -101,7 +101,7 @@
:new-group-chat "New group chat"
;discover
:discovery "Discovery"
:discovery "Discover"
:none "None"
:search-tags "Type your search tags here"
:popular-tags "Popular tags"