|
| 1 | +/* |
| 2 | + * Copyright 2024 The Android Open Source Project |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package androidx.compose.material3.internal |
| 18 | + |
| 19 | +import androidx.compose.ui.graphics.Color |
| 20 | +import androidx.compose.ui.graphics.PathFillType |
| 21 | +import androidx.compose.ui.graphics.SolidColor |
| 22 | +import androidx.compose.ui.graphics.StrokeCap |
| 23 | +import androidx.compose.ui.graphics.StrokeJoin |
| 24 | +import androidx.compose.ui.graphics.vector.DefaultFillType |
| 25 | +import androidx.compose.ui.graphics.vector.ImageVector |
| 26 | +import androidx.compose.ui.graphics.vector.PathBuilder |
| 27 | +import androidx.compose.ui.graphics.vector.path |
| 28 | +import androidx.compose.ui.unit.dp |
| 29 | + |
| 30 | +internal object Icons { |
| 31 | + internal object AutoMirrored { |
| 32 | + internal object Filled { |
| 33 | + internal val KeyboardArrowLeft: ImageVector |
| 34 | + get() { |
| 35 | + if (_keyboardArrowLeft != null) { |
| 36 | + return _keyboardArrowLeft!! |
| 37 | + } |
| 38 | + _keyboardArrowLeft = |
| 39 | + materialIcon( |
| 40 | + name = "AutoMirrored.Filled.KeyboardArrowLeft", |
| 41 | + autoMirror = true |
| 42 | + ) { |
| 43 | + materialPath { |
| 44 | + moveTo(15.41f, 16.59f) |
| 45 | + lineTo(10.83f, 12.0f) |
| 46 | + lineToRelative(4.58f, -4.59f) |
| 47 | + lineTo(14.0f, 6.0f) |
| 48 | + lineToRelative(-6.0f, 6.0f) |
| 49 | + lineToRelative(6.0f, 6.0f) |
| 50 | + lineToRelative(1.41f, -1.41f) |
| 51 | + close() |
| 52 | + } |
| 53 | + } |
| 54 | + return _keyboardArrowLeft!! |
| 55 | + } |
| 56 | + |
| 57 | + private var _keyboardArrowLeft: ImageVector? = null |
| 58 | + |
| 59 | + internal val KeyboardArrowRight: ImageVector |
| 60 | + get() { |
| 61 | + if (_keyboardArrowRight != null) { |
| 62 | + return _keyboardArrowRight!! |
| 63 | + } |
| 64 | + _keyboardArrowRight = |
| 65 | + materialIcon( |
| 66 | + name = "AutoMirrored.Filled.KeyboardArrowRight", |
| 67 | + autoMirror = true |
| 68 | + ) { |
| 69 | + materialPath { |
| 70 | + moveTo(8.59f, 16.59f) |
| 71 | + lineTo(13.17f, 12.0f) |
| 72 | + lineTo(8.59f, 7.41f) |
| 73 | + lineTo(10.0f, 6.0f) |
| 74 | + lineToRelative(6.0f, 6.0f) |
| 75 | + lineToRelative(-6.0f, 6.0f) |
| 76 | + lineToRelative(-1.41f, -1.41f) |
| 77 | + close() |
| 78 | + } |
| 79 | + } |
| 80 | + return _keyboardArrowRight!! |
| 81 | + } |
| 82 | + |
| 83 | + private var _keyboardArrowRight: ImageVector? = null |
| 84 | + } |
| 85 | + } |
| 86 | + |
| 87 | + internal object Filled { |
| 88 | + internal val Close: ImageVector |
| 89 | + get() { |
| 90 | + if (_close != null) { |
| 91 | + return _close!! |
| 92 | + } |
| 93 | + _close = |
| 94 | + materialIcon(name = "Filled.Close") { |
| 95 | + materialPath { |
| 96 | + moveTo(19.0f, 6.41f) |
| 97 | + lineTo(17.59f, 5.0f) |
| 98 | + lineTo(12.0f, 10.59f) |
| 99 | + lineTo(6.41f, 5.0f) |
| 100 | + lineTo(5.0f, 6.41f) |
| 101 | + lineTo(10.59f, 12.0f) |
| 102 | + lineTo(5.0f, 17.59f) |
| 103 | + lineTo(6.41f, 19.0f) |
| 104 | + lineTo(12.0f, 13.41f) |
| 105 | + lineTo(17.59f, 19.0f) |
| 106 | + lineTo(19.0f, 17.59f) |
| 107 | + lineTo(13.41f, 12.0f) |
| 108 | + close() |
| 109 | + } |
| 110 | + } |
| 111 | + return _close!! |
| 112 | + } |
| 113 | + |
| 114 | + private var _close: ImageVector? = null |
| 115 | + |
| 116 | + internal val Check: ImageVector |
| 117 | + get() { |
| 118 | + if (_check != null) { |
| 119 | + return _check!! |
| 120 | + } |
| 121 | + _check = |
| 122 | + materialIcon(name = "Filled.Check") { |
| 123 | + materialPath { |
| 124 | + moveTo(9.0f, 16.17f) |
| 125 | + lineTo(4.83f, 12.0f) |
| 126 | + lineToRelative(-1.42f, 1.41f) |
| 127 | + lineTo(9.0f, 19.0f) |
| 128 | + lineTo(21.0f, 7.0f) |
| 129 | + lineToRelative(-1.41f, -1.41f) |
| 130 | + close() |
| 131 | + } |
| 132 | + } |
| 133 | + return _check!! |
| 134 | + } |
| 135 | + |
| 136 | + private var _check: ImageVector? = null |
| 137 | + |
| 138 | + internal val Edit: ImageVector |
| 139 | + get() { |
| 140 | + if (_edit != null) { |
| 141 | + return _edit!! |
| 142 | + } |
| 143 | + _edit = |
| 144 | + materialIcon(name = "Filled.Edit") { |
| 145 | + materialPath { |
| 146 | + moveTo(3.0f, 17.25f) |
| 147 | + verticalLineTo(21.0f) |
| 148 | + horizontalLineToRelative(3.75f) |
| 149 | + lineTo(17.81f, 9.94f) |
| 150 | + lineToRelative(-3.75f, -3.75f) |
| 151 | + lineTo(3.0f, 17.25f) |
| 152 | + close() |
| 153 | + moveTo(20.71f, 7.04f) |
| 154 | + curveToRelative(0.39f, -0.39f, 0.39f, -1.02f, 0.0f, -1.41f) |
| 155 | + lineToRelative(-2.34f, -2.34f) |
| 156 | + curveToRelative(-0.39f, -0.39f, -1.02f, -0.39f, -1.41f, 0.0f) |
| 157 | + lineToRelative(-1.83f, 1.83f) |
| 158 | + lineToRelative(3.75f, 3.75f) |
| 159 | + lineToRelative(1.83f, -1.83f) |
| 160 | + close() |
| 161 | + } |
| 162 | + } |
| 163 | + return _edit!! |
| 164 | + } |
| 165 | + |
| 166 | + private var _edit: ImageVector? = null |
| 167 | + |
| 168 | + internal val DateRange: ImageVector |
| 169 | + get() { |
| 170 | + if (_dateRange != null) { |
| 171 | + return _dateRange!! |
| 172 | + } |
| 173 | + _dateRange = |
| 174 | + materialIcon(name = "Filled.DateRange") { |
| 175 | + materialPath { |
| 176 | + moveTo(9.0f, 11.0f) |
| 177 | + lineTo(7.0f, 11.0f) |
| 178 | + verticalLineToRelative(2.0f) |
| 179 | + horizontalLineToRelative(2.0f) |
| 180 | + verticalLineToRelative(-2.0f) |
| 181 | + close() |
| 182 | + moveTo(13.0f, 11.0f) |
| 183 | + horizontalLineToRelative(-2.0f) |
| 184 | + verticalLineToRelative(2.0f) |
| 185 | + horizontalLineToRelative(2.0f) |
| 186 | + verticalLineToRelative(-2.0f) |
| 187 | + close() |
| 188 | + moveTo(17.0f, 11.0f) |
| 189 | + horizontalLineToRelative(-2.0f) |
| 190 | + verticalLineToRelative(2.0f) |
| 191 | + horizontalLineToRelative(2.0f) |
| 192 | + verticalLineToRelative(-2.0f) |
| 193 | + close() |
| 194 | + moveTo(19.0f, 4.0f) |
| 195 | + horizontalLineToRelative(-1.0f) |
| 196 | + lineTo(18.0f, 2.0f) |
| 197 | + horizontalLineToRelative(-2.0f) |
| 198 | + verticalLineToRelative(2.0f) |
| 199 | + lineTo(8.0f, 4.0f) |
| 200 | + lineTo(8.0f, 2.0f) |
| 201 | + lineTo(6.0f, 2.0f) |
| 202 | + verticalLineToRelative(2.0f) |
| 203 | + lineTo(5.0f, 4.0f) |
| 204 | + curveToRelative(-1.11f, 0.0f, -1.99f, 0.9f, -1.99f, 2.0f) |
| 205 | + lineTo(3.0f, 20.0f) |
| 206 | + curveToRelative(0.0f, 1.1f, 0.89f, 2.0f, 2.0f, 2.0f) |
| 207 | + horizontalLineToRelative(14.0f) |
| 208 | + curveToRelative(1.1f, 0.0f, 2.0f, -0.9f, 2.0f, -2.0f) |
| 209 | + lineTo(21.0f, 6.0f) |
| 210 | + curveToRelative(0.0f, -1.1f, -0.9f, -2.0f, -2.0f, -2.0f) |
| 211 | + close() |
| 212 | + moveTo(19.0f, 20.0f) |
| 213 | + lineTo(5.0f, 20.0f) |
| 214 | + lineTo(5.0f, 9.0f) |
| 215 | + horizontalLineToRelative(14.0f) |
| 216 | + verticalLineToRelative(11.0f) |
| 217 | + close() |
| 218 | + } |
| 219 | + } |
| 220 | + return _dateRange!! |
| 221 | + } |
| 222 | + |
| 223 | + private var _dateRange: ImageVector? = null |
| 224 | + |
| 225 | + internal val ArrowDropDown: ImageVector |
| 226 | + get() { |
| 227 | + if (_arrowDropDown != null) { |
| 228 | + return _arrowDropDown!! |
| 229 | + } |
| 230 | + _arrowDropDown = |
| 231 | + materialIcon(name = "Filled.ArrowDropDown") { |
| 232 | + materialPath { |
| 233 | + moveTo(7.0f, 10.0f) |
| 234 | + lineToRelative(5.0f, 5.0f) |
| 235 | + lineToRelative(5.0f, -5.0f) |
| 236 | + close() |
| 237 | + } |
| 238 | + } |
| 239 | + return _arrowDropDown!! |
| 240 | + } |
| 241 | + |
| 242 | + private var _arrowDropDown: ImageVector? = null |
| 243 | + } |
| 244 | +} |
| 245 | + |
| 246 | +private inline fun materialIcon( |
| 247 | + name: String, |
| 248 | + block: ImageVector.Builder.() -> ImageVector.Builder |
| 249 | +): ImageVector = |
| 250 | + ImageVector.Builder( |
| 251 | + name = name, |
| 252 | + defaultWidth = MaterialIconDimension.dp, |
| 253 | + defaultHeight = MaterialIconDimension.dp, |
| 254 | + viewportWidth = MaterialIconDimension, |
| 255 | + viewportHeight = MaterialIconDimension |
| 256 | + ) |
| 257 | + .block() |
| 258 | + .build() |
| 259 | + |
| 260 | +private inline fun materialIcon( |
| 261 | + name: String, |
| 262 | + autoMirror: Boolean = false, |
| 263 | + block: ImageVector.Builder.() -> ImageVector.Builder |
| 264 | +): ImageVector = |
| 265 | + ImageVector.Builder( |
| 266 | + name = name, |
| 267 | + defaultWidth = MaterialIconDimension.dp, |
| 268 | + defaultHeight = MaterialIconDimension.dp, |
| 269 | + viewportWidth = MaterialIconDimension, |
| 270 | + viewportHeight = MaterialIconDimension, |
| 271 | + autoMirror = autoMirror |
| 272 | + ) |
| 273 | + .block() |
| 274 | + .build() |
| 275 | + |
| 276 | +private inline fun ImageVector.Builder.materialPath( |
| 277 | + fillAlpha: Float = 1f, |
| 278 | + strokeAlpha: Float = 1f, |
| 279 | + pathFillType: PathFillType = DefaultFillType, |
| 280 | + pathBuilder: PathBuilder.() -> Unit |
| 281 | +) = |
| 282 | + path( |
| 283 | + fill = SolidColor(Color.Black), |
| 284 | + fillAlpha = fillAlpha, |
| 285 | + stroke = null, |
| 286 | + strokeAlpha = strokeAlpha, |
| 287 | + strokeLineWidth = 1f, |
| 288 | + strokeLineCap = StrokeCap.Butt, |
| 289 | + strokeLineJoin = StrokeJoin.Bevel, |
| 290 | + strokeLineMiter = 1f, |
| 291 | + pathFillType = pathFillType, |
| 292 | + pathBuilder = pathBuilder |
| 293 | + ) |
| 294 | + |
| 295 | +// All Material icons (currently) are 24dp by 24dp, with a viewport size of 24 by 24. |
| 296 | +private const val MaterialIconDimension = 24f |
0 commit comments