diff --git a/src/status_im/android/core.cljs b/src/status_im/android/core.cljs index 154c7104ce..daecbff91c 100644 --- a/src/status_im/android/core.cljs +++ b/src/status_im/android/core.cljs @@ -5,7 +5,7 @@ [re-frame.core :refer [subscribe dispatch dispatch-sync]] [status-im.handlers] [status-im.subs] - [status-im.components.react :refer [navigator app-registry]] + [status-im.components.react :refer [navigator app-registry device-event-emitter]] [status-im.components.main-tabs :refer [main-tabs]] [status-im.contacts.screen :refer [contact-list]] [status-im.contacts.views.new-contact :refer [new-contact]] @@ -36,21 +36,33 @@ (defn app-root [] (let [signed-up (subscribe [:get :signed-up]) view-id (subscribe [:get :view-id])] - (fn [] - (case (if @signed-up @view-id :chat) - :discovery [main-tabs] - :discovery-tag [discovery-tag] - :add-participants [new-participants] - :remove-participants [remove-participants] - :chat-list [main-tabs] - :new-group [new-group] - :group-settings [group-settings] - :contact-list [main-tabs] - :new-contact [new-contact] - :qr-scanner [qr-scanner] - :chat [chat] - :profile [profile] - :my-profile [my-profile])))) + (r/create-class + {:component-will-mount + (fn [] + (.addListener device-event-emitter + "keyboardDidShow" + (fn [e] + (let [h (.. e -endCoordinates -height)] + (dispatch [:set :keyboard-height h])))) + (.addListener device-event-emitter + "keyboardDidHide" + #(dispatch [:set :keyboard-height 0]))) + :render + (fn [] + (case (if @signed-up @view-id :chat) + :discovery [main-tabs] + :discovery-tag [discovery-tag] + :add-participants [new-participants] + :remove-participants [remove-participants] + :chat-list [main-tabs] + :new-group [new-group] + :group-settings [group-settings] + :contact-list [main-tabs] + :new-contact [new-contact] + :qr-scanner [qr-scanner] + :chat [chat] + :profile [profile] + :my-profile [my-profile]))}))) (defn init [] (dispatch-sync [:initialize-db]) diff --git a/src/status_im/chat/views/response.cljs b/src/status_im/chat/views/response.cljs index 79f9a772ac..8566da3bb9 100644 --- a/src/status_im/chat/views/response.cljs +++ b/src/status_im/chat/views/response.cljs @@ -34,11 +34,12 @@ ;; TODO stub data: request message info "By ???, MMM 1st at HH:mm"]]) -(defn create-response-pan-responder [response-height] +(defn create-response-pan-responder [response-height kb-height] (drag/create-pan-responder {:on-move (fn [_ gesture] (when (> (Math/abs (.-dy gesture)) 10) (let [to-value (- (:height (react/get-dimensions "window")) + @kb-height (.-moveY gesture))] (anim/start (anim/spring response-height {:toValue to-value}))))) @@ -50,7 +51,8 @@ (.-_value response-height)])))})) (defn request-info [response-height] - (let [pan-responder (create-response-pan-responder response-height) + (let [kb-height (subscribe [:get :keyboard-height]) + pan-responder (create-response-pan-responder response-height kb-height) command (subscribe [:get-chat-command])] (fn [response-height] [view (merge (drag/pan-handlers pan-responder) @@ -65,7 +67,6 @@ (defn container-animation-logic [{:keys [to-value val]}] (fn [_] - (println :to @to-value) (let [to-value @to-value] (anim/start (anim/spring val {:toValue to-value}))))) diff --git a/src/status_im/components/react.cljs b/src/status_im/components/react.cljs index 1347f22ea2..3841331b14 100644 --- a/src/status_im/components/react.cljs +++ b/src/status_im/components/react.cljs @@ -76,3 +76,4 @@ (r/as-element component)) (def dismiss-keyboard! (u/require "dismissKeyboard")) +(def device-event-emitter (.-DeviceEventEmitter react))