|
2 | 2 | (:require [clojure.string :as string]
|
3 | 3 | [quo.core :as quo]
|
4 | 4 | [react-native.core :as rn]
|
| 5 | + [react-native.platform :as platform] |
5 | 6 | [status-im.constants :as constants]
|
6 | 7 | [status-im.contexts.profile.contact.contact-request.style :as style]
|
7 | 8 | [status-im.contexts.profile.utils :as profile.utils]
|
|
15 | 16 | customization-color customization-color
|
16 | 17 | full-name (profile.utils/displayed-name profile)
|
17 | 18 | profile-picture (profile.utils/photo profile)
|
| 19 | + input-ref (rn/use-ref-atom nil) |
18 | 20 | [message set-message] (rn/use-state "")
|
19 | 21 | on-message-change (rn/use-callback #(set-message %))
|
20 | 22 | on-message-submit (rn/use-callback (fn []
|
|
27 | 29 | :text (i18n/label
|
28 | 30 | :t/contact-request-was-sent)}]))
|
29 | 31 | [public-key message])]
|
| 32 | + (rn/use-mount |
| 33 | + (fn [] |
| 34 | + (let [listener (.addListener rn/keyboard |
| 35 | + "keyboardDidHide" |
| 36 | + (fn [_event] |
| 37 | + (when (and platform/android? @input-ref) |
| 38 | + (.blur ^js @input-ref))))] |
| 39 | + #(.remove ^js listener)))) |
30 | 40 | [:<>
|
31 | 41 | [quo/drawer-top
|
32 | 42 | {:type :context-tag
|
|
39 | 49 | (i18n/label :t/contact-request-message-prompt)]
|
40 | 50 | [rn/view {:style style/message-input-wrapper}
|
41 | 51 | [quo/input
|
42 |
| - {:type :text |
43 |
| - :multiline? true |
44 |
| - :char-limit constants/contact-request-message-max-length |
45 |
| - :max-length constants/contact-request-message-max-length |
46 |
| - :placeholder (i18n/label :t/type-something) |
47 |
| - :auto-focus true |
48 |
| - :accessibility-label :contact-request-message |
49 |
| - :label (i18n/label :t/message) |
50 |
| - :on-change-text on-message-change}]] |
| 52 | + {:type :text |
| 53 | + :ref #(reset! input-ref %) |
| 54 | + :multiline? true |
| 55 | + :char-limit constants/contact-request-message-max-length |
| 56 | + :max-length constants/contact-request-message-max-length |
| 57 | + :placeholder (i18n/label :t/type-something) |
| 58 | + :auto-focus true |
| 59 | + :accessibility-label :contact-request-message |
| 60 | + :label (i18n/label :t/message) |
| 61 | + :on-change-text on-message-change |
| 62 | + :container-style {:flex-shrink 1} |
| 63 | + :input-container-style {:flex-shrink 1}}]] |
51 | 64 | [quo/bottom-actions
|
52 |
| - {:actions :one-action |
| 65 | + {:container-style {:style {:flex 1}} |
| 66 | + :actions :one-action |
53 | 67 | :button-one-props {:disabled? (string/blank? message)
|
54 | 68 | :accessibility-label :send-contact-request
|
55 | 69 | :customization-color customization-color
|
|
0 commit comments