feat(profile): update layout to have scrolling header

This commit is contained in:
Diego Beraldin 2023-08-10 20:44:32 +02:00
parent 4ebf2858e2
commit 67c074b42c
4 changed files with 81 additions and 11 deletions

View File

@ -35,22 +35,14 @@ internal class ProfileLoggedScreen(
model.bindToLifecycle(key)
val uiState by model.uiState.collectAsState()
ProfileLoggedHeader(user = user)
ProfileLoggedCounters(user = user)
SectionSelector(
modifier = Modifier.padding(vertical = Spacing.xxs),
currentSection = uiState.currentTab,
onSectionSelected = {
model.reduce(ProfileLoggedMviModel.Intent.SelectTab(it))
},
)
when (uiState.currentTab) {
ProfileLoggedSection.POSTS -> {
ProfilePostsScreen(
modifier = Modifier.weight(1f).fillMaxWidth(),
user = user,
onSectionSelected = {
model.reduce(ProfileLoggedMviModel.Intent.SelectTab(it))
},
).Content()
}
@ -58,6 +50,9 @@ internal class ProfileLoggedScreen(
ProfileCommentsScreen(
modifier = Modifier.weight(1f).fillMaxWidth(),
user = user,
onSectionSelected = {
model.reduce(ProfileLoggedMviModel.Intent.SelectTab(it))
},
).Content()
}
@ -65,6 +60,9 @@ internal class ProfileLoggedScreen(
ProfileSavedScreen(
modifier = Modifier.weight(1f).fillMaxWidth(),
user = user,
onSectionSelected = {
model.reduce(ProfileLoggedMviModel.Intent.SelectTab(it))
},
).Content()
}
}

View File

@ -2,8 +2,11 @@ package com.github.diegoberaldin.raccoonforlemmy.feature.profile.content.logged.
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
@ -25,11 +28,16 @@ import cafe.adriel.voyager.core.screen.Screen
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.Spacing
import com.github.diegoberaldin.raccoonforlemmy.core.architecture.bindToLifecycle
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.UserModel
import com.github.diegoberaldin.raccoonforlemmy.feature.profile.content.logged.ProfileLoggedCounters
import com.github.diegoberaldin.raccoonforlemmy.feature.profile.content.logged.ProfileLoggedHeader
import com.github.diegoberaldin.raccoonforlemmy.feature.profile.content.logged.ProfileLoggedSection
import com.github.diegoberaldin.raccoonforlemmy.feature.profile.content.logged.SectionSelector
import com.github.diegoberaldin.raccoonforlemmy.feature.profile.di.getProfileCommentsViewModel
internal class ProfileCommentsScreen(
private val modifier: Modifier = Modifier,
private val user: UserModel,
private val onSectionSelected: (ProfileLoggedSection) -> Unit,
) : Screen {
@OptIn(ExperimentalMaterialApi::class)
@Composable
@ -48,6 +56,22 @@ internal class ProfileCommentsScreen(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.spacedBy(Spacing.xs),
) {
item {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(Spacing.xs),
) {
ProfileLoggedHeader(user = user)
ProfileLoggedCounters(user = user)
Spacer(modifier = Modifier.height(Spacing.xxs))
SectionSelector(
currentSection = ProfileLoggedSection.COMMENTS,
onSectionSelected = {
onSectionSelected(it)
},
)
}
}
items(uiState.comments) { comment ->
ProfileCommentCard(
comment = comment,

View File

@ -2,8 +2,11 @@ package com.github.diegoberaldin.raccoonforlemmy.feature.profile.content.logged.
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
@ -28,11 +31,16 @@ import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.Spacing
import com.github.diegoberaldin.raccoonforlemmy.core.architecture.bindToLifecycle
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.communitydetail.CommunityDetailScreen
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.UserModel
import com.github.diegoberaldin.raccoonforlemmy.feature.profile.content.logged.ProfileLoggedCounters
import com.github.diegoberaldin.raccoonforlemmy.feature.profile.content.logged.ProfileLoggedHeader
import com.github.diegoberaldin.raccoonforlemmy.feature.profile.content.logged.ProfileLoggedSection
import com.github.diegoberaldin.raccoonforlemmy.feature.profile.content.logged.SectionSelector
import com.github.diegoberaldin.raccoonforlemmy.feature.profile.di.getProfilePostsViewModel
internal class ProfilePostsScreen(
private val modifier: Modifier = Modifier,
private val user: UserModel,
private val onSectionSelected: (ProfileLoggedSection) -> Unit,
) : Screen {
@OptIn(ExperimentalMaterialApi::class)
@Composable
@ -56,6 +64,22 @@ internal class ProfilePostsScreen(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.spacedBy(Spacing.xs),
) {
item {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(Spacing.xs),
) {
ProfileLoggedHeader(user = user)
ProfileLoggedCounters(user = user)
Spacer(modifier = Modifier.height(Spacing.xxs))
SectionSelector(
currentSection = ProfileLoggedSection.POSTS,
onSectionSelected = {
onSectionSelected(it)
},
)
}
}
items(uiState.posts) { post ->
ProfilePostCard(
post = post,

View File

@ -2,8 +2,11 @@ package com.github.diegoberaldin.raccoonforlemmy.feature.profile.content.logged.
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
@ -28,6 +31,10 @@ import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.Spacing
import com.github.diegoberaldin.raccoonforlemmy.core.architecture.bindToLifecycle
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.communitydetail.CommunityDetailScreen
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.UserModel
import com.github.diegoberaldin.raccoonforlemmy.feature.profile.content.logged.ProfileLoggedCounters
import com.github.diegoberaldin.raccoonforlemmy.feature.profile.content.logged.ProfileLoggedHeader
import com.github.diegoberaldin.raccoonforlemmy.feature.profile.content.logged.ProfileLoggedSection
import com.github.diegoberaldin.raccoonforlemmy.feature.profile.content.logged.SectionSelector
import com.github.diegoberaldin.raccoonforlemmy.feature.profile.content.logged.posts.ProfilePostCard
import com.github.diegoberaldin.raccoonforlemmy.feature.profile.content.logged.posts.ProfilePostsMviModel
import com.github.diegoberaldin.raccoonforlemmy.feature.profile.di.getProfilePostsViewModel
@ -35,6 +42,7 @@ import com.github.diegoberaldin.raccoonforlemmy.feature.profile.di.getProfilePos
internal class ProfileSavedScreen(
private val modifier: Modifier = Modifier,
private val user: UserModel,
private val onSectionSelected: (ProfileLoggedSection) -> Unit,
) : Screen {
@OptIn(ExperimentalMaterialApi::class)
@Composable
@ -59,6 +67,22 @@ internal class ProfileSavedScreen(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.spacedBy(Spacing.xs),
) {
item {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(Spacing.xs),
) {
ProfileLoggedHeader(user = user)
ProfileLoggedCounters(user = user)
Spacer(modifier = Modifier.height(Spacing.xxs))
SectionSelector(
currentSection = ProfileLoggedSection.SAVED,
onSectionSelected = {
onSectionSelected(it)
},
)
}
}
items(uiState.posts) { post ->
ProfilePostCard(
post = post,