-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSmartDeleteSwitchItem.kt
More file actions
48 lines (45 loc) · 1.38 KB
/
SmartDeleteSwitchItem.kt
File metadata and controls
48 lines (45 loc) · 1.38 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
package com.rickyhu.hushkeyboard.settings.ui
import androidx.compose.foundation.clickable
import androidx.compose.material3.Icon
import androidx.compose.material3.ListItem
import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import com.rickyhu.hushkeyboard.R
import com.rickyhu.hushkeyboard.theme.HushKeyboardTheme
@Composable
fun SmartDeleteSwitchItem(
value: Boolean,
onValueChanged: (Boolean) -> Unit = {}
) {
ListItem(
modifier = Modifier.clickable { onValueChanged(!value) },
headlineContent = { Text("Smart Delete") },
leadingContent = {
Icon(
painter = painterResource(R.drawable.ic_backspace_filled),
contentDescription = "Delete"
)
},
trailingContent = {
Switch(
checked = value,
onCheckedChange = onValueChanged,
modifier = Modifier.testTag("SmartDeleteSwitchItem")
)
}
)
}
@Preview(showBackground = true)
@Composable
fun SmartDeleteSwitchItemPreview() {
HushKeyboardTheme {
AddSpaceBetweenNotationSwitchItem(
value = true
)
}
}