[Fix] "View Profile" button behaviour on keyboard open in "Add a contact" modal (#15978)

Signed-off-by: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com>
This commit is contained in:
Mohamed Javid 2023-05-26 03:02:45 +08:00 committed by GitHub
parent 682eb841ff
commit e14ed7a637
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 68 additions and 63 deletions

View File

@ -1,11 +1,12 @@
(ns status-im2.contexts.add-new-contact.style (ns status-im2.contexts.add-new-contact.style
(:require [quo2.foundations.colors :as colors] (:require [quo2.foundations.colors :as colors]
[quo2.foundations.typography :as typography]
[react-native.platform :as platform] [react-native.platform :as platform]
[quo2.foundations.typography :as typography])) [react-native.safe-area :as safe-area]))
(defn container-outer (defn container-outer
[] []
{:style {:flex (if platform/ios? 4.5 5) {:style {:flex 1
:background-color (colors/theme-colors colors/white colors/neutral-95) :background-color (colors/theme-colors colors/white colors/neutral-95)
:justify-content :space-between :justify-content :space-between
:align-items :center :align-items :center
@ -171,7 +172,7 @@
:size 40 :size 40
:width 335 :width 335
:style {:margin-top 24 :style {:margin-top 24
:margin-bottom 24} :margin-bottom (+ (safe-area/get-bottom) 12)}
:accessibility-label :new-contact-button :accessibility-label :new-contact-button
:before :i/profile :before :i/profile
:disabled (not= state :valid)}) :disabled (not= state :valid)})

View File

@ -51,64 +51,68 @@
show-paste-button? (and (not (string/blank? @clipboard)) show-paste-button? (and (not (string/blank? @clipboard))
(string/blank? @default-value) (string/blank? @default-value)
(string/blank? input))] (string/blank? input))]
[rn/keyboard-avoiding-view
[rn/view (style/container-outer) {:style {:flex 1}}
[rn/view style/container-inner [rn/touchable-without-feedback
[quo/button {:on-press rn/dismiss-keyboard!}
(merge (style/button-close) [rn/view (style/container-outer)
{:on-press [rn/view style/container-inner
(fn [] [quo/button
(reset! clipboard nil) (merge (style/button-close)
(reset! default-value nil) {:on-press
(rf/dispatch [:contacts/clear-new-identity]) (fn []
(rf/dispatch [:navigate-back]))}) :i/close] (reset! clipboard nil)
[quo/text (style/text-title) (reset! default-value nil)
(i18n/label :t/add-a-contact)] (rf/dispatch [:contacts/clear-new-identity])
[quo/text (style/text-subtitle) (rf/dispatch [:navigate-back]))}) :i/close]
(i18n/label :t/find-your-friends)] [quo/text (style/text-title)
[quo/text (style/text-description) (i18n/label :t/add-a-contact)]
(i18n/label :t/ens-or-chat-key)] [quo/text (style/text-subtitle)
[rn/view style/container-text-input (i18n/label :t/find-your-friends)]
[rn/view (style/text-input-container invalid?) [quo/text (style/text-description)
[rn/text-input (i18n/label :t/ens-or-chat-key)]
(merge (style/text-input) [rn/view style/container-text-input
{:default-value (or scanned @default-value input) [rn/view (style/text-input-container invalid?)
:placeholder (i18n/label :t/type-some-chat-key) [rn/text-input
:on-change-text (fn [v] (merge (style/text-input)
(reset! default-value v) {:default-value (or scanned @default-value input)
(debounce/debounce-and-dispatch :placeholder (i18n/label :t/type-some-chat-key)
[:contacts/set-new-identity v nil] :on-change-text (fn [v]
600))})] (reset! default-value v)
(when show-paste-button? (debounce/debounce-and-dispatch
[quo/button [:contacts/set-new-identity v nil]
(merge style/button-paste 600))
{:on-press :blur-on-submit true
(fn [] :return-key-type :done})]
(reset! default-value @clipboard) (when show-paste-button?
(rf/dispatch [quo/button
[:contacts/set-new-identity @clipboard nil]))}) (merge style/button-paste
(i18n/label :t/paste)])] {:on-press
(fn []
(reset! default-value @clipboard)
(rf/dispatch
[:contacts/set-new-identity @clipboard nil]))})
(i18n/label :t/paste)])]
[quo/button
(merge style/button-qr
{:on-press #(rf/dispatch
[::qr-scanner/scan-code
{:handler :contacts/qr-code-scanned}])})
:i/scan]]
(when invalid?
[rn/view style/container-invalid
[quo/icon :i/alert style/icon-invalid]
[quo/text style/text-invalid
(i18n/label (or msg :t/invalid-ens-or-key))]])
(when (= state :valid)
[found-contact public-key])]
[quo/button [quo/button
(merge style/button-qr (merge (style/button-view-profile state)
{:on-press #(rf/dispatch {:on-press
[::qr-scanner/scan-code (fn []
{:handler :contacts/qr-code-scanned}])}) (reset! clipboard nil)
:i/scan]] (reset! default-value nil)
(when invalid? (rf/dispatch [:contacts/clear-new-identity])
[rn/view style/container-invalid (rf/dispatch [:navigate-back])
[quo/icon :i/alert style/icon-invalid] (rf/dispatch [:chat.ui/show-profile public-key ens]))})
[quo/text style/text-invalid (i18n/label :t/view-profile)]]]]))))
(i18n/label (or msg :t/invalid-ens-or-key))]])
(when (= state :valid)
[found-contact public-key])]
[rn/view
[quo/button
(merge (style/button-view-profile state)
{:on-press
(fn []
(reset! clipboard nil)
(reset! default-value nil)
(rf/dispatch [:contacts/clear-new-identity])
(rf/dispatch [:navigate-back])
(rf/dispatch [:chat.ui/show-profile public-key ens]))})
(i18n/label :t/view-profile)]]]))))