Skip to content

Commit

Permalink
[mod] #72 modfiy following, follower UI
Browse files Browse the repository at this point in the history
  • Loading branch information
seohee0925 committed Jul 15, 2024
1 parent e3bd0f6 commit 14d25b3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,16 @@ fun EmptyFollowerScreen() {
Image(
painter = painterResource(com.record.designsystem.R.drawable.img_no_follower),
contentDescription = null,
modifier = Modifier.weight(10f)
modifier = Modifier
.weight(10f)
.aspectRatio(1f),
)
Spacer(modifier = Modifier.weight(13f))
}

Spacer(modifier = Modifier.size(32.dp))
Text(
text = "아직 팔로우하는 사람이 없어요",
text = "아직 팔로워가 없어요",
style = RecordyTheme.typography.emptybody,
color = RecordyTheme.colors.white,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.record.designsystem.component.container.UserDataContainer
Expand All @@ -22,7 +25,7 @@ fun FollowingRoute(
modifier: Modifier = Modifier,
viewModel: FollowViewModel = hiltViewModel(),
) {
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
val followState by viewModel.uiState.collectAsStateWithLifecycle()

LaunchedEffectWithLifecycle(Unit) {
viewModel.sideEffect.collectLatest { sideEffect ->
Expand All @@ -42,29 +45,37 @@ fun FollowingRoute(
.background(RecordyTheme.colors.background)
.padding(padding),
) {
if (uiState.followingList.isEmpty()) {
EmptyFollowingScreen()
} else {
FollowScreen(
followingList = uiState.followingList,
onClick = { user ->
viewModel.toggleFollow(user)
},
)
}
DefaultProfileScreen(followState, viewModel::toggleFollow)
}
}

@Composable
fun EmptyFollowingScreen() {
UserDataContainer(
user = UserData(
fun DefaultProfileScreen(followState: FollowState, onclickEvent: (UserData) -> Unit) {
val defaultUser =
UserData(
id = 0,
profileImageResId = com.record.designsystem.R.drawable.img_profile,
name = "유영",
isFollowing = false,
),
onClick = {},
showFollowButton = false,
)
)

val sortedList = listOf(defaultUser) + followState.followingList

LazyColumn {
items(sortedList) { user ->
UserDataContainer(
user = user,
onClick = { onclickEvent(user) },
showFollowButton = user.name != "유영",
)
}
}
}

@Preview
@Composable
fun DefaultProfileScreenPreview() {
RecordyTheme {
DefaultProfileScreen(FollowState(), onclickEvent = {})
}
}

0 comments on commit 14d25b3

Please sign in to comment.