-
Notifications
You must be signed in to change notification settings - Fork 984
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow user to select a color for the group chat #18982
- Loading branch information
1 parent
5fd0b27
commit 934cd99
Showing
19 changed files
with
237 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,4 +87,3 @@ | |
:i/face-id])] | ||
(when error? | ||
[error-info error-message processing shell?])])) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
(ns status-im.contexts.chat.group-create.events | ||
(:require [legacy.status-im.data-store.chats :as data-store.chats] | ||
[oops.core :as oops] | ||
[re-frame.core :as rf])) | ||
|
||
(rf/reg-event-fx :group-chat/create | ||
(fn [{:keys [db]} [group-name color image]] | ||
(let [selected-contacts (:group/selected-contacts db)] | ||
{:json-rpc/call [{:method "wakuext_createGroupChatWithMembers" | ||
:params [nil group-name (into [] selected-contacts)] | ||
:js-response true | ||
:on-success (fn [response] | ||
(let [chat-id (-> (oops/oget response :chats) | ||
first | ||
(oops/oget :id))] | ||
(rf/dispatch [:chat-updated response]) | ||
(rf/dispatch [:group-chat/edit | ||
{:chat-id chat-id | ||
:group-name group-name | ||
:color color | ||
:image image}])))}]}))) | ||
|
||
(rf/reg-event-fx :group-chat/edit | ||
(fn [_ [{:keys [chat-id group-name color image]}]] | ||
{:json-rpc/call [{:method "chat_editChat" | ||
:params ["" chat-id group-name (name color) image] | ||
:js-response true | ||
:on-success #(rf/dispatch [:chat/ensure-chats | ||
[(data-store.chats/<-rpc-js %)]])}]})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
(ns status-im.contexts.chat.group-create.style | ||
(:require [quo.foundations.colors :as colors])) | ||
|
||
(def avatar {:width 88 :margin-top 12 :margin-left 20}) | ||
|
||
(def hole | ||
{:y (- 80 32) | ||
:x (+ (- 80 32) 8) | ||
:width 32 | ||
:height 32 | ||
:borderRadius 10}) | ||
|
||
(def camera {:position :absolute :right 0 :bottom 0}) | ||
|
||
(defn color-label | ||
[theme] | ||
{:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme) | ||
:padding-horizontal 20}) | ||
|
||
(def tags {:flex-direction :row :flex-wrap :wrap :padding-horizontal 20 :padding-top 12}) | ||
|
||
(def tag {:margin-right 8 :margin-bottom 8}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
(ns status-im.contexts.chat.group-create.view | ||
(:require [quo.core :as quo] | ||
[quo.foundations.colors :as colors] | ||
[quo.theme] | ||
[react-native.core :as rn] | ||
[react-native.hole-view :as hole-view] | ||
[status-im.common.floating-button-page.view :as floating-button-page] | ||
[status-im.constants :as constants] | ||
[status-im.contexts.chat.group-create.style :as style] | ||
[status-im.contexts.profile.utils :as profile.utils] | ||
[utils.debounce :as debounce] | ||
[utils.i18n :as i18n] | ||
[utils.re-frame :as rf] | ||
[utils.responsiveness :as responsiveness])) | ||
|
||
(defn avatar | ||
[{:keys [customization-color]}] | ||
[rn/pressable {:style style/avatar} | ||
[hole-view/hole-view | ||
{:holes [style/hole]} | ||
[quo/group-avatar | ||
{:customization-color customization-color | ||
:size :size-80}]] | ||
[quo/button | ||
{:on-press (fn [] | ||
#_(rf/dispatch | ||
[:show-bottom-sheet | ||
{:content (fn [] | ||
[profile-picture-picker/view | ||
{:update-profile-pic-callback on-change-profile-pic | ||
:has-picture? has-picture?}]) | ||
:theme :dark | ||
:shell? true}])) | ||
:container-style style/camera | ||
:icon-only? true | ||
:type :grey | ||
:background :photo | ||
:size 32} | ||
:i/camera]]) | ||
|
||
(defn view | ||
[] | ||
(let [theme (quo.theme/use-theme-value) | ||
{window-width :width} (rn/get-window) | ||
profile (rf/sub [:profile/profile-with-image]) | ||
contacts (rf/sub [:selected-group-contacts]) | ||
contacts-count (count contacts) | ||
[group-name set-group-name] (rn/use-state "") | ||
group-name-empty? (not (and (string? group-name) (not-empty group-name))) | ||
[group-color set-group-color] (rn/use-state (rand-nth colors/account-colors)) | ||
create-group-on-press (rn/use-callback #(debounce/throttle-and-dispatch | ||
[:group-chat/create group-name group-color] | ||
300) | ||
[group-name group-color]) | ||
back-on-press (rn/use-callback #(rf/dispatch [:navigate-back]))] | ||
[floating-button-page/view | ||
{:customization-color group-color | ||
:gradient-cover? true | ||
:top? true | ||
:header [quo/page-nav | ||
{:background :photo | ||
:type :no-title | ||
:icon-name :i/arrow-left | ||
:on-press back-on-press}] | ||
:footer [quo/button | ||
{:customization-color group-color | ||
:disabled? group-name-empty? | ||
:on-press create-group-on-press} | ||
(i18n/label :t/create-group-chat)]} | ||
[:<> | ||
[avatar {:customization-color group-color}] | ||
[quo/title-input | ||
{:on-change-text set-group-name | ||
:placeholder (i18n/label :t/name-your-group) | ||
:max-length constants/max-group-chat-name-length}] | ||
[quo/divider-line] | ||
[rn/view | ||
{:style {:padding-vertical 8}} | ||
[quo/text | ||
{:size :paragraph-2 | ||
:weight :medium | ||
:style (style/color-label theme)} | ||
(i18n/label :t/accent-colour)] | ||
[quo/color-picker | ||
{:default-selected group-color | ||
:on-change set-group-color | ||
:container-style {:padding-vertical 12 | ||
:padding-left (responsiveness/iphone-11-Pro-20-pixel-from-width | ||
window-width)}}]] | ||
[quo/divider-label | ||
(i18n/label :t/n-m-people {:n (inc contacts-count) :m constants/max-group-chat-participants})] | ||
[rn/view {:style style/tags} | ||
(for [contact (conj contacts profile)] | ||
^{:key contact} | ||
[quo/context-tag | ||
{:container-style style/tag | ||
:size 24 | ||
:profile-picture (profile.utils/photo contact) | ||
:full-name (profile.utils/displayed-name contact)}])]]])) |
Oops, something went wrong.