keyboard height

This commit is contained in:
Roman Volosovskyi 2016-06-21 11:35:15 +03:00
parent 8c1d2eec1a
commit e6639fc770
3 changed files with 33 additions and 19 deletions

View File

@ -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])

View File

@ -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})))))

View File

@ -76,3 +76,4 @@
(r/as-element component))
(def dismiss-keyboard! (u/require "dismissKeyboard"))
(def device-event-emitter (.-DeviceEventEmitter react))