-
Notifications
You must be signed in to change notification settings - Fork 985
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
2a7ddd4
commit 4dc0e37
Showing
17 changed files
with
221 additions
and
74 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
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,106 @@ | ||
(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.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 {:width 88 :margin-top 12 :margin-left 20}} | ||
[hole-view/hole-view | ||
{:holes [{:y (- 80 32) | ||
:x (+ (- 80 32) 8) | ||
:width 32 | ||
:height 32 | ||
:borderRadius 10}]} | ||
[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 {:position :absolute :right 0 :bottom 0} | ||
:icon-only? true | ||
:type :grey | ||
:background :photo | ||
:size 32} | ||
:i/camera]]) | ||
|
||
(defn color-label | ||
[theme] | ||
{:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme) | ||
:padding-horizontal 20}) | ||
|
||
(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))] | ||
[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 (fn [] | ||
(rf/dispatch [:navigate-back]))}] | ||
:footer [quo/button | ||
{:customization-color group-color | ||
:disabled? group-name-empty? | ||
:on-press #(debounce/throttle-and-dispatch | ||
[:group-chat/create group-name group-color] | ||
300)} | ||
(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 (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 {:flex-direction :row :flex-wrap :wrap :padding-horizontal 20 :padding-top 12} | ||
(for [contact (conj contacts profile)] | ||
^{:key contact} | ||
[quo/context-tag | ||
{:container-style {:margin-right 8 :margin-bottom 8} | ||
:customization-color :army | ||
:size 24 | ||
:profile-picture (profile.utils/photo contact) | ||
:full-name (profile.utils/displayed-name contact)}])]]])) |
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
Oops, something went wrong.
removed