chat, ui: allow non-deletable home items, fix console chat ui
This commit is contained in:
parent
afcc9cb08c
commit
66bcf6562a
|
@ -56,10 +56,11 @@
|
||||||
[toolbar/platform-agnostic-toolbar {}
|
[toolbar/platform-agnostic-toolbar {}
|
||||||
toolbar/nav-back-count
|
toolbar/nav-back-count
|
||||||
[toolbar-content/toolbar-content-view]
|
[toolbar-content/toolbar-content-view]
|
||||||
[toolbar/actions [{:icon :icons/options
|
(when (not= chat-id constants/console-chat-id)
|
||||||
:icon-opts {:color :black
|
[toolbar/actions [{:icon :icons/options
|
||||||
:accessibility-label :chat-menu-button}
|
:icon-opts {:color :black
|
||||||
:handler #(on-options chat-id name group-chat public?)}]]]
|
: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)])]))
|
(when-not (or public? group-chat) [add-contact-bar (-> contacts first :identity)])]))
|
||||||
|
|
||||||
(defmulti message-row (fn [{{:keys [type]} :row}] type))
|
(defmulti message-row (fn [{{:keys [type]} :row}] type))
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
(ns status-im.ui.screens.home.views
|
(ns status-im.ui.screens.home.views
|
||||||
(:require-macros [status-im.utils.views :as views])
|
(:require-macros [status-im.utils.views :as views])
|
||||||
(:require [re-frame.core :as re-frame]
|
(:require [re-frame.core :as re-frame]
|
||||||
|
[status-im.constants :as constants]
|
||||||
[status-im.ui.components.colors :as colors]
|
[status-im.ui.components.colors :as colors]
|
||||||
[status-im.ui.components.list.views :as list]
|
[status-im.ui.components.list.views :as list]
|
||||||
[status-im.ui.components.react :as react]
|
[status-im.ui.components.react :as react]
|
||||||
|
@ -35,24 +36,26 @@
|
||||||
[react/view styles/action-button
|
[react/view styles/action-button
|
||||||
[icons/icon :icons/add {:color :white}]]]])
|
[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]]
|
(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-view (if (:chat-id home-item)
|
||||||
inner-item/home-list-chat-item-inner-view
|
inner-item/home-list-chat-item-inner-view
|
||||||
inner-item/home-list-browser-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-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/view (assoc swipe-pan-handler :accessibility-label :chat-item)
|
||||||
[react/animated-view {:style {:flex 1 :right offset-x}}
|
[react/animated-view {:style {:flex 1 :right offset-x}}
|
||||||
[inner-item-view home-item]
|
[inner-item-view home-item]
|
||||||
[react/touchable-highlight {:style styles/delete-icon-highlight
|
(when is-deletable?
|
||||||
:on-press #(do
|
[react/touchable-highlight {:style styles/delete-icon-highlight
|
||||||
(re-frame/dispatch [:set-swipe-position home-item-id false])
|
:on-press #(do
|
||||||
(re-frame/dispatch [delete-action home-item-id]))}
|
(re-frame/dispatch [:set-swipe-position home-item-id false])
|
||||||
[react/view {:style styles/delete-icon-container}
|
(re-frame/dispatch [delete-action home-item-id]))}
|
||||||
[vector-icons/icon :icons/delete {:color colors/red}]]]]])))
|
[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
|
;;do not remove view-id and will-update or will-unmount handlers, this is how it works
|
||||||
(views/defview welcome [view-id]
|
(views/defview welcome [view-id]
|
||||||
|
@ -85,7 +88,7 @@
|
||||||
[list/flat-list {:data home-items
|
[list/flat-list {:data home-items
|
||||||
:key-fn first
|
:key-fn first
|
||||||
:render-fn (fn [home-item]
|
:render-fn (fn [home-item]
|
||||||
[home-list-deletable home-item])}])
|
[home-list-item home-item])}])
|
||||||
(when platform/android?
|
(when platform/android?
|
||||||
[home-action-button])
|
[home-action-button])
|
||||||
[connectivity/error-view]]))
|
[connectivity/error-view]]))
|
||||||
|
|
Loading…
Reference in New Issue