@@ -26,6 +26,8 @@ import {Text} from '#/components/Typography'
26
26
import { useSimpleVerificationState } from '#/components/verification'
27
27
28
28
const DISPLAY_NAME_MAX_GRAPHEMES = 64
29
+ const PRONOUNS_MAX_GRAPHEMES = 50
30
+ const WEBSITE_MAX_GRAPHEMES = 300
29
31
const DESCRIPTION_MAX_GRAPHEMES = 256
30
32
31
33
const SCREEN_HEIGHT = Dimensions . get ( 'window' ) . height
@@ -115,6 +117,12 @@ function DialogInner({
115
117
const [ displayName , setDisplayName ] = useState ( initialDisplayName )
116
118
const initialDescription = profile . description || ''
117
119
const [ description , setDescription ] = useState ( initialDescription )
120
+ const initialPronouns = ''
121
+ const [ pronouns , setPronouns ] = useState ( initialPronouns )
122
+ const initialWebsite = ''
123
+ const [ website , setWebsite ] = useState ( initialWebsite )
124
+ const initialLocation = ''
125
+ const [ location , setLocation ] = useState ( initialLocation )
118
126
const [ userBanner , setUserBanner ] = useState < string | undefined | null > (
119
127
profile . banner ,
120
128
)
@@ -131,6 +139,9 @@ function DialogInner({
131
139
const dirty =
132
140
displayName !== initialDisplayName ||
133
141
description !== initialDescription ||
142
+ pronouns !== initialPronouns ||
143
+ website !== initialWebsite ||
144
+ location !== initialLocation ||
134
145
userAvatar !== profile . avatar ||
135
146
userBanner !== profile . banner
136
147
@@ -209,6 +220,15 @@ function DialogInner({
209
220
text : displayName ,
210
221
maxCount : DISPLAY_NAME_MAX_GRAPHEMES ,
211
222
} )
223
+ const pronounsTooLong = useWarnMaxGraphemeCount ( {
224
+ text : pronouns ,
225
+ maxCount : PRONOUNS_MAX_GRAPHEMES ,
226
+ } )
227
+ const websiteTooLong = useWarnMaxGraphemeCount ( {
228
+ text : website ,
229
+ maxCount : WEBSITE_MAX_GRAPHEMES ,
230
+ } )
231
+ const websiteInvalidFormat = ! ! ( website && ! website . match ( / ^ h t t p s ? : \/ \/ .+ / ) )
212
232
const descriptionTooLong = useWarnMaxGraphemeCount ( {
213
233
text : description ,
214
234
maxCount : DESCRIPTION_MAX_GRAPHEMES ,
@@ -241,7 +261,10 @@ function DialogInner({
241
261
! dirty ||
242
262
isUpdatingProfile ||
243
263
displayNameTooLong ||
244
- descriptionTooLong
264
+ descriptionTooLong ||
265
+ pronounsTooLong ||
266
+ websiteTooLong ||
267
+ websiteInvalidFormat
245
268
}
246
269
size = "small"
247
270
color = "primary"
@@ -262,6 +285,9 @@ function DialogInner({
262
285
isUpdatingProfile ,
263
286
displayNameTooLong ,
264
287
descriptionTooLong ,
288
+ pronounsTooLong ,
289
+ websiteTooLong ,
290
+ websiteInvalidFormat ,
265
291
] ,
266
292
)
267
293
@@ -389,6 +415,90 @@ function DialogInner({
389
415
</ Text >
390
416
) }
391
417
</ View >
418
+
419
+ < View >
420
+ < TextField . LabelText >
421
+ < Trans > Pronouns</ Trans >
422
+ </ TextField . LabelText >
423
+ < TextField . Root isInvalid = { pronounsTooLong } >
424
+ < Dialog . Input
425
+ defaultValue = { pronouns }
426
+ onChangeText = { setPronouns }
427
+ label = { _ ( msg `Pronouns` ) }
428
+ placeholder = { _ ( msg `Pronouns` ) }
429
+ testID = "editProfilePronounsInput"
430
+ />
431
+ </ TextField . Root >
432
+ { pronounsTooLong && (
433
+ < Text
434
+ style = { [
435
+ a . text_sm ,
436
+ a . mt_xs ,
437
+ a . font_bold ,
438
+ { color : t . palette . negative_400 } ,
439
+ ] } >
440
+ < Plural
441
+ value = { PRONOUNS_MAX_GRAPHEMES }
442
+ other = "The maximum number of characters is #."
443
+ />
444
+ </ Text >
445
+ ) }
446
+ </ View >
447
+
448
+ < View >
449
+ < TextField . LabelText >
450
+ < Trans > Website</ Trans >
451
+ </ TextField . LabelText >
452
+ < TextField . Root isInvalid = { websiteTooLong || websiteInvalidFormat } >
453
+ < Dialog . Input
454
+ defaultValue = { website }
455
+ onChangeText = { setWebsite }
456
+ label = { _ ( msg `Website` ) }
457
+ placeholder = { _ ( msg `URL` ) }
458
+ testID = "editProfileWebsiteInput"
459
+ />
460
+ </ TextField . Root >
461
+ { websiteTooLong && (
462
+ < Text
463
+ style = { [
464
+ a . text_sm ,
465
+ a . mt_xs ,
466
+ a . font_bold ,
467
+ { color : t . palette . negative_400 } ,
468
+ ] } >
469
+ < Plural
470
+ value = { WEBSITE_MAX_GRAPHEMES }
471
+ other = "Website is too long. The maximum number of characters is #."
472
+ />
473
+ </ Text >
474
+ ) }
475
+ { websiteInvalidFormat && (
476
+ < Text
477
+ style = { [
478
+ a . text_sm ,
479
+ a . mt_xs ,
480
+ a . font_bold ,
481
+ { color : t . palette . negative_400 } ,
482
+ ] } >
483
+ < Trans > Website must start with http:// or https://</ Trans >
484
+ </ Text >
485
+ ) }
486
+ </ View >
487
+
488
+ < View >
489
+ < TextField . LabelText >
490
+ < Trans > Location</ Trans >
491
+ </ TextField . LabelText >
492
+ < TextField . Root >
493
+ < Dialog . Input
494
+ defaultValue = { location }
495
+ onChangeText = { setLocation }
496
+ label = { _ ( msg `Location` ) }
497
+ placeholder = { _ ( msg `Location` ) }
498
+ testID = "editProfileLocationInput"
499
+ />
500
+ </ TextField . Root >
501
+ </ View >
392
502
</ View >
393
503
</ Dialog . ScrollableInner >
394
504
)
0 commit comments