File tree 5 files changed +28
-19
lines changed
src/status_im2/contexts/chat/composer
5 files changed +28
-19
lines changed Original file line number Diff line number Diff line change 11
11
[utils.re-frame :as rf]))
12
12
13
13
(defn edit-message
14
- [state ]
14
+ [{ :keys [text-value input-ref]} ]
15
15
[rn/view
16
16
{:style style/container
17
17
:accessibility-label :edit-message }
30
30
{:size 24
31
31
:icon-only? true
32
32
:accessibility-label :edit-cancel-button
33
- :on-press (fn []
34
- (utils/cancel-edit-message state)
35
- (rf/dispatch [:chat.ui/cancel-message-edit ]))
33
+ :on-press #(utils/cancel-edit-message text-value input-ref)
36
34
:type :outline }
37
35
:i/close ]])
38
36
39
37
(defn- f-view
40
- [state ]
38
+ [props ]
41
39
(let [edit (rf/sub [:chats/edit-message ])
42
40
height (reanimated/use-shared-value (if edit constants/edit-container-height 0 ))]
43
41
(rn/use-effect #(reanimated/animate height (if edit constants/edit-container-height 0 )) [edit])
44
42
[reanimated/view {:style (reanimated/apply-animations-to-style {:height height} {})}
45
- (when edit [edit-message state ])]))
43
+ (when edit [edit-message props ])]))
46
44
47
45
(defn view
48
- [state ]
49
- [:f> f-view state ])
46
+ [props ]
47
+ [:f> f-view props ])
Original file line number Diff line number Diff line change 43
43
(reset! emoji-kb-extra-height nil ))
44
44
(reset! maximized? false )
45
45
(rf/dispatch [:chat.ui/set-input-maximized false ])
46
- (when @input-ref
47
- (.blur ^js @input-ref)))
46
+ (utils/blur-input input-ref))
48
47
49
48
(defn bounce-back
50
49
[{:keys [height saved-height opacity background-y]}
96
95
max-height
97
96
bounded-height
98
97
saved-height))
99
- ( when @input-ref ; sheet at min-height, collapse keyboard
100
- ( . blur ^js @ input-ref) ))))))
98
+ ; sheet at min-height, collapse keyboard
99
+ ( utils/ blur-input input-ref))))))
101
100
(gesture/on-end (fn []
102
101
(let [diff (- (reanimated/get-shared-value height)
103
102
(reanimated/get-shared-value saved-height))]
Original file line number Diff line number Diff line change 4
4
[react-native.async-storage :as async-storage]
5
5
[react-native.core :as rn]
6
6
[react-native.platform :as platform]
7
- [react-native.reanimated :as reanimated]))
7
+ [react-native.reanimated :as reanimated]
8
+ [status-im2.contexts.chat.composer.utils :as utils]))
8
9
9
10
(defn get-kb-height
10
11
[curr-height default-height ]
68
69
#(handle-emoji-kb-ios % props state animations dimensions)))
69
70
(reset! keyboard-hide-listener (.addListener rn/keyboard
70
71
" keyboardDidHide"
71
- #(when ( and platform/android? @input-ref)
72
- (. blur ^js @ input-ref)))))
72
+ #(when platform/android?
73
+ (utils/ blur-input input-ref)))))
73
74
74
75
(defn handle-refocus-emoji-kb-ios
75
76
[{:keys [saved-emoji-kb-extra-height]}
Original file line number Diff line number Diff line change 99
99
(not reply?)
100
100
(not audio?)))
101
101
102
+ (defn blur-input
103
+ [input-ref]
104
+ (when @input-ref
105
+ (rf/dispatch [:chat.ui/set-input-focused false ])
106
+ (.blur ^js @input-ref)))
107
+
102
108
(defn cancel-edit-message
103
- [{ :keys [ text-value]} ]
109
+ [text-value input-ref ]
104
110
(reset! text-value " " )
105
- (rf/dispatch [:chat.ui/set-input-content-height constants/input-height]))
111
+ (blur-input input-ref)
112
+ (rf/dispatch [:chat.ui/set-input-content-height constants/input-height])
113
+ (rf/dispatch [:chat.ui/cancel-message-edit ]))
106
114
107
115
(defn count-lines
108
116
[s]
Original file line number Diff line number Diff line change 99
99
(when chat-screen-loaded?
100
100
[:<>
101
101
[reply/view state]
102
- [edit/view state]])
102
+ [edit/view
103
+ {:text-value (:text-value state)
104
+ :input-ref (:input-ref props)}]])
103
105
[reanimated/touchable-opacity
104
106
{:active-opacity 1
105
107
:on-press (fn []
151
153
(let [window-height (:height (rn/get-window ))
152
154
theme (quo.theme/use-theme-value )
153
155
opacity (reanimated/use-shared-value 0 )
154
- background-y (reanimated/use-shared-value (- window-height)) ; Y position of background overlay
156
+ background-y (reanimated/use-shared-value (- window-height)) ; Y position of background
157
+ ; overlay
155
158
blur-height (reanimated/use-shared-value (+ constants/composer-default-height
156
159
(:bottom insets)))
157
160
extra-params {:insets insets
You can’t perform that action at this time.
0 commit comments