-
Notifications
You must be signed in to change notification settings - Fork 984
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
componentizied input-search and added in curency and token
- Loading branch information
Showing
9 changed files
with
196 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,17 @@ | ||
(ns status-im.search.core | ||
(:require [status-im.utils.fx :as fx])) | ||
|
||
(fx/defn filter-changed [cofx search-filter] | ||
(fx/defn filter-changed | ||
{:events [:search/filter-changed]} | ||
[cofx search-filter] | ||
{:db (assoc-in (:db cofx) [:ui/search :filter] search-filter)}) | ||
|
||
(fx/defn currency-filter-changed | ||
{:events [:search/currency-filter-changed]} | ||
[cofx search-filter] | ||
{:db (assoc-in (:db cofx) [:ui/search :currency-filter] search-filter)}) | ||
|
||
(fx/defn token-filter-changed | ||
{:events [:search/token-filter-changed]} | ||
[cofx search-filter] | ||
{:db (assoc-in (:db cofx) [:ui/search :token-filter] search-filter)}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
(ns status-im.ui.components.search-input.styles | ||
(:require [status-im.ui.components.colors :as colors] | ||
[status-im.utils.styles :as styles])) | ||
|
||
(styles/def search-input | ||
{:flex 1 | ||
:android {:margin 0 | ||
:padding 0}}) | ||
|
||
(def search-input-height 56) | ||
|
||
(def search-container | ||
{:height search-input-height | ||
:flex-direction :row | ||
:padding-horizontal 16 | ||
:background-color colors/white | ||
:align-items :center | ||
:justify-content :center}) | ||
|
||
(def search-input-container | ||
{:background-color colors/gray-lighter | ||
:flex 1 | ||
:flex-direction :row | ||
:height 36 | ||
:align-items :center | ||
:justify-content :center | ||
:border-radius 8}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
(ns status-im.ui.components.search-input.view | ||
(:require-macros [status-im.utils.views :as views]) | ||
(:require [reagent.core :as reagent] | ||
[status-im.i18n :as i18n] | ||
[status-im.ui.components.react :as react] | ||
[status-im.ui.components.colors :as colors] | ||
[status-im.ui.components.search-input.styles :as styles] | ||
[status-im.ui.components.icons.vector-icons :as icons])) | ||
|
||
(views/defview search-input [{:keys [on-cancel | ||
on-focus | ||
on-change | ||
search-active? | ||
search-container-style | ||
search-filter | ||
auto-focus]}] | ||
(views/letsubs | ||
[input-ref (reagent/atom nil)] | ||
[react/view {:style (or search-container-style styles/search-container)} | ||
[react/view {:style styles/search-input-container} | ||
[icons/icon :main-icons/search {:color colors/gray | ||
:container-style {:margin-left 6 | ||
:margin-right 2}}] | ||
[react/text-input {:placeholder (i18n/label :t/search) | ||
:blur-on-submit true | ||
:multiline false | ||
:ref #(reset! input-ref %) | ||
:style styles/search-input | ||
:default-value search-filter | ||
:auto-focus auto-focus | ||
:auto-correct false | ||
:on-focus #(do | ||
(when on-focus | ||
(on-focus search-filter)) | ||
(reset! search-active? true)) | ||
:on-change (fn [e] | ||
(let [native-event (.-nativeEvent e) | ||
text (.-text native-event)] | ||
(when on-change | ||
(on-change text))))}]] | ||
(when @search-active? | ||
[react/touchable-highlight | ||
{:on-press (fn [] | ||
(.clear @input-ref) | ||
(.blur @input-ref) | ||
(when on-cancel | ||
(on-cancel)) | ||
(reset! search-active? false)) | ||
:style {:margin-left 16}} | ||
[react/text {:style {:color colors/blue}} | ||
(i18n/label :t/cancel)]])])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.