-
Notifications
You must be signed in to change notification settings - Fork 0
/
Icon.kt
35 lines (31 loc) · 1.08 KB
/
Icon.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.todoapp.component
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.width
import androidx.compose.material.Icon
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Add
import androidx.compose.material.icons.outlined.Delete
import androidx.compose.material.icons.outlined.Search
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import br.com.zup.nimbus.annotation.AutoDeserialize
enum class IconName { Search, Delete, Plus }
@Composable
@AutoDeserialize
fun AppIcon(
name: IconName,
color: Color? = null,
size: Double? = null,
) {
val tint = color ?: Color.Unspecified
val iconSize = size ?: 20.0
val modifier = Modifier.width(iconSize.dp).height(iconSize.dp)
val icon = when (name) {
IconName.Search -> Icons.Outlined.Search
IconName.Delete -> Icons.Outlined.Delete
IconName.Plus -> Icons.Outlined.Add
}
Icon(icon, "", modifier, tint)
}