remove message appearing animation

Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
This commit is contained in:
Roman Volosovskyi 2018-05-18 09:32:31 +03:00 committed by Julien Eluard
parent fd77796cba
commit 579bfe7cf5
No known key found for this signature in database
GPG Key ID: 6FD7DB5437FCBEF6
2 changed files with 3 additions and 38 deletions

View File

@ -87,7 +87,8 @@
(animation/anim-sequence (animation/anim-sequence
[(animation/anim-delay timeout) [(animation/anim-delay timeout)
(animation/spring opacity {:toValue 1 (animation/spring opacity {:toValue 1
:duration duration})])))} :duration duration
:useNativeDriver true})])))}
[react/with-activity-indicator [react/with-activity-indicator
{:style style/message-view-preview {:style style/message-view-preview
:preview [react/view style/message-view-preview]} :preview [react/view style/message-view-preview]}

View File

@ -326,44 +326,8 @@
[react/view style/delivery-status [react/view style/delivery-status
[message-delivery-status message]]]) [message-delivery-status message]]])
(defn message-container-animation-logic [{:keys [to-value val callback]}]
(fn [_]
(let [to-value @to-value]
(when (pos? to-value)
(animation/start
(animation/timing val {:toValue to-value
:duration 250})
(fn [arg]
(when (.-finished arg)
(callback))))))))
(defn message-container [message & children]
(if (:appearing? message)
(let [layout-height (reagent/atom 0)
anim-value (animation/create-value 1)
anim-callback #(re-frame/dispatch [:message-appeared message])
context {:to-value layout-height
:val anim-value
:callback anim-callback}
on-update (message-container-animation-logic context)]
(reagent/create-class
{:component-did-update
on-update
:display-name
"message-container"
:reagent-render
(fn [_ & children]
@layout-height
[react/animated-view {:style (style/message-animated-container anim-value)}
(into [react/view {:style (style/message-container window-width)
:onLayout (fn [event]
(let [height (.. event -nativeEvent -layout -height)]
(reset! layout-height height)))}]
children)])}))
(into [react/view] children)))
(defn chat-message [{:keys [outgoing group-chat current-public-key content-type content] :as message}] (defn chat-message [{:keys [outgoing group-chat current-public-key content-type content] :as message}]
[message-container message [react/view
[react/touchable-highlight {:on-press (fn [_] [react/touchable-highlight {:on-press (fn [_]
(re-frame/dispatch [:set-chat-ui-props {:messages-focused? true}]) (re-frame/dispatch [:set-chat-ui-props {:messages-focused? true}])
(react/dismiss-keyboard!)) (react/dismiss-keyboard!))