keyboard height
This commit is contained in:
parent
8c1d2eec1a
commit
e6639fc770
|
@ -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,6 +36,18 @@
|
|||
(defn app-root []
|
||||
(let [signed-up (subscribe [:get :signed-up])
|
||||
view-id (subscribe [:get :view-id])]
|
||||
(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]
|
||||
|
@ -50,7 +62,7 @@
|
|||
:qr-scanner [qr-scanner]
|
||||
:chat [chat]
|
||||
:profile [profile]
|
||||
:my-profile [my-profile]))))
|
||||
:my-profile [my-profile]))})))
|
||||
|
||||
(defn init []
|
||||
(dispatch-sync [:initialize-db])
|
||||
|
|
|
@ -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})))))
|
||||
|
||||
|
|
|
@ -76,3 +76,4 @@
|
|||
(r/as-element component))
|
||||
|
||||
(def dismiss-keyboard! (u/require "dismissKeyboard"))
|
||||
(def device-event-emitter (.-DeviceEventEmitter react))
|
||||
|
|
Loading…
Reference in New Issue