mirror of
https://github.com/status-im/status-react.git
synced 2025-02-02 22:25:12 +00:00
parent
5bff89a58f
commit
aead730d28
@ -55,4 +55,5 @@
|
|||||||
{:check (i18n/label :t/emojis)})
|
{:check (i18n/label :t/emojis)})
|
||||||
(validators/has-special-characters? s) (i18n/label :t/are-not-allowed
|
(validators/has-special-characters? s) (i18n/label :t/are-not-allowed
|
||||||
{:check (i18n/label :t/special-characters)})
|
{:check (i18n/label :t/special-characters)})
|
||||||
|
(name-too-short? s) (i18n/label :t/minimum-characters {:min-chars min-length})
|
||||||
(name-too-long? s) (i18n/label :t/nickname-is-too-long)))
|
(name-too-long? s) (i18n/label :t/nickname-is-too-long)))
|
||||||
|
@ -19,16 +19,19 @@
|
|||||||
profile-picture (profile.utils/photo profile)
|
profile-picture (profile.utils/photo profile)
|
||||||
[unsaved-nickname set-unsaved-nickname] (rn/use-state nickname)
|
[unsaved-nickname set-unsaved-nickname] (rn/use-state nickname)
|
||||||
[error-msg set-error-msg] (rn/use-state nil)
|
[error-msg set-error-msg] (rn/use-state nil)
|
||||||
|
[typing? set-typing?] (rn/use-state false)
|
||||||
has-nickname? (rn/use-memo (fn [] (not (string/blank? nickname)))
|
has-nickname? (rn/use-memo (fn [] (not (string/blank? nickname)))
|
||||||
[nickname])
|
[nickname])
|
||||||
validate-nickname (rn/use-callback
|
validate-nickname (rn/use-callback
|
||||||
(debounce/debounce
|
(debounce/debounce
|
||||||
(fn [name]
|
(fn [name]
|
||||||
(set-error-msg
|
(set-error-msg
|
||||||
(profile-validator/validation-nickname name)))
|
(profile-validator/validation-nickname name))
|
||||||
|
(set-typing? false))
|
||||||
300))
|
300))
|
||||||
on-cancel (rn/use-callback #(rf/dispatch [:hide-bottom-sheet]))
|
on-cancel (rn/use-callback #(rf/dispatch [:hide-bottom-sheet]))
|
||||||
on-nickname-change (rn/use-callback (fn [text]
|
on-nickname-change (rn/use-callback (fn [text]
|
||||||
|
(set-typing? true)
|
||||||
(set-unsaved-nickname text)
|
(set-unsaved-nickname text)
|
||||||
(validate-nickname text)))
|
(validate-nickname text)))
|
||||||
on-nickname-submit (rn/use-callback
|
on-nickname-submit (rn/use-callback
|
||||||
@ -74,7 +77,8 @@
|
|||||||
[quo/bottom-actions
|
[quo/bottom-actions
|
||||||
{:actions :two-actions
|
{:actions :two-actions
|
||||||
:button-one-label (i18n/label (if has-nickname? :t/update-nickname-title :t/add-nickname-title))
|
:button-one-label (i18n/label (if has-nickname? :t/update-nickname-title :t/add-nickname-title))
|
||||||
:button-one-props {:disabled? (or (string/blank? unsaved-nickname)
|
:button-one-props {:disabled? (or typing?
|
||||||
|
(string/blank? unsaved-nickname)
|
||||||
(not (string/blank? error-msg)))
|
(not (string/blank? error-msg)))
|
||||||
:customization-color customization-color
|
:customization-color customization-color
|
||||||
:on-press on-nickname-submit}
|
:on-press on-nickname-submit}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user