8000 GitHub - arcanegolem/Materialize at v1.0.0
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

arcanegolem/Materialize

Repository files navigation

Materialize

Materialize Header Simple PDF viewer made with and for Jetpack Compose

Requirements

Add INTERNET permission to your Android Manifest

<uses-permission android:name="android.permission.INTERNET" />

[OPTIONAL] Set android:usesCleartextTraffic="true" in your Android Manifest <application> tag to enable downloading of PDF documents from unsecure http:// URLs

<application>
  ...
  android:usesCleartextTraffic="true"
  ...
</application>

Add Jitpack to your project repositories

dependencyResolutionManagement {
  repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
  repositories {
    mavenCentral()
    maven { url 'https://jitpack.io' }
  }
}
  • Add lycoris to your project dependencies
dependencies {
  implementation 'com.github.arcanegolem:Materialize:<version>'
}

Example usage

ColumnPdfViewer composable function provides a simple scrollable column PDF viewer, fillers and "more" menu can be customized using PdfViewerColors and options parameters. PDF document can be provided via URL, Uri or Raw resource using corresponding PdfProvider.

For example, following code (see more in MainActivity.kt) will result in something like this:

ColumnPdfViewer(
  modifier = Modifier.fillMaxSize(),
  pdfProvider = PdfProvider.ResProvider(
    resId = R.raw.sample_multipage,
    bitmapScale = 3,
    identifier = "sample_multipage"
  ),
  colors = PdfViewerColors(
    fillerPageColor = Color.Black,
    floatingElementsColor = Color.Blue,
    iconButtonColors = IconButtonDefaults.iconButtonColors(),
    textFieldColors = TextFieldDefaults.colors()
  ),
  options = listOf(
    PdfViewerOption(
      title = "SampleOption",
      action = {
        Toast.makeText(context, "Sample text", Toast.LENGTH_SHORT).show()
      }
    ),
    PdfViewerOption(
      title = "SampleOption2",
      action = {
        Toast.makeText(context, "Another sample text", Toast.LENGTH_SHORT).show()
      }
    )
  ),
  fillerAspectRatio = 1f / sqrt(2f)
)

About

Simple PDF viewer library made with and for Jetpack Compose (URL, Uri, Resources)

Topics

Resources

License

Stars

Watchers

Forks

Languages

0