Skip to content

Commit a52bc11

Browse files
authored
updated community rules to display the actual rules
* updated community rules to display the actual rules * updated scroll behaviours on community rules inside the bottom sheet * added standard rules for communities without rules * fix android scroll issues
1 parent 354cda3 commit a52bc11

File tree

5 files changed

+84
-45
lines changed

5 files changed

+84
-45
lines changed

src/status_im/contexts/communities/actions/community_options/view.cljs

+20-19
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
{:community-id id}])})
2626

2727
(defn view-rules
28-
[id]
28+
[id intro-message]
2929
{:icon :i/bullet-list
3030
:right-icon :i/chevron-right
3131
:accessibility-label :view-community-rules
3232
:on-press #(rf/dispatch [:show-bottom-sheet
33-
{:content (fn [] [see-rules/view id])}])
33+
{:content (fn [] [see-rules/view id intro-message])}])
3434
:label (i18n/label :t/view-community-rules)})
3535

3636
(defn view-token-gating
@@ -131,9 +131,9 @@
131131
request-id])}])})
132132

133133
(defn not-joined-options
134-
[id token-gated? pending?]
134+
[id token-gated? pending? intro-message]
135135
[[(when-not token-gated? (view-members id))
136-
(when-not token-gated? (view-rules id))
136+
(when-not token-gated? (view-rules id intro-message))
137137
(invite-contacts id)
138138
(when token-gated? (view-token-gating id))
139139
(when (and pending? (ff/enabled? ::ff/community.edit-account-selection))
@@ -142,19 +142,19 @@
142142
(share-community id)]])
143143

144144
(defn join-request-sent-options
145-
[id token-gated? request-id]
146-
[(conj (first (not-joined-options id token-gated? request-id))
145+
[id token-gated? request-id intro-message]
146+
[(conj (first (not-joined-options id token-gated? request-id intro-message))
147147
(assoc (cancel-request-to-join id request-id) :add-divider? true))])
148148

149149
(defn banned-options
150-
[id token-gated?]
150+
[id token-gated? intro-message]
151151
(let [pending? false]
152-
(not-joined-options id token-gated? pending?)))
152+
(not-joined-options id token-gated? pending? intro-message)))
153153

154154
(defn joined-options
155-
[id token-gated? muted? muted-till color]
155+
[id token-gated? muted? muted-till color intro-message]
156156
[[(view-members id)
157-
(view-rules id)
157+
(view-rules id intro-message)
158158
(when token-gated? (view-token-gating id))
159159
(when (ff/enabled? ::ff/community.edit-account-selection)
160160
(edit-shared-addresses id))
@@ -167,9 +167,9 @@
167167
[(assoc (leave-community id color) :add-divider? true)]])
168168

169169
(defn owner-options
170-
[id token-gated? muted? muted-till]
170+
[id token-gated? muted? muted-till intro-message]
171171
[[(view-members id)
172-
(view-rules id)
172+
(view-rules id intro-message)
173173
(when token-gated? (view-token-gating id))
174174
(mark-as-read id)
175175
(mute-community id muted? muted-till)
@@ -181,14 +181,15 @@
181181
(defn get-context-drawers
182182
[{:keys [id]}]
183183
(let [{:keys [token-permissions admin joined
184-
muted banList muted-till color]} (rf/sub [:communities/community id])
185-
request-id (rf/sub [:communities/my-pending-request-to-join id])]
184+
muted banList muted-till color
185+
intro-message]} (rf/sub [:communities/community id])
186+
request-id (rf/sub [:communities/my-pending-request-to-join id])]
186187
(cond
187-
admin (owner-options id token-permissions muted muted-till)
188-
joined (joined-options id token-permissions muted muted-till color)
189-
request-id (join-request-sent-options id token-permissions request-id)
190-
banList (banned-options id token-permissions)
191-
:else (not-joined-options id token-permissions request-id))))
188+
admin (owner-options id token-permissions muted muted-till intro-message)
189+
joined (joined-options id token-permissions muted muted-till color intro-message)
190+
request-id (join-request-sent-options id token-permissions request-id intro-message)
191+
banList (banned-options id token-permissions intro-message)
192+
:else (not-joined-options id token-permissions request-id intro-message))))
192193

193194
(defn community-options-bottom-sheet
194195
[id]

src/status_im/contexts/communities/actions/community_rules_list/style.cljs

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
(def community-rule
44
{:flex-direction :row
55
:flex 1
6-
:align-items :flex-start
7-
:margin-top 16})
6+
:align-items :flex-start})
87

98
(def community-rule-index
109
{:margin-left 4})
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
(ns status-im.contexts.communities.actions.generic-menu.style)
22

3-
(def container
4-
{:flex 1
5-
:margin-left 20
6-
:margin-right 20
7-
:margin-bottom 20})
3+
(defn container
4+
[max-height]
5+
{:flex 1
6+
:max-height max-height
7+
:margin-left 20
8+
:margin-right 20})
9+
10+
(defn scroll-view-style
11+
[max-height]
12+
{:margin-bottom 12
13+
:max-height max-height})
814

915
(def inner-container
1016
{:display :flex
@@ -14,4 +20,4 @@
1420

1521
(def community-tag
1622
{:margin-right :auto
17-
:margin-top 8})
23+
:margin-top 4})
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,49 @@
11
(ns status-im.contexts.communities.actions.generic-menu.view
22
(:require
3+
[oops.core :as oops]
34
[quo.core :as quo]
45
[react-native.core :as rn]
6+
[react-native.gesture :as gesture]
7+
[react-native.safe-area :as safe-area]
58
[status-im.contexts.communities.actions.generic-menu.style :as style]
69
[utils.re-frame :as rf]))
710

811
(defn view
912
[{:keys [id title]} children]
10-
(let [{:keys [name images]} (rf/sub [:communities/community id])]
11-
[rn/view {:style style/container}
12-
[rn/view {:style style/inner-container}
13-
[quo/text
14-
{:accessibility-label :communities-join-community
15-
:weight :semi-bold
16-
:size :heading-2}
17-
title]]
18-
[rn/view {:style style/community-tag}
19-
[quo/context-tag
20-
{:type :community
21-
:size 24
22-
:community-logo (:thumbnail images)
23-
:community-name name}]]
24-
children]))
13+
(let [{:keys [name images]} (rf/sub [:communities/community id])
14+
[content-height set-content-height] (rn/use-state 0)
15+
[sheet-header-height set-header-height] (rn/use-state 0)
16+
insets (safe-area/get-insets)
17+
{window-height :height} (rn/get-window)
18+
sheet-max-height (- window-height (:top insets))
19+
max-height (- sheet-max-height sheet-header-height)]
20+
[rn/view {:style (style/container max-height)}
21+
[rn/view
22+
{:style {:padding-bottom 12}
23+
:on-layout (fn [event]
24+
(set-header-height (oops/oget
25+
event
26+
"nativeEvent.layout.height")))}
27+
[rn/view {:style style/inner-container}
28+
[quo/text
29+
{:accessibility-label :communities-join-community
30+
:weight :semi-bold
31+
:size :heading-2}
32+
title]]
33+
[rn/view {:style style/community-tag}
34+
[quo/context-tag
35+
{:type :community
36+
:size 24
37+
:community-logo (:thumbnail images)
38+
:community-name name}]]]
39+
[gesture/scroll-view
40+
{:scroll-enabled (> content-height max-height)
41+
:scroll-event-throttle 16
42+
:style (style/scroll-view-style max-height)
43+
:shows-vertical-scroll-indicator false}
44+
[rn/view
45+
{:on-layout (fn [event]
46+
(set-content-height (oops/oget
47+
event
48+
"nativeEvent.layout.height")))}
49+
children]]]))
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
(ns status-im.contexts.communities.actions.see-rules.view
22
(:require
3+
[quo.core :as quo]
4+
[react-native.core :as rn]
35
[status-im.contexts.communities.actions.community-rules-list.view :as community-rules]
46
[status-im.contexts.communities.actions.generic-menu.view :as generic-menu]
57
[utils.i18n :as i18n]))
68

79
(defn view
8-
[id]
10+
[id intro-message]
911
[generic-menu/view
1012
{:id id
1113
:title (i18n/label :t/community-rules)}
12-
13-
[community-rules/view community-rules/standard-rules]])
14+
[rn/view {:style {:padding-top 8}}
15+
(if (empty? intro-message)
16+
[community-rules/view community-rules/standard-rules]
17+
[quo/text
18+
{:accessibility-label :communities-rules
19+
:weight :regular
20+
:size :paragraph-2}
21+
intro-message])]])

0 commit comments

Comments
 (0)