From 3b7a4b54ef35b77c33643bd466471d8114386399 Mon Sep 17 00:00:00 2001 From: Gustavo Nunes Date: Wed, 19 Apr 2017 20:39:55 -0300 Subject: [PATCH] whole header is now draggable --- src/status_im/chat/styles/animations.cljs | 9 +++++---- .../chat/views/input/animations/expandable.cljs | 17 +++++++++++------ src/status_im/chat/views/input/result_box.cljs | 14 +++++++------- src/status_im/chat/views/input/utils.cljs | 2 +- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/status_im/chat/styles/animations.cljs b/src/status_im/chat/styles/animations.cljs index 152a38466c..3077e7d199 100644 --- a/src/status_im/chat/styles/animations.cljs +++ b/src/status_im/chat/styles/animations.cljs @@ -16,13 +16,14 @@ :position :absolute}) (def header-container - {:height 17 + {:min-height 19 :background-color common/color-white - :alignItems :center - :justifyContent :center}) + :alignItems :center}) (def header-icon {:background-color header-draggable-icon + :margin-top 8 + :margin-bottom 6 :width 24 :border-radius 1.5 - :height 3}) \ No newline at end of file + :height 3}) diff --git a/src/status_im/chat/views/input/animations/expandable.cljs b/src/status_im/chat/views/input/animations/expandable.cljs index 53a06b4352..a06880444d 100644 --- a/src/status_im/chat/views/input/animations/expandable.cljs +++ b/src/status_im/chat/views/input/animations/expandable.cljs @@ -11,8 +11,9 @@ [status-im.chat.styles.animations :as style] [taoensso.timbre :as log])) -(defn header [key container-height] - (let [max-container-height (subscribe [:get-max-container-area-height]) +(defn header [key container-height custom-header] + (let [set-container-height (subscribe [:chat-animations key :height]) + max-container-height (subscribe [:get-max-container-area-height]) pan-responder (resp/pan-responder container-height max-container-height :fix-expandable-height @@ -20,7 +21,11 @@ (fn [_] [view (merge (drag/pan-handlers pan-responder) {:style style/header-container}) - [view style/header-icon]]))) + [view style/header-icon] + (when (and custom-header + (or (= @set-container-height :max) + (> @set-container-height (:min-height style/header-container)))) + [custom-header])]))) (defn expandable-view-on-update [{:keys [anim-value to-changed-height max-height chat-input-margin height]}] (let [to-default-height (subscribe [:get-default-container-area-height]) @@ -58,10 +63,10 @@ #(dispatch [:set-expandable-height key height]) #(dispatch [:choose-predefined-expandable-height key :default])) :reagent-render - (fn [{:keys [draggable?]} & elements] + (fn [{:keys [draggable? custom-header]} & elements] @to-changed-height @changes-counter @max-height (let [bottom (+ @input-height @chat-input-margin)] (into [animated-view {:style (style/expandable-container anim-value bottom)} (when draggable? - [header key anim-value])] - elements)))}))) \ No newline at end of file + [header key anim-value custom-header])] + elements)))}))) diff --git a/src/status_im/chat/views/input/result_box.cljs b/src/status_im/chat/views/input/result_box.cljs index f62e876238..17ba855990 100644 --- a/src/status_im/chat/views/input/result_box.cljs +++ b/src/status_im/chat/views/input/result_box.cljs @@ -12,7 +12,8 @@ [status-im.i18n :refer [label]] [taoensso.timbre :as log])) -(defn header [title] +(defview header [] + [{:keys [title]} [:chat-ui-props :result-box]] [view {:style style/header-container} [view style/header-title-container [text {:style style/header-title-text @@ -28,10 +29,9 @@ markup]) (defview result-box-view [] - [{:keys [markup title] :as result-box} [:chat-ui-props :result-box]] + [{:keys [markup] :as result-box} [:chat-ui-props :result-box]] (when result-box - [expandable-view {:key :result-box - :draggable? true} - [view {:flex 1} - [header title] - [result-box-container markup]]])) \ No newline at end of file + [expandable-view {:key :result-box + :draggable? true + :custom-header header} + [result-box-container markup]])) diff --git a/src/status_im/chat/views/input/utils.cljs b/src/status_im/chat/views/input/utils.cljs index 4eab998957..ec8a0b8502 100644 --- a/src/status_im/chat/views/input/utils.cljs +++ b/src/status_im/chat/views/input/utils.cljs @@ -3,7 +3,7 @@ [status-im.components.toolbar-new.styles :as toolbar-st] [status-im.utils.platform :as p])) -(def min-height 17) +(def min-height 19) (def default-height 300) (defn default-container-area-height [bottom screen-height]