Skip to content

Commit f7498ef

Browse files
authored
Implement Contact Request flow in Contact Profile (#19039)
* chore: add send-contact-request to i18n translations * feature: add send-contact-request button on contact profile * chore: prop drill full-name and profile-picture for the context-tag inside drawer-top component * chore: add english translation for contact-request-message-prompt text * feature: integrate contact-request sheet * tidy: subscribe to contact data inside contact-request view * tidy: wrap callback with use-callback * tweak: hide contact-request button if contact-request is already sent
1 parent f1834c6 commit f7498ef

File tree

6 files changed

+93
-8
lines changed

6 files changed

+93
-8
lines changed

src/quo/components/drawers/drawer_top/view.cljs

+13-6
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@
7676
(str description " · " (i18n/label :t/on-device))])
7777

7878
(defn- context-tag-subtitle
79-
[{:keys [context-tag-type community-logo community-name account-name emoji customization-color]}]
79+
[{:keys [context-tag-type community-logo community-name account-name emoji customization-color
80+
full-name profile-picture]}]
8081
(let [tag-type (or context-tag-type :account)]
8182
[rn/view
8283
{:accessibility-label :context-tag-wrapper
@@ -88,7 +89,9 @@
8889
:community-name community-name
8990
:community-logo community-logo
9091
:size 24
91-
:customization-color customization-color}]]))
92+
:customization-color customization-color
93+
:profile-picture profile-picture
94+
:full-name full-name}]]))
9295

9396
(defn- description-subtitle
9497
[{:keys [theme blur? description]}]
@@ -100,7 +103,7 @@
100103

101104
(defn- subtitle
102105
[{:keys [type theme blur? keycard? networks description community-name community-logo
103-
context-tag-type account-name emoji customization-color]}]
106+
context-tag-type account-name emoji customization-color full-name profile-picture]}]
104107
(cond
105108
(= :keypair type)
106109
[keypair-subtitle
@@ -128,7 +131,9 @@
128131
:community-name community-name
129132
:account-name account-name
130133
:emoji emoji
131-
:customization-color customization-color}]
134+
:customization-color customization-color
135+
:profile-picture profile-picture
136+
:full-name full-name}]
132137

133138
(and (not= :label type) description)
134139
[description-subtitle
@@ -187,7 +192,7 @@
187192
on-button-press
188193
on-button-long-press
189194
button-disabled? account-avatar-emoji account-avatar-type customization-color icon-avatar
190-
profile-picture keycard? networks label]}]
195+
profile-picture keycard? networks label full-name]}]
191196
[rn/view {:style style/container}
192197
(when (left-image-supported-types type)
193198
[rn/view {:style style/left-container}
@@ -218,7 +223,9 @@
218223
:context-tag-type context-tag-type
219224
:customization-color customization-color
220225
:account-name account-name
221-
:emoji emoji}]]
226+
:emoji emoji
227+
:full-name full-name
228+
:profile-picture profile-picture}]]
222229
[right-icon
223230
{:theme theme
224231
:type type
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
(ns status-im.contexts.profile.contact.contact-request.style)
2+
3+
(def message-prompt-wrapper
4+
{:padding-top 4
5+
:padding-bottom 8
6+
:padding-horizontal 20})
7+
8+
(def message-input-wrapper
9+
{:padding-vertical 8
10+
:padding-horizontal 20})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
(ns status-im.contexts.profile.contact.contact-request.view
2+
(:require [clojure.string :as string]
3+
[quo.core :as quo]
4+
[react-native.core :as rn]
5+
[status-im.contexts.profile.contact.contact-request.style :as style]
6+
[status-im.contexts.profile.utils :as profile.utils]
7+
[utils.i18n :as i18n]
8+
[utils.re-frame :as rf]))
9+
10+
(defn view
11+
[]
12+
(let [{:keys [public-key customization-color]
13+
:as profile} (rf/sub [:contacts/current-contact])
14+
;; TODO: remove :blue when #18733 merged.
15+
customization-color (or customization-color :blue)
16+
full-name (profile.utils/displayed-name profile)
17+
profile-picture (profile.utils/photo profile)
18+
[message set-message] (rn/use-state "")
19+
on-message-change (rn/use-callback #(set-message %))
20+
on-message-submit (rn/use-callback (fn []
21+
(rf/dispatch [:hide-bottom-sheet])
22+
(rf/dispatch [:contact.ui/send-contact-request
23+
public-key message]))
24+
[public-key message])]
25+
[:<>
26+
[quo/drawer-top
27+
{:type :context-tag
28+
:context-tag-type :default
29+
:title (i18n/label :t/send-contact-request)
30+
:full-name full-name
31+
:profile-picture profile-picture
32+
:customization-color customization-color}]
33+
[rn/text {:style style/message-prompt-wrapper}
34+
(i18n/label :t/contact-request-message-prompt)]
35+
[rn/view {:style style/message-input-wrapper}
36+
[quo/input
37+
{:type :text
38+
:multiline? true
39+
:char-limit 280
40+
:label (i18n/label :t/message)
41+
:on-change-text on-message-change}]]
42+
[quo/bottom-actions
43+
{:actions :one-action
44+
:button-one-props {:disabled? (string/blank? message)
45+
:on-press on-message-submit}
46+
:button-one-label (i18n/label :t/send-contact-request)}]]))

src/status_im/contexts/profile/contact/header/style.cljs

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
:padding-left 20
88
:align-items :flex-start})
99

10+
(def button-wrapper
11+
{:padding-top 8
12+
:padding-bottom 16
13+
:padding-horizontal 20})
14+
1015
(defn header-container
1116
[border-radius theme margin-top]
1217
(reanimated/apply-animations-to-style

src/status_im/contexts/profile/contact/header/view.cljs

+17-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
[quo.foundations.colors :as colors]
44
[quo.theme]
55
[react-native.core :as rn]
6+
[status-im.common.not-implemented]
67
[status-im.common.scalable-avatar.view :as avatar]
78
[status-im.constants :as constants]
9+
[status-im.contexts.profile.contact.contact-request.view :as contact-request]
810
[status-im.contexts.profile.contact.header.style :as style]
911
[status-im.contexts.profile.utils :as profile.utils]
1012
[utils.i18n :as i18n]
@@ -19,7 +21,9 @@
1921
full-name (profile.utils/displayed-name profile)
2022
profile-picture (profile.utils/photo profile)
2123
online? (rf/sub [:visibility-status-updates/online? public-key])
22-
theme (quo.theme/use-theme-value)]
24+
theme (quo.theme/use-theme-value)
25+
on-contact-request (rn/use-callback #(rf/dispatch [:show-bottom-sheet
26+
{:content (fn [] [contact-request/view])}]))]
2327
[rn/view {:style style/header-container}
2428
[rn/view {:style style/header-top-wrapper}
2529
[rn/view {:style style/avatar-wrapper}
@@ -40,4 +44,15 @@
4044
{:title full-name
4145
:description :text
4246
:description-text bio
43-
:emoji-dash emoji-hash}]]))
47+
:emoji-dash emoji-hash}]
48+
49+
(cond
50+
(or (not contact-request-state)
51+
(= contact-request-state constants/contact-request-state-none))
52+
[rn/view {:style style/button-wrapper}
53+
[quo/button
54+
{:on-press on-contact-request
55+
:icon-left :i/add-user}
56+
(i18n/label :t/send-contact-request)]]
57+
58+
:else nil)]))

translations/en.json

+2
Original file line numberDiff line numberDiff line change
@@ -1978,12 +1978,14 @@
19781978
"new-ui": "New UI",
19791979
"send-contact-request-message": "To start a chat you need to become contacts",
19801980
"contact-request": "Contact request",
1981+
"send-contact-request": "Send contact request",
19811982
"contact-request-sent-to": "Contact request sent to",
19821983
"contact-request-was-accepted": "Contact request accepted",
19831984
"contact-request-is-now-a-contact": "is now a contact",
19841985
"contact-request-removed-you-as-contact": "removed you as a contact",
19851986
"contact-request-removed-as-contact": "removed as a contact",
19861987
"contact-requests": "Contact requests",
1988+
"contact-request-message-prompt": "Why should they accept your request?",
19871989
"say-hi": "Say hi",
19881990
"opened": "Opened",
19891991
"accepted": "Accepted",

0 commit comments

Comments
 (0)