Skip to content

Commit

Permalink
[#16094] Messaging - In Chat - Implement Options Menu for 1-1 and com…
Browse files Browse the repository at this point in the history
…munties
  • Loading branch information
flexsurfer committed Jun 2, 2023
1 parent 98bdce2 commit 4c87ac6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 deletions.
29 changes: 16 additions & 13 deletions src/status_im2/common/home/actions/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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 []
Expand All @@ -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]
Expand All @@ -94,10 +97,10 @@
:context item
:accessibility-label :leave-group
:button-text (i18n/label :t/leave-group)
:on-press #(do
(rf/dispatch [:navigate-back])
(hide-sheet-and-dispatch [:group-chats.ui/leave-chat-confirmed
chat-id]))}])}]))
:on-press (fn []
(hide-sheet-and-dispatch [:group-chats.ui/leave-chat-confirmed
chat-id])
(rf/dispatch [:navigate-back]))}])}]))

(defn block-user-action
[{:keys [public-key] :as item}]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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?]
Expand Down Expand Up @@ -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}]
Expand Down Expand Up @@ -471,4 +474,4 @@
[quo/action-drawer
[(when admin? [(edit-name-image-entry)])
[(notifications-entry admin?)]
(destructive-actions group)]]))
(destructive-actions group false)]]))
21 changes: 14 additions & 7 deletions src/status_im2/contexts/chat/messages/navigation/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down Expand Up @@ -90,11 +92,16 @@
:size :paragraph-2
:style (style/header-online)}
(i18n/label :t/online)])]]]
[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)}]]]
(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
: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)}
Expand Down
1 change: 0 additions & 1 deletion src/status_im2/contexts/chat/messages/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
[status-im2.contexts.chat.messages.list.view :as messages.list]
[status-im2.contexts.chat.messages.navigation.view :as messages.navigation]
[status-im2.navigation.state :as navigation.state]
[utils.debounce :as debounce]
[utils.re-frame :as rf]))

(defn navigate-back-handler
Expand Down

0 comments on commit 4c87ac6

Please sign in to comment.