mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 21:07:04 +05:30
all: flesh out comments UI and move to common
This commit is contained in:
parent
84fd9a2c61
commit
d56b887a21
6 changed files with 147 additions and 44 deletions
|
@ -1,22 +0,0 @@
|
|||
package dev.msfjarvis.claw.android.comments
|
||||
|
||||
import android.text.Html
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.buildAnnotatedString
|
||||
import androidx.compose.ui.unit.dp
|
||||
import dev.msfjarvis.claw.model.Comment
|
||||
|
||||
@Composable
|
||||
fun CommentEntry(
|
||||
comment: Comment,
|
||||
) {
|
||||
Row(modifier = Modifier.padding(start = (10 * (comment.indentLevel.toFloat() - 1)).dp)) {
|
||||
Text(
|
||||
text = buildAnnotatedString { @Suppress("DEPRECATION") Html.fromHtml(comment.comment) },
|
||||
)
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package dev.msfjarvis.claw.android.comments
|
||||
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.runtime.Composable
|
||||
import dev.msfjarvis.claw.model.LobstersPostDetails
|
||||
|
||||
@Composable
|
||||
private fun CommentsPageInternal(
|
||||
details: LobstersPostDetails,
|
||||
) {
|
||||
LazyColumn { items(details.comments) { CommentEntry(it) } }
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun CommentsPage(
|
||||
postId: String,
|
||||
getDetails: suspend (String) -> LobstersPostDetails,
|
||||
) {}
|
|
@ -1,5 +1,6 @@
|
|||
package dev.msfjarvis.claw.android.ui
|
||||
|
||||
import android.text.Html
|
||||
import androidx.compose.animation.ExperimentalAnimationApi
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
|
@ -28,8 +29,8 @@ import com.google.accompanist.insets.ProvideWindowInsets
|
|||
import com.google.accompanist.insets.navigationBarsPadding
|
||||
import com.google.accompanist.insets.statusBarsPadding
|
||||
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
||||
import dev.msfjarvis.claw.android.comments.CommentsPage
|
||||
import dev.msfjarvis.claw.android.viewmodel.ClawViewModel
|
||||
import dev.msfjarvis.claw.common.comments.CommentsPage
|
||||
import dev.msfjarvis.claw.common.theme.LobstersTheme
|
||||
import dev.msfjarvis.claw.common.urllauncher.UrlLauncher
|
||||
|
||||
|
@ -78,12 +79,12 @@ fun LobstersApp(
|
|||
topBar = { ClawAppBar(modifier = Modifier.statusBarsPadding()) },
|
||||
floatingActionButton = {
|
||||
ClawFab(
|
||||
isFabVisible = isFabVisible,
|
||||
isFabVisible = isFabVisible && navController.currentDestination?.route == "hottest",
|
||||
listState = listState,
|
||||
modifier = Modifier.navigationBarsPadding(),
|
||||
)
|
||||
},
|
||||
) {
|
||||
) { paddingValues ->
|
||||
NavHost(navController, startDestination = "hottest") {
|
||||
composable("hottest") {
|
||||
HottestPosts(
|
||||
|
@ -101,6 +102,8 @@ fun LobstersApp(
|
|||
CommentsPage(
|
||||
postId = requireNotNull(backStackEntry.arguments?.getString("postId")),
|
||||
getDetails = viewModel::getPostComments,
|
||||
parseHtml = { source -> Html.fromHtml(source).toString().trim() },
|
||||
paddingValues = paddingValues,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue