关注和取消关注

This commit is contained in:
2024-10-13 06:18:02 +08:00
parent fab1e0206d
commit 6cb19eb6cf
3 changed files with 19 additions and 7 deletions

View File

@@ -11,6 +11,7 @@ import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.Clear
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@@ -48,15 +49,24 @@ fun OtherProfileAction(
onFollow?.invoke() onFollow?.invoke()
} }
) { ) {
Icon( if (profile.isFollowing) {
Icons.Default.Add, Icon(
contentDescription = "", Icons.Default.Clear,
modifier = Modifier.size(24.dp), contentDescription = "",
tint = if (profile.isFollowing) Color.Black else Color.White modifier = Modifier.size(24.dp),
) tint = Color.Black
)
} else {
Icon(
Icons.Default.Add,
contentDescription = "",
modifier = Modifier.size(24.dp),
tint = Color.White
)
}
Spacer(modifier = Modifier.width(4.dp)) Spacer(modifier = Modifier.width(4.dp))
Text( Text(
text = stringResource(if (profile.isFollowing) R.string.following_upper else R.string.follow_upper), text = stringResource(if (profile.isFollowing) R.string.unfollow_upper else R.string.follow_upper),
fontSize = 14.sp, fontSize = 14.sp,
fontWeight = FontWeight.W600, fontWeight = FontWeight.W600,
color = if (profile.isFollowing) Color.Black else Color.White, color = if (profile.isFollowing) Color.Black else Color.White,

View File

@@ -15,6 +15,7 @@
<string name="favourites_upper">收藏</string> <string name="favourites_upper">收藏</string>
<string name="notifications_upper">消息</string> <string name="notifications_upper">消息</string>
<string name="following_upper">关注中</string> <string name="following_upper">关注中</string>
<string name="unfollow_upper">取消关注</string>
<string name="comment_count">%d条评论</string> <string name="comment_count">%d条评论</string>
<string name="post_comment_hint">说点什么</string> <string name="post_comment_hint">说点什么</string>
<string name="follow_upper">关注</string> <string name="follow_upper">关注</string>

View File

@@ -14,6 +14,7 @@
<string name="favourites_upper">FAVOURITES</string> <string name="favourites_upper">FAVOURITES</string>
<string name="notifications_upper">NOTIFICATIONS</string> <string name="notifications_upper">NOTIFICATIONS</string>
<string name="following_upper">FOLLOWING</string> <string name="following_upper">FOLLOWING</string>
<string name="unfollow_upper">UNFOLLOW</string>
<string name="comment_count">%d Comments</string> <string name="comment_count">%d Comments</string>
<string name="post_comment_hint">Say something...</string> <string name="post_comment_hint">Say something...</string>
<string name="follow_upper">FOLLOW</string> <string name="follow_upper">FOLLOW</string>