Skip to content

Commit

Permalink
Update post card view (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcoding810 authored Dec 2, 2024
1 parent 778c878 commit 616bfee
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
35 changes: 22 additions & 13 deletions app/src/main/java/com/paulcoding/hviewer/ui/page/posts/PostsPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
Expand All @@ -29,6 +31,7 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.lifecycle.viewmodel.compose.viewModel
import com.paulcoding.hviewer.MainApp.Companion.appContext
import com.paulcoding.hviewer.extensions.isScrolledToEnd
Expand Down Expand Up @@ -151,7 +154,7 @@ fun PageContent(
state = listState
) {
items(uiState.postItems) { post ->
PostItemView(post) {
PostCard(post) {
onClick(post)
}
}
Expand All @@ -174,16 +177,22 @@ fun PageContent(
}

@Composable
fun PostItemView(postItem: PostItem, viewPost: () -> Unit) {
return Column(modifier = Modifier
.padding(horizontal = 16.dp, vertical = 12.dp)
.clickable {
viewPost()
}) {
Text(postItem.name)
HImage(
url = postItem.thumbnail
)
fun PostCard(postItem: PostItem, viewPost: () -> Unit) {
Card(
elevation = CardDefaults.cardElevation(8.dp),
modifier = Modifier
.padding(horizontal = 16.dp, vertical = 12.dp),
shape = MaterialTheme.shapes.medium,
) {
Column(modifier = Modifier
.padding(8.dp)
.clickable {
viewPost()
}) {
HImage(
url = postItem.thumbnail
)
Text(postItem.name, fontSize = 12.sp)
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import com.paulcoding.hviewer.ui.component.HLoading
import com.paulcoding.hviewer.ui.component.HPageProgress
import com.paulcoding.hviewer.ui.icon.EditIcon
import com.paulcoding.hviewer.ui.page.AppViewModel
import com.paulcoding.hviewer.ui.page.posts.PostItemView
import com.paulcoding.hviewer.ui.page.posts.PostCard


@OptIn(ExperimentalMaterial3Api::class)
Expand Down Expand Up @@ -138,7 +138,7 @@ fun PageContent(
state = listState
) {
items(uiState.postItems) { post ->
PostItemView(post) {
PostCard(post) {
onClick(post)
}
}
Expand Down

0 comments on commit 616bfee

Please sign in to comment.