feat: show online and rest friends in friends screen
Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
parent
f8af5e4abd
commit
6a7a82636d
|
|
@ -10,27 +10,27 @@ object FriendRequests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getIncomingCount(): Int {
|
|
||||||
return getIncoming().size
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getOutgoing(): List<User> {
|
fun getOutgoing(): List<User> {
|
||||||
return RevoltAPI.userCache.values.filter { user ->
|
return RevoltAPI.userCache.values.filter { user ->
|
||||||
user.relationship == "Outgoing"
|
user.relationship == "Outgoing"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getOutgoingCount(): Int {
|
|
||||||
return getOutgoing().size
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getBlocked(): List<User> {
|
fun getBlocked(): List<User> {
|
||||||
return RevoltAPI.userCache.values.filter { user ->
|
return RevoltAPI.userCache.values.filter { user ->
|
||||||
user.relationship == "Blocked"
|
user.relationship == "Blocked"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getBlockedCount(): Int {
|
fun getOnlineFriends(): List<User> {
|
||||||
return getBlocked().size
|
return RevoltAPI.userCache.values.filter { user ->
|
||||||
|
user.relationship == "Friend" && user.online == true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getFriends(excludeOnline: Boolean = false): List<User> {
|
||||||
|
return RevoltAPI.userCache.values.filter { user ->
|
||||||
|
user.relationship == "Friend" && (excludeOnline && user.online == false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -199,6 +199,78 @@ fun FriendsScreen(useDrawer: Boolean, onDrawerClicked: () -> Unit) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stickyHeader(key = "online") {
|
||||||
|
Text(
|
||||||
|
text = AnnotatedString.Builder().apply {
|
||||||
|
pushStyle(SpanStyle(fontWeight = FontWeight.Bold))
|
||||||
|
append(stringResource(id = R.string.status_online))
|
||||||
|
pop()
|
||||||
|
|
||||||
|
pushStyle(
|
||||||
|
SpanStyle(
|
||||||
|
fontWeight = FontWeight.Medium,
|
||||||
|
fontSize = LocalTextStyle.current.fontSize * 0.8,
|
||||||
|
color = LocalContentColor.current.copy(alpha = 0.6f)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
append("—${FriendRequests.getOnlineFriends().size}")
|
||||||
|
pop()
|
||||||
|
}.toAnnotatedString(),
|
||||||
|
style = MaterialTheme.typography.labelLarge,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.background(MaterialTheme.colorScheme.background)
|
||||||
|
.padding(10.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
items(FriendRequests.getOnlineFriends().size) {
|
||||||
|
val item = FriendRequests.getOnlineFriends()[it]
|
||||||
|
UserItem(item, onClick = {
|
||||||
|
scope.launch {
|
||||||
|
item.id?.let { userId ->
|
||||||
|
ActionChannel.send(Action.OpenUserSheet(userId, null))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
stickyHeader(key = "not_online") {
|
||||||
|
Text(
|
||||||
|
text = AnnotatedString.Builder().apply {
|
||||||
|
pushStyle(SpanStyle(fontWeight = FontWeight.Bold))
|
||||||
|
append(stringResource(id = R.string.friends_all))
|
||||||
|
pop()
|
||||||
|
|
||||||
|
pushStyle(
|
||||||
|
SpanStyle(
|
||||||
|
fontWeight = FontWeight.Medium,
|
||||||
|
fontSize = LocalTextStyle.current.fontSize * 0.8,
|
||||||
|
color = LocalContentColor.current.copy(alpha = 0.6f)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
append("—${FriendRequests.getFriends(true).size}")
|
||||||
|
pop()
|
||||||
|
}.toAnnotatedString(),
|
||||||
|
style = MaterialTheme.typography.labelLarge,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.background(MaterialTheme.colorScheme.background)
|
||||||
|
.padding(10.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
items(FriendRequests.getFriends(true).size) {
|
||||||
|
val item = FriendRequests.getFriends(true)[it]
|
||||||
|
UserItem(item, onClick = {
|
||||||
|
scope.launch {
|
||||||
|
item.id?.let { userId ->
|
||||||
|
ActionChannel.send(Action.OpenUserSheet(userId, null))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
stickyHeader(key = "blocked") {
|
stickyHeader(key = "blocked") {
|
||||||
Text(
|
Text(
|
||||||
text = AnnotatedString.Builder().apply {
|
text = AnnotatedString.Builder().apply {
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,7 @@
|
||||||
<string name="friends">Friends</string>
|
<string name="friends">Friends</string>
|
||||||
<string name="friends_incoming_requests">Incoming Requests</string>
|
<string name="friends_incoming_requests">Incoming Requests</string>
|
||||||
<string name="friends_outgoing_requests">Outgoing Requests</string>
|
<string name="friends_outgoing_requests">Outgoing Requests</string>
|
||||||
|
<string name="friends_all">All</string>
|
||||||
<string name="friends_blocked">Blocked</string>
|
<string name="friends_blocked">Blocked</string>
|
||||||
<string name="friends_deny_all_incoming">Clear all incoming requests</string>
|
<string name="friends_deny_all_incoming">Clear all incoming requests</string>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue