@@ -9,6 +9,7 @@ import androidx.compose.foundation.layout.size
9
9
import androidx.compose.material.icons.Icons
10
10
import androidx.compose.material.icons.outlined.Delete
11
11
import androidx.compose.material.icons.outlined.Upload
12
+ import androidx.compose.material3.CircularProgressIndicator
12
13
import androidx.compose.material3.DropdownMenu
13
14
import androidx.compose.material3.DropdownMenuItem
14
15
import androidx.compose.material3.Icon
@@ -19,16 +20,19 @@ import androidx.compose.runtime.getValue
19
20
import androidx.compose.runtime.mutableStateOf
20
21
import androidx.compose.runtime.remember
21
22
import androidx.compose.runtime.setValue
23
+ import androidx.compose.ui.Alignment
22
24
import androidx.compose.ui.Modifier
23
25
import androidx.compose.ui.draganddrop.mimeTypes
24
26
import androidx.compose.ui.graphics.Color
25
27
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
26
28
import androidx.compose.ui.platform.LocalHapticFeedback
27
29
import androidx.compose.ui.res.stringResource
30
+ import androidx.compose.ui.tooling.preview.Preview
28
31
import androidx.compose.ui.unit.dp
29
32
import app.fyreplace.api.data.User
30
33
import app.fyreplace.fyreplace.R
31
34
import app.fyreplace.fyreplace.extensions.activity
35
+ import app.fyreplace.fyreplace.fakes.placeholder
32
36
import app.fyreplace.fyreplace.ui.views.Avatar
33
37
import java.io.File
34
38
import java.time.format.DateTimeFormatter
@@ -38,6 +42,7 @@ import java.time.format.FormatStyle
38
42
@Composable
39
43
fun AvatarListItem (
40
44
user : User ? ,
45
+ isLoading : Boolean ,
41
46
onUpdateAvatar : (File ) -> Unit ,
42
47
onRemoveAvatar : () -> Unit
43
48
) {
@@ -79,7 +84,20 @@ fun AvatarListItem(
79
84
}
80
85
)
81
86
},
82
- leadingContent = { Avatar (user = user, modifier = Modifier .size(56 .dp)) },
87
+ leadingContent = {
88
+ val modifier = Modifier .size(56 .dp)
89
+
90
+ if (isLoading) {
91
+ Box (
92
+ contentAlignment = Alignment .Center ,
93
+ modifier = modifier
94
+ ) {
95
+ CircularProgressIndicator ()
96
+ }
97
+ } else {
98
+ Avatar (user = user, modifier = modifier)
99
+ }
100
+ },
83
101
modifier = Modifier .combinedClickable(
84
102
onClick = ::selectImage,
85
103
onLongClick = {
@@ -112,3 +130,25 @@ fun AvatarListItem(
112
130
}
113
131
}
114
132
}
133
+
134
+ @Preview
135
+ @Composable
136
+ fun AvatarListItemPreview () {
137
+ AvatarListItem (
138
+ user = User .placeholder,
139
+ isLoading = false ,
140
+ onUpdateAvatar = {},
141
+ onRemoveAvatar = {}
142
+ )
143
+ }
144
+
145
+ @Preview
146
+ @Composable
147
+ fun AvatarListItemLoadingPreview () {
148
+ AvatarListItem (
149
+ user = User .placeholder,
150
+ isLoading = true ,
151
+ onUpdateAvatar = {},
152
+ onRemoveAvatar = {}
153
+ )
154
+ }
0 commit comments