Tobias
02/06/2024, 8:42 AMAndroidView(
factory = { context ->
WebView(context).apply {
webViewClient = WebViewClient()
settings.loadWithOverviewMode = true
settings.useWideViewPort = true
settings.setSupportZoom(true)
}
},
update = { webView ->
webView.loadUrl("<https://www.dummy.com/sample.pdf>")
}
)
For iOS:
UIKitView(modifier = Modifier.fillMaxSize(),
factory = {
WKWebView()
},
update = { webView ->
webView.loadRequest(
NSURLRequest.requestWithURL(
NSURL.URLWithString("<https://www.dummy.com/sample.pdf>")!!
)
)
}
)
What I want to achieve is having the PDF locally on the device to be able to display the PDF without requiring a network connection.
I only want to have the PDFs under common, but its not clear to me how (or if at all) I can reference the files from my Android and iOS source set. Any pointers highly appreciated.Swapnil Musale
02/06/2024, 8:44 AMTobias
02/06/2024, 8:47 AMSwapnil Musale
02/06/2024, 8:49 AMTobias
02/06/2024, 8:52 AMcommonMain/resources
and distribute it with the app, then be able to display it from androidMain
and iosMain
Jan Holešovský
02/06/2024, 8:55 AMSwapnil Musale
02/06/2024, 8:56 AMTobias
02/06/2024, 9:00 AMandroidMain/res/myfile.pdf
, to check if it can load at least load it from androidMain
, in code I try loading it with webView.loadUrl("<file://android_asset/myfile.pdf>")
, but still can’t find it.Jan Holešovský
02/06/2024, 9:03 AMTobias
02/06/2024, 9:10 AMassets
folder in the root of the project” :_ In the context of a Compose Multiplatform app, what is the “root” of the project? Would that be directly having a folder called assets
under composeApp
? (Which doesn’t work either, just tried …)Jan Holešovský
02/06/2024, 9:16 AMTobias
02/06/2024, 9:30 AMandroidMain/assets
leaves me with an empty view but no error message. Maybe an issue with my composable. It does not work though when trying to load from commonMain/assets
, but at least its a hint.
Maybe there is a way using MOKO-resources and then handing over “something” to the actual classes …Jan Holešovský
02/06/2024, 9:33 AMJan Holešovský
02/06/2024, 9:34 AMTobias
02/06/2024, 9:35 AMJan Holešovský
02/06/2024, 9:35 AMJan Holešovský
02/06/2024, 9:35 AMJan Holešovský
02/06/2024, 9:36 AMJan Holešovský
02/06/2024, 9:36 AMJan Holešovský
02/06/2024, 9:36 AMTobias
02/06/2024, 9:37 AMJan Holešovský
02/06/2024, 9:48 AMMcEna
02/06/2024, 2:44 PMMcEna
02/06/2024, 2:45 PMMcEna
02/06/2024, 2:47 PM