@@ -7,16 +7,21 @@ import androidx.compose.foundation.layout.padding
77import androidx.compose.foundation.layout.width
88import androidx.compose.foundation.shape.RoundedCornerShape
99import androidx.compose.material3.ButtonDefaults
10+ import androidx.compose.material3.Card
11+ import androidx.compose.material3.CardDefaults
1012import androidx.compose.material3.ListItem
1113import androidx.compose.material3.ListItemDefaults
1214import androidx.compose.material3.MaterialTheme
15+ import androidx.compose.material3.Surface
1316import androidx.compose.material3.Switch
1417import androidx.compose.material3.Text
1518import androidx.compose.material3.TextButton
1619import androidx.compose.runtime.Composable
1720import androidx.compose.ui.Alignment
1821import androidx.compose.ui.Modifier
1922import androidx.compose.ui.draw.clip
23+ import androidx.compose.ui.graphics.Color
24+ import androidx.compose.ui.text.font.FontWeight
2025import androidx.compose.ui.tooling.preview.Preview
2126import androidx.compose.ui.unit.dp
2227import com.github.umercodez.sensorspot.ui.SensorSpotTheme
@@ -32,48 +37,64 @@ fun GpsItem(
3237 locationPermissionGranted : Boolean = false,
3338 onGrantLocationPermissionClick : (() -> Unit )? = null
3439) {
35- ListItem (
40+ Card (
3641 modifier = modifier
3742 .fillMaxWidth()
38- .padding(5 .dp)
39- .clip(RoundedCornerShape (16 .dp)),
40- headlineContent = {
41- Row (
42- verticalAlignment = Alignment .CenterVertically ,
43- ) {
44- Text (" GPS" )
45- Spacer (Modifier .width(10 .dp))
46- if (! locationPermissionGranted) {
47- TextButton (
48- onClick = { onGrantLocationPermissionClick?.invoke() },
49- colors = ButtonDefaults .textButtonColors(
50- contentColor = MaterialTheme .colorScheme.error
51- )
52- ) {
53- Text (" Grant Permission" )
43+ .padding(horizontal = 10 .dp, vertical = 5 .dp),
44+ shape = RoundedCornerShape (16 .dp),
45+ elevation = CardDefaults .cardElevation(defaultElevation = 2 .dp),
46+ colors = CardDefaults .cardColors(
47+ containerColor = MaterialTheme .colorScheme.surfaceContainer
48+ )
49+ ) {
50+ ListItem (
51+ modifier = modifier
52+ .fillMaxWidth()
53+ .padding(5 .dp)
54+ .clip(RoundedCornerShape (16 .dp)),
55+ headlineContent = {
56+ Row (
57+ verticalAlignment = Alignment .CenterVertically ,
58+ ) {
59+ Text (
60+ text = " GPS" ,
61+ style = MaterialTheme .typography.titleMedium,
62+ fontWeight = FontWeight .SemiBold
63+ )
64+ Spacer (Modifier .width(10 .dp))
65+ if (! locationPermissionGranted) {
66+ TextButton (
67+ onClick = { onGrantLocationPermissionClick?.invoke() },
68+ colors = ButtonDefaults .textButtonColors(
69+ contentColor = MaterialTheme .colorScheme.error
70+ )
71+ ) {
72+ Text (" Grant Permission" )
73+ }
5474 }
55- }
5675
57- }
58- },
59- supportingContent = {
60- Text (
61- text = if (dedicatedTopics) " topic = ${mqttTopic} /gps" else " type = android.gps" ,
62- color = MaterialTheme .colorScheme.onSurface
63- )
64- },
76+ }
77+ },
78+ supportingContent = {
79+ Text (
80+ text = if (dedicatedTopics) " topic = ${mqttTopic} /gps" else " type = android.gps" ,
81+ style = MaterialTheme .typography.bodyLarge,
82+ color = MaterialTheme .colorScheme.onSurface
83+ )
84+ },
6585
66- trailingContent = {
67- Switch (
68- checked = checked,
69- onCheckedChange = onCheckedChange,
70- enabled = locationPermissionGranted
86+ trailingContent = {
87+ Switch (
88+ checked = checked,
89+ onCheckedChange = onCheckedChange,
90+ enabled = locationPermissionGranted
91+ )
92+ },
93+ colors = ListItemDefaults .colors(
94+ containerColor = Color .Transparent
7195 )
72- },
73- colors = ListItemDefaults .colors(
74- containerColor = MaterialTheme .colorScheme.surfaceContainer
7596 )
76- )
97+ }
7798
7899
79100}
@@ -82,11 +103,13 @@ fun GpsItem(
82103@Composable
83104fun GpsItemPreview () {
84105 SensorSpotTheme {
85- GpsItem (
86- checked = true ,
87- onCheckedChange = {},
88- locationPermissionGranted = true ,
89- onGrantLocationPermissionClick = {}
90- )
106+ Surface {
107+ GpsItem (
108+ checked = true ,
109+ onCheckedChange = {},
110+ locationPermissionGranted = true ,
111+ onGrantLocationPermissionClick = {}
112+ )
113+ }
91114 }
92115}
0 commit comments