[#3006]: No more search features

Signed-off-by: alwxndr <alwxndr@gmail.com>
This commit is contained in:
alwxndr 2018-01-30 22:11:56 +01:00
parent d0dff14ea6
commit ce524507da
No known key found for this signature in database
GPG Key ID: 69AE782ACD540F0B
25 changed files with 46 additions and 315 deletions

View File

@ -1,3 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<path fill="" d="M9.92798871,13.8799812 L9.92798871,13.8799812 C12.1106139,13.8799812 13.8799812,12.1106139 13.8799812,9.92798871 C13.8799812,7.74536354 12.1106139,5.97599624 9.92798871,5.97599624 C7.74536354,5.97599624 5.97599624,7.74536354 5.97599624,9.92798871 C5.97599624,12.1106139 7.74536354,13.8799812 9.92798871,13.8799812 L9.92798871,13.8799812 Z M19.7118864,18.3146461 C20.0959479,18.6987076 20.0971983,19.3201438 19.7086711,19.7086711 L19.7086711,19.7086711 C19.3228338,20.0945083 18.6917146,20.0889549 18.3146461,19.7118864 L12.719254,14.1164944 C12.3351926,13.7324329 12.3339421,13.1109966 12.7224694,12.7224694 L12.7224694,12.7224694 C13.1083067,12.3366321 13.7394259,12.3421856 14.1164944,12.719254 L19.7118864,18.3146461 Z M9.92798871,15.8559774 L9.92798871,15.8559774 C6.65405095,15.8559774 4,13.2019265 4,9.92798871 C4,6.65405095 6.65405095,4 9.92798871,4 C13.2019265,4 15.8559774,6.65405095 15.8559774,9.92798871 C15.8559774,13.2019265 13.2019265,15.8559774 9.92798871,15.8559774 L9.92798871,15.8559774 Z"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -47,15 +47,6 @@
:handler #(do (re-frame/dispatch [:remove-chat chat-id])
(re-frame/dispatch [:navigation-replace :home]))})
(def item-search
{:title (i18n/label :t/search-chat)
:subtitle (i18n/label :t/not-implemented)
:icon :search_gray_copy
:icon-style {:width 17
:height 17}
;; TODO not implemented: action Search chat
:handler nil})
(def item-notifications
{:title (i18n/label :t/notifications-title)
:subtitle (i18n/label :t/not-implemented)
@ -76,14 +67,12 @@
(defn group-chat-items [members public?]
(into (if public? [] [(item-members members)])
[item-search
item-notifications
[item-notifications
item-settings]))
(defn user-chat-items [chat-id]
[(item-user chat-id)
(item-delete chat-id)
item-search
item-notifications])
(defn overlay [{:keys [on-click-outside]} items]

View File

@ -17,7 +17,7 @@
(defview choose-contact-view [{title :title
arg-index :index
bot-db-key :bot-db-key}]
[contacts [:contacts-filtered :people-in-current-chat]]
[contacts [:people-in-current-chat]]
[react/view {:flex 1}
[react/text {:style {:font-size 14
:color "rgb(147, 155, 161)"

View File

@ -62,7 +62,6 @@
:icons/public (slurp/slurp-svg "./resources/icons/public.svg")
:icons/public-chat (slurp/slurp-svg "./resources/icons/public_chat.svg")
:icons/qr (slurp/slurp-svg "./resources/icons/QR.svg")
:icons/search (slurp/slurp-svg "./resources/icons/search.svg")
:icons/smile (slurp/slurp-svg "./resources/icons/smile.svg")
:icons/commands-list (slurp/slurp-svg "./resources/icons/commands_list.svg")
:icons/back (slurp/slurp-svg "./resources/icons/back.svg")

View File

@ -95,10 +95,6 @@
(def flex
{:flex 1})
(def icon-search
{:width 24
:height 24})
(def create-icon
{:fontSize 20
:height 22

View File

@ -9,14 +9,6 @@
{:icon :icons/options
:options options})
(defn search [handler]
{:icon :icons/search
:handler handler})
(def search-icon
{:icon :icons/search
:icon-opts {:container-style {:opacity 0.4}}})
(defn back [handler]
{:icon :icons/back
:handler handler

View File

@ -64,27 +64,6 @@
:align-items :center
:justify-content :center})
(def toolbar-with-search
{:background-color toolbar-background1})
(defstyle toolbar-with-search-content
{:flex 1
:android {:padding-left 18}
:ios {:align-items :center}})
(defstyle toolbar-search-input
{:line-height 24
:height 24
:font-size 17
:padding-top 0
:padding-left 0
:padding-bottom 0
:text-align-vertical :center
:color styles/color-black
:ios {:padding-left 8
:padding-top 2
:letter-spacing -0.2}})
(def action-default
{:width 24
:height 24})

View File

@ -129,67 +129,4 @@
(defn simple-toolbar
"A simple toolbar composed of a nav-back item and a single line title."
([] (simple-toolbar nil))
([title] (simple-toolbar nil title))
([m title] (simple-toolbar m default-nav-back title))
([m nav-back title]
(toolbar m nav-back [content-title title])))
(def search-text-input (reagent/atom nil))
(defn- toolbar-search-submit [on-search-submit]
(let [text @(re-frame/subscribe [:get-in [:toolbar-search :text]])]
(on-search-submit text)
(re-frame/dispatch [:set-in [:toolbar-search :text] nil])))
(defn- toolbar-with-search-content [{:keys [show-search?
search-placeholder
title
custom-title
on-search-submit]}]
[react/view styles/toolbar-with-search-content
(if show-search?
[react/text-input
{:style styles/toolbar-search-input
:ref #(reset! search-text-input %)
:auto-focus true
:placeholder search-placeholder
:placeholder-text-color colors/gray
:on-change-text #(re-frame/dispatch [:set-in [:toolbar-search :text] %])
:on-submit-editing (when on-search-submit
#(toolbar-search-submit on-search-submit))}]
(or custom-title
[react/view
[react/text {:style styles/toolbar-title-text
:font :toolbar-title}
title]]))])
(defn- toggle-search-fn [text]
(re-frame/dispatch [:set-in [:toolbar-search :show] text])
(re-frame/dispatch [:set-in [:toolbar-search :text] ""]))
(defn- search-actions [show-search? search-text search-key actions]
(if show-search?
(if (pos? (count search-text))
[(actions/close #(do
(.clear @search-text-input)
(re-frame/dispatch [:set-in [:toolbar-search :text] ""])))]
[actions/search-icon])
(into [(actions/search #(toggle-search-fn search-key))] actions)))
(defn toolbar-with-search [{:keys [show-search?
search-text
search-key
nav-action
style
modal?]
:as opts}]
;; TODO(jeluard) refactor to components? Drop modal? and nav-action support
[toolbar {:modal? modal?
:style style}
[nav-button
(if show-search?
(actions/back #(toggle-search-fn nil))
(or nav-action (if modal? actions/default-close actions/default-back)))]
[toolbar-with-search-content opts]
[actions (search-actions show-search? search-text search-key (:actions opts))]])
([title] (toolbar nil default-nav-back [content-title title])))

View File

@ -43,7 +43,7 @@
:on-press #()}]])
(defview add-new []
(letsubs [contacts [:all-added-group-contacts-filtered]
(letsubs [contacts [:all-added-group-contacts]
params [:get :contacts/click-params]]
[react/view {:flex 1}
[status-bar/status-bar]

View File

@ -11,6 +11,8 @@
[status-im.ui.screens.contacts.views :as contact-options]
[status-im.i18n :as i18n]))
;; TODO(alwx): this namespace is not used; should it be removed?
(defn render-row [group edit?]
(fn [row _ _]
[contact-view/contact-view {:contact row
@ -26,22 +28,8 @@
(i18n/label :t/contacts)
(or (:name group) (i18n/label :t/contacts-group-new-chat)))]])
(defview contact-list-toolbar [group]
(letsubs [show-search [:get-in [:toolbar-search :show]]
search-text [:get-in [:toolbar-search :text]]]
(toolbar/toolbar-with-search
{:show-search? (= show-search :contact-list)
:search-text search-text
:search-key :contact-list
:title (if-not group
(i18n/label :t/contacts)
(or (:name group) (i18n/label :t/contacts-group-new-chat)))
:search-placeholder (i18n/label :t/search-contacts)
:actions [(act/opts [{:text (i18n/label :t/edit)
:value #(re-frame/dispatch [:set-in [:contacts/list-ui-props :edit?] true])}])]})))
(defview contacts-list-view [group edit?]
(letsubs [contacts [:all-added-group-contacts-filtered (:group-id group)]]
(letsubs [contacts [:all-added-group-contacts (:group-id group)]]
[list/flat-list {:style styles/contacts-list
:data contacts
:render-fn (render-row group edit?)
@ -58,5 +46,7 @@
[status-bar/status-bar]
(if edit?
[contact-list-toolbar-edit group]
[contact-list-toolbar group])]
[toolbar/simple-toolbar (if-not group
(i18n/label :t/contacts)
(or (:name group) (i18n/label :t/contacts-group-new-chat)))])]
[contacts-list-view group edit?]]))

View File

@ -9,21 +9,10 @@
[status-im.ui.components.list.views :as list]
[status-im.ui.components.react :as react]
[status-im.ui.components.status-bar.view :refer [status-bar]]
[status-im.ui.components.toolbar.view :refer [toolbar-with-search]]
[status-im.ui.components.toolbar.view :as toolbar]
[status-im.ui.screens.contacts.styles :as st]
[status-im.i18n :as i18n]))
(defview contact-list-modal-toolbar []
(letsubs [show-search [:get-in [:toolbar-search :show]]
search-text [:get-in [:toolbar-search :text]]]
(toolbar-with-search
{:modal? true
:show-search? (= show-search :contact-list)
:search-text search-text
:search-key :contact-list
:title (i18n/label :t/contacts)
:search-placeholder (i18n/label :t/search-contacts)})))
(defn actions-view [action click-handler]
[react/view actions-list
[action-button
@ -53,13 +42,13 @@
(defview contact-list-modal []
(letsubs [contacts [:contacts-filtered :all-added-people-contacts]
(letsubs [contacts [:all-added-people-contacts]
click-handler [:get :contacts/click-handler]
action [:get :contacts/click-action]
params [:get :contacts/click-params]]
[react/view {:flex 1}
[status-bar {:type :modal-white}]
[contact-list-modal-toolbar]
[toolbar/simple-toolbar (i18n/label :t/contacts)]
[list/flat-list {:style st/contacts-list-modal
:data contacts
:render-fn (render-row click-handler action params)

View File

@ -4,7 +4,6 @@
(defmethod nav/preload-data! :contact-list
[db [_ _ click-handler]]
(-> db
(assoc-in [:toolbar-search :show] nil)
(assoc-in [:contacts/list-ui-props :edit?] false)
(assoc-in [:contacts/ui-props :edit?] false)
(assoc :contacts/click-handler click-handler)))

View File

@ -93,13 +93,3 @@
(def qr-input
{:margin-right 42})
(def search-container
{:flex 1
:background-color common/color-white})
(def search-empty-view
{:flex 1
:background-color common/color-white
:align-items :center
:justify-content :center})

View File

@ -98,52 +98,6 @@
(->> (remove :pending? (vals groups))
(sort-by :order >))))
(defn search-filter [text item]
(let [name (-> (or (:name item) "")
(string/lower-case))
text (string/lower-case text)]
(not= (string/index-of name text) nil)))
(defn search-filter-reaction [contacts text]
(if text
(filter #(search-filter text %) contacts)
contacts))
(reg-sub :all-added-group-contacts-filtered
(fn [[_ group-id] _]
[(if group-id
(subscribe [:all-added-group-contacts group-id])
(subscribe [:all-added-contacts]))
(subscribe [:get-in [:toolbar-search :text]])])
(fn [[contacts text] _]
(search-filter-reaction contacts text)))
(reg-sub :contact-group-contacts
:<- [:get-contact-group]
(fn [group]
(:contacts group)))
(reg-sub :all-not-added-contact-group-contacts
(fn [_ _]
[(subscribe [:all-added-contacts])
(subscribe [:contact-group-contacts])])
(fn [[contacts group-contacts]]
(filter-not-group-contacts group-contacts contacts)))
(reg-sub :all-group-not-added-contacts-filtered
(fn [_ _]
[(subscribe [:all-not-added-contact-group-contacts])
(subscribe [:get-in [:toolbar-search :text]])])
(fn [[contacts text] _]
(search-filter-reaction contacts text)))
(reg-sub :contacts-filtered
(fn [[_ subscription-id] _]
[(subscribe [subscription-id])
(subscribe [:get-in [:toolbar-search :text]])])
(fn [[contacts text]]
(search-filter-reaction contacts text)))
(reg-sub :contact
(fn [db]
(let [identity (:contacts/identity db)]

View File

@ -67,7 +67,6 @@
(spec/def ::webview-bridge (spec/nilable any?))
(spec/def ::status-module-initialized? (spec/nilable boolean?))
(spec/def ::status-node-started? (spec/nilable boolean?))
(spec/def ::toolbar-search (spec/nilable map?))
;;height of native keyboard if shown
(spec/def ::keyboard-height (spec/nilable number?))
(spec/def ::keyboard-max-height (spec/nilable number?))
@ -173,7 +172,6 @@
::webview-bridge
::status-module-initialized?
::status-node-started?
::toolbar-search
::keyboard-height
::keyboard-max-height
::orientation

View File

@ -1,7 +1,6 @@
(ns status-im.ui.screens.discover.events
(:require [re-frame.core :as re-frame]
[status-im.protocol.core :as protocol]
[status-im.ui.screens.discover.navigation]
[status-im.utils.handlers :as handlers]
[clojure.string :as string]
[status-im.utils.utils :as utils]))
@ -115,19 +114,6 @@
:identities (handlers/identities contacts)}
:dispatch [:status-received message]}))))
(handlers/register-handler-fx
:init-discoveries
[(re-frame/inject-cofx :data-store/discoveries)]
(fn [{:keys [data-store/discoveries db] {:keys [request-discoveries-timer]} :db} _]
(when request-discoveries-timer
(utils/clear-interval request-discoveries-timer))
{:db (assoc db
:discoveries discoveries
:request-discoveries-timer
(utils/set-interval #(re-frame/dispatch [:request-discoveries])
(* request-discoveries-interval-s 1000)))
:dispatch [:request-discoveries]}))
(handlers/register-handler-fx
:request-discoveries
[(re-frame/inject-cofx :random-id)]

View File

@ -1,7 +0,0 @@
(ns status-im.ui.screens.discover.navigation
(:require [status-im.ui.screens.navigation :as navigation]
[status-im.data-store.discover :as discoveries]))
(defmethod navigation/preload-data! :discover
[db _]
(assoc-in db [:toolbar-search :show] nil))

View File

@ -269,10 +269,6 @@
{:width 8
:height 14})
(def icon-search
{:width 17
:height 17})
(def discover-container
{:flex 1
:background-color styles/color-light-gray})
@ -280,10 +276,6 @@
(def list-container
{:flex 1})
(def search-icon
{:width 17
:height 17})
(defn title-action-text [active?]
{:color (if active?
styles/color-blue

View File

@ -30,17 +30,6 @@
(let [hashtags (map #(string/lower-case (string/replace % #"#" "")) (re-seq #"[^ !?,;:.]+" status))]
(or hashtags [])))
(defn toolbar-view [show-search? search-text]
[toolbar/toolbar-with-search
{:show-search? show-search?
:search-text search-text
:search-key :discover
:title (i18n/label :t/discover)
:search-placeholder (i18n/label :t/search-tags)
:on-search-submit (fn [text]
(when-not (string/blank? text)
(re-frame/dispatch [:discover/search-tags-results-view text])))}])
(defn top-status-for-popular-hashtag [{:keys [popular-hashtag current-account contacts]}]
(let [{:keys [tag discovery total]} popular-hashtag]
[react/view styles/popular-list-container
@ -140,16 +129,13 @@
:render-fn render-public-chats-item}]])
(defview discover [current-view?]
(letsubs [show-search [:get-in [:toolbar-search :show]]
search-text [:get-in [:toolbar-search :text]]
contacts [:get-contacts]
(letsubs [contacts [:get-contacts]
current-account [:get-current-account]
discoveries [:discover/recent-discoveries]
all-dapps [:discover/all-dapps]
popular-hashtags [:discover/popular-hashtags-preview]]
[react/view styles/discover-container
[toolbar-view (and current-view?
(= show-search :discover)) search-text]
[toolbar/simple-toolbar (i18n/label :t/discover)]
[react/scroll-view styles/list-container
[recent-statuses-preview {:contacts contacts
:current-account current-account

View File

@ -291,7 +291,6 @@
[:load-contact-groups]
[:initialize-debugging {:address address}]
[:send-account-update-if-needed]
[:init-discoveries]
[:update-wallet]
[:update-transactions]
[:get-fcm-token]]

View File

@ -6,7 +6,7 @@
[status-im.ui.components.react :as react]
[status-im.ui.components.sticky-button :refer [sticky-button]]
[status-im.ui.components.status-bar.view :refer [status-bar]]
[status-im.ui.components.toolbar.view :refer [toolbar-with-search]]
[status-im.ui.components.toolbar.view :as toolbar]
[status-im.ui.screens.group.styles :as styles]
[status-im.ui.screens.contacts.styles :as contacts.styles]
[status-im.i18n :as i18n]
@ -28,26 +28,19 @@
(defn group-toggle-participant [{:keys [whisper-identity] :as contact}]
[toogle-contact-view contact :is-participant-selected? on-toggle-participant])
(defn title-with-count [title count-value]
(defn toggle-list-toolbar [title contacts-count]
[toolbar/toolbar {}
toolbar/default-nav-back
[react/view styles/toolbar-container
[react/view styles/toolbar-title-with-count
[react/text {:style styles/toolbar-title-with-count-text
:font :toolbar-title}
title]
(when (pos? count-value)
(when (pos? contacts-count)
[react/view styles/toolbar-title-with-count-container
[react/text {:style styles/toolbar-title-with-count-text-count
:font :toolbar-title}
count-value]])])
(defview toggle-list-toolbar [title contacts-count]
(letsubs [show-search [:get-in [:toolbar-search :show]]
search-text [:get-in [:toolbar-search :text]]]
(toolbar-with-search
{:show-search? (= show-search :contact-group-list)
:search-text search-text
:search-key :contact-group-list
:custom-title (title-with-count title contacts-count)
:search-placeholder (i18n/label :t/search-contacts)})))
contacts-count]])]]])
(defn toggle-list [contacts render-function]
[react/view {:flex 1}
@ -59,7 +52,7 @@
:keyboardShouldPersistTaps :always}]])
(defview contact-toggle-list []
(letsubs [contacts [:all-added-group-contacts-filtered]
(letsubs [contacts [:all-added-contacts]
selected-contacts-count [:selected-contacts-count]
group-type [:get-group-type]]
[react/keyboard-avoiding-view {:style styles/group-container}
@ -74,7 +67,7 @@
[sticky-button (i18n/label :t/next) #(re-frame/dispatch [:navigate-to :new-group])])]))
(defview add-contacts-toggle-list []
(letsubs [contacts [:all-group-not-added-contacts-filtered]
(letsubs [contacts [:all-group-not-added-contacts]
group [:get-contact-group]
selected-contacts-count [:selected-contacts-count]]
[react/keyboard-avoiding-view {:style styles/group-container}
@ -87,7 +80,7 @@
(re-frame/dispatch [:navigate-back]))])]))
(defview add-participants-toggle-list []
(letsubs [contacts [:contacts-filtered :all-new-contacts]
(letsubs [contacts [:all-new-contacts]
chat-name [:chat :name]
selected-contacts-count [:selected-participants-count]]
[react/keyboard-avoiding-view {:style styles/group-container}

View File

@ -5,20 +5,10 @@
[status-im.ui.components.list.views :as list]
[status-im.ui.components.react :as react]
[status-im.ui.components.status-bar.view :refer [status-bar]]
[status-im.ui.components.toolbar.view :refer [toolbar-with-search]]
[status-im.ui.components.toolbar.view :as toolbar]
[status-im.ui.screens.group.styles :as styles]
[status-im.i18n :as i18n]))
(defview contact-list-toolbar [title]
(letsubs [show-search [:get-in [:toolbar-search :show]]
search-text [:get-in [:toolbar-search :text]]]
(toolbar-with-search
{:show-search? (= show-search :contact-list)
:search-text search-text
:search-key :contact-list
:title title
:search-placeholder (i18n/label :t/search-contacts)})))
(defn contacts-list [contacts extended? extend-options]
[react/view {:flex 1}
[list/flat-list {:data contacts
@ -46,20 +36,20 @@
(defview edit-chat-group-contact-list []
(letsubs [chat-name [:chat :name]
contacts [:contacts-filtered :current-chat-contacts]
contacts [:current-chat-contacts]
current-pk [:get :current-public-key]
group-admin [:chat :group-admin]]
(let [admin? (= current-pk group-admin)]
[react/view styles/group-container
[status-bar]
[contact-list-toolbar chat-name]
[toolbar/simple-toolbar chat-name]
[contacts-list
contacts
admin?
chat-extended-options]])))
(defview contacts-list-view [group-id]
(letsubs [contacts [:all-added-group-contacts-filtered group-id]]
(letsubs [contacts [:all-added-group-contacts group-id]]
[contacts-list
contacts
true
@ -69,5 +59,5 @@
(letsubs [group [:get-contact-group]]
[react/view styles/group-container
[status-bar]
[contact-list-toolbar (:name group)]
[toolbar/simple-toolbar (:name group)]
[contacts-list-view (:group-id group)]]))

View File

@ -1,36 +1,18 @@
(ns status-im.ui.screens.group.navigation
(:require [status-im.ui.screens.navigation :as nav]))
(defn clear-toolbar-search [db]
(-> db
(assoc-in [:toolbar-search :show] nil)
(assoc-in [:toolbar-search :text] "")))
(defmethod nav/preload-data! :add-contacts-toggle-list
[db _]
(->
(assoc db :group/selected-contacts #{})
(clear-toolbar-search)))
(assoc db :group/selected-contacts #{}))
(defmethod nav/preload-data! :add-participants-toggle-list
[db _]
(->
(assoc db :selected-participants #{})
(clear-toolbar-search)))
(assoc db :selected-participants #{}))
(defmethod nav/preload-data! :new-public-chat
[db]
(dissoc db :public-group-topic))
(defmethod nav/preload-data! :group-contacts
[db [_ _ {:keys [show-search?]}]]
(-> db
(update :toolbar-search
assoc
:show (when show-search? :contact-list)
:text "")))
(defmethod nav/preload-data! :reorder-groups
[db [_ _]]
(assoc db :group/groups-order (->> (vals (:group/contact-groups db))

View File

@ -60,7 +60,6 @@
:justify-content :center
:ios {:background-color "#628fe333"
:border-radius 50}})
(def add-icon
{:align-items :center
:width 24
@ -163,6 +162,11 @@
:ios {:margin-left 16
:opacity 0.5}})
(defstyle toolbar-container
{:flex 1
:android {:padding-left 18}
:ios {:align-items :center}})
(def toolbar-title-with-count-text
{:color common/text1-color
:letter-spacing -0.2

View File

@ -33,14 +33,11 @@
(:signed-up? current-account)))
(reg-sub :tabs-hidden?
:<- [:get-in [:toolbar-search :show]]
:<- [:get-in [:chat-list-ui-props :edit?]]
:<- [:get-in [:contacts/ui-props :edit?]]
:<- [:get :view-id]
(fn [[search-mode? chats-edit-mode? contacts-edit-mode? view-id]]
(or search-mode?
(and (= view-id :home) chats-edit-mode?)
(and (= view-id :contact-list) contacts-edit-mode?))))
(fn [[chats-edit-mode? contacts-edit-mode? view-id]]
(and (= view-id :contact-list) contacts-edit-mode?)))
(reg-sub :network
(fn [db]