Fixes for discover search input field (#478)

This commit is contained in:
Alexander Pantyukhov 2016-11-22 16:38:15 +03:00
parent 4c876587ed
commit 7c1319e966
7 changed files with 27 additions and 24 deletions

View File

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

View File

@ -38,7 +38,7 @@
[text {:style st/toolbar-title-text [text {:style st/toolbar-title-text
:font :toolbar-title} :font :toolbar-title}
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 (if actions
(for [{action-image :image (for [{action-image :image
action-handler :handler} actions] action-handler :handler} actions]

View File

@ -25,6 +25,7 @@
(defmethod nav/preload-data! :discovery (defmethod nav/preload-data! :discovery
[db _] [db _]
(dispatch [:set :discovery-show-search? false])
(-> db (-> db
(assoc :tags (discoveries/get-all-tags)) (assoc :tags (discoveries/get-all-tags))
(assoc :discoveries (->> (discoveries/get-all :desc) (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.popular-list :refer [discovery-popular-list]]
[status-im.discovery.views.discovery-list-item :refer [discovery-list-item]] [status-im.discovery.views.discovery-list-item :refer [discovery-list-item]]
[status-im.contacts.styles :as contacts-styles] [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] (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))]
@ -26,21 +27,23 @@
(defn title-content [show-search?] (defn title-content [show-search?]
[view st/discovery-toolbar-content [view st/discovery-toolbar-content
(if show-search? (if show-search?
[text-input {:style st/discovery-search-input [text-input {:style st/discovery-search-input
:autoFocus true :auto-focus true
:placeholder (label :t/search-tags) :placeholder (label :t/search-tags)
:onSubmitEditing (fn [e] :on-blur (fn [e]
(let [search (aget e "nativeEvent" "text") (dispatch [:set :discovery-show-search? false]))
hashtags (get-hashtags search)] :on-submit-editing (fn [e]
(dispatch [:set :discovery-search-tags hashtags]) (let [search (aget e "nativeEvent" "text")
(dispatch [:navigate-to :discovery-search-results])))}] hashtags (get-hashtags search)]
(dispatch [:set :discovery-search-tags hashtags])
(dispatch [:navigate-to :discovery-search-results])))}]
[view [view
[text {:style st/discovery-title [text {:style st/discovery-title
:font :toolbar-title} :font :toolbar-title}
(label :t/discovery)]])]) (label :t/discovery)]])])
(defn toogle-search [current-value] (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?] (defn discovery-toolbar [show-search?]
[toolbar [toolbar
@ -83,18 +86,18 @@
[view st/recent-list [view st/recent-list
(let [discoveries (map-indexed vector discoveries)] (let [discoveries (map-indexed vector discoveries)]
(for [[i {:keys [message-id] :as message}] 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 [discovery-list-item {:message message
:show-separator? (not= (inc i) (count discoveries)) :show-separator? (not= (inc i) (count discoveries))
:current-account current-account}]))]])) :current-account current-account}]))]]))
(defview discovery [] (defview discovery [current-view?]
[show-search? [:get ::show-search?] [show-search? [:get :discovery-show-search?]
contacts [:get :contacts] contacts [:get :contacts]
current-account [:get-current-account] current-account [:get-current-account]
discoveries [:get-recent-discoveries]] discoveries [:get-recent-discoveries]]
[view st/discovery-container [view st/discovery-container
[discovery-toolbar show-search?] [discovery-toolbar (and current-view? show-search?)]
(if discoveries (if discoveries
[scroll-view st/scroll-view-container [scroll-view st/scroll-view-container
[discovery-popular {:contacts contacts [discovery-popular {:contacts contacts

View File

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

View File

@ -30,7 +30,7 @@
(:total discoveries)]]] (:total discoveries)]]]
(let [discoveries (map-indexed vector (:discoveries discoveries))] (let [discoveries (map-indexed vector (:discoveries discoveries))]
(for [[i {:keys [message-id] :as discovery}] 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 [discovery-list-item {:message discovery
:show-separator? (not= (inc i) (count discoveries)) :show-separator? (not= (inc i) (count discoveries))
:current-account current-account}]))]) :current-account current-account}]))])

View File

@ -101,7 +101,7 @@
:new-group-chat "New group chat" :new-group-chat "New group chat"
;discover ;discover
:discovery "Discovery" :discovery "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 tags"