Fix #774 - Profile and drawer input inconsistencies

This commit is contained in:
Gustavo Nunes 2017-02-08 22:58:58 -02:00 committed by Roman Volosovskyi
parent 289a43ace8
commit 8957e00592
4 changed files with 11 additions and 4 deletions

View File

@ -73,8 +73,10 @@
:wrapper-style st/name-input-wrapper :wrapper-style st/name-input-wrapper
:value (or new-name name) :value (or new-name name)
:on-change-text #(dispatch [:set-in [:profile-edit :name] %]) :on-change-text #(dispatch [:set-in [:profile-edit :name] %])
:on-end-editing #(when (s/valid? ::v/name new-name) :on-end-editing #(do
(dispatch [:account-update {:name (clean-text new-name)}]))}]] (dispatch [:set-in [:profile-edit :name] nil])
(when (s/valid? ::v/name new-name)
(dispatch [:account-update {:name (clean-text new-name)}])))}]]
[view st/status-container [view st/status-container
(if @status-edit? (if @status-edit?
[text-input {:style st/status-input [text-input {:style st/status-input
@ -114,6 +116,7 @@
[view st/switch-users-container [view st/switch-users-container
[touchable-opacity {:onPress (fn [] [touchable-opacity {:onPress (fn []
(close-drawer) (close-drawer)
(dispatch [:set-in [:profile-edit :name] nil])
(dispatch [:navigate-to :accounts]))} (dispatch [:navigate-to :accounts]))}
[text {:style st/switch-users-text [text {:style st/switch-users-text
:font :default} :font :default}

View File

@ -95,6 +95,7 @@
(defn reagent-render [_ _] (defn reagent-render [_ _]
(let [component (r/current-component) (let [component (r/current-component)
input-ref (r/atom nil)
{:keys [float-label? {:keys [float-label?
label-top label-top
label-font-size label-font-size
@ -112,7 +113,8 @@
[view (merge st/text-field-container wrapper-style) [view (merge st/text-field-container wrapper-style)
(when-not label-hidden? (when-not label-hidden?
[animated-text {:style (st/label label-top label-font-size label-color)} label]) [animated-text {:style (st/label label-top label-font-size label-color)} label])
[text-input {:style (merge st/text-input input-style) [text-input {:ref #(reset! input-ref %)
:style (merge st/text-input input-style)
:placeholder (or placeholder "") :placeholder (or placeholder "")
:editable editable :editable editable
:secure-text-entry secure-text-entry :secure-text-entry secure-text-entry
@ -138,6 +140,7 @@
(on-change-text text)) (on-change-text text))
:on-change #(on-change %) :on-change #(on-change %)
:default-value value :default-value value
:on-submit-editing #(.blur @input-ref)
:on-end-editing (when on-end-editing :on-end-editing (when on-end-editing
on-end-editing)}] on-end-editing)}]
[view {:style (st/underline-container line-color) [view {:style (st/underline-container line-color)

View File

@ -191,6 +191,7 @@
qr [:get-in [:profile-edit :qr-code]] qr [:get-in [:profile-edit :qr-code]]
current-account [:get-current-account] current-account [:get-current-account]
changed-account [:get :profile-edit]] changed-account [:get :profile-edit]]
{:component-will-unmount #(dispatch [:set-in [:profile-edit :name] nil])}
(let [{:keys [phone (let [{:keys [phone
address address
public-key] public-key]

View File

@ -6,7 +6,7 @@
[status-im.utils.homoglyph :as h])) [status-im.utils.homoglyph :as h]))
(defn correct-name? [username] (defn correct-name? [username]
(let [username (some-> username (str/trim))] (when-let [username (some-> username (str/trim))]
(every? false? (every? false?
[(str/blank? username) [(str/blank? username)
(h/matches username console-chat-id) (h/matches username console-chat-id)