From 82b3587fb0b9d85e3e399527f65fcad3c924e6ca Mon Sep 17 00:00:00 2001 From: Alexander Pantyuhov Date: Thu, 3 Nov 2016 14:16:04 +0300 Subject: [PATCH] Request icon in message is overlapped by the next message fix (#400) Former-commit-id: f1b687872b0f171cfaa9b692aedd0573631809f6 --- src/status_im/chat/styles/message.cljs | 4 ++-- src/status_im/chat/views/request_message.cljs | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/status_im/chat/styles/message.cljs b/src/status_im/chat/styles/message.cljs index c42c6cffc5..4a1a1379b2 100644 --- a/src/status_im/chat/styles/message.cljs +++ b/src/status_im/chat/styles/message.cljs @@ -140,9 +140,9 @@ (def command-request-from-text (merge style-sub-text {:marginBottom 2})) -(def command-request-image-touchable +(defn command-request-image-touchable [top-offset?] {:position :absolute - :top 4 + :top (if top-offset? 4 -1) :right -8 :alignItems :center :justifyContent :center diff --git a/src/status_im/chat/views/request_message.cljs b/src/status_im/chat/views/request_message.cljs index 4a639dc5cb..1cecc1d4b0 100644 --- a/src/status_im/chat/views/request_message.cljs +++ b/src/status_im/chat/views/request_message.cljs @@ -43,7 +43,7 @@ (anim/start (button-animation val min-scale loop? answered?))))) -(defn request-button [message-id command status-initialized?] +(defn request-button [message-id command status-initialized? top-offset?] (let [scale-anim-val (anim/create-value min-scale) answered? (subscribe [:is-request-answered? message-id]) loop? (r/atom true) @@ -62,7 +62,7 @@ [touchable-highlight {:on-press (when (and (not @answered?) status-initialized?) #(set-chat-command message-id command)) - :style st/command-request-image-touchable + :style (st/command-request-image-touchable top-offset?) :accessibility-label (label command)} [animated-view {:style (st/command-request-image-view command scale-anim-val)} (when command-icon @@ -70,7 +70,8 @@ (defn message-content-command-request [{:keys [message-id content from incoming-group]}] - (let [commands-atom (subscribe [:get-responses]) + (let [top-offset (r/atom {:specified? false}) + commands-atom (subscribe [:get-responses]) answered? (subscribe [:is-request-answered? message-id]) status-initialized? (subscribe [:get :status-module-initialized?])] (fn [{:keys [message-id content from incoming-group]}] @@ -86,6 +87,11 @@ :font :default} from]) [text {:style st/style-message-text + :on-layout #(reset! top-offset {:specified? true + :value (-> (.-nativeEvent %) + (.-layout) + (.-height)
 + (> 25))}) :font :default} content]]] (when (:request-text command) @@ -93,4 +99,5 @@ [text {:style st/style-sub-text :font :default} (:request-text command)]]) - [request-button message-id command @status-initialized?]])))) + (when (:specified? @top-offset) + [request-button message-id command @status-initialized? (:value @top-offset)])]))))