Initial API skeleton around Material Icons
Adds base Icons object, with documentation, samples, and a test
(currently no-ops, but shows how we will compare with xml vectors).
Also removes width / height parsing from IconParser - Material icons
have recently been updated to all be 24 by 24.
Bug: b/146212531
Test: IconComparisonTest
Change-Id: I818a6bf1e30369a3189cc667f941c94292f05ade
diff --git a/ui/ui-material/icons/core/api/0.1.0-dev05.txt b/ui/ui-material/icons/core/api/0.1.0-dev05.txt
new file mode 100644
index 0000000..fe4ae06
--- /dev/null
+++ b/ui/ui-material/icons/core/api/0.1.0-dev05.txt
@@ -0,0 +1,36 @@
+// Signature format: 3.0
+package androidx.ui.material.icons {
+
+ public final class Icons {
+ method public androidx.ui.material.icons.Icons.Filled getDefault();
+ property public final androidx.ui.material.icons.Icons.Filled Default;
+ field public static final androidx.ui.material.icons.Icons! INSTANCE;
+ }
+
+ public static final class Icons.Filled {
+ field public static final androidx.ui.material.icons.Icons.Filled! INSTANCE;
+ }
+
+ public static final class Icons.Outlined {
+ field public static final androidx.ui.material.icons.Icons.Outlined! INSTANCE;
+ }
+
+ public static final class Icons.Rounded {
+ field public static final androidx.ui.material.icons.Icons.Rounded! INSTANCE;
+ }
+
+ public static final class Icons.Sharp {
+ field public static final androidx.ui.material.icons.Icons.Sharp! INSTANCE;
+ }
+
+ public static final class Icons.TwoTone {
+ field public static final androidx.ui.material.icons.Icons.TwoTone! INSTANCE;
+ }
+
+ public final class IconsKt {
+ method public static kotlin.Lazy<androidx.ui.graphics.vector.VectorAsset> lazyMaterialIcon(kotlin.jvm.functions.Function1<? super androidx.ui.graphics.vector.VectorAssetBuilder,androidx.ui.graphics.vector.VectorAssetBuilder> block);
+ method public static androidx.ui.graphics.vector.VectorAssetBuilder materialPath(androidx.ui.graphics.vector.VectorAssetBuilder, float fillAlpha = 1f, float strokeAlpha = 1f, kotlin.jvm.functions.Function1<? super androidx.ui.graphics.vector.PathBuilder,kotlin.Unit> pathBuilder);
+ }
+
+}
+
diff --git a/ui/ui-material/icons/core/api/current.txt b/ui/ui-material/icons/core/api/current.txt
new file mode 100644
index 0000000..fe4ae06
--- /dev/null
+++ b/ui/ui-material/icons/core/api/current.txt
@@ -0,0 +1,36 @@
+// Signature format: 3.0
+package androidx.ui.material.icons {
+
+ public final class Icons {
+ method public androidx.ui.material.icons.Icons.Filled getDefault();
+ property public final androidx.ui.material.icons.Icons.Filled Default;
+ field public static final androidx.ui.material.icons.Icons! INSTANCE;
+ }
+
+ public static final class Icons.Filled {
+ field public static final androidx.ui.material.icons.Icons.Filled! INSTANCE;
+ }
+
+ public static final class Icons.Outlined {
+ field public static final androidx.ui.material.icons.Icons.Outlined! INSTANCE;
+ }
+
+ public static final class Icons.Rounded {
+ field public static final androidx.ui.material.icons.Icons.Rounded! INSTANCE;
+ }
+
+ public static final class Icons.Sharp {
+ field public static final androidx.ui.material.icons.Icons.Sharp! INSTANCE;
+ }
+
+ public static final class Icons.TwoTone {
+ field public static final androidx.ui.material.icons.Icons.TwoTone! INSTANCE;
+ }
+
+ public final class IconsKt {
+ method public static kotlin.Lazy<androidx.ui.graphics.vector.VectorAsset> lazyMaterialIcon(kotlin.jvm.functions.Function1<? super androidx.ui.graphics.vector.VectorAssetBuilder,androidx.ui.graphics.vector.VectorAssetBuilder> block);
+ method public static androidx.ui.graphics.vector.VectorAssetBuilder materialPath(androidx.ui.graphics.vector.VectorAssetBuilder, float fillAlpha = 1f, float strokeAlpha = 1f, kotlin.jvm.functions.Function1<? super androidx.ui.graphics.vector.PathBuilder,kotlin.Unit> pathBuilder);
+ }
+
+}
+
diff --git a/ui/ui-material/icons/core/api/public_plus_experimental_0.1.0-dev05.txt b/ui/ui-material/icons/core/api/public_plus_experimental_0.1.0-dev05.txt
new file mode 100644
index 0000000..fe4ae06
--- /dev/null
+++ b/ui/ui-material/icons/core/api/public_plus_experimental_0.1.0-dev05.txt
@@ -0,0 +1,36 @@
+// Signature format: 3.0
+package androidx.ui.material.icons {
+
+ public final class Icons {
+ method public androidx.ui.material.icons.Icons.Filled getDefault();
+ property public final androidx.ui.material.icons.Icons.Filled Default;
+ field public static final androidx.ui.material.icons.Icons! INSTANCE;
+ }
+
+ public static final class Icons.Filled {
+ field public static final androidx.ui.material.icons.Icons.Filled! INSTANCE;
+ }
+
+ public static final class Icons.Outlined {
+ field public static final androidx.ui.material.icons.Icons.Outlined! INSTANCE;
+ }
+
+ public static final class Icons.Rounded {
+ field public static final androidx.ui.material.icons.Icons.Rounded! INSTANCE;
+ }
+
+ public static final class Icons.Sharp {
+ field public static final androidx.ui.material.icons.Icons.Sharp! INSTANCE;
+ }
+
+ public static final class Icons.TwoTone {
+ field public static final androidx.ui.material.icons.Icons.TwoTone! INSTANCE;
+ }
+
+ public final class IconsKt {
+ method public static kotlin.Lazy<androidx.ui.graphics.vector.VectorAsset> lazyMaterialIcon(kotlin.jvm.functions.Function1<? super androidx.ui.graphics.vector.VectorAssetBuilder,androidx.ui.graphics.vector.VectorAssetBuilder> block);
+ method public static androidx.ui.graphics.vector.VectorAssetBuilder materialPath(androidx.ui.graphics.vector.VectorAssetBuilder, float fillAlpha = 1f, float strokeAlpha = 1f, kotlin.jvm.functions.Function1<? super androidx.ui.graphics.vector.PathBuilder,kotlin.Unit> pathBuilder);
+ }
+
+}
+
diff --git a/ui/ui-material/icons/core/api/public_plus_experimental_current.txt b/ui/ui-material/icons/core/api/public_plus_experimental_current.txt
new file mode 100644
index 0000000..fe4ae06
--- /dev/null
+++ b/ui/ui-material/icons/core/api/public_plus_experimental_current.txt
@@ -0,0 +1,36 @@
+// Signature format: 3.0
+package androidx.ui.material.icons {
+
+ public final class Icons {
+ method public androidx.ui.material.icons.Icons.Filled getDefault();
+ property public final androidx.ui.material.icons.Icons.Filled Default;
+ field public static final androidx.ui.material.icons.Icons! INSTANCE;
+ }
+
+ public static final class Icons.Filled {
+ field public static final androidx.ui.material.icons.Icons.Filled! INSTANCE;
+ }
+
+ public static final class Icons.Outlined {
+ field public static final androidx.ui.material.icons.Icons.Outlined! INSTANCE;
+ }
+
+ public static final class Icons.Rounded {
+ field public static final androidx.ui.material.icons.Icons.Rounded! INSTANCE;
+ }
+
+ public static final class Icons.Sharp {
+ field public static final androidx.ui.material.icons.Icons.Sharp! INSTANCE;
+ }
+
+ public static final class Icons.TwoTone {
+ field public static final androidx.ui.material.icons.Icons.TwoTone! INSTANCE;
+ }
+
+ public final class IconsKt {
+ method public static kotlin.Lazy<androidx.ui.graphics.vector.VectorAsset> lazyMaterialIcon(kotlin.jvm.functions.Function1<? super androidx.ui.graphics.vector.VectorAssetBuilder,androidx.ui.graphics.vector.VectorAssetBuilder> block);
+ method public static androidx.ui.graphics.vector.VectorAssetBuilder materialPath(androidx.ui.graphics.vector.VectorAssetBuilder, float fillAlpha = 1f, float strokeAlpha = 1f, kotlin.jvm.functions.Function1<? super androidx.ui.graphics.vector.PathBuilder,kotlin.Unit> pathBuilder);
+ }
+
+}
+
diff --git a/ui/ui-material/icons/core/api/res-0.1.0-dev05.txt b/ui/ui-material/icons/core/api/res-0.1.0-dev05.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ui/ui-material/icons/core/api/res-0.1.0-dev05.txt
diff --git a/ui/ui-material/icons/core/api/restricted_0.1.0-dev05.txt b/ui/ui-material/icons/core/api/restricted_0.1.0-dev05.txt
new file mode 100644
index 0000000..fe4ae06
--- /dev/null
+++ b/ui/ui-material/icons/core/api/restricted_0.1.0-dev05.txt
@@ -0,0 +1,36 @@
+// Signature format: 3.0
+package androidx.ui.material.icons {
+
+ public final class Icons {
+ method public androidx.ui.material.icons.Icons.Filled getDefault();
+ property public final androidx.ui.material.icons.Icons.Filled Default;
+ field public static final androidx.ui.material.icons.Icons! INSTANCE;
+ }
+
+ public static final class Icons.Filled {
+ field public static final androidx.ui.material.icons.Icons.Filled! INSTANCE;
+ }
+
+ public static final class Icons.Outlined {
+ field public static final androidx.ui.material.icons.Icons.Outlined! INSTANCE;
+ }
+
+ public static final class Icons.Rounded {
+ field public static final androidx.ui.material.icons.Icons.Rounded! INSTANCE;
+ }
+
+ public static final class Icons.Sharp {
+ field public static final androidx.ui.material.icons.Icons.Sharp! INSTANCE;
+ }
+
+ public static final class Icons.TwoTone {
+ field public static final androidx.ui.material.icons.Icons.TwoTone! INSTANCE;
+ }
+
+ public final class IconsKt {
+ method public static kotlin.Lazy<androidx.ui.graphics.vector.VectorAsset> lazyMaterialIcon(kotlin.jvm.functions.Function1<? super androidx.ui.graphics.vector.VectorAssetBuilder,androidx.ui.graphics.vector.VectorAssetBuilder> block);
+ method public static androidx.ui.graphics.vector.VectorAssetBuilder materialPath(androidx.ui.graphics.vector.VectorAssetBuilder, float fillAlpha = 1f, float strokeAlpha = 1f, kotlin.jvm.functions.Function1<? super androidx.ui.graphics.vector.PathBuilder,kotlin.Unit> pathBuilder);
+ }
+
+}
+
diff --git a/ui/ui-material/icons/core/api/restricted_current.txt b/ui/ui-material/icons/core/api/restricted_current.txt
new file mode 100644
index 0000000..fe4ae06
--- /dev/null
+++ b/ui/ui-material/icons/core/api/restricted_current.txt
@@ -0,0 +1,36 @@
+// Signature format: 3.0
+package androidx.ui.material.icons {
+
+ public final class Icons {
+ method public androidx.ui.material.icons.Icons.Filled getDefault();
+ property public final androidx.ui.material.icons.Icons.Filled Default;
+ field public static final androidx.ui.material.icons.Icons! INSTANCE;
+ }
+
+ public static final class Icons.Filled {
+ field public static final androidx.ui.material.icons.Icons.Filled! INSTANCE;
+ }
+
+ public static final class Icons.Outlined {
+ field public static final androidx.ui.material.icons.Icons.Outlined! INSTANCE;
+ }
+
+ public static final class Icons.Rounded {
+ field public static final androidx.ui.material.icons.Icons.Rounded! INSTANCE;
+ }
+
+ public static final class Icons.Sharp {
+ field public static final androidx.ui.material.icons.Icons.Sharp! INSTANCE;
+ }
+
+ public static final class Icons.TwoTone {
+ field public static final androidx.ui.material.icons.Icons.TwoTone! INSTANCE;
+ }
+
+ public final class IconsKt {
+ method public static kotlin.Lazy<androidx.ui.graphics.vector.VectorAsset> lazyMaterialIcon(kotlin.jvm.functions.Function1<? super androidx.ui.graphics.vector.VectorAssetBuilder,androidx.ui.graphics.vector.VectorAssetBuilder> block);
+ method public static androidx.ui.graphics.vector.VectorAssetBuilder materialPath(androidx.ui.graphics.vector.VectorAssetBuilder, float fillAlpha = 1f, float strokeAlpha = 1f, kotlin.jvm.functions.Function1<? super androidx.ui.graphics.vector.PathBuilder,kotlin.Unit> pathBuilder);
+ }
+
+}
+
diff --git a/ui/ui-material/icons/core/build.gradle b/ui/ui-material/icons/core/build.gradle
new file mode 100644
index 0000000..39c8b0a
--- /dev/null
+++ b/ui/ui-material/icons/core/build.gradle
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import androidx.build.LibraryGroups
+import androidx.build.LibraryVersions
+import androidx.build.Publish
+
+import static androidx.build.dependencies.DependenciesKt.*
+
+plugins {
+ id("AndroidXPlugin")
+ id("com.android.library")
+ id("AndroidXUiPlugin")
+ id("org.jetbrains.kotlin.android")
+}
+
+dependencies {
+ implementation(KOTLIN_STDLIB)
+
+ api project(":ui:ui-core")
+ api project(":ui:ui-framework")
+}
+
+androidx {
+ name = "AndroidX Core Material Icons"
+ publish = Publish.SNAPSHOT_AND_RELEASE
+ mavenVersion = LibraryVersions.UI
+ mavenGroup = LibraryGroups.UI
+ inceptionYear = "2020"
+ description = "AndroidX Core Material Icons"
+}
diff --git a/ui/ui-material/icons/core/integration-tests/samples/build.gradle b/ui/ui-material/icons/core/integration-tests/samples/build.gradle
new file mode 100644
index 0000000..84bbd18
--- /dev/null
+++ b/ui/ui-material/icons/core/integration-tests/samples/build.gradle
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
+
+import static androidx.build.dependencies.DependenciesKt.*
+
+plugins {
+ id("AndroidXPlugin")
+ id("com.android.library")
+ id("AndroidXUiPlugin")
+ id("org.jetbrains.kotlin.android")
+}
+
+dependencies {
+ kotlinPlugin project(path: ":compose:compose-compiler")
+
+ implementation(KOTLIN_STDLIB)
+
+ implementation project(":annotation:annotation-sampled")
+
+ implementation project(":compose:compose-runtime")
+ implementation project(":ui:ui-material-icons-core")
+ implementation project(":ui:ui-vector")
+}
+
+android {
+ tasks.withType(KotlinCompile).configureEach {
+ kotlinOptions {
+ useIR = true
+ }
+ }
+}
diff --git a/ui/ui-material/icons/core/integration-tests/samples/src/main/AndroidManifest.xml b/ui/ui-material/icons/core/integration-tests/samples/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..1f7495d
--- /dev/null
+++ b/ui/ui-material/icons/core/integration-tests/samples/src/main/AndroidManifest.xml
@@ -0,0 +1,16 @@
+<!--
+ ~ Copyright (C) 2020 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+<manifest package="androidx.ui.material.icons.samples" />
diff --git a/ui/ui-material/icons/core/integration-tests/samples/src/main/java/androidx/ui/material/icons/samples/IconSamples.kt b/ui/ui-material/icons/core/integration-tests/samples/src/main/java/androidx/ui/material/icons/samples/IconSamples.kt
new file mode 100644
index 0000000..fc5d152c
--- /dev/null
+++ b/ui/ui-material/icons/core/integration-tests/samples/src/main/java/androidx/ui/material/icons/samples/IconSamples.kt
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.ui.material.icons.samples
+
+import androidx.annotation.Sampled
+import androidx.compose.Composable
+import androidx.ui.graphics.vector.DrawVector
+import androidx.ui.graphics.vector.VectorAsset
+import androidx.ui.graphics.vector.VectorAssetBuilder
+import androidx.ui.material.icons.Icons
+import androidx.ui.unit.dp
+
+@Sampled
+@Composable
+@Suppress("LocalVariableName", "UNUSED_VARIABLE")
+fun AppIcons() {
+ val MyAppIcons = Icons.Rounded
+ SomeComposable(icon = MyAppIcons.Menu)
+}
+
+@Sampled
+@Composable
+fun DrawIcon() {
+ DrawVector(vectorImage = Icons.Rounded.Menu)
+}
+
+@Composable
+private fun SomeComposable(icon: VectorAsset) { DrawVector(icon) }
+
+// TODO: b/146212531 remove once main code has merged
+private val Icons.Rounded.Menu get() = VectorAssetBuilder("", 0.dp, 0.dp, 24f, 24f).build()
diff --git a/ui/ui-material/icons/core/src/main/AndroidManifest.xml b/ui/ui-material/icons/core/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..88c6032
--- /dev/null
+++ b/ui/ui-material/icons/core/src/main/AndroidManifest.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2020 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<manifest package="androidx.ui.material.icons" />
diff --git a/ui/ui-material/icons/core/src/main/java/androidx/ui/material/icons/Icons.kt b/ui/ui-material/icons/core/src/main/java/androidx/ui/material/icons/Icons.kt
new file mode 100644
index 0000000..7bee4c5
--- /dev/null
+++ b/ui/ui-material/icons/core/src/main/java/androidx/ui/material/icons/Icons.kt
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.ui.material.icons
+
+import androidx.ui.graphics.Color
+import androidx.ui.graphics.SolidColor
+import androidx.ui.graphics.StrokeCap
+import androidx.ui.graphics.StrokeJoin
+import androidx.ui.graphics.vector.PathBuilder
+import androidx.ui.graphics.vector.VectorAsset
+import androidx.ui.graphics.vector.VectorAssetBuilder
+import androidx.ui.graphics.vector.path
+import androidx.ui.unit.dp
+
+/**
+ * Entry point for using [Material Icons](https://material.io/resources/icons) in Compose.
+ *
+ * There are five distinct icon themes: [Filled], [Outlined], [Rounded], [TwoTone], and [Sharp].
+ * Each theme contains the same icons, but with a distinct visual style. You should typically
+ * choose one theme and use it across your application for consistency. For example, you may want
+ * to use a property or a typealias to refer to a specific theme, so it can be accessed in a
+ * semantically meaningful way from inside other composables.
+ *
+ * @sample androidx.ui.material.icons.samples.AppIcons
+ *
+ * Icons maintain the same names defined by Material, but with their snake_case name converted to
+ * PascalCase. For example: add_alarm becomes AddAlarm.
+ *
+ * Note: Icons that start with a number, such as `360`, are prefixed with a '_', becoming '_360'.
+ *
+ * Icons are represented as [androidx.ui.graphics.vector.VectorAsset]s and hence can be drawn by
+ * simply using [androidx.ui.graphics.vector.DrawVector].
+ *
+ * @sample androidx.ui.material.icons.samples.DrawIcon
+ */
+object Icons {
+ /**
+ * [Filled icons](https://material.io/resources/icons/?style=baseline) (previously the only
+ * available theme, also known as the baseline theme) are the default icon theme. You can
+ * also use [Default] as an alias for these icons.
+ */
+ object Filled
+
+ /**
+ * [Outlined icons](https://material.io/resources/icons/?style=outline) make use of a thin
+ * stroke and empty space inside for a lighter appearance.
+ */
+ object Outlined
+
+ /**
+ * [Rounded icons](https://material.io/resources/icons/?style=round) use a corner radius that
+ * pairs well with brands that use heavier typography, curved logos, or circular elements to
+ * express their style.
+ */
+ object Rounded
+
+ /**
+ * [Two-Tone icons](https://material.io/resources/icons/?style=twotone) display corners with
+ * straight edges, for a crisp style that remains legible even at smaller scales. These
+ * rectangular shapes can support brand styles that are not well-reflected by rounded shapes.
+ */
+ object TwoTone
+
+ /**
+ * [Sharp icons](https://material.io/resources/icons/?style=sharp) display corners with
+ * straight edges, for a crisp style that remains legible even at smaller scales. These
+ * rectangular shapes can support brand styles that are not well-reflected by rounded shapes.
+ */
+ object Sharp
+
+ /**
+ * Alias for [Filled], the baseline icon theme.
+ */
+ val Default = Filled
+}
+
+/**
+ * Utility delegate to construct a lazily initialized Material icon with default size information.
+ * This is used by generated icons, and should not be used manually.
+ *
+ * @param block builder lambda to add paths to this vector asset
+ */
+fun lazyMaterialIcon(
+ block: VectorAssetBuilder.() -> VectorAssetBuilder
+): Lazy<VectorAsset> = lazy(LazyThreadSafetyMode.NONE) {
+ VectorAssetBuilder(
+ defaultWidth = MaterialIconDimension.dp,
+ defaultHeight = MaterialIconDimension.dp,
+ viewportWidth = MaterialIconDimension,
+ viewportHeight = MaterialIconDimension
+ ).block().build()
+}
+
+/**
+ * Adds a vector path to this icon with sane Material defaults.
+ *
+ * @param fillAlpha fill alpha for this path
+ * @param strokeAlpha stroke alpha for this path
+ * @param pathBuilder builder lambda to add commands to this path
+ */
+fun VectorAssetBuilder.materialPath(
+ fillAlpha: Float = 1f,
+ strokeAlpha: Float = 1f,
+ pathBuilder: PathBuilder.() -> Unit
+) =
+ // TODO: b/146213225
+ // Some of these defaults are already set when parsing from XML, but do not currently exist
+ // when added programmatically. We should unify these and simplify them where possible.
+ path(
+ fill = SolidColor(Color.Black),
+ fillAlpha = fillAlpha,
+ stroke = null,
+ strokeAlpha = strokeAlpha,
+ strokeLineWidth = 1f,
+ strokeLineCap = StrokeCap.butt,
+ strokeLineJoin = StrokeJoin.bevel,
+ strokeLineMiter = 1f,
+ pathBuilder = pathBuilder
+ )
+
+// All Material icons (currently) are 24dp by 24dp, with a viewport size of 24 by 24.
+private const val MaterialIconDimension = 24f