Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feed + Comment Polish #99

Merged
merged 9 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fun App() {
selected = navItem.selected,
colors = NavigationBarItemDefaults.colors(
selectedIconColor = MaterialTheme.colorScheme.primary,
indicatorColor = MaterialTheme.colorScheme.primaryContainer
indicatorColor = MaterialTheme.colorScheme.primary.copy(alpha = 0.2f)
),
onClick = {
model.actions(AppAction.NavItemSelected(navItem))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.emergetools.hackernews.features.comments.CommentsDestinations
import com.emergetools.hackernews.features.stories.ListSeparator
import com.emergetools.hackernews.features.stories.StoriesDestinations
import com.emergetools.hackernews.features.stories.StoryItem
import com.emergetools.hackernews.features.stories.StoryRow
Expand All @@ -40,7 +42,7 @@ fun BookmarksScreen(
style = MaterialTheme.typography.titleMedium
)
LazyColumn {
items(items = state.bookmarks, key = { it.id }) { item ->
itemsIndexed(items = state.bookmarks, key = {_, item -> item.id }) { index, item ->
StoryRow(
item = item,
onClick = {
Expand All @@ -55,6 +57,11 @@ fun BookmarksScreen(
navigator(BookmarksNavigation.GoToComments(CommentsDestinations.Comments(it.id)))
}
)
if(index != state.bookmarks.lastIndex) {
ListSeparator(
lineColor = MaterialTheme.colorScheme.surfaceContainerHighest,
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import java.time.LocalDateTime
import java.time.ZoneOffset
import java.time.ZonedDateTime

sealed interface CommentsState {
val headerState: HeaderState
Expand All @@ -40,6 +41,7 @@ sealed interface CommentsState {
val title: String,
val author: String,
val points: Int,
val timeLabel: String,
val body: String?,
val loggedIn: Boolean,
val upvoted: Boolean,
Expand All @@ -53,6 +55,7 @@ sealed interface CommentsState {
title = title,
author = author,
points = points,
timeLabel = timeLabel,
body = body,
upvoted = upvoted,
upvoteUrl = upvoteUrl
Expand Down Expand Up @@ -104,6 +107,7 @@ sealed interface HeaderState {
val title: String,
val author: String,
val points: Int,
val timeLabel: String,
val body: String?,
val upvoted: Boolean,
val upvoteUrl: String,
Expand Down Expand Up @@ -179,6 +183,11 @@ class CommentsViewModel(
title = searchResponse.item.title ?: "",
author = searchResponse.item.author ?: "",
points = searchResponse.item.points ?: 0,
timeLabel = relativeTimeStamp(
epochSeconds = ZonedDateTime
.parse(searchResponse.item.createdAt)
.toEpochSecond()
),
body = searchResponse.item.text,
loggedIn = loggedIn,
upvoted = postPage.postInfo.upvoted,
Expand Down
Loading
Loading