mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-17 22:37:03 +05:30
Merge pull request #35 from msfjarvis/update-followups
This commit is contained in:
commit
f71bd27a03
2 changed files with 34 additions and 30 deletions
|
@ -7,6 +7,7 @@ import androidx.compose.foundation.Text
|
|||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumnForIndexed
|
||||
import androidx.compose.material.Scaffold
|
||||
import androidx.compose.material.TopAppBar
|
||||
|
@ -18,6 +19,7 @@ import androidx.compose.ui.Alignment
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.setContent
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import dev.msfjarvis.lobsters.api.LobstersApi
|
||||
import dev.msfjarvis.lobsters.compose.utils.IconResource
|
||||
|
@ -68,7 +70,10 @@ fun LobstersApp(
|
|||
Text(stringResource(R.string.nothing_to_see_here))
|
||||
}
|
||||
} else {
|
||||
LazyColumnForIndexed(state.value) { index, item ->
|
||||
LazyColumnForIndexed(
|
||||
items = state.value,
|
||||
modifier = Modifier.padding(horizontal = 8.dp)
|
||||
) { index, item ->
|
||||
if (lastIndex == index) {
|
||||
viewModel.getMorePosts()
|
||||
}
|
||||
|
|
|
@ -6,12 +6,12 @@ import androidx.compose.foundation.background
|
|||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumnFor
|
||||
import androidx.compose.foundation.lazy.LazyItemScope
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.ListItem
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
|
@ -28,41 +28,40 @@ fun LazyItemScope.LobstersItem(
|
|||
linkOpenAction: (LobstersPost) -> Unit,
|
||||
commentOpenAction: (LobstersPost) -> Unit,
|
||||
) {
|
||||
ListItem(
|
||||
modifier = modifier.padding(horizontal = 8.dp)
|
||||
Column(
|
||||
modifier = modifier
|
||||
.fillParentMaxWidth()
|
||||
.clickable(
|
||||
onClick = { linkOpenAction.invoke(post) },
|
||||
onLongClick = { commentOpenAction.invoke(post) }
|
||||
),
|
||||
text = {
|
||||
Text(
|
||||
text = post.title,
|
||||
color = Color(0xFF7395D9),
|
||||
fontWeight = FontWeight.Bold,
|
||||
modifier = Modifier.padding(top = 4.dp)
|
||||
)
|
||||
Row(
|
||||
modifier = Modifier.padding(vertical = 8.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
) {
|
||||
post.tags.take(4).forEach { tag ->
|
||||
Text(
|
||||
text = tag,
|
||||
modifier = Modifier
|
||||
.border(BorderStroke(1.dp, Color.Gray))
|
||||
.background(Color(0xFFFFFCD7), RoundedCornerShape(4.dp))
|
||||
.padding(vertical = 2.dp, horizontal = 4.dp),
|
||||
color = Color.DarkGray,
|
||||
)
|
||||
}
|
||||
) {
|
||||
Text(
|
||||
text = post.title,
|
||||
color = Color(0xFF7395D9),
|
||||
fontWeight = FontWeight.Bold,
|
||||
modifier = Modifier.padding(top = 4.dp)
|
||||
)
|
||||
Row(
|
||||
modifier = Modifier.padding(vertical = 8.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
) {
|
||||
post.tags.take(4).forEach { tag ->
|
||||
Text(
|
||||
text = tag,
|
||||
modifier = Modifier
|
||||
.border(BorderStroke(1.dp, Color.Gray))
|
||||
.background(Color(0xFFFFFCD7), RoundedCornerShape(4.dp))
|
||||
.padding(vertical = 2.dp, horizontal = 4.dp),
|
||||
color = Color.DarkGray,
|
||||
)
|
||||
}
|
||||
Text(
|
||||
text = "submitted by ${post.submitterUser.username}",
|
||||
modifier = Modifier.padding(bottom = 4.dp),
|
||||
)
|
||||
}
|
||||
)
|
||||
Text(
|
||||
text = "submitted by ${post.submitterUser.username}",
|
||||
modifier = Modifier.padding(bottom = 4.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue