[go: nahoru, domu]

blob: eaadd484921302a4ea809cf4a5eb1d15b7252e00 [file] [log] [blame]
Clara Bayarri5bace4e2020-02-06 16:42:21 +00001/*
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
17package androidx.ui.material.studies.rally
18
19import androidx.compose.Composable
20import androidx.ui.core.Modifier
Adam Powell999a89b2020-03-11 09:08:07 -070021import androidx.ui.core.paint
Louis Pullen-Freilichddda7be2020-07-17 18:28:12 +010022import androidx.compose.foundation.Box
Louis Pullen-Freilich4dc4dac2020-07-22 14:39:14 +010023import androidx.compose.ui.graphics.Color
24import androidx.compose.ui.graphics.ColorFilter
25import androidx.compose.ui.graphics.vector.VectorAsset
26import androidx.compose.ui.graphics.vector.VectorPainter
Louis Pullen-Freilich623e4052020-07-19 20:24:03 +010027import androidx.compose.foundation.layout.preferredSize
Louis Pullen-Freilicha5a9e152020-03-12 23:19:53 +000028import androidx.ui.material.icons.Icons
29import androidx.ui.material.icons.lazyMaterialIcon
30import androidx.ui.material.icons.materialPath
Louis Pullen-Freilicha7eeb102020-07-22 17:54:24 +010031import androidx.compose.ui.unit.Dp
32import androidx.compose.ui.unit.dp
Clara Bayarri5bace4e2020-02-06 16:42:21 +000033
Clara Bayarri581b24d2020-02-10 16:15:28 +000034/**
Clara Bayarri581b24d2020-02-10 16:15:28 +000035 * 24x24dp icon from a resource id.
Louis Pullen-Freilicha5a9e152020-03-12 23:19:53 +000036 *
Louis Pullen-Freilichddda7be2020-07-17 18:28:12 +010037 * TODO: b/150460257 remove this when androidx.compose.foundation.Icon supports minimum sizes
Clara Bayarri581b24d2020-02-10 16:15:28 +000038 */
39@Composable
Clara Bayarri73725732020-02-12 18:27:38 +000040fun Icon(
41 vectorImage: VectorAsset,
42 tintColor: Color = Color.White,
Adam Powellb6d8db22020-04-02 12:40:03 -070043 modifier: Modifier = Modifier,
Clara Bayarri73725732020-02-12 18:27:38 +000044 size: Dp = 24.dp
45) {
George Mount11777a52020-02-29 14:04:22 -080046 Box(
Adam Powell999a89b2020-03-11 09:08:07 -070047 Modifier.preferredSize(size)
Matvei Malkov1eec3ee2020-07-17 15:09:02 +010048 .then(modifier)
Adam Powell999a89b2020-03-11 09:08:07 -070049 .paint(
50 VectorPainter(vectorImage), colorFilter = ColorFilter.tint(tintColor)
51 )
George Mount11777a52020-02-29 14:04:22 -080052 )
Louis Pullen-Freilicha5a9e152020-03-12 23:19:53 +000053}
54
55/**
Louis Pullen-Freilich5d182632020-07-01 14:30:26 +010056 * Icons below are copied from [Icons.Filled] in material-icons-extended to avoid recompiling the
Louis Pullen-Freilicha5a9e152020-03-12 23:19:53 +000057 * 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-Freilich5d182632020-07-01 14:30:26 +010060 * If the generated icons change, just build material-icons-extended and copy the generated
Louis Pullen-Freilicha5a9e152020-03-12 23:19:53 +000061 * file, which should appear in Studio sources by searching for the name of that icon.
62 */
63
64val 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
87val 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
99val 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
126val 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
159val 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}