Make some visual changes to the add/remove user button, and move the add callback to the right place.
This commit is contained in:
+43
-31
@@ -21,7 +21,7 @@
|
|||||||
package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile
|
package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile
|
||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import androidx.compose.animation.animateContentSize
|
import android.util.Log
|
||||||
import androidx.compose.animation.core.tween
|
import androidx.compose.animation.core.tween
|
||||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
@@ -65,7 +65,6 @@ import androidx.compose.material.icons.filled.ArrowDropDown
|
|||||||
import androidx.compose.material.icons.filled.ArrowDropUp
|
import androidx.compose.material.icons.filled.ArrowDropUp
|
||||||
import androidx.compose.material.icons.filled.ContentCopy
|
import androidx.compose.material.icons.filled.ContentCopy
|
||||||
import androidx.compose.material.icons.filled.Delete
|
import androidx.compose.material.icons.filled.Delete
|
||||||
import androidx.compose.material.icons.filled.Done
|
|
||||||
import androidx.compose.material.icons.filled.EditNote
|
import androidx.compose.material.icons.filled.EditNote
|
||||||
import androidx.compose.material.icons.filled.Link
|
import androidx.compose.material.icons.filled.Link
|
||||||
import androidx.compose.material.icons.filled.MoreVert
|
import androidx.compose.material.icons.filled.MoreVert
|
||||||
@@ -76,7 +75,6 @@ import androidx.compose.material3.ButtonDefaults
|
|||||||
import androidx.compose.material3.DropdownMenu
|
import androidx.compose.material3.DropdownMenu
|
||||||
import androidx.compose.material3.DropdownMenuItem
|
import androidx.compose.material3.DropdownMenuItem
|
||||||
import androidx.compose.material3.FilterChip
|
import androidx.compose.material3.FilterChip
|
||||||
import androidx.compose.material3.FilterChipDefaults
|
|
||||||
import androidx.compose.material3.HorizontalDivider
|
import androidx.compose.material3.HorizontalDivider
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
@@ -934,7 +932,10 @@ private fun ProfileActions(
|
|||||||
userHex = baseUser.pubkeyHex,
|
userHex = baseUser.pubkeyHex,
|
||||||
followLists = tempFollowLists,
|
followLists = tempFollowLists,
|
||||||
addUser = { index, list ->
|
addUser = { index, list ->
|
||||||
list.members.add(baseUser.pubkeyHex)
|
Log.d("Amethyst", "ProfileActions: Updating list ...")
|
||||||
|
val newList = list.memberList + baseUser.pubkeyHex
|
||||||
|
tempFollowLists[index] = tempFollowLists[index].copy(memberList = newList)
|
||||||
|
println("Updated List.")
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -1089,12 +1090,12 @@ fun FollowSetsActionMenu(
|
|||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
listHeader = list.name,
|
listHeader = list.name,
|
||||||
listIsPublic = !list.isPrivate,
|
listIsPublic = !list.isPrivate,
|
||||||
isUserInList = list.members.contains(userHex),
|
isUserInList = list.memberList.contains(userHex),
|
||||||
) {
|
) {
|
||||||
println("List contains user -> ${list.members.contains(userHex)}")
|
println("List contains user -> ${list.memberList.contains(userHex)}")
|
||||||
println("Adding user to List -> ${list.name}")
|
println("Adding user to List -> ${list.name}")
|
||||||
addUser(index, list)
|
addUser(index, list)
|
||||||
println("List contains user -> ${list.members.contains(userHex)}")
|
println("List contains user -> ${list.memberList.contains(userHex)}")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onClick = {},
|
onClick = {},
|
||||||
@@ -1122,16 +1123,14 @@ private fun DropDownMenuHeader(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class FollowInfo(
|
data class FollowInfo(
|
||||||
val name: String,
|
val name: String,
|
||||||
val isPrivate: Boolean,
|
val isPrivate: Boolean,
|
||||||
memberList: MutableList<String> = mutableListOf(),
|
val memberList: List<String> = listOf(),
|
||||||
) {
|
)
|
||||||
var members = memberList
|
|
||||||
}
|
|
||||||
|
|
||||||
fun generateFollowLists(): List<FollowInfo> =
|
fun generateFollowLists(): List<FollowInfo> =
|
||||||
(1..10).map { index: Int ->
|
List(10) { index: Int ->
|
||||||
FollowInfo(
|
FollowInfo(
|
||||||
name = "List No $index",
|
name = "List No $index",
|
||||||
isPrivate = index % 2 == 0,
|
isPrivate = index % 2 == 0,
|
||||||
@@ -1149,26 +1148,26 @@ fun FollowSetItem(
|
|||||||
Row(
|
Row(
|
||||||
modifier =
|
modifier =
|
||||||
modifier
|
modifier
|
||||||
|
// .clickable(onClick = onAddUser)
|
||||||
.border(
|
.border(
|
||||||
width = Dp.Hairline,
|
width = Dp.Hairline,
|
||||||
color = Color.Gray,
|
color = Color.Gray,
|
||||||
shape = RoundedCornerShape(percent = 20),
|
shape = RoundedCornerShape(percent = 20),
|
||||||
).padding(all = 10.dp)
|
).padding(all = 10.dp),
|
||||||
.clickable(onClick = onAddUser),
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
if (isUserInList) {
|
// if (isUserInList) {
|
||||||
Column(
|
// Column(
|
||||||
modifier = Modifier.animateContentSize(),
|
// modifier = Modifier.animateContentSize(),
|
||||||
verticalArrangement = Arrangement.spacedBy(5.dp),
|
// verticalArrangement = Arrangement.spacedBy(5.dp),
|
||||||
) {
|
// ) {
|
||||||
Icon(
|
// Icon(
|
||||||
imageVector = Icons.Filled.Done,
|
// imageVector = Icons.Filled.Done,
|
||||||
contentDescription = "Done icon",
|
// contentDescription = "Done icon",
|
||||||
modifier = Modifier.size(FilterChipDefaults.IconSize),
|
// modifier = Modifier.size(FilterChipDefaults.IconSize),
|
||||||
)
|
// )
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
Column(
|
Column(
|
||||||
modifier = modifier.weight(1f),
|
modifier = modifier.weight(1f),
|
||||||
verticalArrangement = Arrangement.Center,
|
verticalArrangement = Arrangement.Center,
|
||||||
@@ -1198,16 +1197,18 @@ fun FollowSetItem(
|
|||||||
)
|
)
|
||||||
Spacer(modifier = StdHorzSpacer)
|
Spacer(modifier = StdHorzSpacer)
|
||||||
AssistChip(
|
AssistChip(
|
||||||
onClick = {},
|
onClick = {
|
||||||
|
onAddUser()
|
||||||
|
},
|
||||||
label = {
|
label = {
|
||||||
Text(text = if (isUserInList) "Delete" else "Add")
|
Text(text = if (isUserInList) "Remove" else "Add")
|
||||||
},
|
},
|
||||||
leadingIcon = {
|
leadingIcon = {
|
||||||
if (isUserInList) {
|
if (isUserInList) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Filled.Delete,
|
imageVector = Icons.Filled.Delete,
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
tint = MaterialTheme.colorScheme.onError,
|
tint = MaterialTheme.colorScheme.onBackground,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
Icon(
|
Icon(
|
||||||
@@ -1222,11 +1223,22 @@ fun FollowSetItem(
|
|||||||
AssistChipDefaults.assistChipColors(
|
AssistChipDefaults.assistChipColors(
|
||||||
containerColor =
|
containerColor =
|
||||||
if (isUserInList) {
|
if (isUserInList) {
|
||||||
MaterialTheme.colorScheme.errorContainer
|
Color.Red.copy(alpha = 0.5f)
|
||||||
} else {
|
} else {
|
||||||
MaterialTheme.colorScheme.primary
|
MaterialTheme.colorScheme.primary
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
border =
|
||||||
|
AssistChipDefaults
|
||||||
|
.assistChipBorder(
|
||||||
|
enabled = true,
|
||||||
|
borderColor =
|
||||||
|
if (!isUserInList) {
|
||||||
|
MaterialTheme.colorScheme.primary
|
||||||
|
} else {
|
||||||
|
MaterialTheme.colorScheme.error
|
||||||
|
},
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user