Skip to content

Commit 83b4b33

Browse files
wiryadevafreakyelf
andauthored
adjust Composable function signature to make source mandatory (#135)
* adjust Composable function signature to make source mandatory * update readme to reflect new function signature * fix missing attribute --------- Co-authored-by: Rajat Mittal <[email protected]>
1 parent ddb92f8 commit 83b4b33

File tree

3 files changed

+13
-30
lines changed

3 files changed

+13
-30
lines changed

README.md

+3-29
Original file line numberDiff line numberDiff line change
@@ -159,38 +159,12 @@ binding.pdfView.initWithUrl(
159159
```
160160

161161
#### Using with Jetpack Compose
162-
163-
For Jetpack Compose, utilize `PdfRendererViewCompose` to render PDF files.
164-
165-
To render a PDF from a URL:
166-
167-
```kotlin
168-
PdfRendererViewCompose(
169-
url = "your_pdf_url_here",
170-
)
171-
```
172-
173-
To render a PDF from a local file:
174-
175-
```kotlin
176-
PdfRendererViewCompose(
177-
file = yourFile,
178-
)
179-
```
180-
181-
To render a PDF from a URI:
182-
183-
```kotlin
184-
PdfRendererViewCompose(
185-
uri = yourUri,
186-
)
187-
```
188-
189-
You can also provide arguments for additional parameters such as `modifier`, `headers`, `lifecycleOwner`, and `statusCallBack`:
162+
For Jetpack Compose, utilize PdfRendererViewCompose:
190163

191164
```kotlin
192165
PdfRendererViewCompose(
193-
url = "your_pdf_url_here",
166+
source = PdfSource.Remote("your_pdf_url_here"),
167+
lifecycleOwner = LocalLifecycleOwner.current
194168
modifier = Modifier,
195169
headers = HeaderData(mapOf("Authorization" to "123456789")),
196170
lifecycleOwner = LocalLifecycleOwner.current,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.rajat.pdfviewer
2+
3+
import android.net.Uri
4+
import java.io.File
5+
6+
sealed interface PdfSource {
7+
data class Remote(val url: String) : PdfSource
8+
data class LocalFile(val file: File) : PdfSource
9+
data class LocalUri(val uri: Uri) : PdfSource
10+
}

pdfViewer/src/main/res/layout/activity_pdf_viewer.xml

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
app:pdfView_divider="@drawable/pdf_viewer_divider"
5454
app:pdfView_showDivider="false"/>
5555

56-
5756
</FrameLayout>
5857

5958
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)