Show search cancel on android
Signed-off-by: Gheorghe Pinzaru <feross95@gmail.com>
This commit is contained in:
parent
ce1ce1c9a6
commit
10237be747
|
@ -66,9 +66,9 @@
|
||||||
false)))
|
false)))
|
||||||
|
|
||||||
;; TODO(Ferossgp): Check performance for android layout animations
|
;; TODO(Ferossgp): Check performance for android layout animations
|
||||||
;; (when (and platform/android?
|
(when (and platform/android?
|
||||||
;; (aget rn/ui-manager "setLayoutAnimationEnabledExperimental"))
|
(aget rn/ui-manager "setLayoutAnimationEnabledExperimental"))
|
||||||
;; (ocall rn/ui-manager "setLayoutAnimationEnabledExperimental" true))
|
(ocall rn/ui-manager "setLayoutAnimationEnabledExperimental" true))
|
||||||
|
|
||||||
(def height 44) ; 22 line-height + 11*2 vertical padding
|
(def height 44) ; 22 line-height + 11*2 vertical padding
|
||||||
(def multiline-height 88) ; 3 * 22 three line-height + 11* vertical padding
|
(def multiline-height 88) ; 3 * 22 three line-height + 11* vertical padding
|
||||||
|
@ -152,11 +152,14 @@
|
||||||
cancel-label on-focus on-blur show-cancel accessibility-label
|
cancel-label on-focus on-blur show-cancel accessibility-label
|
||||||
bottom-value secure-text-entry container-style get-ref on-cancel
|
bottom-value secure-text-entry container-style get-ref on-cancel
|
||||||
monospace]
|
monospace]
|
||||||
:or {cancel-label "Cancel"
|
:or {cancel-label "Cancel"}
|
||||||
show-cancel true}
|
|
||||||
:as props}]
|
:as props}]
|
||||||
{:pre [(check-spec ::text-input props)]}
|
{:pre [(check-spec ::text-input props)]}
|
||||||
(let [after (cond
|
(let [show-cancel (if (nil? show-cancel)
|
||||||
|
;; Enabled by default on iOs and disabled on Android
|
||||||
|
platform/ios?
|
||||||
|
show-cancel)
|
||||||
|
after (cond
|
||||||
(and secure-text-entry @visible)
|
(and secure-text-entry @visible)
|
||||||
{:icon :main-icons/hide
|
{:icon :main-icons/hide
|
||||||
:on-press #(reset! visible false)}
|
:on-press #(reset! visible false)}
|
||||||
|
@ -190,12 +193,12 @@
|
||||||
:secure-text-entry secure
|
:secure-text-entry secure
|
||||||
:on-focus (fn [evt]
|
:on-focus (fn [evt]
|
||||||
(when on-focus (on-focus evt))
|
(when on-focus (on-focus evt))
|
||||||
(when (and platform/ios? show-cancel)
|
(when show-cancel
|
||||||
(rn/configure-next (:ease-in-ease-out rn/layout-animation-presets)))
|
(rn/configure-next (:ease-in-ease-out rn/layout-animation-presets)))
|
||||||
(reset! focused true))
|
(reset! focused true))
|
||||||
:on-blur (fn [evt]
|
:on-blur (fn [evt]
|
||||||
(when on-blur (on-blur evt))
|
(when on-blur (on-blur evt))
|
||||||
(when (and platform/ios? show-cancel)
|
(when show-cancel
|
||||||
(rn/configure-next (:ease-in-ease-out rn/layout-animation-presets)))
|
(rn/configure-next (:ease-in-ease-out rn/layout-animation-presets)))
|
||||||
(reset! focused false))}
|
(reset! focused false))}
|
||||||
(when (and platform/ios? (not after))
|
(when (and platform/ios? (not after))
|
||||||
|
@ -208,8 +211,7 @@
|
||||||
:secure-text-entry :ref :get-ref))]
|
:secure-text-entry :ref :get-ref))]
|
||||||
(when after
|
(when after
|
||||||
[accessory-element after])]
|
[accessory-element after])]
|
||||||
(when (and platform/ios?
|
(when (and show-cancel
|
||||||
show-cancel
|
|
||||||
(not multiline)
|
(not multiline)
|
||||||
@focused)
|
@focused)
|
||||||
[rn/touchable-opacity {:style (cancel-style)
|
[rn/touchable-opacity {:style (cancel-style)
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
:default-value search-filter
|
:default-value search-filter
|
||||||
:auto-focus auto-focus
|
:auto-focus auto-focus
|
||||||
:on-cancel on-cancel
|
:on-cancel on-cancel
|
||||||
|
:show-cancel true
|
||||||
:auto-correct false
|
:auto-correct false
|
||||||
:auto-capitalize :none
|
:auto-capitalize :none
|
||||||
:input-style {:height 36
|
:input-style {:height 36
|
||||||
|
|
Loading…
Reference in New Issue