keyboard height
This commit is contained in:
parent
8c1d2eec1a
commit
e6639fc770
|
@ -5,7 +5,7 @@
|
||||||
[re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
[re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
||||||
[status-im.handlers]
|
[status-im.handlers]
|
||||||
[status-im.subs]
|
[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.components.main-tabs :refer [main-tabs]]
|
||||||
[status-im.contacts.screen :refer [contact-list]]
|
[status-im.contacts.screen :refer [contact-list]]
|
||||||
[status-im.contacts.views.new-contact :refer [new-contact]]
|
[status-im.contacts.views.new-contact :refer [new-contact]]
|
||||||
|
@ -36,21 +36,33 @@
|
||||||
(defn app-root []
|
(defn app-root []
|
||||||
(let [signed-up (subscribe [:get :signed-up])
|
(let [signed-up (subscribe [:get :signed-up])
|
||||||
view-id (subscribe [:get :view-id])]
|
view-id (subscribe [:get :view-id])]
|
||||||
(fn []
|
(r/create-class
|
||||||
(case (if @signed-up @view-id :chat)
|
{:component-will-mount
|
||||||
:discovery [main-tabs]
|
(fn []
|
||||||
:discovery-tag [discovery-tag]
|
(.addListener device-event-emitter
|
||||||
:add-participants [new-participants]
|
"keyboardDidShow"
|
||||||
:remove-participants [remove-participants]
|
(fn [e]
|
||||||
:chat-list [main-tabs]
|
(let [h (.. e -endCoordinates -height)]
|
||||||
:new-group [new-group]
|
(dispatch [:set :keyboard-height h]))))
|
||||||
:group-settings [group-settings]
|
(.addListener device-event-emitter
|
||||||
:contact-list [main-tabs]
|
"keyboardDidHide"
|
||||||
:new-contact [new-contact]
|
#(dispatch [:set :keyboard-height 0])))
|
||||||
:qr-scanner [qr-scanner]
|
:render
|
||||||
:chat [chat]
|
(fn []
|
||||||
:profile [profile]
|
(case (if @signed-up @view-id :chat)
|
||||||
:my-profile [my-profile]))))
|
: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 []
|
(defn init []
|
||||||
(dispatch-sync [:initialize-db])
|
(dispatch-sync [:initialize-db])
|
||||||
|
|
|
@ -34,11 +34,12 @@
|
||||||
;; TODO stub data: request message info
|
;; TODO stub data: request message info
|
||||||
"By ???, MMM 1st at HH:mm"]])
|
"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
|
(drag/create-pan-responder
|
||||||
{:on-move (fn [_ gesture]
|
{:on-move (fn [_ gesture]
|
||||||
(when (> (Math/abs (.-dy gesture)) 10)
|
(when (> (Math/abs (.-dy gesture)) 10)
|
||||||
(let [to-value (- (:height (react/get-dimensions "window"))
|
(let [to-value (- (:height (react/get-dimensions "window"))
|
||||||
|
@kb-height
|
||||||
(.-moveY gesture))]
|
(.-moveY gesture))]
|
||||||
(anim/start
|
(anim/start
|
||||||
(anim/spring response-height {:toValue to-value})))))
|
(anim/spring response-height {:toValue to-value})))))
|
||||||
|
@ -50,7 +51,8 @@
|
||||||
(.-_value response-height)])))}))
|
(.-_value response-height)])))}))
|
||||||
|
|
||||||
(defn request-info [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])]
|
command (subscribe [:get-chat-command])]
|
||||||
(fn [response-height]
|
(fn [response-height]
|
||||||
[view (merge (drag/pan-handlers pan-responder)
|
[view (merge (drag/pan-handlers pan-responder)
|
||||||
|
@ -65,7 +67,6 @@
|
||||||
|
|
||||||
(defn container-animation-logic [{:keys [to-value val]}]
|
(defn container-animation-logic [{:keys [to-value val]}]
|
||||||
(fn [_]
|
(fn [_]
|
||||||
(println :to @to-value)
|
|
||||||
(let [to-value @to-value]
|
(let [to-value @to-value]
|
||||||
(anim/start (anim/spring val {:toValue to-value})))))
|
(anim/start (anim/spring val {:toValue to-value})))))
|
||||||
|
|
||||||
|
|
|
@ -76,3 +76,4 @@
|
||||||
(r/as-element component))
|
(r/as-element component))
|
||||||
|
|
||||||
(def dismiss-keyboard! (u/require "dismissKeyboard"))
|
(def dismiss-keyboard! (u/require "dismissKeyboard"))
|
||||||
|
(def device-event-emitter (.-DeviceEventEmitter react))
|
||||||
|
|
Loading…
Reference in New Issue