feat: add ability to join open community in new-ui (#14001)
This commit is contained in:
parent
5a55c6ccb2
commit
6992b625d6
|
@ -47,15 +47,17 @@
|
|||
:size :paragraph-2}
|
||||
(trim-public-key public-key)]]))
|
||||
|
||||
(defn user-avatar-tag []
|
||||
(fn [params username photo]
|
||||
(defn context-tag [params photo name]
|
||||
[base-tag (assoc-in params [:style :padding-left] 3)
|
||||
[rn/image {:style {:width 20
|
||||
:border-radius 10
|
||||
:background-color :white
|
||||
:height 20}
|
||||
:source {:uri photo}}]
|
||||
:source photo}]
|
||||
[text/text {:weight :medium
|
||||
:size :paragraph-2}
|
||||
(str " " name)]])
|
||||
|
||||
(str " " username)]]))
|
||||
(defn user-avatar-tag []
|
||||
(fn [params username photo]
|
||||
[context-tag params {:uri photo} username]))
|
||||
|
|
|
@ -28,9 +28,10 @@
|
|||
(def view-type (reagent/atom :card-view))
|
||||
(def sort-list-by (reagent/atom :name))
|
||||
|
||||
(def mock-community-item-data ;; TO Do remove once communities are loaded with this data.
|
||||
(def mock-community-item-data ;; TODO: remove once communities are loaded with this data.
|
||||
{:data {:status :gated
|
||||
:locked true
|
||||
:images {:thumbnail {:uri (resources/get-image :status-logo)}}
|
||||
:cover (resources/get-image :community-cover)
|
||||
:tokens [{:id 1 :group [{:id 1 :token-icon (resources/get-image :status-logo)}]}]
|
||||
:tags [{:id 1 :tag-label (i18n/label :t/music) :resource (resources/get-image :music)}
|
||||
|
@ -59,9 +60,6 @@
|
|||
{:featured true})]
|
||||
[community-card/community-card-view-item item #(>evt [:navigate-to :community-overview item])]))
|
||||
|
||||
(defn community-list-key-fn [item]
|
||||
(:id item))
|
||||
|
||||
(defn get-item-layout-js [_ index]
|
||||
#js {:length 64 :offset (* 64 index) :index index})
|
||||
|
||||
|
@ -77,9 +75,12 @@
|
|||
[quo2.tabs/tabs {:size 32
|
||||
:on-change #(reset! selected-tab %)
|
||||
:default-active :all
|
||||
:data [{:id :all :label (i18n/label :t/all)}
|
||||
{:id :open :label (i18n/label :t/open)}
|
||||
{:id :gated :label (i18n/label :t/gated)}]}]]
|
||||
:data [{:id :all
|
||||
:label (i18n/label :t/all)}
|
||||
{:id :open
|
||||
:label (i18n/label :t/open)}
|
||||
{:id :gated
|
||||
:label (i18n/label :t/gated)}]}]]
|
||||
[react/view {:flex-direction :row}
|
||||
[quo2.button/button
|
||||
{:icon true
|
||||
|
@ -101,7 +102,7 @@
|
|||
|
||||
(defn featured-communities [communities]
|
||||
[list/flat-list
|
||||
{:key-fn str
|
||||
{:key-fn :id
|
||||
:horizontal true
|
||||
:getItemLayout get-item-layout-js
|
||||
:keyboard-should-persist-taps :always
|
||||
|
@ -112,7 +113,7 @@
|
|||
(defn other-communities [communities sort-list-by]
|
||||
(let [sorted-communities (sort-by sort-list-by communities)]
|
||||
[list/flat-list
|
||||
{:key-fn str
|
||||
{:key-fn :id
|
||||
:getItemLayout get-item-layout-js
|
||||
:keyboard-should-persist-taps :always
|
||||
:shows-horizontal-scroll-indicator false
|
||||
|
@ -206,7 +207,7 @@
|
|||
(let [multiaccount (<sub [:multiaccount])
|
||||
communities (<sub [:communities/communities])
|
||||
featured-communities (<sub [:communities/featured-communities])]
|
||||
(fn []
|
||||
|
||||
[safe-area/consumer
|
||||
(fn [insets]
|
||||
[react/view {:style {:flex 1
|
||||
|
@ -236,4 +237,4 @@
|
|||
:padding-horizontal 20}
|
||||
[separator/separator]]
|
||||
[community-segments]])
|
||||
[community-segments-view communities]]])])))
|
||||
[community-segments-view communities]]])]))
|
|
@ -4,7 +4,8 @@
|
|||
[quo2.components.markdown.text :as quo2.text]
|
||||
[quo2.components.buttons.button :as quo2.button]
|
||||
[quo2.components.community.community-view :as community-view]
|
||||
[status-im.utils.handlers :refer [<sub]]
|
||||
[status-im.ui.screens.communities.request-to-join-bottom-sheet-redesign :as request-to-join]
|
||||
[status-im.utils.handlers :refer [<sub >evt]]
|
||||
[status-im.ui.screens.communities.styles :as styles]
|
||||
[status-im.ui.screens.communities.icon :as communities.icon]))
|
||||
|
||||
|
@ -22,7 +23,7 @@
|
|||
:size :label}
|
||||
"placeholder for channel list component"]])
|
||||
|
||||
(defn community-card-page-view [{:keys [name description locked
|
||||
(defn community-card-page-view [{:keys [name description locked joined
|
||||
status tokens cover tags] :as community}]
|
||||
[react/view
|
||||
{:style
|
||||
|
@ -49,14 +50,18 @@
|
|||
[community-view/community-stats-column :card-view]
|
||||
[community-view/community-tags tags]
|
||||
[preview-list-component]
|
||||
(when (not joined)
|
||||
[quo2.button/button
|
||||
{:style
|
||||
{:on-press #(>evt [:bottom-sheet/show-sheet
|
||||
{:content (fn [] [request-to-join/request-to-join community])
|
||||
:content-height 300}])
|
||||
:style
|
||||
{:width "100%"
|
||||
:margin-top 20
|
||||
:margin-left :auto
|
||||
:margin-right :auto}
|
||||
:before :main-icons/community}
|
||||
(i18n/label :join-open-community)]
|
||||
(i18n/label :join-open-community)])
|
||||
[channel-list-component]]])
|
||||
|
||||
(defn overview []
|
||||
|
|
|
@ -0,0 +1,139 @@
|
|||
(ns status-im.ui.screens.communities.request-to-join-bottom-sheet-redesign
|
||||
(:require [status-im.i18n.i18n :as i18n]
|
||||
[quo.core :as quo]
|
||||
[reagent.core :as reagent]
|
||||
[status-im.ui.components.list.views :as list]
|
||||
[status-im.ui.components.react :as react]
|
||||
[quo2.components.markdown.text :as quo2.text]
|
||||
[quo2.components.buttons.button :as quo2.button]
|
||||
[quo2.components.icon :as quo2.icon]
|
||||
[status-im.utils.handlers :refer [>evt]]
|
||||
[quo2.components.tags.context-tags :as quo2.context-tags]
|
||||
[status-im.communities.core :as communities]
|
||||
[quo2.foundations.colors :as quo2.colors]))
|
||||
|
||||
;; TODO: update with real data
|
||||
(def community-rules [{:index 1
|
||||
:title "Be respectful"
|
||||
:content "You must respect all users, regardless of your liking towards them. Treat others the way you want to be treated."}
|
||||
{:index 2
|
||||
:title "No Inappropriate Language"
|
||||
:content "The use of profanity should be kept to a minimum. However, any derogatory language towards any user is prohibited."}
|
||||
{:index 3
|
||||
:title "No spamming"
|
||||
:content "Don't send a lot of small messages right after each other. Do not disrupt chat by spamming."}
|
||||
{:index 4
|
||||
:title "No pornographic, adult or NSFW material"
|
||||
:content "This is a community server and not meant to share this kind of material."}
|
||||
{:index 5
|
||||
:title "No advertisements"
|
||||
:content "We do not tolerate any kind of advertisements, whether it be for other communities or streams."}
|
||||
{:index 6
|
||||
:title "No offensive names and profile pictures"
|
||||
:content "You will be asked to change your name or picture if the staff deems them inappropriate."}])
|
||||
|
||||
(defn community-rule-item [{:keys [title content index]}]
|
||||
[react/view
|
||||
{:style {:flex 1 :margin-top 16}}
|
||||
[react/view
|
||||
{:style
|
||||
{:flex 1
|
||||
:flex-direction :row
|
||||
:align-items :center}}
|
||||
[react/view
|
||||
{:style
|
||||
{:height 18
|
||||
:width 18
|
||||
:margin-left 1
|
||||
:margin-right 9
|
||||
:background-color quo2.colors/white
|
||||
:border-color quo2.colors/neutral-20
|
||||
:border-width 1
|
||||
:border-radius 6}}
|
||||
[quo2.text/text {:style
|
||||
{:margin-left :auto
|
||||
:margin-right :auto
|
||||
:margin-top :auto
|
||||
:margin-bottom :auto}
|
||||
:accessibility-label :communities-rule-index
|
||||
:weight :medium
|
||||
:size :label}
|
||||
|
||||
(str index)]]
|
||||
[quo2.text/text
|
||||
{:accessibility-label :communities-rule-title
|
||||
:weight :semi-bold
|
||||
:size :paragraph-2}
|
||||
title]]
|
||||
[quo2.text/text
|
||||
{:style {:margin-left 28}
|
||||
:accessibility-label :communities-rule-content
|
||||
:size :paragraph-2}
|
||||
content]])
|
||||
|
||||
(defn community-rules-list [rules]
|
||||
|
||||
[list/flat-list
|
||||
{:shows-horizontal-scroll-indicator false
|
||||
:data rules
|
||||
:render-fn community-rule-item}])
|
||||
|
||||
(defn rules-checkbox [agreed-to-rules?]
|
||||
[react/view {:style
|
||||
{:flex 1
|
||||
:flex-direction :row
|
||||
:margin-top 20
|
||||
:background-color quo2.colors/neutral-20
|
||||
:padding 12
|
||||
:border-radius 12
|
||||
:border-width 1
|
||||
:border-color quo2.colors/neutral-30}}
|
||||
[quo/checkbox {:value @agreed-to-rules?
|
||||
:on-change #(swap! agreed-to-rules? not)}]
|
||||
[quo2.text/text {:accessibility-label :communities-accept-rules
|
||||
:size :paragraph-2
|
||||
:style {:margin-left 8}}
|
||||
(i18n/label :t/accept-community-rules)]])
|
||||
|
||||
(defn request-to-join [community]
|
||||
(let [agreed-to-rules? (reagent/atom false)]
|
||||
(fn []
|
||||
[react/view {:style {:flex 1 :margin-left 20 :margin-right 20 :margin-bottom 20}}
|
||||
[react/view {:style {:flex 1 :flex-direction :row :align-items :center :justify-content :space-between}}
|
||||
|
||||
[quo2.text/text {:accessibility-label :communities-join-community
|
||||
:weight :semi-bold
|
||||
:size :heading-1}
|
||||
(i18n/label :t/join-open-community)]
|
||||
[react/view {:style {:height 32
|
||||
:width 32
|
||||
:align-items :center
|
||||
:background-color quo2.colors/white
|
||||
:border-color quo2.colors/neutral-20
|
||||
:border-width 1
|
||||
:border-radius 6
|
||||
:display :flex
|
||||
:justify-content :center}}
|
||||
[quo2.icon/icon :main-icons2/info]]]
|
||||
|
||||
[quo2.context-tags/context-tag {:style {:margin-right :auto :margin-top 8}} (get-in community [:images :thumbnail :uri]) (:name community)]
|
||||
|
||||
[quo2.text/text {:style {:margin-top 24}
|
||||
:accessibility-label :communities-rules-title
|
||||
:weight :semi-bold
|
||||
:size :paragraph-1}
|
||||
(i18n/label :t/community-rules)]
|
||||
[community-rules-list community-rules]
|
||||
[rules-checkbox agreed-to-rules?]
|
||||
|
||||
[react/view {:style {:width "100%"
|
||||
:margin-top 32 :margin-bottom 16
|
||||
:flex 1
|
||||
:flex-direction :row
|
||||
:align-items :center
|
||||
:justify-content :space-evenly}}
|
||||
[quo2.button/button {:on-press #(>evt [:bottom-sheet/hide])
|
||||
:type :grey :style {:flex 1 :margin-right 12}} (i18n/label :t/cancel)]
|
||||
[quo2.button/button
|
||||
{:on-press #(>evt [::communities/join (:id community)])
|
||||
:disabled (not agreed-to-rules?) :style {:flex 1}} (i18n/label :t/join-open-community)]]])))
|
|
@ -7,6 +7,7 @@
|
|||
"access-key": "Access key",
|
||||
"access-existing-keys": "Access existing keys",
|
||||
"accept-and-share-address": "Accept and share address",
|
||||
"accept-community-rules": "I agree with the community rules",
|
||||
"account-added": "Account added",
|
||||
"account-color": "Account color",
|
||||
"anyone": "Anyone",
|
||||
|
@ -167,6 +168,7 @@
|
|||
"one": "{{count}} member",
|
||||
"other": "{{count}} members"
|
||||
},
|
||||
"community-rules": "Community rules",
|
||||
"members-label": "Members",
|
||||
"open-membership": "Open membership",
|
||||
"member-kick": "Kick member",
|
||||
|
@ -683,7 +685,7 @@
|
|||
"invalid-username-or-key": "Invalid username or chat key",
|
||||
"join-me": "Hey join me on Status: {{url}}",
|
||||
"join-a-community": "or join a community",
|
||||
"join-open-community": "Join community",
|
||||
"join-open-community": "Join Community",
|
||||
"http-gateway-error": "Oops, request failed!",
|
||||
"sign-request-failed": "Could not sign message",
|
||||
"invite-friends": "Invite friends",
|
||||
|
|
Loading…
Reference in New Issue