@@ -2,7 +2,6 @@ package com.esri.arcgismaps.kotlin.sampleviewer.ui.components
2
2
3
3
import android.content.res.Configuration
4
4
import androidx.compose.animation.AnimatedVisibility
5
- import androidx.compose.animation.core.tween
6
5
import androidx.compose.animation.expandVertically
7
6
import androidx.compose.animation.shrinkVertically
8
7
import androidx.compose.foundation.background
@@ -11,11 +10,9 @@ import androidx.compose.foundation.layout.Arrangement
11
10
import androidx.compose.foundation.layout.Column
12
11
import androidx.compose.foundation.layout.IntrinsicSize
13
12
import androidx.compose.foundation.layout.Row
14
- import androidx.compose.foundation.layout.Spacer
15
13
import androidx.compose.foundation.layout.fillMaxWidth
16
14
import androidx.compose.foundation.layout.height
17
15
import androidx.compose.foundation.layout.padding
18
- import androidx.compose.foundation.layout.width
19
16
import androidx.compose.material.icons.Icons
20
17
import androidx.compose.material.icons.filled.Info
21
18
import androidx.compose.material.icons.filled.MoreVert
@@ -62,6 +59,7 @@ fun SampleCardItem(
62
59
TitleAndIconsRow (sample, dropdownSampleItems)
63
60
}
64
61
}
62
+
65
63
@OptIn(ExperimentalMaterial3Api ::class )
66
64
@Composable
67
65
private fun TitleAndIconsRow (
@@ -77,16 +75,20 @@ private fun TitleAndIconsRow(
77
75
modifier = Modifier
78
76
.fillMaxWidth()
79
77
.background(MaterialTheme .colorScheme.surfaceContainer)
80
- .padding(horizontal = 8 .dp),
78
+ .padding(start = 16 .dp)
81
79
) {
82
- Text (
83
- text = sample.metadata.title,
80
+ Column (
84
81
modifier = Modifier
85
82
.weight(1f )
86
- .padding(vertical = 16 .dp),
87
- fontSize = MaterialTheme .typography.bodyMedium.fontSize,
88
- color = MaterialTheme .colorScheme.onSurface
89
- )
83
+ .padding(vertical = 16 .dp)
84
+ ) {
85
+ Text (
86
+ text = sample.metadata.title,
87
+ style = MaterialTheme .typography.bodyLarge,
88
+ color = MaterialTheme .colorScheme.onSurface
89
+ )
90
+ ExpandedDescriptionAnimation (expandedDescription, sample)
91
+ }
90
92
91
93
IconButton (onClick = { expandedDescription = ! expandedDescription }) {
92
94
Icon (
@@ -97,9 +99,7 @@ private fun TitleAndIconsRow(
97
99
}
98
100
99
101
Column {
100
- IconButton (
101
- onClick = { expandedMenu = ! expandedMenu },
102
- ) {
102
+ IconButton (onClick = { expandedMenu = ! expandedMenu }) {
103
103
Icon (
104
104
imageVector = Icons .Filled .MoreVert ,
105
105
contentDescription = " More options" ,
@@ -111,23 +111,23 @@ private fun TitleAndIconsRow(
111
111
.height(IntrinsicSize .Max )
112
112
.background(MaterialTheme .colorScheme.surfaceContainer),
113
113
expanded = expandedMenu,
114
- onDismissRequest = { expandedMenu = false },
114
+ onDismissRequest = { expandedMenu = false }
115
115
) {
116
116
dropdownSampleItems.forEach { option ->
117
117
DropdownMenuItem (
118
118
text = {
119
119
Row (
120
120
verticalAlignment = Alignment .CenterVertically ,
121
- horizontalArrangement = Arrangement .Start ,
122
- modifier = Modifier
123
- .padding(horizontal = 8 .dp, vertical = 8 .dp),
121
+ horizontalArrangement = Arrangement .spacedBy(
122
+ space = 8 .dp,
123
+ alignment = Alignment .CenterHorizontally
124
+ )
124
125
) {
125
126
Icon (
126
127
painter = painterResource(id = option.icon),
127
128
contentDescription = null ,
128
129
tint = MaterialTheme .colorScheme.onSurface
129
130
)
130
- Spacer (modifier = Modifier .width(8 .dp))
131
131
Text (
132
132
text = option.title,
133
133
style = MaterialTheme .typography.bodyMedium,
@@ -136,7 +136,7 @@ private fun TitleAndIconsRow(
136
136
}
137
137
},
138
138
onClick = {
139
- expandedMenu = option.title.lowercase() == " favorite " || option.title.lowercase() == " unfavorite "
139
+ expandedMenu = option.title.lowercase().contains( " favorite " )
140
140
option.onClick()
141
141
},
142
142
contentPadding = ExposedDropdownMenuDefaults .ItemContentPadding ,
@@ -145,8 +145,6 @@ private fun TitleAndIconsRow(
145
145
}
146
146
}
147
147
}
148
-
149
- ExpandedDescriptionAnimation (expandedDescription, sample)
150
148
}
151
149
152
150
@Composable
@@ -157,23 +155,17 @@ private fun ExpandedDescriptionAnimation(
157
155
AnimatedVisibility (
158
156
visible = expandedDescription,
159
157
enter = expandVertically(),
160
- exit = shrinkVertically(
161
- animationSpec = tween(
162
- durationMillis = 1000
163
- )
164
- )
158
+ exit = shrinkVertically()
165
159
) {
166
160
Row (
167
161
verticalAlignment = Alignment .CenterVertically ,
168
162
horizontalArrangement = Arrangement .Start ,
169
- modifier = Modifier
170
- .fillMaxWidth()
171
- .padding(start = 8 .dp, bottom = 8 .dp, end = 32 .dp)
163
+ modifier = Modifier .fillMaxWidth().padding(vertical = 8 .dp)
172
164
) {
173
165
Text (
174
166
text = sample.metadata.description,
175
167
textAlign = TextAlign .Start ,
176
- fontSize = MaterialTheme .typography.bodyMedium.fontSize ,
168
+ style = MaterialTheme .typography.bodyMedium,
177
169
color = Color .Gray ,
178
170
)
179
171
}
@@ -189,11 +181,7 @@ fun PreviewSampleCardItem() {
189
181
SampleCardItem (
190
182
Sample (
191
183
name = " Analyze hotspots" ,
192
- codeFiles = listOf (
193
- CodeFile (
194
- " " , " "
195
- )
196
- ),
184
+ codeFiles = listOf (CodeFile (" " , " " )),
197
185
url = " " ,
198
186
readMe = " " ,
199
187
screenshotURL = " " ,
0 commit comments