fix inability to move cursor to next line in bio field (#20403)

This commit is contained in:
Parvesh Monu 2024-06-13 13:56:33 +05:30 committed by GitHub
parent 874906b11f
commit df939bf85f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 60 additions and 61 deletions

View File

@ -4,7 +4,6 @@
[react-native.core :as rn] [react-native.core :as rn]
[react-native.platform :as platform] [react-native.platform :as platform]
[react-native.safe-area :as safe-area] [react-native.safe-area :as safe-area]
[reagent.core :as reagent]
[status-im.common.validation.profile :as profile-validator] [status-im.common.validation.profile :as profile-validator]
[status-im.constants :as constants] [status-im.constants :as constants]
[status-im.contexts.profile.edit.bio.style :as style] [status-im.contexts.profile.edit.bio.style :as style]
@ -14,63 +13,63 @@
(defn view (defn view
[] []
(let [insets (safe-area/get-insets) (let [insets (safe-area/get-insets)
profile (rf/sub [:profile/profile-with-image]) profile (rf/sub [:profile/profile-with-image])
customization-color (rf/sub [:profile/customization-color]) customization-color (rf/sub [:profile/customization-color])
alert-banners-top-margin (rf/sub [:alert-banners/top-margin]) alert-banners-top-margin (rf/sub [:alert-banners/top-margin])
profile-bio (:bio profile) current-bio (:bio profile)
unsaved-bio (reagent/atom profile-bio) [bio set-bio] (rn/use-state current-bio)
error-msg (reagent/atom nil) [error-msg set-error-msg] (rn/use-state nil)
typing? (reagent/atom false) [typing? set-typing] (rn/use-state false)
validate-bio (debounce/debounce (fn [bio] validate-bio (debounce/debounce (fn [bio]
(reset! error-msg (set-error-msg (profile-validator/validation-bio
(profile-validator/validation-bio bio)) bio))
(reset! typing? false)) (set-typing false))
300) 300)
on-change-text (fn [s] on-change-text (fn [s]
(reset! typing? true) (set-typing true)
(reset! unsaved-bio s) (set-bio s)
(validate-bio s))] (validate-bio s))]
(fn [] [quo/overlay
[quo/overlay {:type :shell
{:type :shell :container-style (style/page-wrapper insets)}
:container-style (style/page-wrapper insets)} [quo/page-nav
[quo/page-nav {:key :header
{:key :header :background :blur
:background :blur :icon-name :i/arrow-left
:icon-name :i/arrow-left :on-press #(rf/dispatch [:navigate-back])}]
:on-press #(rf/dispatch [:navigate-back])}] [rn/keyboard-avoiding-view
[rn/keyboard-avoiding-view {:key :content
{:key :content :keyboard-vertical-offset (if platform/ios? alert-banners-top-margin 0)
:keyboard-vertical-offset (if platform/ios? alert-banners-top-margin 0) :style style/screen-container}
:style style/screen-container} [rn/view {:style {:gap 22}}
[rn/view {:style {:gap 22}} [quo/text-combinations {:title (i18n/label :t/bio)}]
[quo/text-combinations {:title (i18n/label :t/bio)}] [quo/input
[quo/input {:blur? true
{:blur? true :multiline? true
:multiline? true :error? (not (string/blank? error-msg))
:error? (not (string/blank? @error-msg)) :container-style {:margin-bottom -11}
:container-style {:margin-bottom -11} :default-value bio
:default-value @unsaved-bio :auto-focus true
:auto-focus true :max-height 200
:char-limit constants/profile-bio-max-length :char-limit constants/profile-bio-max-length
:label (i18n/label :t/profile-bio) :label (i18n/label :t/profile-bio)
:placeholder (i18n/label :t/something-about-you) :placeholder (i18n/label :t/something-about-you)
:on-change-text on-change-text}] :on-change-text on-change-text}]
(when-not (string/blank? @error-msg) (when-not (string/blank? error-msg)
[quo/info-message [quo/info-message
{:type :error {:type :error
:size :default :size :default
:icon :i/info} :icon :i/info}
@error-msg])] error-msg])]
[rn/view {:style style/button-wrapper} [rn/view {:style style/button-wrapper}
[quo/button [quo/button
{:type :primary {:type :primary
:customization-color customization-color :customization-color customization-color
:on-press (fn [] :on-press (fn []
(rf/dispatch [:profile/edit-bio @unsaved-bio])) (rf/dispatch [:profile/edit-bio bio]))
:disabled? (boolean (or @typing? :disabled? (boolean (or typing?
(and (string/blank? profile-bio) (and (string/blank? current-bio)
(string/blank? @unsaved-bio)) (string/blank? bio))
(not (string/blank? @error-msg))))} (not (string/blank? error-msg))))}
(i18n/label :t/save-bio)]]]]))) (i18n/label :t/save-bio)]]]]))