mirror of
https://github.com/status-im/status-react.git
synced 2025-01-22 08:49:22 +00:00
[#12066] Add category to communities
Signed-off-by: andrey <motor4ik@gmail.com>
This commit is contained in:
parent
ebf951d110
commit
7d9a2f074e
BIN
resources/images/icons/channel_category@2x.png
Normal file
BIN
resources/images/icons/channel_category@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
resources/images/icons/channel_category@3x.png
Normal file
BIN
resources/images/icons/channel_category@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
BIN
resources/images/icons/delete_circle@2x.png
Normal file
BIN
resources/images/icons/delete_circle@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 843 B |
BIN
resources/images/icons/delete_circle@3x.png
Normal file
BIN
resources/images/icons/delete_circle@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
@ -47,6 +47,14 @@
|
||||
{}
|
||||
chats))
|
||||
|
||||
(defn <-categories-rpc [categ]
|
||||
(reduce-kv (fn [acc k v]
|
||||
(assoc acc
|
||||
(name k)
|
||||
v))
|
||||
{}
|
||||
categ))
|
||||
|
||||
(defn <-rpc [c]
|
||||
(-> c
|
||||
(clojure.set/rename-keys {:canRequestAccess :can-request-access?
|
||||
@ -55,7 +63,8 @@
|
||||
:requestedToJoinAt :requested-to-join-at
|
||||
:isMember :is-member?})
|
||||
(update :members walk/stringify-keys)
|
||||
(update :chats <-chats-rpc)))
|
||||
(update :chats <-chats-rpc)
|
||||
(update :categories <-categories-rpc)))
|
||||
|
||||
(defn fetch-community-id-input [{:keys [db]}]
|
||||
(:communities/community-id-input db))
|
||||
@ -321,7 +330,7 @@
|
||||
(fx/merge cofx
|
||||
(reset-community-id-input id)
|
||||
(reset-channel-info)
|
||||
(navigation/navigate-to :create-community-channel nil)))
|
||||
(navigation/open-modal :create-community-channel {:community-id id})))
|
||||
|
||||
(fx/defn edit-channel-pressed
|
||||
{:events [::edit-channel-pressed]}
|
||||
@ -331,7 +340,7 @@
|
||||
:description description
|
||||
:color color
|
||||
:community-id community-id})}
|
||||
(navigation/navigate-to :edit-community-channel nil)))
|
||||
(navigation/open-modal :edit-community-channel nil)))
|
||||
|
||||
(fx/defn community-created
|
||||
{:events [::community-created]}
|
||||
@ -503,3 +512,59 @@
|
||||
[{:keys [db]} enabled?]
|
||||
{::async-storage/set! {:communities-enabled? enabled?}
|
||||
:db (assoc db :communities/enabled? enabled?)})
|
||||
|
||||
(fx/defn create-category
|
||||
{:events [::create-category-confirmation-pressed]}
|
||||
[_ community-id category-title chat-ids]
|
||||
{::json-rpc/call [{:method "wakuext_createCommunityCategory"
|
||||
:params [{:communityId community-id
|
||||
:categoryName category-title
|
||||
:chatIds (map #(string/replace % community-id "") chat-ids)}]
|
||||
:js-response true
|
||||
:on-success #(do
|
||||
(re-frame/dispatch [:navigate-back])
|
||||
(re-frame/dispatch [:sanitize-messages-and-process-response %]))
|
||||
:on-error #(log/error "failed to create community category" %)}]})
|
||||
|
||||
(fx/defn remove-chat-from-category
|
||||
{:events [:remove-chat-from-community-category]}
|
||||
[{:keys [db]} community-id id categoryID]
|
||||
(let [category (get-in db [:communities community-id :categories categoryID])
|
||||
category-chats (map :id (filter #(and (= (:categoryID %) categoryID) (not= id (:id %)))
|
||||
(vals (get-in db [:communities community-id :chats]))))]
|
||||
{::json-rpc/call [{:method "wakuext_editCommunityCategory"
|
||||
:params [{:communityId community-id
|
||||
:categoryId categoryID
|
||||
:categoryName (:name category)
|
||||
:chatIds category-chats}]
|
||||
:js-response true
|
||||
:on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %])
|
||||
:on-error #(log/error "failed to remove chat from community" %)}]}))
|
||||
|
||||
(fx/defn delete-category
|
||||
{:events [:delete-community-category]}
|
||||
[_ community-id category-id]
|
||||
{::json-rpc/call [{:method "wakuext_deleteCommunityCategory"
|
||||
:params [{:communityId community-id
|
||||
:categoryId category-id}]
|
||||
:js-response true
|
||||
:on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %])
|
||||
:on-error #(log/error "failed to delete community category" %)}]})
|
||||
|
||||
(fx/defn change-category
|
||||
{:events [::change-category-confirmation-pressed]}
|
||||
[cofx community-id category-id {:keys [id position categoryID]}]
|
||||
(if (not (string/blank? category-id))
|
||||
{::json-rpc/call [{:method "wakuext_reorderCommunityChat"
|
||||
:params [{:communityId community-id
|
||||
:categoryId category-id
|
||||
:chatId id
|
||||
:position position}]
|
||||
:js-response true
|
||||
:on-success #(do
|
||||
(re-frame/dispatch [:navigate-back])
|
||||
(re-frame/dispatch [:sanitize-messages-and-process-response %]))
|
||||
:on-error #(log/error "failed to change community category" %)}]}
|
||||
(fx/merge cofx
|
||||
(navigation/navigate-back)
|
||||
(remove-chat-from-category community-id id categoryID))))
|
@ -148,6 +148,11 @@
|
||||
"wakuext_communities" {}
|
||||
"wakuext_importCommunity" {}
|
||||
"wakuext_exportCommunity" {}
|
||||
"wakuext_createCommunityCategory" {}
|
||||
"wakuext_reorderCommunityCategories" {}
|
||||
"wakuext_reorderCommunityChat" {}
|
||||
"wakuext_editCommunityCategory" {}
|
||||
"wakuext_deleteCommunityCategory" {}
|
||||
"wakuext_ensVerified" {}
|
||||
"wakuext_dismissActivityCenterNotifications" {}
|
||||
"wakuext_acceptActivityCenterNotifications" {}
|
||||
|
@ -40,7 +40,8 @@
|
||||
[status-im.notifications.core :as notifications]
|
||||
[status-im.utils.currency :as currency]
|
||||
[status-im.signing.eip1559 :as eip1559]
|
||||
[clojure.set :as clojure.set]))
|
||||
[clojure.set :as clojure.set]
|
||||
[status-im.ui.components.colors :as colors]))
|
||||
|
||||
;; TOP LEVEL ===========================================================================================================
|
||||
|
||||
@ -265,6 +266,12 @@
|
||||
(fn [communities [_ id]]
|
||||
(get communities id)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:communities/community-chats
|
||||
:<- [:communities]
|
||||
(fn [communities [_ id]]
|
||||
(get-in communities [id :chats])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:communities/communities
|
||||
:<- [:communities/enabled?]
|
||||
@ -761,6 +768,47 @@
|
||||
chat)))
|
||||
(sort-by :timestamp >))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:chats/with-empty-category-by-community-id
|
||||
(fn [[_ community-id]]
|
||||
[(re-frame/subscribe [:chats/by-community-id community-id])
|
||||
(re-frame/subscribe [:communities/community-chats community-id])])
|
||||
(fn [[chats comm-chats] [_ community-id]]
|
||||
(filter #(string/blank? (get-in comm-chats [(string/replace (:chat-id %) community-id "") :categoryID])) chats)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:chats/categories-by-community-id
|
||||
(fn [[_ community-id]]
|
||||
[(re-frame/subscribe [:chats/by-community-id community-id])
|
||||
(re-frame/subscribe [:communities/community-chats community-id])])
|
||||
(fn [[chats comm-chats] [_ community-id]]
|
||||
(let [chat-cat (into {} (map (fn [{:keys [id categoryID]}] {(str community-id id) categoryID}) (vals comm-chats)))]
|
||||
(group-by :categoryID (map #(cond-> (assoc % :categoryID (chat-cat (:chat-id %)))
|
||||
(= community-id constants/status-community-id)
|
||||
(assoc :color colors/blue))
|
||||
chats)))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:chats/category-by-chat-id
|
||||
(fn [[_ community-id _]]
|
||||
[(re-frame/subscribe [:communities/community community-id])])
|
||||
(fn [[{:keys [chats categories]}] [_ community-id chat-id]]
|
||||
(get categories (get-in chats [(string/replace chat-id community-id "") :categoryID]))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:chats/community-chat-by-id
|
||||
(fn [[_ community-id _]]
|
||||
[(re-frame/subscribe [:communities/community community-id])])
|
||||
(fn [[{:keys [chats]}] [_ community-id chat-id]]
|
||||
(get chats (string/replace chat-id community-id ""))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:community/categories
|
||||
(fn [[_ community-id]]
|
||||
[(re-frame/subscribe [:communities/community community-id])])
|
||||
(fn [[{:keys [categories]}] _]
|
||||
categories))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:chats/current-chat-ui-props
|
||||
:<- [::chat-ui-props]
|
||||
|
@ -88,7 +88,7 @@
|
||||
(js-delete response-js "communities")
|
||||
(fx/merge cofx
|
||||
(process-next response-js sync-handler)
|
||||
(models.communities/handle-communities (types/js->clj communities-clj))))
|
||||
(models.communities/handle-communities communities-clj)))
|
||||
|
||||
(seq pin-messages)
|
||||
(let [pin-messages (types/js->clj pin-messages)]
|
||||
@ -102,13 +102,13 @@
|
||||
(js-delete response-js "removedChats")
|
||||
(fx/merge cofx
|
||||
(process-next response-js sync-handler)
|
||||
(models.communities/handle-removed-chats (types/js->clj removed-chats-clj))))
|
||||
(models.communities/handle-removed-chats removed-chats-clj)))
|
||||
|
||||
(seq requests-to-join-community)
|
||||
(let [request (.pop requests-to-join-community)]
|
||||
(let [request-js (types/js->clj (.pop requests-to-join-community))]
|
||||
(fx/merge cofx
|
||||
(process-next response-js sync-handler)
|
||||
(models.communities/handle-request-to-join (types/js->clj request))))
|
||||
(models.communities/handle-request-to-join request-js)))
|
||||
|
||||
(seq emoji-reactions)
|
||||
(let [reactions (types/js->clj emoji-reactions)]
|
||||
|
@ -18,19 +18,20 @@
|
||||
"Render collapsible section"
|
||||
[_props]
|
||||
(let [opened? (reagent/atom false)]
|
||||
(fn [{:keys [title content icon]}]
|
||||
(fn [{:keys [title content icon opened disabled]}]
|
||||
[react/view {:padding-vertical 8}
|
||||
(if (string? title)
|
||||
[quo/list-item
|
||||
{:title title
|
||||
:icon icon
|
||||
:on-press #(swap! opened? not)
|
||||
:accessory [drop-down-icon @opened?]}]
|
||||
[react/touchable-opacity {:on-press #(swap! opened? not)}
|
||||
:accessory [drop-down-icon (or @opened? opened)]}]
|
||||
[react/touchable-opacity {:on-press #(swap! opened? not) :disabled disabled}
|
||||
[react/view {:flex-direction :row
|
||||
:margin-right 14
|
||||
:justify-content :space-between}
|
||||
title
|
||||
[drop-down-icon @opened?]]])
|
||||
(when @opened?
|
||||
[drop-down-icon (or @opened? opened)]]])
|
||||
(when (or @opened? opened)
|
||||
content)])))
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
(defn memo-icon-fn
|
||||
([name] (memo-icon-fn name nil))
|
||||
([name {:keys [color resize-mode container-style
|
||||
accessibility-label width height]
|
||||
accessibility-label width height no-color]
|
||||
:or {accessibility-label :icon}}]
|
||||
^{:key name}
|
||||
[react/image {:style (merge (cond-> {:width (or width 24)
|
||||
@ -38,7 +38,7 @@
|
||||
resize-mode
|
||||
(assoc :resize-mode resize-mode)
|
||||
|
||||
:always
|
||||
(not no-color)
|
||||
(assoc :tint-color (match-color color)))
|
||||
container-style)
|
||||
:accessibility-label accessibility-label
|
||||
|
@ -11,25 +11,35 @@
|
||||
(fn []
|
||||
(let [current-chat (<sub [:chat-by-id chat-id])
|
||||
{:keys [chat-name color description community-id]} current-chat
|
||||
category (<sub [:chats/category-by-chat-id community-id chat-id])
|
||||
{:keys [admin]} (<sub [:communities/community community-id])]
|
||||
[:<>
|
||||
[quo/animated-header {:left-accessories [{:icon :main-icons/arrow-left
|
||||
:accessibility-label :back-button
|
||||
:on-press #(>evt [:navigate-back])}]
|
||||
:right-accessories (when admin [{:icon :edit
|
||||
:accessibility-label :invite-button
|
||||
:on-press #(>evt [::communities/edit-channel-pressed
|
||||
community-id
|
||||
chat-name
|
||||
description
|
||||
color])}])
|
||||
:extended-header (profile-header/extended-header
|
||||
{:title chat-name
|
||||
:color color
|
||||
:subtitle (i18n/label :t/public-channel)})
|
||||
:use-insets true}
|
||||
(when-not (string/blank? description)
|
||||
[:<>
|
||||
[quo/list-footer {:color :main}
|
||||
description]
|
||||
[quo/separator {:style {:margin-vertical 8}}]])]]))))
|
||||
[quo/animated-header {:left-accessories [{:icon :main-icons/arrow-left
|
||||
:accessibility-label :back-button
|
||||
:on-press #(>evt [:navigate-back])}]
|
||||
:right-accessories (when admin [{:icon :edit
|
||||
:accessibility-label :invite-button
|
||||
:on-press #(>evt [::communities/edit-channel-pressed
|
||||
community-id
|
||||
chat-name
|
||||
description
|
||||
color])}])
|
||||
:extended-header (profile-header/extended-header
|
||||
{:title chat-name
|
||||
:color color
|
||||
:subtitle (i18n/label :t/public-channel)})
|
||||
:use-insets true}
|
||||
(when-not (string/blank? description)
|
||||
[:<>
|
||||
[quo/list-footer {:color :main}
|
||||
description]
|
||||
[quo/separator {:style {:margin-vertical 8}}]
|
||||
(when admin
|
||||
[quo/list-item {:title (i18n/label :t/category)
|
||||
:on-press #(>evt [:open-modal :select-category {:chat current-chat
|
||||
:category category
|
||||
:community-id community-id}])
|
||||
:chevron true
|
||||
:accessory :text
|
||||
:accessory-text (if category
|
||||
(:name category)
|
||||
(i18n/label :t/none))}])])]))))
|
@ -18,7 +18,10 @@
|
||||
[status-im.utils.core :as utils]
|
||||
[status-im.ui.components.plus-button :as components.plus-button]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.ui.screens.chat.sheets :as sheets]))
|
||||
[status-im.ui.screens.chat.sheets :as sheets]
|
||||
[status-im.ui.components.accordion :as accordion]
|
||||
[clojure.string :as string]
|
||||
[status-im.ui.screens.communities.styles :as styles]))
|
||||
|
||||
(def request-cooldown-ms (* 60 1000))
|
||||
|
||||
@ -70,6 +73,12 @@
|
||||
:accessibility-label :community-create-channel
|
||||
:icon :main-icons/channel
|
||||
:on-press #(hide-sheet-and-dispatch [::communities/create-channel-pressed id])}]
|
||||
[quo/list-item
|
||||
{:theme :accent
|
||||
:title (i18n/label :t/create-category)
|
||||
:accessibility-label :community-create-category
|
||||
:icon :main-icons/channel-category
|
||||
:on-press #(hide-sheet-and-dispatch [:open-modal :create-community-category {:community-id id}])}]
|
||||
[quo/separator]
|
||||
(when can-invite?
|
||||
[quo/list-item
|
||||
@ -109,12 +118,20 @@
|
||||
name
|
||||
(or color (rand-nth colors/chat-colors))])}]
|
||||
(when can-manage-users?
|
||||
[quo/list-item
|
||||
{:theme :accent
|
||||
:title (i18n/label :t/export-key)
|
||||
:accessibility-label :community-export-key
|
||||
:icon :main-icons/objects
|
||||
:on-press #(hide-sheet-and-dispatch [::communities/export-pressed id])}])]))
|
||||
[:<>
|
||||
[quo/list-item
|
||||
{:theme :accent
|
||||
:title (i18n/label :t/export-key)
|
||||
:accessibility-label :community-export-key
|
||||
:icon :main-icons/objects
|
||||
:on-press #(hide-sheet-and-dispatch [::communities/export-pressed id])}]
|
||||
[quo/separator]
|
||||
[quo/list-item
|
||||
{:theme :accent
|
||||
:title (i18n/label :t/edit-chats)
|
||||
:accessibility-label :community-edit-chats
|
||||
:icon :main-icons/edit
|
||||
:on-press #(hide-sheet-and-dispatch [:open-modal :community-edit-chats {:community-id id}])}]])]))
|
||||
|
||||
(defn blank-page [text]
|
||||
[rn/view {:style {:padding 16 :flex 1 :flex-direction :row :align-items :center :justify-content :center}}
|
||||
@ -137,23 +154,49 @@
|
||||
{:content (fn []
|
||||
[sheets/actions home-item])}])}])
|
||||
|
||||
(defn community-chat-list [chats]
|
||||
(if (empty? chats)
|
||||
[blank-page (i18n/label :t/welcome-community-blank-message)]
|
||||
[list/flat-list
|
||||
{:key-fn :chat-id
|
||||
:content-container-style {:padding-vertical 8}
|
||||
:keyboard-should-persist-taps :always
|
||||
:data chats
|
||||
:render-fn community-chat-item
|
||||
:footer [rn/view {:height 68}]}]))
|
||||
(defn categories-accordion [community-id chats categories edit]
|
||||
[rn/view {:padding-bottom 8}
|
||||
(for [{:keys [name id]} (vals categories)]
|
||||
^{:key (str "cat" name id)}
|
||||
[:<>
|
||||
[accordion/section
|
||||
{:opened edit
|
||||
:disabled edit
|
||||
:title [rn/view styles/category-item
|
||||
(if edit
|
||||
[rn/touchable-opacity {:on-press #(>evt [:delete-community-category community-id id])}
|
||||
[icons/icon :main-icons/delete-circle {:no-color true}]]
|
||||
[icons/icon :main-icons/channel-category {:color colors/gray}])
|
||||
[rn/text {:style {:font-size 17 :margin-left 10}} name]]
|
||||
:content [rn/view
|
||||
(for [chat (get chats id)]
|
||||
(if edit
|
||||
^{:key (str "chat" chat id)}
|
||||
[rn/view styles/category-item
|
||||
[rn/touchable-opacity {:on-press #(>evt [:remove-chat-from-community-category
|
||||
community-id
|
||||
(string/replace (:chat-id chat) community-id "")
|
||||
(:categoryID chat)])}
|
||||
[icons/icon :main-icons/delete-circle {:no-color true}]]
|
||||
[rn/view {:flex 1}
|
||||
[inner-item/home-list-item
|
||||
(assoc chat :public? true)]]]
|
||||
^{:key (str "chat" chat id)}
|
||||
[community-chat-item chat]))]}]
|
||||
[quo/separator]])])
|
||||
|
||||
(defn community-channel-list [id]
|
||||
(let [chats (<sub [:chats/by-community-id id])
|
||||
chats (cond->> chats
|
||||
(= id constants/status-community-id)
|
||||
(map #(assoc % :color colors/blue)))]
|
||||
[community-chat-list chats]))
|
||||
(defn community-chat-list [community-id categories edit]
|
||||
(let [chats (<sub [:chats/categories-by-community-id community-id])]
|
||||
(if (and (empty? categories) (empty? chats))
|
||||
[blank-page (i18n/label :t/welcome-community-blank-message)]
|
||||
[list/flat-list
|
||||
{:key-fn :chat-id
|
||||
:content-container-style {:padding-bottom 8}
|
||||
:keyboard-should-persist-taps :always
|
||||
:data (get chats "")
|
||||
:render-fn community-chat-item
|
||||
:header [categories-accordion community-id chats categories edit]
|
||||
:footer [rn/view {:height 68}]}])))
|
||||
|
||||
(defn channel-preview-item [{:keys [id color name]}]
|
||||
(let [color (or color colors/default-community-color)]
|
||||
@ -196,11 +239,27 @@
|
||||
[topbar/topbar {:title (i18n/label :t/not-found)}]
|
||||
[blank-page (i18n/label :t/community-info-not-found)]])
|
||||
|
||||
(defn community-edit []
|
||||
(let [{:keys [community-id]} (<sub [:get-screen-params])]
|
||||
(fn []
|
||||
(let [{:keys [id name images members permissions color categories]} (<sub [:communities/community community-id])]
|
||||
[:<>
|
||||
[topbar/topbar
|
||||
{:modal? true
|
||||
:content [toolbar-content
|
||||
id
|
||||
name
|
||||
color
|
||||
images
|
||||
(not= (:access permissions) constants/community-no-membership-access)
|
||||
(count members)]}]
|
||||
[community-chat-list id categories true]]))))
|
||||
|
||||
(defn community []
|
||||
(let [{:keys [community-id]} (<sub [:get-screen-params])]
|
||||
(fn []
|
||||
(let [{:keys [id chats name images members permissions color joined can-request-access?
|
||||
can-join? requested-to-join-at admin]
|
||||
can-join? requested-to-join-at admin categories]
|
||||
:as community} (<sub [:communities/community community-id])]
|
||||
(if community
|
||||
[rn/view {:style {:flex 1}}
|
||||
@ -221,7 +280,7 @@
|
||||
{:content (fn []
|
||||
[community-actions community])}])}])}]
|
||||
(if joined
|
||||
[community-channel-list id]
|
||||
[community-chat-list id categories false]
|
||||
[community-channel-preview-list id chats])
|
||||
(when admin
|
||||
[components.plus-button/plus-button
|
||||
|
@ -160,7 +160,7 @@
|
||||
|
||||
(defn view []
|
||||
(let [{:keys [name description]} (<sub [:communities/create])]
|
||||
[:<>
|
||||
[rn/keyboard-avoiding-view {:style {:flex 1}}
|
||||
[form]
|
||||
[toolbar/toolbar
|
||||
{:show-border? true
|
||||
|
68
src/status_im/ui/screens/communities/create_category.cljs
Normal file
68
src/status_im/ui/screens/communities/create_category.cljs
Normal file
@ -0,0 +1,68 @@
|
||||
(ns status-im.ui.screens.communities.create-category
|
||||
(:require [status-im.ui.components.keyboard-avoid-presentation :as kb-presentation]
|
||||
[status-im.utils.handlers :refer [<sub]]
|
||||
[status-im.ui.components.toolbar :as toolbar]
|
||||
[status-im.ui.components.react :as react]
|
||||
[quo.core :as quo]
|
||||
[status-im.utils.debounce :as debounce]
|
||||
[status-im.i18n.i18n :as i18n]
|
||||
[clojure.string :as str]
|
||||
[status-im.ui.components.list.views :as list]
|
||||
[status-im.ui.screens.home.views.inner-item :as inner-item]
|
||||
[status-im.communities.core :as communities]
|
||||
[reagent.core :as reagent]))
|
||||
|
||||
(defn valid? [category-name]
|
||||
(and (not (str/blank? category-name))
|
||||
(<= (count category-name) 30)))
|
||||
|
||||
(def selected-items (reagent/atom #{}))
|
||||
|
||||
(defn render-fn [{:keys [chat-id] :as home-item}]
|
||||
(let [selected (get @selected-items chat-id)
|
||||
on-change (fn []
|
||||
(swap! selected-items #(if selected (disj % chat-id) (conj % chat-id))))]
|
||||
[react/view {:flex-direction :row :flex 1 :align-items :center}
|
||||
[react/view {:padding-left 16}
|
||||
[quo/checkbox {:value selected
|
||||
:on-change on-change}]]
|
||||
[react/view {:flex 1}
|
||||
[inner-item/home-list-item
|
||||
(assoc home-item :public? true)
|
||||
{:on-press on-change}]]]))
|
||||
|
||||
(defn view []
|
||||
(let [{:keys [community-id]} (<sub [:get-screen-params])
|
||||
category-name (reagent/atom "")
|
||||
_ (reset! selected-items #{})]
|
||||
(fn []
|
||||
(let [chats (<sub [:chats/with-empty-category-by-community-id community-id])]
|
||||
[kb-presentation/keyboard-avoiding-view {:style {:flex 1}}
|
||||
[react/view {:flex 1}
|
||||
[react/view {:padding-horizontal 16}
|
||||
[quo/text-input
|
||||
{:placeholder (i18n/label :t/category-title)
|
||||
:on-change-text #(reset! category-name %)
|
||||
:auto-focus true}]]
|
||||
[quo/separator {:style {:margin-vertical 10}}]
|
||||
(when (seq chats)
|
||||
[:<>
|
||||
[quo/list-header (i18n/label :t/include)]
|
||||
[list/flat-list
|
||||
{:key-fn :chat-id
|
||||
:content-container-style {:padding-vertical 8}
|
||||
:keyboard-should-persist-taps :always
|
||||
:data chats
|
||||
:render-fn render-fn}]])]
|
||||
[toolbar/toolbar
|
||||
{:show-border? true
|
||||
:center
|
||||
[quo/button {:disabled (not (valid? @category-name))
|
||||
:type :secondary
|
||||
:on-press #(debounce/dispatch-and-chill
|
||||
[::communities/create-category-confirmation-pressed
|
||||
community-id
|
||||
@category-name
|
||||
(vec @selected-items)]
|
||||
3000)}
|
||||
(i18n/label :t/create)]}]]))))
|
@ -7,7 +7,8 @@
|
||||
[status-im.communities.core :as communities]
|
||||
[status-im.utils.debounce :as debounce]
|
||||
[status-im.utils.handlers :refer [>evt <sub]]
|
||||
[status-im.ui.screens.communities.create :as create]))
|
||||
[status-im.ui.screens.communities.create :as create]
|
||||
[status-im.ui.components.keyboard-avoid-presentation :as kb-presentation]))
|
||||
|
||||
(defn valid? [channel-name channel-description]
|
||||
(and (not (str/blank? channel-name))
|
||||
@ -20,19 +21,15 @@
|
||||
[rn/scroll-view {:style {:flex 1}
|
||||
:content-container-style {:padding-vertical 16}}
|
||||
[rn/view {:style {:padding-bottom 16
|
||||
:padding-top 10
|
||||
:padding-horizontal 16}}
|
||||
[rn/view
|
||||
[create/countable-label {:label (i18n/label :t/name)
|
||||
:text name
|
||||
:max-length create/max-name-length}]
|
||||
:padding-top 10}}
|
||||
[rn/view {:padding-horizontal 16}
|
||||
[quo/text-input
|
||||
{:placeholder (i18n/label :t/name-your-channel-placeholder)
|
||||
:on-change-text #(>evt [::communities/create-channel-field :name %])
|
||||
:default-value name
|
||||
:auto-focus true}]]
|
||||
[quo/separator {:style {:margin-vertical 10}}]
|
||||
[rn/view
|
||||
[rn/view {:padding-horizontal 16}
|
||||
[create/countable-label {:label (i18n/label :t/description)
|
||||
:text description
|
||||
:max-length create/max-description-length}]
|
||||
@ -44,7 +41,7 @@
|
||||
|
||||
(defn view []
|
||||
(let [{:keys [name description]} (<sub [:communities/create-channel])]
|
||||
[:<>
|
||||
[kb-presentation/keyboard-avoiding-view {:style {:flex 1}}
|
||||
[form]
|
||||
[toolbar/toolbar
|
||||
{:show-border? true
|
||||
|
59
src/status_im/ui/screens/communities/select_category.cljs
Normal file
59
src/status_im/ui/screens/communities/select_category.cljs
Normal file
@ -0,0 +1,59 @@
|
||||
(ns status-im.ui.screens.communities.select-category
|
||||
(:require [status-im.ui.components.react :as react]
|
||||
[status-im.ui.components.toolbar :as toolbar]
|
||||
[quo.core :as quo]
|
||||
[status-im.i18n.i18n :as i18n]
|
||||
[status-im.utils.debounce :as debounce]
|
||||
[status-im.ui.components.list.views :as list]
|
||||
[reagent.core :as reagent]
|
||||
[status-im.utils.handlers :refer [>evt <sub]]
|
||||
[status-im.ui.components.topbar :as topbar]
|
||||
[status-im.ui.components.icons.icons :as icons]
|
||||
[status-im.ui.components.colors :as colors]
|
||||
[status-im.communities.core :as communities]))
|
||||
|
||||
(def selected-item (reagent/atom ""))
|
||||
|
||||
(defn render-fn [{:keys [name id]}]
|
||||
[quo/list-item {:title name
|
||||
:accessory :radio
|
||||
:on-press #(reset! selected-item id)
|
||||
:active (= id @selected-item)
|
||||
:icon [icons/icon :main-icons/channel-category {:color colors/gray}]}])
|
||||
|
||||
(defn view []
|
||||
(let [{:keys [community-id chat]} (<sub [:get-screen-params])]
|
||||
(fn []
|
||||
(let [categories (<sub [:community/categories community-id])
|
||||
comm-chat (<sub [:chats/community-chat-by-id community-id (:chat-id chat)])
|
||||
_ (reset! selected-item (:categoryID comm-chat))]
|
||||
[:<>
|
||||
[topbar/topbar {:title (str "#" (:chat-name chat))
|
||||
:subtitle (i18n/label :t/public-channel)
|
||||
:modal? true}]
|
||||
[react/view {:flex 1}
|
||||
[quo/list-header (i18n/label :t/category)]
|
||||
[list/flat-list
|
||||
{:key-fn :chat-id
|
||||
:content-container-style {:padding-vertical 8}
|
||||
:keyboard-should-persist-taps :always
|
||||
:footer [quo/list-item
|
||||
{:theme :accent
|
||||
:icon :main-icons/channel-category
|
||||
:on-press #(>evt [:open-modal
|
||||
:create-community-category
|
||||
{:community-id community-id}])
|
||||
:title (i18n/label :t/create-category)}]
|
||||
:data (conj (vec (vals categories)) {:name (i18n/label :t/none) :id ""})
|
||||
:render-fn render-fn}]]
|
||||
[toolbar/toolbar
|
||||
{:show-border? true
|
||||
:center
|
||||
[quo/button {:type :secondary
|
||||
:on-press #(debounce/dispatch-and-chill
|
||||
[::communities/change-category-confirmation-pressed
|
||||
community-id
|
||||
@selected-item
|
||||
comm-chat]
|
||||
3000)}
|
||||
(i18n/label :t/done)]}]]))))
|
8
src/status_im/ui/screens/communities/styles.cljs
Normal file
8
src/status_im/ui/screens/communities/styles.cljs
Normal file
@ -0,0 +1,8 @@
|
||||
(ns status-im.ui.screens.communities.styles)
|
||||
|
||||
(def category-item
|
||||
{:flex 1
|
||||
:flex-direction :row
|
||||
:align-items :center
|
||||
:height 52
|
||||
:margin-left 18})
|
@ -106,7 +106,9 @@
|
||||
[status-im.ui.screens.anonymous-metrics-settings.views :as anonymous-metrics-settings]
|
||||
[status-im.ui.components.colors :as colors]
|
||||
[status-im.ui.components.icons.icons :as icons]
|
||||
[status-im.ui.screens.chat.pinned-messages :as pin-messages]))
|
||||
[status-im.ui.screens.chat.pinned-messages :as pin-messages]
|
||||
[status-im.ui.screens.communities.create-category :as create-category]
|
||||
[status-im.ui.screens.communities.select-category :as select-category]))
|
||||
|
||||
(def components
|
||||
[{:name :chat-toolbar
|
||||
@ -259,10 +261,25 @@
|
||||
:options {:topBar {:visible false}}
|
||||
:component requests-to-join/requests-to-join-container}
|
||||
{:name :create-community-channel
|
||||
:insets {:bottom true}
|
||||
:options {:topBar {:title {:text (i18n/label :t/create-channel-title)}}}
|
||||
:component create-channel/view}
|
||||
{:name :create-community-category
|
||||
:insets {:bottom true}
|
||||
:options {:topBar {:title {:text (i18n/label :t/new-category)}}}
|
||||
:component create-category/view}
|
||||
{:name :select-category
|
||||
:insets {:bottom true}
|
||||
;;TODO custom
|
||||
:options {:topBar {:visible false}}
|
||||
:component create-channel/view}
|
||||
:component select-category/view}
|
||||
{:name :community-edit-chats
|
||||
;;TODO custom
|
||||
:insets {:bottom true}
|
||||
:options {:topBar {:visible false}}
|
||||
:component community/community-edit}
|
||||
{:name :community-channel-details
|
||||
:insets {:top false}
|
||||
;;TODO custom
|
||||
:options {:topBar {:visible false}}
|
||||
:component communities.channel-details/view}
|
||||
|
@ -174,6 +174,7 @@
|
||||
"request-access": "Request access",
|
||||
"membership-request-pending": "Membership request pending",
|
||||
"create-community": "Create a community",
|
||||
"create-category": "Create category",
|
||||
"edited": "Edited",
|
||||
"edit-community": "Edit community",
|
||||
"editing-message": "Editing message",
|
||||
@ -188,6 +189,8 @@
|
||||
"name-your-community-placeholder": "A catchy name",
|
||||
"give-a-short-description-community": "Give it a short description",
|
||||
"new-community-title": "New community",
|
||||
"new-category": "New category",
|
||||
"category-title": "Category title",
|
||||
"membership-title": "Membership requirement",
|
||||
"create-channel-title": "New channel",
|
||||
"edit-channel-title": "Edit channel",
|
||||
@ -1578,7 +1581,6 @@
|
||||
"help-improve-status": "Help improve Status",
|
||||
"thank-you": "Thank you",
|
||||
"count-metrics-collected": "{{count}} metrics collected",
|
||||
"bip39-password-placeholder": "BIP39 password",
|
||||
"current-password": "Current password",
|
||||
"reset-password": "Reset password",
|
||||
"password-reset-success": "Password changed",
|
||||
@ -1638,5 +1640,8 @@
|
||||
"your-tip-limit": "Your tip limit",
|
||||
"your-price-limit": "Your price limit",
|
||||
"suggested-min-tip": "Suggested min. tip",
|
||||
"suggested-price-limit": "Suggested price limit"
|
||||
"suggested-price-limit": "Suggested price limit",
|
||||
"include": "Include",
|
||||
"category": "Category",
|
||||
"edit-chats": "Edit chats"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user