Skip to content

Commit

Permalink
refactored mute chat drawer
Browse files Browse the repository at this point in the history
  • Loading branch information
jo-mut committed May 15, 2023
1 parent dc63c15 commit c95c0cf
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 94 deletions.
Binary file modified resources/images/icons2/20x20/muted@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/images/icons2/20x20/muted@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 8 additions & 7 deletions src/status_im2/common/bottom_sheet/styles.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@

(defn selected-item
[override-theme]
{:position :absolute
:bottom 10
:left 0
:right 0
:border-radius 12
:margin-horizontal 8
:background-color (colors/theme-colors colors/white colors/neutral-90 override-theme)})
{:position :absolute
:bottom 10
:left 0
:right 0
:border-radius 12
:margin-horizontal 8
:padding-horizontal 12
:background-color (colors/theme-colors colors/white colors/neutral-90 override-theme)})
65 changes: 0 additions & 65 deletions src/status_im2/common/mute_chat_drawer/view.cljs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns status-im2.common.mute-chat-drawer.style
(ns status-im2.common.mute-drawer.style
(:require [quo2.foundations.colors :as colors]))

(defn header-text
Expand Down
90 changes: 90 additions & 0 deletions src/status_im2/common/mute_drawer/view.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
(ns status-im2.common.mute-drawer.view
(:require [utils.i18n :as i18n]
[quo2.core :as quo]
[react-native.core :as rn]
[status-im2.constants :as constants]
[utils.re-frame :as rf]
[status-im2.common.mute-drawer.style :as style]))

(defn mute-chat
[id]
(rf/dispatch [:chat.ui/mute id]))

(defn mute-community
[id muted?]
(rf/dispatch [:community/set-muted id (not muted?)]))

(defn hide-sheet-and-dispatch
[{:keys [chat-id community-id muted? type]}]
(rf/dispatch [:hide-bottom-sheet])
(if (= type :community)
(mute-community community-id muted?)
(mute-chat chat-id)))

(defn mute-drawer
[{:keys [chat-id community-id accessibility-label type]}]
[rn/view {:accessibility-label accessibility-label}
[quo/text
{:weight :medium
:size :paragraph-2
:style (style/header-text)} (i18n/label (if community-id :t/mute-community :t/mute-channel))]
[quo/menu-item
{:type :transparent
:title (i18n/label :t/mute-for-15-mins)
:icon-bg-color :transparent
:container-padding-vertical 12
:title-column-style {:margin-left 2}
:on-press (fn []
(hide-sheet-and-dispatch
{:chat-id chat-id
:type type
:community-id community-id
:duration constants/mute-for-15-mins-type}))}]
[quo/menu-item
{:type :transparent
:title (i18n/label :t/mute-for-1-hour)
:icon-bg-color :transparent
:container-padding-vertical 12
:title-column-style {:margin-left 2}
:on-press (fn []
(hide-sheet-and-dispatch
{:chat-id chat-id
:type type
:community-id community-id
:duration constants/mute-for-1-hour-type}))}]
[quo/menu-item
{:type :transparent
:title (i18n/label :t/mute-for-8-hours)
:icon-bg-color :transparent
:container-padding-vertical 12
:title-column-style {:margin-left 2}
:on-press (fn []
(hide-sheet-and-dispatch
{:chat-id chat-id
:type type
:community-id community-id
:duration constants/mute-for-8-hours-type}))}]
[quo/menu-item
{:type :transparent
:title (i18n/label :t/mute-for-1-week)
:icon-bg-color :transparent
:container-padding-vertical 12
:title-column-style {:margin-left 2}
:on-press (fn []
(hide-sheet-and-dispatch
{:chat-id chat-id
:type type
:community-id community-id
:duration constants/mute-for-1-week}))}]
[quo/menu-item
{:type :transparent
:title (i18n/label :t/mute-till-unmute)
:icon-bg-color :transparent
:container-padding-vertical 12
:title-column-style {:margin-left 2}
:on-press (fn []
(hide-sheet-and-dispatch
{:chat-id chat-id
:type type
:community-id community-id
:duration constants/mute-till-unmuted}))}]])
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,33 @@
[utils.re-frame :as rf]
[quo2.core :as quo]
[status-im2.contexts.communities.actions.see-rules.view :as see-rules]
[status-im2.contexts.communities.actions.leave.view :as leave-menu]))
[status-im2.contexts.communities.actions.leave.view :as leave-menu]
[status-im2.common.mute-drawer.view :as mute-options]))

(defn hide-sheet-and-dispatch
[event]
(rf/dispatch [:hide-bottom-sheet])
(rf/dispatch event))

(defn muted-duration
[duration]
(cond
(= duration 15)
(str "Muted for " duration "minutes")

(= duration 1)
(str "Muted for " duration "hour")

(= duration 8)
(str "Muted for " duration "hours")

(= duration 7)
(str "Muted for " duration "days")

:else
;; (jo-mut) update with "Until you turn it back on"
""))

(defn view-members
[id]
{:icon :i/members
Expand Down Expand Up @@ -43,12 +63,21 @@
:on-press #(hide-sheet-and-dispatch [:chat.ui/mark-all-read-in-community-pressed id])})

(defn mute-community
[id muted?]
[id muted? duration]
{:icon (if muted? :i/muted :i/activity-center)
:accessibility-label (if muted? :unmute-community :mute-community)
:label (i18n/label (if muted? :t/unmute-community :t/mute-community))
:sub-label (when muted? (muted-duration duration))
:right-icon :i/chevron-right
:on-press #(hide-sheet-and-dispatch [:community/set-muted id (not muted?)])})
:on-press (if muted?
#(hide-sheet-and-dispatch [:community/set-muted id (not muted?)])
#(hide-sheet-and-dispatch
[:show-bottom-sheet
{:content (fn []
[mute-options/mute-drawer
{:community-id id
:type :community
:accessibility-label :mute-community-title}])}]))})

(defn community-notification-settings
[id]
Expand Down Expand Up @@ -125,26 +154,26 @@
(not-joined-options id token-gated?))

(defn joined-options
[id token-gated? muted?]
[id token-gated? muted? duration]
[[(view-members id)
(view-rules id)
(when token-gated? (view-token-gating id))
(mark-as-read id)
(mute-community id muted?)
(mute-community id muted? duration)
(community-notification-settings id)
(invite-contacts id)
(show-qr id)
(share-community id)]
[(assoc (leave-community id) :add-divider? true)]])

(defn owner-options
[id token-gated? muted?]
[id token-gated? muted? duration]
[[(view-members id)
(view-rules id)
(when token-gated? (view-token-gating id))
(edit-community id)
(mark-as-read id)
(mute-community id muted?)
(mute-community id muted? duration)
(community-notification-settings id)
(invite-contacts id)
(show-qr id)
Expand All @@ -153,11 +182,11 @@
(defn get-context-drawers
[{:keys [id]}]
(let [{:keys [token-gated? admin joined
muted banList]} (rf/sub [:communities/community id])
request-id (rf/sub [:communities/my-pending-request-to-join id])]
muted duration banList]} (rf/sub [:communities/community id])
request-id (rf/sub [:communities/my-pending-request-to-join id])]
(cond
admin (owner-options id token-gated? muted)
joined (joined-options id token-gated? muted)
admin (owner-options id token-gated? muted duration)
joined (joined-options id token-gated? muted duration)
request-id (join-request-sent-options id token-gated? request-id)
banList (banned-options id token-gated?)
:else (not-joined-options id token-gated?))))
Expand Down
36 changes: 26 additions & 10 deletions src/status_im2/contexts/communities/overview/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,30 @@
[category (update v :chats add-on-press)])
categorized-chats)))

(defn muted-status
[muted? icon-color]
(when muted?
[quo/icon :i/muted
{:container-style {:align-items :center
:margin-left 6
:justify-content :center}
:resize-mode :center
:size 20
:color icon-color}]))

(defn community-header
[name]
[quo/text
{:accessibility-label :chat-name-text
:number-of-lines 1
:ellipsize-mode :tail
:weight :semi-bold
:size :heading-1}
name])
[name muted? icon-color]
[rn/view
{:flex-direction :row
:align-items :center}
[quo/text
{:accessibility-label :chat-name-text
:number-of-lines 1
:ellipsize-mode :tail
:weight :semi-bold
:size :heading-1}
name]
[muted-status muted? icon-color]])

(defn community-description
[description]
Expand All @@ -231,7 +246,8 @@
(let [thumbnail-image (:thumbnail images)
chats-by-category (rf/sub [:communities/categorized-channels id])
users (rf/sub [:communities/users id])
community-muted? muted]
community-muted? muted
icon-color (colors/theme-colors colors/neutral-50 colors/neutral-40)]
[rn/view
[rn/view {:padding-horizontal 20}
(when (and (not joined)
Expand Down Expand Up @@ -260,7 +276,7 @@
:right 12}
[get-tag joined]])
[rn/view {:margin-top 56}
[community-header name]]
[community-header name community-muted? icon-color]]
[community-description description]
[quo/community-stats-column :card-view]
[rn/view {:margin-top 12}]
Expand Down

0 comments on commit c95c0cf

Please sign in to comment.