[#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])}])}]))
(defn delete-chat-action
[{:keys [chat-id] :as item}]
[{:keys [chat-id] :as item} inside-chat?]
(hide-sheet-and-dispatch
[:show-bottom-sheet
{:content (fn []
@ -81,7 +81,10 @@
:context item
:accessibility-label :delete-chat-confirm
: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
[item chat-id]
@ -94,10 +97,10 @@
:context item
:accessibility-label :leave-group
:button-text (i18n/label :t/leave-group)
:on-press #(do
(rf/dispatch [:navigate-back])
:on-press (fn []
(hide-sheet-and-dispatch [:group-chats.ui/leave-chat-confirmed
chat-id]))}])}]))
chat-id])
(rf/dispatch [:navigate-back]))}])}]))
(defn block-user-action
[{:keys [public-key] :as item}]
@ -152,10 +155,10 @@
:add-divider? true}))
(defn delete-chat-entry
[item]
[item inside-chat?]
(entry {:icon :i/delete
:label (i18n/label :t/delete-chat)
:on-press #(delete-chat-action item)
:on-press #(delete-chat-action item inside-chat?)
:danger? true
:accessibility-label :delete-chat
:sub-label nil
@ -393,11 +396,11 @@
:chevron? false}))
(defn destructive-actions
[{:keys [group-chat] :as item}]
[{:keys [group-chat] :as item} inside-chat?]
[(clear-history-entry item)
(if group-chat
(leave-group-entry item nil)
(delete-chat-entry item))])
(delete-chat-entry item inside-chat?))])
(defn notification-actions
[{:keys [chat-id group-chat public?]} inside-chat?]
@ -431,14 +434,14 @@
[[(view-profile-entry chat-id)
(edit-nickname-entry chat-id)]
(notification-actions item inside-chat?)
(destructive-actions item)]])
(destructive-actions item inside-chat?)]])
(defn private-group-chat-actions
[item inside-chat?]
[quo/action-drawer
[(group-actions item inside-chat?)
(notification-actions item inside-chat?)
(destructive-actions item)]])
(destructive-actions item inside-chat?)]])
(defn contact-actions
[{:keys [public-key] :as contact} {:keys [chat-id admin?] :as extra-data}]
@ -471,4 +474,4 @@
[quo/action-drawer
[(when admin? [(edit-name-image-entry)])
[(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.constants :as constants]
[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
[{:keys [scroll-y]}]
(let [insets (safe-area/get-insets)
status-bar-height (:top insets)
{: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])
display-name (if (= chat-type constants/one-to-one-chat-type)
(first (rf/sub [:contacts/contact-two-names-by-identity chat-id]))
@ -90,11 +92,16 @@
:size :paragraph-2
:style (style/header-online)}
(i18n/label :t/online)])]]]
(when (not= chat-type constants/community-chat-type)
[rn/touchable-opacity
{:active-opacity 1
:style (style/button-container {:margin-right 20})
:accessibility-label :options-button}
[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
{:style (style/animated-pinned-banner all-loaded? banner-opacity-animation status-bar-height)}