[#12919] Allowing adding emoji in status input even if it exceeds limit

This commit is contained in:
Roman Volosovskyi 2022-01-17 10:47:44 +02:00
parent 826dd32c40
commit c44e5bbb67
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
1 changed files with 15 additions and 7 deletions

View File

@ -12,7 +12,8 @@
[status-im.ui.components.icons.icons :as icons] [status-im.ui.components.icons.icons :as icons]
[quo.components.animated.pressable :as pressable] [quo.components.animated.pressable :as pressable]
[status-im.ui.screens.status.views :as status.views] [status-im.ui.screens.status.views :as status.views]
[status-im.ui.screens.status.new.styles :as styles])) [status-im.ui.screens.status.new.styles :as styles]
[status-im.utils.platform :as platform]))
(defn buttons [] (defn buttons []
[react/view styles/buttons [react/view styles/buttons
@ -43,7 +44,7 @@
^{:key (str "image" img)} ^{:key (str "image" img)}
[image-preview img])]])) [image-preview img])]]))
(def message-max-lenght 600) (def message-max-length 600)
(defn my-status [] (defn my-status []
(let [images-opened (reagent/atom false) (let [images-opened (reagent/atom false)
@ -53,7 +54,8 @@
input-text (re-frame/subscribe [:chats/timeline-chat-input-text]) input-text (re-frame/subscribe [:chats/timeline-chat-input-text])
sending-image (re-frame/subscribe [:chats/timeline-sending-image])] sending-image (re-frame/subscribe [:chats/timeline-sending-image])]
(fn [] (fn []
(let [{:keys [uri]} (first (vals @sending-image))] (let [{:keys [uri]} (first (vals @sending-image))
text-length (count @input-text)]
[kb-presentation/keyboard-avoiding-view {:style {:flex 1}} [kb-presentation/keyboard-avoiding-view {:style {:flex 1}}
[:<> [:<>
[react/scroll-view {:style {:flex 1} [react/scroll-view {:style {:flex 1}
@ -65,7 +67,10 @@
{:style {:margin 16} {:style {:margin 16}
:scroll-enabled false :scroll-enabled false
:accessibility-label :my-status-input :accessibility-label :my-status-input
:max-length message-max-lenght :max-length (if platform/android?
message-max-length
(when (>= text-length message-max-length)
text-length))
:auto-focus true :auto-focus true
:multiline true :multiline true
:on-selection-change (fn [args] :on-selection-change (fn [args]
@ -100,11 +105,14 @@
{:accessibility-label :send-my-status-button {:accessibility-label :send-my-status-button
:type :secondary :type :secondary
:after :main-icon/send :after :main-icon/send
:disabled (and (string/blank? @input-text) (not uri)) :disabled (or (> text-length message-max-length)
(and (string/blank? @input-text) (not uri)))
:on-press #(do :on-press #(do
(re-frame/dispatch [:profile.ui/send-my-status-message]) (re-frame/dispatch [:profile.ui/send-my-status-message])
(re-frame/dispatch [:navigate-back]))} (re-frame/dispatch [:navigate-back]))}
(i18n/label :t/wallet-send)]}] (i18n/label :t/wallet-send)]}]
[react/view styles/count-container [react/view styles/count-container
[react/text {:style {:color colors/gray}} [react/text {:style {:color (if (> text-length message-max-length)
(str (count @input-text) " / " message-max-lenght)]]]]]])))) colors/red
colors/gray)}}
(str text-length " / " message-max-length)]]]]]]))))