修正展示用户搜索结果时的布局错误

This commit is contained in:
2024-10-12 10:30:46 +08:00
parent dee954ef5e
commit 723adf52c2
2 changed files with 42 additions and 26 deletions

View File

@@ -44,6 +44,7 @@ fun ActionButton(
loadingBackgroundColor: Color = Color(0xFFD95757), loadingBackgroundColor: Color = Color(0xFFD95757),
disabledBackgroundColor: Color = Color(0xFFD0D0D0), disabledBackgroundColor: Color = Color(0xFFD0D0D0),
enabled: Boolean = true, enabled: Boolean = true,
fullWidth:Boolean = false,
click: () -> Unit = {} click: () -> Unit = {}
) { ) {
val animatedBackgroundColor by animateColorAsState( val animatedBackgroundColor by animateColorAsState(
@@ -76,7 +77,13 @@ fun ActionButton(
Box( Box(
modifier = Modifier modifier = Modifier
.align(Alignment.Center) .align(Alignment.Center)
.fillMaxWidth(), .let {
if(fullWidth){
it.fillMaxWidth()
}else{
it
}
},
contentAlignment = Alignment.Center contentAlignment = Alignment.Center
) { ) {
Box(modifier = Modifier.align(Alignment.CenterStart)){ Box(modifier = Modifier.align(Alignment.CenterStart)){
@@ -93,7 +100,13 @@ fun ActionButton(
}else{ }else{
Box( Box(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .let {
if(fullWidth){
it.fillMaxWidth()
}else{
it
}
}
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp),
contentAlignment = Alignment.Center contentAlignment = Alignment.Center
) { ) {

View File

@@ -16,6 +16,7 @@ import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.systemBars import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.pager.HorizontalPager import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.PagerState import androidx.compose.foundation.pager.PagerState
@@ -322,7 +323,7 @@ fun UserItem(
modifier = Modifier.weight(1f) modifier = Modifier.weight(1f)
) { ) {
Text(text = accountProfile.nickName, fontSize = 16.sp, fontWeight = FontWeight.Bold) Text(text = accountProfile.nickName, fontSize = 16.sp, fontWeight = FontWeight.Bold)
Spacer(modifier = Modifier.padding(2.dp)) Spacer(modifier = Modifier.width(2.dp))
Text( Text(
text = stringResource( text = stringResource(
R.string.search_user_item_follower_count, R.string.search_user_item_follower_count,
@@ -330,14 +331,18 @@ fun UserItem(
), fontSize = 14.sp, color = Color(0xFF9E9E9E) ), fontSize = 14.sp, color = Color(0xFF9E9E9E)
) )
} }
Spacer(modifier = Modifier.padding(8.dp)) Spacer(modifier = Modifier.width(16.dp))
Box(
modifier = Modifier
) {
if (accountProfile.id != AppState.UserId) { if (accountProfile.id != AppState.UserId) {
if (accountProfile.isFollowing) { if (accountProfile.isFollowing) {
ActionButton( ActionButton(
text = stringResource(R.string.following_upper), text = stringResource(R.string.following_upper),
backgroundColor = Color(0xFF9E9E9E), backgroundColor = Color(0xFF9E9E9E),
contentPadding = PaddingValues(vertical = 4.dp, horizontal = 8.dp), contentPadding = PaddingValues(vertical = 4.dp, horizontal = 8.dp),
color = Color.White color = Color.White,
fullWidth = false
) { ) {
onFollow(accountProfile) onFollow(accountProfile)
} }
@@ -346,16 +351,14 @@ fun UserItem(
text = stringResource(R.string.follow_upper), text = stringResource(R.string.follow_upper),
backgroundColor = Color(0xffda3832), backgroundColor = Color(0xffda3832),
contentPadding = PaddingValues(vertical = 4.dp, horizontal = 8.dp), contentPadding = PaddingValues(vertical = 4.dp, horizontal = 8.dp),
color = Color.White color = Color.White,
fullWidth = false
) { ) {
onFollow(accountProfile) onFollow(accountProfile)
} }
} }
} }
}
}
}
} }
} }