Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
serbelga authored Jan 13, 2024
1 parent 72e0469 commit 30619b3
Showing 1 changed file with 73 additions and 2 deletions.
75 changes: 73 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,79 @@ Converts the XML files located in the `xml-images` folder and creates categories

## How to Use

- [Android](https://github.com/serbelga/compose-vectorize/blob/main/docs/android.md)
- [Multiplatform](https://github.com/serbelga/compose-vectorize/blob/main/docs/multiplatform.md)
- [Android](#android)
- [Multiplatform](#multiplatform)
- [Generate images](#generate-images)

### Android

```kotlin
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("dev.sergiobelda.compose.vectorize") version "$VERSION"
}

dependencies {
implementation("dev.sergiobelda.compose.vectorize:compose-vectorize-core:$VERSION")
}

composeVectorize {
packageName = "dev.example.myproject" // Custom package name
}
```

Create a folder called `xml-images` in the module folder. For example, if you're using this plugin in your application module called `app`, you need to create a folder inside the app folder.

`app/xml-images`

<img width="332" alt="Captura de pantalla 2024-01-05 a las 16 57 56" src="https://github.com/serbelga/compose-vectorize/assets/26246782/97c4082a-28d8-4009-addd-427d9f893340">

### Multiplatform

```kotlin
plugins {
kotlin("multiplatform")
id("org.jetbrains.compose")
id("dev.sergiobelda.compose.vectorize") version "$VERSION"
}

kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation(compose.ui)
implementation("dev.sergiobelda.compose.vectorize:compose-vectorize-core:$VERSION")
}
}
}
}

composeVectorize {
packageName = "dev.example.myproject" // Custom package name
}
```

Create a folder called `xml-images` in the module folder. For example:

`common/xml-images`

<img width="330" alt="Captura de pantalla 2024-01-05 a las 17 10 28" src="https://github.com/serbelga/compose-vectorize/assets/26246782/2c0a380d-2580-4898-b581-560e4b7c6e6b">

### Generate images

You can manually generate ImageVector for these XML files by calling `gradle generateImages`. This will create a Kotlin file for each XML file containing the ImageVector in the build folder.

<img width="429" alt="Captura de pantalla 2024-01-05 a las 17 00 45" src="https://github.com/serbelga/compose-vectorize/assets/26246782/45ed3cd3-5773-4cf7-9474-4ef6a30a6476">
<br></br>

Now, you can use reference this image in the Compose code:

```kotlin
Icon(Images.Icons.Add, contentDescription = null)
```

Note that automatically a category called "Icons" has been created. A category is created for each subfolder in `xml-images` folder.

## License

Expand Down

0 comments on commit 30619b3

Please sign in to comment.