[go: nahoru, domu]

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