-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIconList.kt
More file actions
106 lines (100 loc) · 3.64 KB
/
IconList.kt
File metadata and controls
106 lines (100 loc) · 3.64 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package com.alexzh.kmp.playground.presentation.features.icons
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.Card
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowLeft
import androidx.compose.material.icons.filled.Delete
import androidx.compose.material.icons.filled.Edit
import androidx.compose.material.icons.outlined.Delete
import androidx.compose.material.icons.outlined.Edit
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.dp
import com.alexzh.kmp.playground.Platform
import com.alexzh.kmp.playground.platform
import kotlinmultiplatformplayground.composeapp.generated.resources.Res
import kotlinmultiplatformplayground.composeapp.generated.resources.ic_back_ios
import kotlinmultiplatformplayground.composeapp.generated.resources.ic_delete_ios
import kotlinmultiplatformplayground.composeapp.generated.resources.ic_edit_ios
import org.jetbrains.compose.resources.vectorResource
@Composable
fun IconList(
onBack: () -> Unit
) {
Scaffold(
topBar = {
TopAppBar(
title = { Text("Demo: Icons") },
navigationIcon = {
IconButton(onClick = onBack) {
Icon(
imageVector = BackIcon,
contentDescription = "Back"
)
}
},
backgroundColor = Color.White
)
},
) {
Column(
modifier = Modifier.fillMaxSize().padding(vertical = 16.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
Card(modifier = Modifier.size(100.dp)) {
Image(
imageVector = EditIcon,
contentDescription = "Edit"
)
}
Card(modifier = Modifier.size(100.dp)) {
Image(
imageVector = DeleteIcon,
contentDescription = "Delete"
)
}
}
}
}
val BackIcon: ImageVector
@Composable
get() {
return when (platform) {
Platform.Android -> Icons.AutoMirrored.Default.ArrowBack
Platform.Ios -> vectorResource(Res.drawable.ic_back_ios)
else -> Icons.AutoMirrored.Default.KeyboardArrowLeft
}
}
val EditIcon: ImageVector
@Composable
get() {
return when (platform) {
Platform.Android -> Icons.Outlined.Edit
Platform.Ios -> vectorResource(Res.drawable.ic_edit_ios)
else -> Icons.Filled.Edit
}
}
val DeleteIcon: ImageVector
@Composable
get() {
return when (platform) {
Platform.Android -> Icons.Outlined.Delete
Platform.Ios -> vectorResource(Res.drawable.ic_delete_ios)
else -> Icons.Filled.Delete
}
}