Delete unnecessary view nesting

This commit is contained in:
virvar 2016-05-03 16:45:06 +03:00
parent ac11508703
commit bbaff31570
1 changed files with 63 additions and 65 deletions

View File

@ -184,72 +184,70 @@
[actions-list-view navigator chat]]) [actions-list-view navigator chat]])
(defn toolbar [navigator chat show-actions] (defn toolbar [navigator chat show-actions]
[view {:style {:flex (if show-actions 1 0)}} [view {:style {:flexDirection "row"
[view {:style {:flexDirection "column" :height 56
:backgroundColor color-white :backgroundColor color-white
:elevation 2}} :elevation 2}}
[view {:style {:flexDirection "row" (when (not show-actions)
:height 56}} [touchable-highlight {:on-press (fn []
(when (not show-actions) (nav-pop navigator))
[touchable-highlight {:on-press (fn [] :underlay-color :transparent}
(nav-pop navigator)) [view {:width 56
:underlay-color :transparent} :height 56}
[view {:width 56 [image {:source {:uri "icon_back"}
:height 56} :style {:marginTop 21
[image {:source {:uri "icon_back"} :marginLeft 23
:style {:marginTop 21 :width 8
:marginLeft 23 :height 14}}]]])
:width 8 [view {:style {:flex 1
:height 14}}]]]) :marginLeft (if show-actions 16 0)
[view {:style {:flex 1 :alignItems "flex-start"
:marginLeft (if show-actions 16 0) :justifyContent "center"}}
:alignItems "flex-start" [text {:style {:marginTop -2.5
:justifyContent "center"}} :color text1-color
[text {:style {:marginTop -2.5 :fontSize 16
:color text1-color :fontFamily font}}
:fontSize 16 (or (chat :name)
"Chat name")]
(if (:group-chat chat)
[view {:style {:flexDirection "row"}}
[image {:source {:uri "icon_group"}
:style {:marginTop 4
:width 14
:height 9}}]
[text {:style {:marginTop -0.5
:marginLeft 4
:fontFamily font
:fontSize 12
:color text2-color}}
(str (count (:contacts chat))
(if (< 1 (count (:contacts chat)))
" members"
" member")
", " (count (:contacts chat)) " active")]]
[text {:style {:marginTop 1
:color text2-color
:fontSize 12
:fontFamily font}} :fontFamily font}}
(or (chat :name) "Active a minute ago"])]
"Chat name")] (if show-actions
(if (:group-chat chat) [touchable-highlight {:on-press (fn []
[view {:style {:flexDirection "row"}} (dispatch [:set-show-actions false]))
[image {:source {:uri "icon_group"} :underlay-color :transparent}
:style {:marginTop 4 [view {:style {:width 56
:width 14 :height 56}}
:height 9}}] [image {:source {:uri "icon_up"}
[text {:style {:marginTop -0.5 :style {:marginTop 23
:marginLeft 4 :marginLeft 21
:fontFamily font :width 14
:fontSize 12 :height 8}}]]]
:color text2-color}} [touchable-highlight {:on-press (fn []
(str (count (:contacts chat)) (dispatch [:set-show-actions true]))
(if (< 1 (count (:contacts chat))) :underlay-color :transparent}
" members" [view {:style {:width 56
" member") :height 56}}
", " (count (:contacts chat)) " active")]] [chat-photo {}]
[text {:style {:marginTop 1 [contact-online {:online true}]]])])
:color text2-color
:fontSize 12
:fontFamily font}}
"Active a minute ago"])]
(if show-actions
[touchable-highlight {:on-press (fn []
(dispatch [:set-show-actions false]))
:underlay-color :transparent}
[view {:style {:width 56
:height 56}}
[image {:source {:uri "icon_up"}
:style {:marginTop 23
:marginLeft 21
:width 14
:height 8}}]]]
[touchable-highlight {:on-press (fn []
(dispatch [:set-show-actions true]))
:underlay-color :transparent}
[view {:style {:width 56
:height 56}}
[chat-photo {}]
[contact-online {:online true}]]])]]])
(defn chat [{:keys [navigator]}] (defn chat [{:keys [navigator]}]
(let [messages (subscribe [:get-chat-messages]) (let [messages (subscribe [:get-chat-messages])