fix #197 weird animation

Former-commit-id: b98293cedd
This commit is contained in:
Roman Volosovskyi 2016-08-26 12:37:13 +03:00
parent dacc9a5446
commit b9c5d84e90
1 changed files with 28 additions and 47 deletions

View File

@ -42,50 +42,31 @@
:style st/search-icon} :style st/search-icon}
:handler (fn [])}}]]) :handler (fn [])}}]])
(defn chats-list [{platform-specific :platform-specific}] (defview chats-list [{platform-specific :platform-specific}]
(let [chats (subscribe [:get :chats]) [chats [:get :chats]]
chats-scrolled? (subscribe [:get :chats-scrolled?]) ;; todo what is this?!
animation? (subscribe [:animations :tabs-bar-animation?]) #_(dispatch [:set :chats-scrolled? false])
tabs-bar-value (subscribe [:animations :tabs-bar-value]) [view st/chats-container
container-height (r/atom 0) [chats-list-toolbar platform-specific]
content-height (r/atom 0)] [list-view {:dataSource (to-datasource chats)
(dispatch [:set :chats-scrolled? false]) :renderRow (fn [row _ _]
(fn [] (list-item [chat-list-item row]))
[view st/chats-container :style st/list-container}]
[chats-list-toolbar platform-specific] [view {:style (st/action-buttons-container false 0)
[list-view {:dataSource (to-datasource @chats) :pointerEvents :box-none}
:renderRow (fn [row _ _] [action-button {:buttonColor color-blue
(list-item [chat-list-item row])) :offsetY 16
:style st/list-container :offsetX 16}
;;; if "maximizing" chat list will make scroll to 0, [action-button-item
;;; then disable maximazing {:title (label :t/new-chat)
:onLayout (fn [event] :buttonColor :#9b59b6
(when-not @chats-scrolled? :onPress #(dispatch [:show-group-contacts :people])}
(let [height (.. event -nativeEvent -layout -height)] [ion-icon {:name :md-create
(reset! container-height height)))) :style st/create-icon}]]
:onContentSizeChange (fn [width height] [action-button-item
(reset! content-height height)) {:title (label :t/new-group-chat)
:onScroll (fn [e] :buttonColor :#1abc9c
(let [offset (.. e -nativeEvent -contentOffset -y) :onPress #(dispatch [:show-group-new])}
min-content-height (+ @container-height tabs-height) [ion-icon {:name :md-person
scrolled? (and (< 0 offset) (< min-content-height @content-height))] :style st/person-stalker-icon}]]]]
(dispatch [:set :chats-scrolled? scrolled?]) [bottom-gradient]])
(dispatch [:set-animation :tabs-bar-animation? true])))}]
[animated-view {:style (st/action-buttons-container @animation? (or @tabs-bar-value 0))
:pointerEvents :box-none}
[action-button {:buttonColor color-blue
:offsetY 16
:offsetX 16}
[action-button-item
{:title (label :t/new-chat)
:buttonColor :#9b59b6
:onPress #(dispatch [:show-group-contacts :people])}
[ion-icon {:name :md-create
:style st/create-icon}]]
[action-button-item
{:title (label :t/new-group-chat)
:buttonColor :#1abc9c
:onPress #(dispatch [:show-group-new])}
[ion-icon {:name :md-person
:style st/person-stalker-icon}]]]]
[bottom-gradient]])))