https://kotlinlang.org logo
Title
p

Peter Mandeljc

02/17/2023, 1:51 PM
is it possible for Accompanist WebView to follow app theme?
j

Jakub Syty

02/17/2023, 1:54 PM
What do you mean by that? Are you talking about system light/dark setting?
p

Peter Mandeljc

02/17/2023, 1:54 PM
also that yeah
j

Jakub Syty

02/17/2023, 1:57 PM
looking at the code i don't think it's implemented
but i think it might follow the app "dark mode", docs here seems to suggest that: https://developer.android.com/develop/ui/views/layout/webapps/dark-theme
but other than dark mode - i don't know how do you expect to follow app theme
p

Peter Mandeljc

02/17/2023, 2:05 PM
I was only thinking about basic background and text color
dunno, neither Accompanist WebView or WebView View doesn't seem to go into dark mode. I can force it tough.
j

Jakub Syty

02/17/2023, 2:06 PM
Background and text colors are fully website domain. You can inject javascript into WebView and modify colors this way, but WebView never will pass anything like this by itself
p

Peter Mandeljc

02/17/2023, 2:09 PM
I see. I basically have a html text content, that I need to render. Any suggestions?
j

Jakub Syty

02/17/2023, 2:14 PM
you can inject css that is based on your app theme
but i doubt there is something ready to use in that regard
or, you could load html in old TextView
e

ephemient

02/17/2023, 2:15 PM
How complex is the HTML? in a private project, I have a parser for the subset of HTML that we use into AnnotatedString, and I've seen other people use Android's HTML to spannable then convert that
j

Jakub Syty

02/17/2023, 2:15 PM
and then wrap this TextView into composable AndroidView
p

Peter Mandeljc

02/17/2023, 2:20 PM
I've already tried out Html.fromHtml() stuff. I guess there is no lazy solution atm 🙂
I'm looking at what simplest option is atm
How complex is the HTML?
Not that complex, some titles, lists and links. Should be able to convert it I guess
e

ephemient

02/17/2023, 2:24 PM
most of the complexity in my private project results from having to deal with inline CSS and custom classes. if you don't have that, it's really not that hard
p

Peter Mandeljc

02/17/2023, 2:30 PM
ok, will think about doing that. Thanks for info guys 🍺