chore(deps): update dependency com.facebook:ktfmt to v0.47
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
050007ff1b
commit
a187752659
|
@ -42,16 +42,8 @@ abstract class BaseActivity : ComponentActivity() {
|
|||
preLaunch()
|
||||
Whetstone.inject(this)
|
||||
enableEdgeToEdge(
|
||||
statusBarStyle =
|
||||
SystemBarStyle.light(
|
||||
Color.TRANSPARENT,
|
||||
Color.TRANSPARENT,
|
||||
),
|
||||
navigationBarStyle =
|
||||
SystemBarStyle.light(
|
||||
Color.TRANSPARENT,
|
||||
Color.TRANSPARENT,
|
||||
),
|
||||
statusBarStyle = SystemBarStyle.light(Color.TRANSPARENT, Color.TRANSPARENT),
|
||||
navigationBarStyle = SystemBarStyle.light(Color.TRANSPARENT, Color.TRANSPARENT),
|
||||
)
|
||||
setContent {
|
||||
LobstersTheme(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2023 Harsh Shandilya.
|
||||
* Copyright © 2023-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -30,9 +30,7 @@ import dev.msfjarvis.claw.common.theme.DarkThemeColors
|
|||
import dev.msfjarvis.claw.common.theme.LightThemeColors
|
||||
import dev.msfjarvis.claw.database.local.SavedPost
|
||||
|
||||
class SavedPostsWidget(
|
||||
private val posts: List<SavedPost>,
|
||||
) : GlanceAppWidget() {
|
||||
class SavedPostsWidget(private val posts: List<SavedPost>) : GlanceAppWidget() {
|
||||
override suspend fun provideGlance(context: Context, id: GlanceId) {
|
||||
provideContent {
|
||||
GlanceTheme(
|
||||
|
@ -51,7 +49,7 @@ class SavedPostsWidget(
|
|||
GlanceModifier.fillMaxSize()
|
||||
.background(GlanceTheme.colors.background)
|
||||
.appWidgetBackground(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
item {
|
||||
val style = MaterialTheme.typography.titleLarge
|
||||
|
|
|
@ -39,10 +39,7 @@ private val destinationKey = Key<String>(NAVIGATION_KEY)
|
|||
|
||||
@Composable
|
||||
@GlanceComposable
|
||||
fun WidgetListEntry(
|
||||
post: SavedPost,
|
||||
modifier: GlanceModifier = GlanceModifier,
|
||||
) {
|
||||
fun WidgetListEntry(post: SavedPost, modifier: GlanceModifier = GlanceModifier) {
|
||||
val titleStyle = MaterialTheme.typography.titleMedium
|
||||
val commentsAction =
|
||||
actionStartActivity<MainActivity>(actionParametersOf(destinationKey to post.shortId))
|
||||
|
@ -67,12 +64,12 @@ fun WidgetListEntry(
|
|||
fontSize = titleStyle.fontSize,
|
||||
fontWeight = titleStyle.fontWeight.toGlance(),
|
||||
fontStyle = titleStyle.fontStyle.toGlance(),
|
||||
)
|
||||
),
|
||||
)
|
||||
Image(
|
||||
provider = ImageProvider(R.drawable.ic_comment),
|
||||
contentDescription = "${post.commentCount ?: 0} comments",
|
||||
modifier = GlanceModifier.padding(end = 4.dp).clickable(commentsAction)
|
||||
modifier = GlanceModifier.padding(end = 4.dp).clickable(commentsAction),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2021-2023 Harsh Shandilya.
|
||||
* Copyright © 2021-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -32,13 +32,7 @@ object MetadataExtractorModule {
|
|||
}
|
||||
|
||||
@Provides
|
||||
fun provideUnfurler(
|
||||
okHttpClient: OkHttpClient,
|
||||
logger: UnfurlLogger,
|
||||
): Unfurler {
|
||||
return Unfurler(
|
||||
httpClient = okHttpClient,
|
||||
logger = logger,
|
||||
)
|
||||
fun provideUnfurler(okHttpClient: OkHttpClient, logger: UnfurlLogger): Unfurler {
|
||||
return Unfurler(httpClient = okHttpClient, logger = logger)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2022 Harsh Shandilya.
|
||||
* Copyright © 2022-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -17,18 +17,14 @@ import dev.msfjarvis.claw.core.injection.AppPlugin
|
|||
import javax.inject.Inject
|
||||
|
||||
@ContributesMultibinding(ApplicationScope::class)
|
||||
class WorkManagerPlugin
|
||||
@Inject
|
||||
constructor(
|
||||
private val workerFactory: WorkerFactory,
|
||||
) : AppPlugin {
|
||||
class WorkManagerPlugin @Inject constructor(private val workerFactory: WorkerFactory) : AppPlugin {
|
||||
override fun apply(application: Application) {
|
||||
WorkManager.initialize(
|
||||
application,
|
||||
Configuration.Builder()
|
||||
.setWorkerFactory(workerFactory)
|
||||
.setMinimumLoggingLevel(Log.DEBUG)
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2023 Harsh Shandilya.
|
||||
* Copyright © 2023-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -145,11 +145,7 @@ private fun GenericExportOption(
|
|||
}
|
||||
}
|
||||
}
|
||||
SettingsActionItem(
|
||||
title = title,
|
||||
description = description,
|
||||
icon = icon,
|
||||
) {
|
||||
SettingsActionItem(title = title, description = description, icon = icon) {
|
||||
exportAction.launch(fileName)
|
||||
}
|
||||
}
|
||||
|
@ -167,11 +163,7 @@ private fun SettingsActionItem(
|
|||
supportingContent = { description?.let { Text(it) } },
|
||||
leadingContent = {
|
||||
icon?.let {
|
||||
Icon(
|
||||
imageVector = icon,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.height(32.dp),
|
||||
)
|
||||
Icon(imageVector = icon, contentDescription = null, modifier = Modifier.height(32.dp))
|
||||
}
|
||||
},
|
||||
modifier = modifier.clickable { onClick?.invoke() },
|
||||
|
@ -179,9 +171,7 @@ private fun SettingsActionItem(
|
|||
}
|
||||
|
||||
/** Shows a Snackbar but dismisses any existing ones first. */
|
||||
private suspend fun SnackbarHostState.showSnackbarDismissing(
|
||||
text: String,
|
||||
) {
|
||||
private suspend fun SnackbarHostState.showSnackbarDismissing(text: String) {
|
||||
currentSnackbarData?.dismiss()
|
||||
showSnackbar(text)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2021-2023 Harsh Shandilya.
|
||||
* Copyright © 2021-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -46,9 +46,5 @@ fun ClawAppBar(
|
|||
@ThemePreviews
|
||||
@Composable
|
||||
fun ClawAppBarPreview() {
|
||||
LobstersTheme {
|
||||
ClawAppBar(
|
||||
title = { Text("Claw", fontWeight = FontWeight.Bold) },
|
||||
)
|
||||
}
|
||||
LobstersTheme { ClawAppBar(title = { Text("Claw", fontWeight = FontWeight.Bold) }) }
|
||||
}
|
||||
|
|
|
@ -53,11 +53,7 @@ fun DatabasePosts(
|
|||
LazyColumn(state = listState) {
|
||||
items.forEach { (month, posts) ->
|
||||
stickyHeader(contentType = "month-header") { MonthHeader(label = month) }
|
||||
items(
|
||||
items = posts,
|
||||
key = { it.shortId },
|
||||
contentType = { "LobstersItem" },
|
||||
) { item ->
|
||||
items(items = posts, key = { it.shortId }, contentType = { "LobstersItem" }) { item ->
|
||||
LobstersListItem(
|
||||
item = item,
|
||||
isSaved = { true },
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2021-2023 Harsh Shandilya.
|
||||
* Copyright © 2021-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -35,9 +35,7 @@ fun LobstersListItem(
|
|||
background = MaterialTheme.colorScheme.tertiary,
|
||||
onSwipe = { postActions.viewCommentsPage(item.commentsUrl) },
|
||||
)
|
||||
SwipeableActionsBox(
|
||||
endActions = listOf(commentsAction),
|
||||
) {
|
||||
SwipeableActionsBox(endActions = listOf(commentsAction)) {
|
||||
LobstersCard(
|
||||
post = item,
|
||||
isSaved = isSaved(item),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2021-2023 Harsh Shandilya.
|
||||
* Copyright © 2021-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -56,9 +56,7 @@ fun NetworkPosts(
|
|||
modifier = Modifier.align(Alignment.Center),
|
||||
)
|
||||
} else {
|
||||
LazyColumn(
|
||||
state = listState,
|
||||
) {
|
||||
LazyColumn(state = listState) {
|
||||
items(
|
||||
count = lazyPagingItems.itemCount,
|
||||
key = lazyPagingItems.itemKey { it.shortId },
|
||||
|
@ -83,7 +81,7 @@ fun NetworkPosts(
|
|||
modifier =
|
||||
Modifier.fillMaxWidth()
|
||||
.wrapContentWidth(Alignment.CenterHorizontally)
|
||||
.padding(vertical = 16.dp),
|
||||
.padding(vertical = 16.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2023 Harsh Shandilya.
|
||||
* Copyright © 2023-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -20,9 +20,7 @@ import okhttp3.HttpUrl.Companion.toHttpUrl
|
|||
|
||||
@Suppress("Unused")
|
||||
@Composable
|
||||
fun LobstersLoginWebView(
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
fun LobstersLoginWebView(modifier: Modifier = Modifier) {
|
||||
val state = rememberWebViewState(url = "https://lobste.rs/login")
|
||||
val webClient = remember {
|
||||
object : AccompanistWebViewClient() {
|
||||
|
@ -43,10 +41,5 @@ fun LobstersLoginWebView(
|
|||
}
|
||||
}
|
||||
}
|
||||
WebView(
|
||||
state = state,
|
||||
client = webClient,
|
||||
modifier = modifier,
|
||||
captureBackPresses = false,
|
||||
)
|
||||
WebView(state = state, client = webClient, modifier = modifier, captureBackPresses = false)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2021-2023 Harsh Shandilya.
|
||||
* Copyright © 2021-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -162,7 +162,7 @@ fun LobstersPostsScreen(
|
|||
navItems.none { it.route == currentDestination }
|
||||
) {
|
||||
IconButton(
|
||||
onClick = { if (!navController.popBackStack()) context.getActivity()?.finish() },
|
||||
onClick = { if (!navController.popBackStack()) context.getActivity()?.finish() }
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
|
||||
|
@ -202,7 +202,7 @@ fun LobstersPostsScreen(
|
|||
imageVector = Icons.Filled.ImportExport,
|
||||
contentDescription = "Data transfer options",
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
DropdownMenuItem(
|
||||
text = { Text("Search posts") },
|
||||
|
@ -211,11 +211,8 @@ fun LobstersPostsScreen(
|
|||
expanded = false
|
||||
},
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
imageVector = Icons.Filled.Search,
|
||||
contentDescription = "Search posts",
|
||||
)
|
||||
}
|
||||
Icon(imageVector = Icons.Filled.Search, contentDescription = "Search posts")
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -273,11 +270,7 @@ fun LobstersPostsScreen(
|
|||
}
|
||||
composable(route = Destinations.Saved.route) {
|
||||
setWebUri(null)
|
||||
DatabasePosts(
|
||||
items = savedPosts,
|
||||
listState = savedListState,
|
||||
postActions = postActions,
|
||||
)
|
||||
DatabasePosts(items = savedPosts, listState = savedListState, postActions = postActions)
|
||||
}
|
||||
composable(
|
||||
route = Destinations.Comments.route,
|
||||
|
@ -304,18 +297,14 @@ fun LobstersPostsScreen(
|
|||
composable(
|
||||
route = Destinations.User.route,
|
||||
arguments = listOf(navArgument("username") { type = NavType.StringType }),
|
||||
deepLinks =
|
||||
listOf(navDeepLink { uriPattern = "$uri/u/${Destinations.User.PLACEHOLDER}" }),
|
||||
deepLinks = listOf(navDeepLink { uriPattern = "$uri/u/${Destinations.User.PLACEHOLDER}" }),
|
||||
) { backStackEntry ->
|
||||
val username =
|
||||
requireNotNull(backStackEntry.arguments?.getString("username")) {
|
||||
"Navigating to ${Destinations.User.route} without necessary 'username' argument"
|
||||
}
|
||||
setWebUri("https://lobste.rs/u/$username")
|
||||
UserProfile(
|
||||
username = username,
|
||||
getProfile = viewModel::getUserProfile,
|
||||
)
|
||||
UserProfile(username = username, getProfile = viewModel::getUserProfile)
|
||||
}
|
||||
composable(route = Destinations.DataTransfer.route) {
|
||||
DataTransferScreen(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2023 Harsh Shandilya.
|
||||
* Copyright © 2023-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -37,12 +37,7 @@ constructor(
|
|||
|
||||
suspend fun importPosts(input: InputStream) {
|
||||
val posts: List<SavedPost> =
|
||||
withContext(ioDispatcher) {
|
||||
json.decodeFromStream(
|
||||
serializer,
|
||||
input,
|
||||
)
|
||||
}
|
||||
withContext(ioDispatcher) { json.decodeFromStream(serializer, input) }
|
||||
withContext(dbDispatcher) {
|
||||
savedPostQueries.transaction { posts.forEach(savedPostQueries::insertOrReplacePost) }
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2023 Harsh Shandilya.
|
||||
* Copyright © 2023-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -77,7 +77,7 @@ object SearchConverter : Converter<ResponseBody, List<LobstersPost>> {
|
|||
override fun responseBodyConverter(
|
||||
type: Type,
|
||||
annotations: Array<out Annotation>,
|
||||
retrofit: Retrofit
|
||||
retrofit: Retrofit,
|
||||
): Converter<ResponseBody, List<LobstersPost>> {
|
||||
return SearchConverter
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2023 Harsh Shandilya.
|
||||
* Copyright © 2023-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -91,10 +91,7 @@ object RetrofitModule {
|
|||
@Provides
|
||||
@SearchApi
|
||||
fun provideConverters(): List<@JvmSuppressWildcards Converter.Factory> =
|
||||
listOf(
|
||||
ApiResultConverterFactory,
|
||||
SearchConverter.Factory,
|
||||
)
|
||||
listOf(ApiResultConverterFactory, SearchConverter.Factory)
|
||||
|
||||
@Provides @Named("LobstersURL") fun provideLobstersUrl(): String = LobstersApi.BASE_URL
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2022-2023 Harsh Shandilya.
|
||||
* Copyright © 2022-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -43,10 +43,7 @@ class KotlinCommonPlugin : Plugin<Project> {
|
|||
}
|
||||
|
||||
companion object {
|
||||
private val ADDITIONAL_COMPILER_ARGS =
|
||||
listOf(
|
||||
"-opt-in=kotlin.RequiresOptIn",
|
||||
)
|
||||
private val ADDITIONAL_COMPILER_ARGS = listOf("-opt-in=kotlin.RequiresOptIn")
|
||||
|
||||
val JVM_TOOLCHAIN_ACTION =
|
||||
Action<JavaToolchainSpec> { languageVersion.set(JavaLanguageVersion.of(17)) }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2022-2023 Harsh Shandilya.
|
||||
* Copyright © 2022-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -45,7 +45,7 @@ class SpotlessPlugin : Plugin<Project> {
|
|||
endWithNewline()
|
||||
licenseHeaderFile(
|
||||
project.file("spotless/license.xml"),
|
||||
"<(adaptive-icon|appwidget-provider|data-extraction-rules|full-backup-content|manifest|vector|resources)"
|
||||
"<(adaptive-icon|appwidget-provider|data-extraction-rules|full-backup-content|manifest|vector|resources)",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +55,6 @@ class SpotlessPlugin : Plugin<Project> {
|
|||
}
|
||||
|
||||
private companion object {
|
||||
private const val KTFMT_VERSION = "0.46"
|
||||
private const val KTFMT_VERSION = "0.47"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2021-2023 Harsh Shandilya.
|
||||
* Copyright © 2021-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -60,9 +60,7 @@ internal fun CommentsHeader(
|
|||
) {
|
||||
val uriHandler = LocalUriHandler.current
|
||||
val linkMetadata by
|
||||
produceState(
|
||||
initialValue = LinkMetadata(postDetails.url, null),
|
||||
) {
|
||||
produceState(initialValue = LinkMetadata(postDetails.url, null)) {
|
||||
runSuspendCatching { postActions.getLinkMetadata(postDetails.url) }
|
||||
.onSuccess { metadata -> value = metadata }
|
||||
}
|
||||
|
@ -105,10 +103,7 @@ internal fun CommentsHeader(
|
|||
}
|
||||
|
||||
@Composable
|
||||
private fun PostLink(
|
||||
linkMetadata: LinkMetadata,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
private fun PostLink(linkMetadata: LinkMetadata, modifier: Modifier = Modifier) {
|
||||
Box(
|
||||
modifier.background(
|
||||
color = MaterialTheme.colorScheme.secondary,
|
||||
|
@ -155,7 +150,7 @@ internal fun CommentEntry(
|
|||
end = CommentEntryPadding,
|
||||
top = CommentEntryPadding,
|
||||
bottom = CommentEntryPadding,
|
||||
),
|
||||
)
|
||||
) {
|
||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Submitter(
|
||||
|
@ -175,7 +170,7 @@ internal fun CommentEntry(
|
|||
if (commentNode.isExpanded) {
|
||||
ThemedRichText(
|
||||
text = htmlConverter.convertHTMLToMarkdown(comment.comment),
|
||||
modifier = Modifier.padding(top = 8.dp)
|
||||
modifier = Modifier.padding(top = 8.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -228,11 +223,7 @@ fun buildCommenterString(
|
|||
if (isUnread) {
|
||||
append(' ')
|
||||
withStyle(
|
||||
style =
|
||||
SpanStyle(
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = MaterialTheme.colorScheme.error,
|
||||
)
|
||||
style = SpanStyle(fontWeight = FontWeight.Bold, color = MaterialTheme.colorScheme.error)
|
||||
) {
|
||||
append("(unread)")
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2022-2023 Harsh Shandilya.
|
||||
* Copyright © 2022-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -17,7 +17,7 @@ internal data class CommentNode(
|
|||
val children: MutableList<CommentNode> = mutableListOf(),
|
||||
val isUnread: Boolean = false,
|
||||
var isExpanded: Boolean = true,
|
||||
var indentLevel: Int
|
||||
var indentLevel: Int,
|
||||
) {
|
||||
fun addChild(child: CommentNode) {
|
||||
if (comment.shortId == child.comment.parentComment) {
|
||||
|
@ -32,7 +32,7 @@ internal data class CommentNode(
|
|||
|
||||
internal fun createListNode(
|
||||
comments: List<Comment>,
|
||||
commentState: PostComments?
|
||||
commentState: PostComments?,
|
||||
): MutableList<CommentNode> {
|
||||
val commentNodes = mutableListOf<CommentNode>()
|
||||
val isUnread = { id: String -> commentState?.commentIds?.contains(id) == false }
|
||||
|
@ -43,7 +43,7 @@ internal fun createListNode(
|
|||
CommentNode(
|
||||
comment = comments[i],
|
||||
isUnread = isUnread(comments[i].shortId),
|
||||
indentLevel = 1
|
||||
indentLevel = 1,
|
||||
)
|
||||
)
|
||||
} else {
|
||||
|
@ -52,7 +52,7 @@ internal fun createListNode(
|
|||
CommentNode(
|
||||
comment = comments[i],
|
||||
isUnread = isUnread(comments[i].shortId),
|
||||
indentLevel = it.indentLevel + 1
|
||||
indentLevel = it.indentLevel + 1,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -86,11 +86,7 @@ internal fun LazyListScope.nodes(
|
|||
toggleExpanded: (CommentNode) -> Unit,
|
||||
) {
|
||||
nodes.forEach { node ->
|
||||
node(
|
||||
node = node,
|
||||
htmlConverter = htmlConverter,
|
||||
toggleExpanded = toggleExpanded,
|
||||
)
|
||||
node(node = node, htmlConverter = htmlConverter, toggleExpanded = toggleExpanded)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,18 +100,10 @@ private fun LazyListScope.node(
|
|||
return
|
||||
}
|
||||
item {
|
||||
CommentEntry(
|
||||
commentNode = node,
|
||||
htmlConverter = htmlConverter,
|
||||
toggleExpanded = toggleExpanded,
|
||||
)
|
||||
CommentEntry(commentNode = node, htmlConverter = htmlConverter, toggleExpanded = toggleExpanded)
|
||||
HorizontalDivider()
|
||||
}
|
||||
if (node.children.isNotEmpty()) {
|
||||
nodes(
|
||||
node.children,
|
||||
htmlConverter = htmlConverter,
|
||||
toggleExpanded = toggleExpanded,
|
||||
)
|
||||
nodes(node.children, htmlConverter = htmlConverter, toggleExpanded = toggleExpanded)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2021-2023 Harsh Shandilya.
|
||||
* Copyright © 2021-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -73,17 +73,13 @@ fun LobstersCard(
|
|||
.fillMaxWidth()
|
||||
.clickable { postActions.viewPost(post.shortId, post.url, post.commentsUrl) }
|
||||
.background(MaterialTheme.colorScheme.background)
|
||||
.padding(start = 16.dp, top = 16.dp, end = 4.dp, bottom = 16.dp),
|
||||
.padding(start = 16.dp, top = 16.dp, end = 4.dp, bottom = 16.dp)
|
||||
) {
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
PostDetails(
|
||||
modifier = Modifier.weight(1f),
|
||||
post = post,
|
||||
isRead = isRead,
|
||||
)
|
||||
PostDetails(modifier = Modifier.weight(1f), post = post, isRead = isRead)
|
||||
Column(
|
||||
modifier = Modifier.wrapContentHeight(),
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||
|
@ -126,11 +122,7 @@ fun PostDetails(post: SavedPost, isRead: Boolean, modifier: Modifier = Modifier)
|
|||
}
|
||||
|
||||
@Composable
|
||||
internal fun PostTitle(
|
||||
title: String,
|
||||
isRead: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
internal fun PostTitle(title: String, isRead: Boolean, modifier: Modifier = Modifier) {
|
||||
Text(
|
||||
text = title,
|
||||
modifier = modifier,
|
||||
|
@ -169,10 +161,7 @@ internal fun Submitter(
|
|||
}
|
||||
|
||||
@Composable
|
||||
private fun SaveButton(
|
||||
isSaved: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
private fun SaveButton(isSaved: Boolean, modifier: Modifier = Modifier) {
|
||||
Crossfade(targetState = isSaved, label = "save-button") { saved ->
|
||||
Box(modifier = modifier.padding(12.dp)) {
|
||||
Icon(
|
||||
|
@ -186,10 +175,7 @@ private fun SaveButton(
|
|||
}
|
||||
|
||||
@Composable
|
||||
private fun CommentsButton(
|
||||
commentCount: Int?,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
private fun CommentsButton(commentCount: Int?, modifier: Modifier = Modifier) {
|
||||
BadgedBox(
|
||||
modifier = modifier.padding(12.dp),
|
||||
badge = {
|
||||
|
@ -219,10 +205,7 @@ private fun CommentsButton(
|
|||
|
||||
@Composable
|
||||
@OptIn(ExperimentalLayoutApi::class)
|
||||
internal fun TagRow(
|
||||
tags: ImmutableList<String>,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
internal fun TagRow(tags: ImmutableList<String>, modifier: Modifier = Modifier) {
|
||||
FlowRow(
|
||||
modifier = modifier,
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
|
@ -233,10 +216,7 @@ internal fun TagRow(
|
|||
}
|
||||
|
||||
@Composable
|
||||
private fun TagText(
|
||||
tag: String,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
private fun TagText(tag: String, modifier: Modifier = Modifier) {
|
||||
Text(
|
||||
text = tag,
|
||||
modifier =
|
||||
|
|
|
@ -23,10 +23,7 @@ import dev.msfjarvis.claw.common.theme.LobstersTheme
|
|||
import dev.msfjarvis.claw.common.ui.preview.ThemePreviews
|
||||
|
||||
@Composable
|
||||
internal fun ThemedRichText(
|
||||
text: String,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
internal fun ThemedRichText(text: String, modifier: Modifier = Modifier) {
|
||||
val linkStyle =
|
||||
SpanStyle(
|
||||
background = MaterialTheme.colorScheme.surfaceVariant,
|
||||
|
@ -39,10 +36,7 @@ internal fun ThemedRichText(
|
|||
LocalTextStyle provides MaterialTheme.typography.bodyLarge,
|
||||
LocalContentColor provides MaterialTheme.colorScheme.onBackground,
|
||||
) {
|
||||
RichText(
|
||||
modifier = modifier,
|
||||
style = RichTextStyle.Default.copy(stringStyle = stringStyle),
|
||||
) {
|
||||
RichText(modifier = modifier, style = RichTextStyle.Default.copy(stringStyle = stringStyle)) {
|
||||
Markdown(text)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2022-2023 Harsh Shandilya.
|
||||
* Copyright © 2022-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -29,11 +29,7 @@ import dev.msfjarvis.claw.common.ui.preview.ThemePreviews
|
|||
import io.github.aakira.napier.Napier
|
||||
|
||||
@Composable
|
||||
fun NetworkError(
|
||||
label: String,
|
||||
error: Throwable,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
fun NetworkError(label: String, error: Throwable, modifier: Modifier = Modifier) {
|
||||
LaunchedEffect(true) { Napier.e(error, "NetworkError") { "Failed to load posts" } }
|
||||
var showDialog by remember { mutableStateOf(false) }
|
||||
Column(verticalArrangement = Arrangement.spacedBy(4.dp), modifier = modifier) {
|
||||
|
@ -60,15 +56,10 @@ fun NetworkError(
|
|||
Modifier.clickable {
|
||||
clipboard.setText(AnnotatedString(error.stackTraceToString()))
|
||||
showDialog = false
|
||||
}
|
||||
},
|
||||
)
|
||||
},
|
||||
text = {
|
||||
Text(
|
||||
text = "${error.message}",
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
)
|
||||
}
|
||||
text = { Text(text = "${error.message}", style = MaterialTheme.typography.bodyLarge) },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2023 Harsh Shandilya.
|
||||
* Copyright © 2023-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -45,7 +45,7 @@ fun PasswordField(
|
|||
if (isPasswordVisible) rememberVectorPainter(Icons.Filled.VisibilityOff)
|
||||
else rememberVectorPainter(Icons.Filled.Visibility),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.clickable { isPasswordVisible = !isPasswordVisible }
|
||||
modifier = Modifier.clickable { isPasswordVisible = !isPasswordVisible },
|
||||
)
|
||||
},
|
||||
modifier = modifier,
|
||||
|
@ -57,10 +57,6 @@ fun PasswordField(
|
|||
private fun PasswordFieldPreview() {
|
||||
LobstersTheme {
|
||||
var value by remember { mutableStateOf("") }
|
||||
PasswordField(
|
||||
value = value,
|
||||
label = "Password",
|
||||
onValueChange = { value = it },
|
||||
)
|
||||
PasswordField(value = value, label = "Password", onValueChange = { value = it })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2023 Harsh Shandilya.
|
||||
* Copyright © 2023-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -59,10 +59,7 @@ fun SearchBar(
|
|||
},
|
||||
keyboardActions = KeyboardActions(onSearch = { onSearch(value) }),
|
||||
keyboardOptions =
|
||||
KeyboardOptions(
|
||||
keyboardType = KeyboardType.Text,
|
||||
imeAction = ImeAction.Search,
|
||||
),
|
||||
KeyboardOptions(keyboardType = KeyboardType.Text, imeAction = ImeAction.Search),
|
||||
singleLine = true,
|
||||
modifier = modifier.focusable().focusRequester(focusRequester),
|
||||
)
|
||||
|
@ -81,7 +78,7 @@ fun SearchBarPreview() {
|
|||
value = value,
|
||||
onValueChange = { value = it },
|
||||
onSearch = {},
|
||||
modifier = Modifier.align(Alignment.TopCenter).fillMaxWidth()
|
||||
modifier = Modifier.align(Alignment.TopCenter).fillMaxWidth(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,10 +22,7 @@ import dev.msfjarvis.claw.common.ui.preview.ThemePreviews
|
|||
import dev.msfjarvis.claw.common.ui.surfaceColorAtNavigationBarElevation
|
||||
|
||||
@Composable
|
||||
fun MonthHeader(
|
||||
label: String,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
fun MonthHeader(label: String, modifier: Modifier = Modifier) {
|
||||
Box(
|
||||
modifier
|
||||
.fillMaxWidth()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2022-2023 Harsh Shandilya.
|
||||
* Copyright © 2022-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -50,12 +50,8 @@ fun UserProfile(
|
|||
.fold(
|
||||
success = { profile -> value = Success(profile) },
|
||||
failure = {
|
||||
value =
|
||||
Error(
|
||||
error = it,
|
||||
description = "Failed to load profile for $username",
|
||||
)
|
||||
}
|
||||
value = Error(error = it, description = "Failed to load profile for $username")
|
||||
},
|
||||
)
|
||||
}
|
||||
when (user) {
|
||||
|
@ -81,10 +77,7 @@ fun UserProfile(
|
|||
}
|
||||
|
||||
@Composable
|
||||
private fun UserProfileInternal(
|
||||
user: User,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
private fun UserProfileInternal(user: User, modifier: Modifier = Modifier) {
|
||||
Surface(modifier = modifier) {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
|
@ -97,17 +90,10 @@ private fun UserProfileInternal(
|
|||
contentDescription = "Avatar of ${user.username}",
|
||||
modifier = Modifier.requiredSize(120.dp).clip(CircleShape),
|
||||
)
|
||||
Text(
|
||||
text = user.username,
|
||||
style = MaterialTheme.typography.displaySmall,
|
||||
)
|
||||
ThemedRichText(
|
||||
text = user.about,
|
||||
)
|
||||
Text(text = user.username, style = MaterialTheme.typography.displaySmall)
|
||||
ThemedRichText(text = user.about)
|
||||
user.invitedBy?.let { invitedBy ->
|
||||
ThemedRichText(
|
||||
text = "Invited by [${invitedBy}](https://lobste.rs/u/${user.invitedBy})",
|
||||
)
|
||||
ThemedRichText(text = "Invited by [${invitedBy}](https://lobste.rs/u/${user.invitedBy})")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2022 Harsh Shandilya.
|
||||
* Copyright © 2022-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -29,7 +29,7 @@ open class DelegatingSocketFactory(private val delegate: SocketFactory) : Socket
|
|||
host: String,
|
||||
port: Int,
|
||||
localAddress: InetAddress,
|
||||
localPort: Int
|
||||
localPort: Int,
|
||||
): Socket {
|
||||
val socket = delegate.createSocket(host, port, localAddress, localPort)
|
||||
return configureSocket(socket)
|
||||
|
@ -44,7 +44,7 @@ open class DelegatingSocketFactory(private val delegate: SocketFactory) : Socket
|
|||
host: InetAddress,
|
||||
port: Int,
|
||||
localAddress: InetAddress,
|
||||
localPort: Int
|
||||
localPort: Int,
|
||||
): Socket {
|
||||
val socket = delegate.createSocket(host, port, localAddress, localPort)
|
||||
return configureSocket(socket)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2023 Harsh Shandilya.
|
||||
* Copyright © 2023-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -32,9 +32,7 @@ object QueriesModule {
|
|||
}
|
||||
|
||||
@Provides
|
||||
fun provideReadPostsQueries(
|
||||
@InternalDatabaseApi database: LobstersDatabase,
|
||||
): ReadPostsQueries {
|
||||
fun provideReadPostsQueries(@InternalDatabaseApi database: LobstersDatabase): ReadPostsQueries {
|
||||
return database.readPostsQueries
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2022-2023 Harsh Shandilya.
|
||||
* Copyright © 2022-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -10,8 +10,4 @@ package dev.msfjarvis.claw.model
|
|||
|
||||
import dev.drewhamilton.poko.Poko
|
||||
|
||||
@Poko
|
||||
class LinkMetadata(
|
||||
val url: String,
|
||||
val faviconUrl: String?,
|
||||
)
|
||||
@Poko class LinkMetadata(val url: String, val faviconUrl: String?)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2021-2023 Harsh Shandilya.
|
||||
* Copyright © 2021-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -21,14 +21,8 @@ import kotlinx.serialization.Serializable
|
|||
value = SavedPost::class,
|
||||
mappings =
|
||||
[
|
||||
Mapping(
|
||||
target = "submitterName",
|
||||
expression = "it.submitter.username",
|
||||
),
|
||||
Mapping(
|
||||
target = "submitterAvatarUrl",
|
||||
expression = "it.submitter.avatarUrl",
|
||||
),
|
||||
Mapping(target = "submitterName", expression = "it.submitter.username"),
|
||||
Mapping(target = "submitterAvatarUrl", expression = "it.submitter.avatarUrl"),
|
||||
],
|
||||
)
|
||||
class LobstersPost(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2021-2023 Harsh Shandilya.
|
||||
* Copyright © 2021-2024 Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
|
@ -21,14 +21,8 @@ import kotlinx.serialization.Serializable
|
|||
value = SavedPost::class,
|
||||
mappings =
|
||||
[
|
||||
Mapping(
|
||||
target = "submitterName",
|
||||
expression = "it.submitter.username",
|
||||
),
|
||||
Mapping(
|
||||
target = "submitterAvatarUrl",
|
||||
expression = "it.submitter.avatarUrl",
|
||||
),
|
||||
Mapping(target = "submitterName", expression = "it.submitter.username"),
|
||||
Mapping(target = "submitterAvatarUrl", expression = "it.submitter.avatarUrl"),
|
||||
],
|
||||
)
|
||||
class LobstersPostDetails(
|
||||
|
|
|
@ -28,7 +28,7 @@ pluginManagement {
|
|||
includeModule("dev.iurysouza", "modulegraph")
|
||||
includeModule(
|
||||
"com.jraska.module.graph.assertion",
|
||||
"com.jraska.module.graph.assertion.gradle.plugin"
|
||||
"com.jraska.module.graph.assertion.gradle.plugin",
|
||||
)
|
||||
includeModule("com.gradle", "gradle-enterprise-gradle-plugin")
|
||||
includeModule("com.gradle.enterprise", "com.gradle.enterprise.gradle.plugin")
|
||||
|
|
|
@ -103,7 +103,7 @@ public fun WebView(
|
|||
onDispose,
|
||||
client,
|
||||
chromeClient,
|
||||
factory
|
||||
factory,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ public fun WebView(
|
|||
content.data,
|
||||
content.mimeType,
|
||||
content.encoding,
|
||||
content.historyUrl
|
||||
content.historyUrl,
|
||||
)
|
||||
}
|
||||
is WebContent.Post -> {
|
||||
|
@ -204,7 +204,7 @@ public fun WebView(
|
|||
.also { state.webView = it }
|
||||
},
|
||||
modifier = modifier,
|
||||
onRelease = { onDispose(it) }
|
||||
onRelease = { onDispose(it) },
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -248,7 +248,7 @@ public open class AccompanistWebViewClient : WebViewClient() {
|
|||
override fun onReceivedError(
|
||||
view: WebView,
|
||||
request: WebResourceRequest?,
|
||||
error: WebResourceError?
|
||||
error: WebResourceError?,
|
||||
) {
|
||||
super.onReceivedError(view, request, error)
|
||||
|
||||
|
@ -298,7 +298,7 @@ public sealed class WebContent {
|
|||
val baseUrl: String? = null,
|
||||
val encoding: String = "utf-8",
|
||||
val mimeType: String? = null,
|
||||
val historyUrl: String? = null
|
||||
val historyUrl: String? = null,
|
||||
) : WebContent()
|
||||
|
||||
public data class Post(val url: String, val postData: ByteArray) : WebContent() {
|
||||
|
@ -417,7 +417,7 @@ public class WebViewNavigator(
|
|||
|
||||
data class LoadUrl(
|
||||
val url: String,
|
||||
val additionalHttpHeaders: Map<String, String> = emptyMap()
|
||||
val additionalHttpHeaders: Map<String, String> = emptyMap(),
|
||||
) : NavigationEvent
|
||||
|
||||
data class LoadHtml(
|
||||
|
@ -425,7 +425,7 @@ public class WebViewNavigator(
|
|||
val baseUrl: String? = null,
|
||||
val mimeType: String? = null,
|
||||
val encoding: String? = "utf-8",
|
||||
val historyUrl: String? = null
|
||||
val historyUrl: String? = null,
|
||||
) : NavigationEvent
|
||||
|
||||
data class PostUrl(val url: String, val postData: ByteArray) : NavigationEvent {
|
||||
|
@ -466,7 +466,7 @@ public class WebViewNavigator(
|
|||
event.html,
|
||||
event.mimeType,
|
||||
event.encoding,
|
||||
event.historyUrl
|
||||
event.historyUrl,
|
||||
)
|
||||
is NavigationEvent.LoadUrl -> {
|
||||
loadUrl(event.url, event.additionalHttpHeaders)
|
||||
|
@ -497,7 +497,7 @@ public class WebViewNavigator(
|
|||
baseUrl: String? = null,
|
||||
mimeType: String? = null,
|
||||
encoding: String? = "utf-8",
|
||||
historyUrl: String? = null
|
||||
historyUrl: String? = null,
|
||||
) {
|
||||
coroutineScope.launch {
|
||||
navigationEvents.emit(NavigationEvent.LoadHtml(html, baseUrl, mimeType, encoding, historyUrl))
|
||||
|
@ -546,7 +546,7 @@ public data class WebViewError(
|
|||
/** The request the error came from. */
|
||||
val request: WebResourceRequest?,
|
||||
/** The error that was reported. */
|
||||
val error: WebResourceError
|
||||
val error: WebResourceError,
|
||||
)
|
||||
|
||||
/**
|
||||
|
@ -559,7 +559,7 @@ public data class WebViewError(
|
|||
@Composable
|
||||
public fun rememberWebViewState(
|
||||
url: String,
|
||||
additionalHttpHeaders: ImmutableMap<String, String> = persistentMapOf()
|
||||
additionalHttpHeaders: ImmutableMap<String, String> = persistentMapOf(),
|
||||
): WebViewState =
|
||||
// Rather than using .apply {} here we will recreate the state, this prevents
|
||||
// a recomposition loop when the webview updates the url itself.
|
||||
|
@ -581,7 +581,7 @@ public fun rememberWebViewStateWithHTMLData(
|
|||
baseUrl: String? = null,
|
||||
encoding: String = "utf-8",
|
||||
mimeType: String? = null,
|
||||
historyUrl: String? = null
|
||||
historyUrl: String? = null,
|
||||
): WebViewState =
|
||||
remember { WebViewState(WebContent.Data(data, baseUrl, encoding, mimeType, historyUrl)) }
|
||||
.apply { this.content = WebContent.Data(data, baseUrl, encoding, mimeType, historyUrl) }
|
||||
|
@ -619,7 +619,7 @@ public val WebStateSaver: Saver<WebViewState, Any> = run {
|
|||
mapOf(
|
||||
pageTitleKey to it.pageTitle,
|
||||
lastLoadedUrlKey to it.lastLoadedUrl,
|
||||
stateBundle to viewState
|
||||
stateBundle to viewState,
|
||||
)
|
||||
},
|
||||
restore = {
|
||||
|
@ -628,6 +628,6 @@ public val WebStateSaver: Saver<WebViewState, Any> = run {
|
|||
this.lastLoadedUrl = it[lastLoadedUrlKey] as String?
|
||||
this.viewState = it[stateBundle] as Bundle?
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue