新增空动态卡片

新增空动态卡片,当用户没有发布过动态时展示。
This commit is contained in:
2024-09-06 02:11:56 +08:00
parent e936f9cb77
commit 3d315b1ac3

View File

@@ -36,6 +36,8 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material3.DropdownMenu import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
@@ -246,6 +248,9 @@ fun ProfilePage() {
} }
) )
} }
if (moments.itemCount == 0) {
EmptyMomentPostUnit()
}
} }
items(moments.itemCount) { idx -> items(moments.itemCount) { idx ->
@@ -434,14 +439,16 @@ fun UserInformationFollowing(modifier: Modifier, accountProfileEntity: AccountPr
horizontalAlignment = Alignment.End horizontalAlignment = Alignment.End
) { ) {
Text( Text(
modifier = Modifier.padding(bottom = 5.dp).noRippleClickable { modifier = Modifier
navController.navigate( .padding(bottom = 5.dp)
NavigationRoute.FollowingList.route.replace( .noRippleClickable {
"{id}", navController.navigate(
accountProfileEntity.id.toString() NavigationRoute.FollowingList.route.replace(
"{id}",
accountProfileEntity.id.toString()
)
) )
) },
},
text = accountProfileEntity.followingCount.toString(), text = accountProfileEntity.followingCount.toString(),
fontSize = 24.sp, fontSize = 24.sp,
color = Color.Black, color = Color.Black,
@@ -610,6 +617,82 @@ fun RidingStyleItem(styleContent: String) {
} }
} }
@Composable
fun EmptyMomentPostUnit() {
TimeGroup("You haven't left any tracks yet")
ProfileEmptyMomentCard()
}
@Composable
fun ProfileEmptyMomentCard(
) {
var columnHeight by remember { mutableStateOf(0) }
val navController = LocalNavController.current
Column(
modifier = Modifier
.fillMaxWidth()
.padding(start = 24.dp, top = 18.dp, end = 24.dp)
) {
Row(
modifier = Modifier
.fillMaxWidth()
) {
Canvas(
modifier = Modifier
.height(with(LocalDensity.current) { columnHeight.toDp() })
.width(14.dp)
) {
drawLine(
color = Color(0xff899DA9),
start = Offset(0f, 0f),
end = Offset(0f, size.height),
strokeWidth = 4f,
pathEffect = PathEffect.dashPathEffect(floatArrayOf(20f, 20f), 0f)
)
}
Spacer(modifier = Modifier.width(10.dp))
Column(
modifier = Modifier
.weight(1f)
.onGloballyPositioned { coordinates ->
columnHeight = coordinates.size.height
}
) {
Text("Post a moment now", fontSize = 16.sp)
Spacer(modifier = Modifier.height(24.dp))
Box(
modifier = Modifier
.fillMaxWidth()
.aspectRatio(3f / 2f)
.background(Color.White)
.padding(16.dp)
) {
Box(
modifier = Modifier
.fillMaxSize()
.background(Color(0xFFF5F5F5))
.noRippleClickable {
navController.navigate(NavigationRoute.NewPost.route)
}
) {
Icon(
Icons.Default.Add,
tint = Color(0xFFD8D8D8),
contentDescription = "New post",
modifier = Modifier
.size(32.dp)
.align(Alignment.Center)
)
}
}
}
}
}
}
@Composable @Composable
fun MomentPostUnit(momentEntity: MomentEntity) { fun MomentPostUnit(momentEntity: MomentEntity) {
TimeGroup(momentEntity.time.formatPostTime2()) TimeGroup(momentEntity.time.formatPostTime2())