Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Communities - Show modal title and community context tag #18077

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
(ns status-im2.contexts.communities.actions.accounts-selection.style
(:require
[quo.foundations.colors :as colors]))

(def screen-horizontal-padding 20)

(def container
{:flex 1})

(def page-top
{:padding-vertical 12
:padding-horizontal screen-horizontal-padding})

(def content
{:margin-bottom 20
:padding-horizontal screen-horizontal-padding})

(defn bottom-actions
[]
{:position :absolute
:background-color (colors/theme-colors colors/white colors/neutral-95)
:bottom 0
:left 0
:right 0
:padding-horizontal screen-horizontal-padding
:padding-vertical 12
:flex 1})
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
[react-native.core :as rn]
[react-native.gesture :as gesture]
[status-im2.common.password-authentication.view :as password-authentication]
[status-im2.contexts.communities.actions.accounts-selection.style :as style]
[status-im2.contexts.communities.actions.community-rules.view :as community-rules]
[status-im2.contexts.communities.actions.request-to-join.style :as style]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))

(defn join-community-and-navigate-back
(defn- join-community-and-navigate-back
[id]
(rf/dispatch [:password-authentication/show
{:content (fn [] [password-authentication/view])}
Expand All @@ -18,31 +18,46 @@
{:community-id id :password %}])}])
(rf/dispatch [:navigate-back]))

(defn- page-top
[{:keys [community-name logo-uri]}]
[rn/view {:style style/page-top}
[quo/text
{:size :heading-1
:weight :semi-bold}
(i18n/label :t/request-to-join)]
[quo/context-tag
{:type :community
:size 24
:community-logo logo-uri
:community-name community-name
:container-style {:margin-top 8}}]])

(defn view
[]
(fn []
(let [{:keys [_name
id
_images]} (rf/sub [:get-screen-params])]
[rn/view {:flex 1}
[gesture/scroll-view {:style {:flex 1}}
[rn/view style/page-container
[quo/text
{:style {:margin-top 24}
:accessibility-label :community-rules-title
:weight :semi-bold
:size :paragraph-1}
(i18n/label :t/community-rules)]
[community-rules/view id]
[rn/view {:style (style/bottom-container)}
[quo/button
{:accessibility-label :cancel
:on-press #(rf/dispatch [:navigate-back])
:type :grey
:container-style style/cancel-button}
(i18n/label :t/cancel)]
[quo/button
{:accessibility-label :join-community-button
:on-press #(join-community-and-navigate-back id)
:container-style {:flex 1}}
(i18n/label :t/request-to-join)]]]]])))
(let [{id :community-id} (rf/sub [:get-screen-params])
{:keys [name color images]} (rf/sub [:communities/community id])]
[rn/view {:style style/container}
[quo/page-nav
{:text-align :left
:icon-name :i/close
:on-press #(rf/dispatch [:navigate-back])
:accessibility-label :back-button}]
[page-top
{:community-name name
:logo-uri (get-in images [:thumbnail :uri])}]
[gesture/scroll-view
[rn/view {:style style/content}
[quo/text
{:style {:margin-top 24}
:accessibility-label :community-rules-title
:weight :semi-bold
:size :paragraph-1}
(i18n/label :t/community-rules)]
[community-rules/view id]]]
[rn/view {:style (style/bottom-actions)}
[quo/slide-button
{:size :size-48
:track-text (i18n/label :t/slide-to-request-to-join)
:track-icon :i/face-id
:customization-color color
:on-complete #(join-community-and-navigate-back id)}]]]))
4 changes: 2 additions & 2 deletions src/status_im2/contexts/communities/overview/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
(i18n/label :t/join-open-community)]])))

(defn join-community
[{:keys [joined color permissions token-permissions] :as community}
[{:keys [joined color permissions token-permissions id] :as community}
pending?]
(let [access-type (get-access-type (:access permissions))
unknown-access? (= access-type :unknown-access)
Expand All @@ -185,7 +185,7 @@
[quo/button
{:on-press
(if config/community-accounts-selection-enabled?
#(rf/dispatch [:open-modal :community-account-selection community])
#(rf/dispatch [:open-modal :community-account-selection {:community-id id}])
#(rf/dispatch [:open-modal :community-requests-to-join community]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we pass the argument as line above?
instead of comunity we use {:community-id id}?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The community map is huge, even containing encoded images. We should avoid passing it around if possible because the data (screen params) is going to be stored in the app db and used by a subscription and the view too. This puts more stress on re-frame and Reagent to compute if something needs to rendered. So here I changed the code to pass the community ID to the screen params so that the view layer can get the community from a subscription.


:accessibility-label :show-request-to-join-screen-button
Expand Down
3 changes: 2 additions & 1 deletion translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1902,6 +1902,7 @@
"swap": "Swap",
"select-token-to-swap": "Select token to Swap",
"select-token-to-receive": "Select token to receive",
"slide-to-request-to-join": "Slide to request to join",
"slide-to-reveal-code": "Slide to reveal code",
"slide-to-create-account": "Slide to create account",
"minimum-received": "Minimum received",
Expand Down Expand Up @@ -2405,5 +2406,5 @@
"send-limit": "Max: {{limit}}",
"searching-for-activity": "Searching for activity...",
"this-address-has-no-activity": "This address has no activity",
"this-address-has-activity": "This address has activity"
"this-address-has-activity": "This address has activity"
}