From 66bcf6562ada8cb4c28295af68b8edd06daf0dd2 Mon Sep 17 00:00:00 2001 From: kwingram25 Date: Fri, 6 Apr 2018 19:57:56 -0700 Subject: [PATCH] chat, ui: allow non-deletable home items, fix console chat ui --- src/status_im/chat/screen.cljs | 9 +++++---- src/status_im/ui/screens/home/views.cljs | 25 +++++++++++++----------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/status_im/chat/screen.cljs b/src/status_im/chat/screen.cljs index 34dcc4c7a8..1331c0afef 100644 --- a/src/status_im/chat/screen.cljs +++ b/src/status_im/chat/screen.cljs @@ -56,10 +56,11 @@ [toolbar/platform-agnostic-toolbar {} toolbar/nav-back-count [toolbar-content/toolbar-content-view] - [toolbar/actions [{:icon :icons/options - :icon-opts {:color :black - :accessibility-label :chat-menu-button} - :handler #(on-options chat-id name group-chat public?)}]]] + (when (not= chat-id constants/console-chat-id) + [toolbar/actions [{:icon :icons/options + :icon-opts {:color :black + :accessibility-label :chat-menu-button} + :handler #(on-options chat-id name group-chat public?)}]])] (when-not (or public? group-chat) [add-contact-bar (-> contacts first :identity)])])) (defmulti message-row (fn [{{:keys [type]} :row}] type)) diff --git a/src/status_im/ui/screens/home/views.cljs b/src/status_im/ui/screens/home/views.cljs index 36dba0b82a..467361a716 100644 --- a/src/status_im/ui/screens/home/views.cljs +++ b/src/status_im/ui/screens/home/views.cljs @@ -1,6 +1,7 @@ (ns status-im.ui.screens.home.views (:require-macros [status-im.utils.views :as views]) (:require [re-frame.core :as re-frame] + [status-im.constants :as constants] [status-im.ui.components.colors :as colors] [status-im.ui.components.list.views :as list] [status-im.ui.components.react :as react] @@ -35,24 +36,26 @@ [react/view styles/action-button [icons/icon :icons/add {:color :white}]]]]) -(views/defview home-list-deletable [[home-item-id home-item]] +(views/defview home-list-item [[home-item-id home-item]] (views/letsubs [swiped? [:delete-swipe-position home-item-id]] - (let [delete-action (if (:chat-id home-item) :delete-chat :remove-browser) + (let [delete-action (if (:chat-id home-item) :remove-chat :remove-browser) inner-item-view (if (:chat-id home-item) inner-item/home-list-chat-item-inner-view inner-item/home-list-browser-item-inner-view) - offset-x (animation/create-value (if swiped? styles/delete-button-width 0)) + is-deletable? (not= (:chat-id home-item) constants/console-chat-id) + offset-x (animation/create-value (if (and is-deletable? swiped?) styles/delete-button-width 0)) swipe-pan-responder (responder/swipe-pan-responder offset-x styles/delete-button-width home-item-id swiped?) - swipe-pan-handler (responder/pan-handlers swipe-pan-responder)] + swipe-pan-handler (if is-deletable? (responder/pan-handlers swipe-pan-responder) {})] [react/view (assoc swipe-pan-handler :accessibility-label :chat-item) [react/animated-view {:style {:flex 1 :right offset-x}} [inner-item-view home-item] - [react/touchable-highlight {:style styles/delete-icon-highlight - :on-press #(do - (re-frame/dispatch [:set-swipe-position home-item-id false]) - (re-frame/dispatch [delete-action home-item-id]))} - [react/view {:style styles/delete-icon-container} - [vector-icons/icon :icons/delete {:color colors/red}]]]]]))) + (when is-deletable? + [react/touchable-highlight {:style styles/delete-icon-highlight + :on-press #(do + (re-frame/dispatch [:set-swipe-position home-item-id false]) + (re-frame/dispatch [delete-action home-item-id]))} + [react/view {:style styles/delete-icon-container} + [vector-icons/icon :icons/delete {:color colors/red}]]])]]))) ;;do not remove view-id and will-update or will-unmount handlers, this is how it works (views/defview welcome [view-id] @@ -85,7 +88,7 @@ [list/flat-list {:data home-items :key-fn first :render-fn (fn [home-item] - [home-list-deletable home-item])}]) + [home-list-item home-item])}]) (when platform/android? [home-action-button]) [connectivity/error-view]]))