Skip to content

Commit

Permalink
Adds support for pronouns when the user makes them available.
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorpamplona committed Nov 21, 2024
1 parent b3e3b70 commit 4a80a16
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,7 @@ class Account(
picture: String? = null,
banner: String? = null,
website: String? = null,
pronouns: String? = null,
about: String? = null,
nip05: String? = null,
lnAddress: String? = null,
Expand All @@ -1165,6 +1166,7 @@ class Account(
picture = picture,
banner = banner,
website = website,
pronouns = pronouns,
about = about,
nip05 = nip05,
lnAddress = lnAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,22 @@ fun NewUserMetadataView(

Spacer(modifier = Modifier.height(10.dp))

OutlinedTextField(
label = { Text(text = stringRes(R.string.pronouns)) },
modifier = Modifier.fillMaxWidth(),
value = postViewModel.pronouns.value,
onValueChange = { postViewModel.pronouns.value = it },
placeholder = {
Text(
text = "they/them, ...",
color = MaterialTheme.colorScheme.placeholderText,
)
},
singleLine = true,
)

Spacer(modifier = Modifier.height(10.dp))

OutlinedTextField(
label = { Text(text = stringRes(R.string.website_url)) },
modifier = Modifier.fillMaxWidth(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class NewUserMetadataViewModel : ViewModel() {
val banner = mutableStateOf("")

val website = mutableStateOf("")
val pronouns = mutableStateOf("")
val nip05 = mutableStateOf("")
val lnAddress = mutableStateOf("")
val lnURL = mutableStateOf("")
Expand All @@ -72,6 +73,7 @@ class NewUserMetadataViewModel : ViewModel() {
picture.value = it.info?.picture ?: ""
banner.value = it.info?.banner ?: ""
website.value = it.info?.website ?: ""
pronouns.value = it.info?.pronouns ?: ""
nip05.value = it.info?.nip05 ?: ""
lnAddress.value = it.info?.lud16 ?: ""
lnURL.value = it.info?.lud06 ?: ""
Expand Down Expand Up @@ -99,6 +101,7 @@ class NewUserMetadataViewModel : ViewModel() {
picture = picture.value,
banner = banner.value,
website = website.value,
pronouns = pronouns.value,
about = about.value,
nip05 = nip05.value,
lnAddress = lnAddress.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,14 @@ private fun DrawAdditionalInfo(
fontSize = 25.sp,
)
Spacer(StdHorzSpacer)
user.info?.pronouns.let {
Text(
text = "($it)",
modifier = Modifier,
)
Spacer(StdHorzSpacer)
}

DrawPlayName(it)
}
}
Expand Down
1 change: 1 addition & 0 deletions amethyst/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
<string name="avatar_url">Avatar URL</string>
<string name="banner_url">Banner URL</string>
<string name="website_url">Website URL</string>
<string name="pronouns">Pronouns</string>
<string name="ln_address">LN Address</string>
<string name="ln_url_outdated">LN URL (outdated)</string>
<string name="save_to_gallery">Save to Gallery</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ class UserMetadata {
var website: String? = null
var about: String? = null
var bot: Boolean? = null
var pronouns: String? = null

var nip05: String? = null
var nip05Verified: Boolean = false
Expand Down Expand Up @@ -471,6 +472,7 @@ class UserMetadata {
if (username?.isNotEmpty() == true) username = username?.trim()
if (lud06?.isNotEmpty() == true) lud06 = lud06?.trim()
if (lud16?.isNotEmpty() == true) lud16 = lud16?.trim()
if (pronouns?.isNotEmpty() == true) pronouns = pronouns?.trim()

if (banner?.isNotEmpty() == true) banner = banner?.trim()
if (website?.isNotEmpty() == true) website = website?.trim()
Expand All @@ -487,6 +489,7 @@ class UserMetadata {
if (banner?.isBlank() == true) banner = null
if (website?.isBlank() == true) website = null
if (domain?.isBlank() == true) domain = null
if (pronouns?.isBlank() == true) pronouns = null
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ class MetadataEvent(
nip05: String?,
lnAddress: String?,
lnURL: String?,
pronouns: String?,
twitter: String?,
mastodon: String?,
github: String?,
Expand All @@ -231,6 +232,7 @@ class MetadataEvent(
picture?.let { addIfNotBlank(currentJson, "picture", it.trim()) }
banner?.let { addIfNotBlank(currentJson, "banner", it.trim()) }
website?.let { addIfNotBlank(currentJson, "website", it.trim()) }
pronouns?.let { addIfNotBlank(currentJson, "pronouns", it.trim()) }
about?.let { addIfNotBlank(currentJson, "about", it.trim()) }
nip05?.let { addIfNotBlank(currentJson, "nip05", it.trim()) }
lnAddress?.let { addIfNotBlank(currentJson, "lud16", it.trim()) }
Expand Down

0 comments on commit 4a80a16

Please sign in to comment.