Clara Bayarri | 5bace4e | 2020-02-06 16:42:21 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020 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.ui.material.studies.rally |
| 18 | |
| 19 | import androidx.compose.Composable |
| 20 | import androidx.ui.core.Modifier |
Adam Powell | 999a89b | 2020-03-11 09:08:07 -0700 | [diff] [blame] | 21 | import androidx.ui.core.paint |
Clara Bayarri | 5bace4e | 2020-02-06 16:42:21 +0000 | [diff] [blame] | 22 | import androidx.ui.foundation.Box |
Clara Bayarri | 5bace4e | 2020-02-06 16:42:21 +0000 | [diff] [blame] | 23 | import androidx.ui.graphics.Color |
Nader Jawad | 4dd1188 | 2020-03-09 18:22:06 -0700 | [diff] [blame] | 24 | import androidx.ui.graphics.ColorFilter |
Clara Bayarri | 5bace4e | 2020-02-06 16:42:21 +0000 | [diff] [blame] | 25 | import androidx.ui.graphics.vector.VectorAsset |
Nader Jawad | 4dd1188 | 2020-03-09 18:22:06 -0700 | [diff] [blame] | 26 | import androidx.ui.graphics.vector.VectorPainter |
Adam Powell | 999a89b | 2020-03-11 09:08:07 -0700 | [diff] [blame] | 27 | import androidx.ui.layout.preferredSize |
Louis Pullen-Freilich | a5a9e15 | 2020-03-12 23:19:53 +0000 | [diff] [blame] | 28 | import androidx.ui.material.icons.Icons |
| 29 | import androidx.ui.material.icons.lazyMaterialIcon |
| 30 | import androidx.ui.material.icons.materialPath |
Clara Bayarri | 7372573 | 2020-02-12 18:27:38 +0000 | [diff] [blame] | 31 | import androidx.ui.unit.Dp |
Clara Bayarri | 5bace4e | 2020-02-06 16:42:21 +0000 | [diff] [blame] | 32 | import androidx.ui.unit.dp |
| 33 | |
Clara Bayarri | 581b24d | 2020-02-10 16:15:28 +0000 | [diff] [blame] | 34 | /** |
Clara Bayarri | 581b24d | 2020-02-10 16:15:28 +0000 | [diff] [blame] | 35 | * 24x24dp icon from a resource id. |
Louis Pullen-Freilich | a5a9e15 | 2020-03-12 23:19:53 +0000 | [diff] [blame] | 36 | * |
| 37 | * TODO: b/150460257 remove this when androidx.ui.foundation.Icon supports minimum sizes |
Clara Bayarri | 581b24d | 2020-02-10 16:15:28 +0000 | [diff] [blame] | 38 | */ |
| 39 | @Composable |
Clara Bayarri | 7372573 | 2020-02-12 18:27:38 +0000 | [diff] [blame] | 40 | fun Icon( |
| 41 | vectorImage: VectorAsset, |
| 42 | tintColor: Color = Color.White, |
Adam Powell | b6d8db2 | 2020-04-02 12:40:03 -0700 | [diff] [blame] | 43 | modifier: Modifier = Modifier, |
Clara Bayarri | 7372573 | 2020-02-12 18:27:38 +0000 | [diff] [blame] | 44 | size: Dp = 24.dp |
| 45 | ) { |
George Mount | 11777a5 | 2020-02-29 14:04:22 -0800 | [diff] [blame] | 46 | Box( |
Adam Powell | 999a89b | 2020-03-11 09:08:07 -0700 | [diff] [blame] | 47 | Modifier.preferredSize(size) |
| 48 | .plus(modifier) |
| 49 | .paint( |
| 50 | VectorPainter(vectorImage), colorFilter = ColorFilter.tint(tintColor) |
| 51 | ) |
George Mount | 11777a5 | 2020-02-29 14:04:22 -0800 | [diff] [blame] | 52 | ) |
Louis Pullen-Freilich | a5a9e15 | 2020-03-12 23:19:53 +0000 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | /** |
Louis Pullen-Freilich | 5d18263 | 2020-07-01 14:30:26 +0100 | [diff] [blame^] | 56 | * Icons below are copied from [Icons.Filled] in material-icons-extended to avoid recompiling the |
Louis Pullen-Freilich | a5a9e15 | 2020-03-12 23:19:53 +0000 | [diff] [blame] | 57 | * module in demos. In the future when we release a stable artifact we could directly depend on |
| 58 | * that, instead of a project dependency which causes recompilation. |
| 59 | * |
Louis Pullen-Freilich | 5d18263 | 2020-07-01 14:30:26 +0100 | [diff] [blame^] | 60 | * If the generated icons change, just build material-icons-extended and copy the generated |
Louis Pullen-Freilich | a5a9e15 | 2020-03-12 23:19:53 +0000 | [diff] [blame] | 61 | * file, which should appear in Studio sources by searching for the name of that icon. |
| 62 | */ |
| 63 | |
| 64 | val Icons.Filled.Sort: VectorAsset by lazyMaterialIcon { |
| 65 | materialPath { |
| 66 | moveTo(3.0f, 18.0f) |
| 67 | horizontalLineToRelative(6.0f) |
| 68 | verticalLineToRelative(-2.0f) |
| 69 | lineTo(3.0f, 16.0f) |
| 70 | verticalLineToRelative(2.0f) |
| 71 | close() |
| 72 | moveTo(3.0f, 6.0f) |
| 73 | verticalLineToRelative(2.0f) |
| 74 | horizontalLineToRelative(18.0f) |
| 75 | lineTo(21.0f, 6.0f) |
| 76 | lineTo(3.0f, 6.0f) |
| 77 | close() |
| 78 | moveTo(3.0f, 13.0f) |
| 79 | horizontalLineToRelative(12.0f) |
| 80 | verticalLineToRelative(-2.0f) |
| 81 | lineTo(3.0f, 11.0f) |
| 82 | verticalLineToRelative(2.0f) |
| 83 | close() |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | val Icons.Filled.ArrowForwardIos: VectorAsset by lazyMaterialIcon { |
| 88 | materialPath { |
| 89 | moveTo(5.88f, 4.12f) |
| 90 | lineTo(13.76f, 12.0f) |
| 91 | lineToRelative(-7.88f, 7.88f) |
| 92 | lineTo(8.0f, 22.0f) |
| 93 | lineToRelative(10.0f, -10.0f) |
| 94 | lineTo(8.0f, 2.0f) |
| 95 | close() |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | val Icons.Filled.AttachMoney: VectorAsset by lazyMaterialIcon { |
| 100 | materialPath { |
| 101 | moveTo(11.8f, 10.9f) |
| 102 | curveToRelative(-2.27f, -0.59f, -3.0f, -1.2f, -3.0f, -2.15f) |
| 103 | curveToRelative(0.0f, -1.09f, 1.01f, -1.85f, 2.7f, -1.85f) |
| 104 | curveToRelative(1.78f, 0.0f, 2.44f, 0.85f, 2.5f, 2.1f) |
| 105 | horizontalLineToRelative(2.21f) |
| 106 | curveToRelative(-0.07f, -1.72f, -1.12f, -3.3f, -3.21f, -3.81f) |
| 107 | verticalLineTo(3.0f) |
| 108 | horizontalLineToRelative(-3.0f) |
| 109 | verticalLineToRelative(2.16f) |
| 110 | curveToRelative(-1.94f, 0.42f, -3.5f, 1.68f, -3.5f, 3.61f) |
| 111 | curveToRelative(0.0f, 2.31f, 1.91f, 3.46f, 4.7f, 4.13f) |
| 112 | curveToRelative(2.5f, 0.6f, 3.0f, 1.48f, 3.0f, 2.41f) |
| 113 | curveToRelative(0.0f, 0.69f, -0.49f, 1.79f, -2.7f, 1.79f) |
| 114 | curveToRelative(-2.06f, 0.0f, -2.87f, -0.92f, -2.98f, -2.1f) |
| 115 | horizontalLineToRelative(-2.2f) |
| 116 | curveToRelative(0.12f, 2.19f, 1.76f, 3.42f, 3.68f, 3.83f) |
| 117 | verticalLineTo(21.0f) |
| 118 | horizontalLineToRelative(3.0f) |
| 119 | verticalLineToRelative(-2.15f) |
| 120 | curveToRelative(1.95f, -0.37f, 3.5f, -1.5f, 3.5f, -3.55f) |
| 121 | curveToRelative(0.0f, -2.84f, -2.43f, -3.81f, -4.7f, -4.4f) |
| 122 | close() |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | val Icons.Filled.MoneyOff: VectorAsset by lazyMaterialIcon { |
| 127 | materialPath { |
| 128 | moveTo(12.5f, 6.9f) |
| 129 | curveToRelative(1.78f, 0.0f, 2.44f, 0.85f, 2.5f, 2.1f) |
| 130 | horizontalLineToRelative(2.21f) |
| 131 | curveToRelative(-0.07f, -1.72f, -1.12f, -3.3f, -3.21f, -3.81f) |
| 132 | verticalLineTo(3.0f) |
| 133 | horizontalLineToRelative(-3.0f) |
| 134 | verticalLineToRelative(2.16f) |
| 135 | curveToRelative(-0.53f, 0.12f, -1.03f, 0.3f, -1.48f, 0.54f) |
| 136 | lineToRelative(1.47f, 1.47f) |
| 137 | curveToRelative(0.41f, -0.17f, 0.91f, -0.27f, 1.51f, -0.27f) |
| 138 | close() |
| 139 | moveTo(5.33f, 4.06f) |
| 140 | lineTo(4.06f, 5.33f) |
| 141 | lineTo(7.5f, 8.77f) |
| 142 | curveToRelative(0.0f, 2.08f, 1.56f, 3.21f, 3.91f, 3.91f) |
| 143 | lineToRelative(3.51f, 3.51f) |
| 144 | curveToRelative(-0.34f, 0.48f, -1.05f, 0.91f, -2.42f, 0.91f) |
| 145 | curveToRelative(-2.06f, 0.0f, -2.87f, -0.92f, -2.98f, -2.1f) |
| 146 | horizontalLineToRelative(-2.2f) |
| 147 | curveToRelative(0.12f, 2.19f, 1.76f, 3.42f, 3.68f, 3.83f) |
| 148 | verticalLineTo(21.0f) |
| 149 | horizontalLineToRelative(3.0f) |
| 150 | verticalLineToRelative(-2.15f) |
| 151 | curveToRelative(0.96f, -0.18f, 1.82f, -0.55f, 2.45f, -1.12f) |
| 152 | lineToRelative(2.22f, 2.22f) |
| 153 | lineToRelative(1.27f, -1.27f) |
| 154 | lineTo(5.33f, 4.06f) |
| 155 | close() |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | val Icons.Filled.PieChart: VectorAsset by lazyMaterialIcon { |
| 160 | materialPath { |
| 161 | moveTo(11.0f, 2.0f) |
| 162 | verticalLineToRelative(20.0f) |
| 163 | curveToRelative(-5.07f, -0.5f, -9.0f, -4.79f, -9.0f, -10.0f) |
| 164 | reflectiveCurveToRelative(3.93f, -9.5f, 9.0f, -10.0f) |
| 165 | close() |
| 166 | moveTo(13.03f, 2.0f) |
| 167 | verticalLineToRelative(8.99f) |
| 168 | lineTo(22.0f, 10.99f) |
| 169 | curveToRelative(-0.47f, -4.74f, -4.24f, -8.52f, -8.97f, -8.99f) |
| 170 | close() |
| 171 | moveTo(13.03f, 13.01f) |
| 172 | lineTo(13.03f, 22.0f) |
| 173 | curveToRelative(4.74f, -0.47f, 8.5f, -4.25f, 8.97f, -8.99f) |
| 174 | horizontalLineToRelative(-8.97f) |
| 175 | close() |
| 176 | } |
| 177 | } |