[#4728] make [Enter] button default to proceed during account creation, chat creation, account restoring

more :on-submit-editing

Signed-off-by: Roman Volosovskyi <roman.wolosovskyi@gmail.com>
This commit is contained in:
Roman Volosovskyi 2018-09-27 18:16:39 +03:00
parent f3f476fa89
commit 0a768bdd9c
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
3 changed files with 29 additions and 19 deletions

View File

@ -27,12 +27,14 @@
:input-placeholder (i18n/label :t/name-placeholder)
:input-description (i18n/label :t/name-description)}})
(defview input [step error]
(defview input [{:keys [step error password password-confirm]}]
[text-input/text-input-with-label
{:label (get-in steps [step :input-label])
:placeholder (get-in steps [step :input-placeholder])
:on-change-text #(re-frame/dispatch [:accounts.create.ui/input-text-changed (get-in steps [step :input-key]) %])
:secure-text-entry (boolean (#{:enter-password :confirm-password} step))
:auto-focus true
:on-submit-editing #(re-frame/dispatch [:accounts.create.ui/next-step-pressed step password password-confirm])
:error error}])
(defview create-account []
@ -61,7 +63,10 @@
[react/view components.styles/flex
[react/view {:style styles/input-container
:important-for-accessibility :no-hide-descendants}
[input step error]
[input {:step step
:error error
:password password
:password-confirm password-confirm}]
[react/text {:style styles/input-description}
(get-in steps [step :input-description])]]
[react/view {:style components.styles/flex}]

View File

@ -47,7 +47,8 @@
:on-change-text #(re-frame/dispatch [:accounts.recover.ui/password-input-changed (security/mask-data %)])
:on-blur #(re-frame/dispatch [:accounts.recover.ui/password-input-blured])
:secure-text-entry true
:error (when error (i18n/label error))}]])
:error (when error (i18n/label error))
:on-submit-editing #(re-frame/dispatch [:accounts.recover.ui/sign-in-button-pressed])}]])
(defview recover []
(letsubs [recovered-account [:get-recover-account]]

View File

@ -59,21 +59,23 @@
(let [disable? (or (not (string/blank? chat-error))
(string/blank? new-contact-identity))
show-error-tooltip? (and chat-error
(not (string/blank? new-contact-identity)))]
(not (string/blank? new-contact-identity)))
create-1to1-chat #(re-frame/dispatch [:add-contact-handler new-contact-identity])]
[react/view {:style styles/add-contact-edit-view}
[react/view {:flex 1
:style (styles/add-contact-input show-error-tooltip?)}
(when show-error-tooltip?
[error-tooltip chat-error])
[react/text-input {:placeholder "0x..."
:flex 1
:selection-color colors/hawkes-blue
:font :default
:on-change (fn [e]
(let [native-event (.-nativeEvent e)
text (.-text native-event)]
(re-frame/dispatch [:new-chat/set-new-identity text])))}]]
[react/touchable-highlight {:disabled disable? :on-press #(re-frame/dispatch [:add-contact-handler new-contact-identity])}
[react/text-input {:placeholder "0x..."
:flex 1
:selection-color colors/hawkes-blue
:font :default
:on-change (fn [e]
(let [native-event (.-nativeEvent e)
text (.-text native-event)]
(re-frame/dispatch [:new-chat/set-new-identity text])))
:on-submit-editing (when-not disable? create-1to1-chat)}]]
[react/touchable-highlight {:disabled disable? :on-press create-1to1-chat}
[react/view
{:style (styles/add-contact-button disable?)}
[react/text
@ -103,7 +105,11 @@
[react/view {:style styles/new-contact-separator}]
(let [disable? (or (not (string/blank? topic-error))
(string/blank? topic))
show-error-tooltip? (and topic-error (not (string/blank? topic)))]
show-error-tooltip? (and topic-error (not (string/blank? topic)))
create-public-chat #(when-not topic-error
(do
(re-frame/dispatch [:set :public-group-topic nil])
(re-frame/dispatch [:chat.ui/start-public-chat topic])))]
[react/view {:style styles/add-contact-edit-view}
[react/view {:flex 1
:style (styles/add-pub-chat-input show-error-tooltip?)}
@ -114,12 +120,10 @@
:font :default
:selection-color colors/hawkes-blue
:placeholder ""
:on-change on-topic-change}]]
:on-change on-topic-change
:on-submit-editing (when-not disable? create-public-chat)}]]
[react/touchable-highlight {:disabled disable?
:on-press #(when-not topic-error
(do
(re-frame/dispatch [:set :public-group-topic nil])
(re-frame/dispatch [:chat.ui/start-public-chat topic])))}
:on-press create-public-chat}
[react/view {:style (styles/add-contact-button disable?)}
[react/text {:style (styles/add-contact-button-text disable?)}
(i18n/label :new-public-group-chat)]]]])