[#16094] Messaging - In Chat - Implement Options Menu for 1-1 and com… (#16131)

This commit is contained in:
flexsurfer 2023-06-05 10:25:13 +02:00 committed by GitHub
parent eea737625d
commit ba2f037f48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 20 deletions

View File

@ -71,7 +71,7 @@
:on-press #(hide-sheet-and-dispatch [:chat.ui/clear-history chat-id])}])}])) :on-press #(hide-sheet-and-dispatch [:chat.ui/clear-history chat-id])}])}]))
(defn delete-chat-action (defn delete-chat-action
[{:keys [chat-id] :as item}] [{:keys [chat-id] :as item} inside-chat?]
(hide-sheet-and-dispatch (hide-sheet-and-dispatch
[:show-bottom-sheet [:show-bottom-sheet
{:content (fn [] {:content (fn []
@ -81,7 +81,10 @@
:context item :context item
:accessibility-label :delete-chat-confirm :accessibility-label :delete-chat-confirm
:button-text (i18n/label :t/delete-chat) :button-text (i18n/label :t/delete-chat)
:on-press #(hide-sheet-and-dispatch [:chat.ui/remove-chat chat-id])}])}])) :on-press (fn []
(hide-sheet-and-dispatch [:chat.ui/remove-chat chat-id])
(when inside-chat?
(rf/dispatch [:navigate-back])))}])}]))
(defn leave-group-action (defn leave-group-action
[item chat-id] [item chat-id]
@ -94,10 +97,10 @@
:context item :context item
:accessibility-label :leave-group :accessibility-label :leave-group
:button-text (i18n/label :t/leave-group) :button-text (i18n/label :t/leave-group)
:on-press #(do :on-press (fn []
(rf/dispatch [:navigate-back]) (hide-sheet-and-dispatch [:group-chats.ui/leave-chat-confirmed
(hide-sheet-and-dispatch [:group-chats.ui/leave-chat-confirmed chat-id])
chat-id]))}])}])) (rf/dispatch [:navigate-back]))}])}]))
(defn block-user-action (defn block-user-action
[{:keys [public-key] :as item}] [{:keys [public-key] :as item}]
@ -152,10 +155,10 @@
:add-divider? true})) :add-divider? true}))
(defn delete-chat-entry (defn delete-chat-entry
[item] [item inside-chat?]
(entry {:icon :i/delete (entry {:icon :i/delete
:label (i18n/label :t/delete-chat) :label (i18n/label :t/delete-chat)
:on-press #(delete-chat-action item) :on-press #(delete-chat-action item inside-chat?)
:danger? true :danger? true
:accessibility-label :delete-chat :accessibility-label :delete-chat
:sub-label nil :sub-label nil
@ -393,11 +396,11 @@
:chevron? false})) :chevron? false}))
(defn destructive-actions (defn destructive-actions
[{:keys [group-chat] :as item}] [{:keys [group-chat] :as item} inside-chat?]
[(clear-history-entry item) [(clear-history-entry item)
(if group-chat (if group-chat
(leave-group-entry item nil) (leave-group-entry item nil)
(delete-chat-entry item))]) (delete-chat-entry item inside-chat?))])
(defn notification-actions (defn notification-actions
[{:keys [chat-id group-chat public?]} inside-chat?] [{:keys [chat-id group-chat public?]} inside-chat?]
@ -431,14 +434,14 @@
[[(view-profile-entry chat-id) [[(view-profile-entry chat-id)
(edit-nickname-entry chat-id)] (edit-nickname-entry chat-id)]
(notification-actions item inside-chat?) (notification-actions item inside-chat?)
(destructive-actions item)]]) (destructive-actions item inside-chat?)]])
(defn private-group-chat-actions (defn private-group-chat-actions
[item inside-chat?] [item inside-chat?]
[quo/action-drawer [quo/action-drawer
[(group-actions item inside-chat?) [(group-actions item inside-chat?)
(notification-actions item inside-chat?) (notification-actions item inside-chat?)
(destructive-actions item)]]) (destructive-actions item inside-chat?)]])
(defn contact-actions (defn contact-actions
[{:keys [public-key] :as contact} {:keys [chat-id admin?] :as extra-data}] [{:keys [public-key] :as contact} {:keys [chat-id admin?] :as extra-data}]
@ -471,4 +474,4 @@
[quo/action-drawer [quo/action-drawer
[(when admin? [(edit-name-image-entry)]) [(when admin? [(edit-name-image-entry)])
[(notifications-entry admin?)] [(notifications-entry admin?)]
(destructive-actions group)]])) (destructive-actions group false)]]))

View File

@ -9,14 +9,16 @@
[status-im2.contexts.chat.messages.pin.banner.view :as pin.banner] [status-im2.contexts.chat.messages.pin.banner.view :as pin.banner]
[status-im2.constants :as constants] [status-im2.constants :as constants]
[utils.re-frame :as rf] [utils.re-frame :as rf]
[utils.i18n :as i18n])) [utils.i18n :as i18n]
[status-im2.common.home.actions.view :as actions]))
(defn f-navigation-view (defn f-navigation-view
[{:keys [scroll-y]}] [{:keys [scroll-y]}]
(let [insets (safe-area/get-insets) (let [insets (safe-area/get-insets)
status-bar-height (:top insets) status-bar-height (:top insets)
{:keys [group-chat chat-id chat-name emoji {:keys [group-chat chat-id chat-name emoji
chat-type]} (rf/sub [:chats/current-chat-chat-view]) chat-type]
:as chat} (rf/sub [:chats/current-chat-chat-view])
all-loaded? (rf/sub [:chats/all-loaded? chat-id]) all-loaded? (rf/sub [:chats/all-loaded? chat-id])
display-name (if (= chat-type constants/one-to-one-chat-type) display-name (if (= chat-type constants/one-to-one-chat-type)
(first (rf/sub [:contacts/contact-two-names-by-identity chat-id])) (first (rf/sub [:contacts/contact-two-names-by-identity chat-id]))
@ -90,11 +92,16 @@
:size :paragraph-2 :size :paragraph-2
:style (style/header-online)} :style (style/header-online)}
(i18n/label :t/online)])]]] (i18n/label :t/online)])]]]
[rn/touchable-opacity (when (not= chat-type constants/community-chat-type)
{:active-opacity 1 [rn/touchable-opacity
:style (style/button-container {:margin-right 20}) {:active-opacity 1
:accessibility-label :options-button} :style (style/button-container {:margin-right 20})
[quo/icon :i/options {:size 20 :color (colors/theme-colors colors/black colors/white)}]]] :accessibility-label :options-button
:on-press (fn []
(rf/dispatch [:dismiss-keyboard])
(rf/dispatch [:show-bottom-sheet
{:content (fn [] [actions/chat-actions chat true])}]))}
[quo/icon :i/options {:size 20 :color (colors/theme-colors colors/black colors/white)}]])]
[reanimated/view [reanimated/view
{:style (style/animated-pinned-banner all-loaded? banner-opacity-animation status-bar-height)} {:style (style/animated-pinned-banner all-loaded? banner-opacity-animation status-bar-height)}