From 67c074b42cef63f20c719b40ee73c93f8caa33c5 Mon Sep 17 00:00:00 2001 From: Diego Beraldin Date: Thu, 10 Aug 2023 20:44:32 +0200 Subject: [PATCH] feat(profile): update layout to have scrolling header --- .../content/logged/ProfileLoggedScreen.kt | 20 +++++++--------- .../logged/comments/ProfileCommentsScreen.kt | 24 +++++++++++++++++++ .../logged/posts/ProfilePostsScreen.kt | 24 +++++++++++++++++++ .../logged/saved/ProfileSavedScreen.kt | 24 +++++++++++++++++++ 4 files changed, 81 insertions(+), 11 deletions(-) diff --git a/feature-profile/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/profile/content/logged/ProfileLoggedScreen.kt b/feature-profile/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/profile/content/logged/ProfileLoggedScreen.kt index 6d8027345..f280b1734 100644 --- a/feature-profile/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/profile/content/logged/ProfileLoggedScreen.kt +++ b/feature-profile/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/profile/content/logged/ProfileLoggedScreen.kt @@ -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() } } diff --git a/feature-profile/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/profile/content/logged/comments/ProfileCommentsScreen.kt b/feature-profile/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/profile/content/logged/comments/ProfileCommentsScreen.kt index cc8c49bfc..0bca484bf 100644 --- a/feature-profile/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/profile/content/logged/comments/ProfileCommentsScreen.kt +++ b/feature-profile/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/profile/content/logged/comments/ProfileCommentsScreen.kt @@ -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, diff --git a/feature-profile/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/profile/content/logged/posts/ProfilePostsScreen.kt b/feature-profile/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/profile/content/logged/posts/ProfilePostsScreen.kt index 1ba26db0d..9287e4c99 100644 --- a/feature-profile/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/profile/content/logged/posts/ProfilePostsScreen.kt +++ b/feature-profile/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/profile/content/logged/posts/ProfilePostsScreen.kt @@ -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, diff --git a/feature-profile/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/profile/content/logged/saved/ProfileSavedScreen.kt b/feature-profile/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/profile/content/logged/saved/ProfileSavedScreen.kt index 5316bf407..281e71e9a 100644 --- a/feature-profile/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/profile/content/logged/saved/ProfileSavedScreen.kt +++ b/feature-profile/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/feature/profile/content/logged/saved/ProfileSavedScreen.kt @@ -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,