@@ -48,19 +48,15 @@ import androidx.lifecycle.Lifecycle
48
48
import androidx.lifecycle.compose.LocalLifecycleOwner
49
49
import androidx.lifecycle.repeatOnLifecycle
50
50
import androidx.lifecycle.viewmodel.compose.viewModel
51
- import com.gravatar.extensions.defaultProfile
52
51
import com.gravatar.quickeditor.R
53
52
import com.gravatar.quickeditor.ui.components.AlertBanner
54
53
import com.gravatar.quickeditor.ui.components.AvatarDeletionConfirmationDialog
55
54
import com.gravatar.quickeditor.ui.components.AvatarOption
56
55
import com.gravatar.quickeditor.ui.components.AvatarsSection
57
56
import com.gravatar.quickeditor.ui.components.CtaSection
58
57
import com.gravatar.quickeditor.ui.components.DownloadManagerDisabledAlertDialog
59
- import com.gravatar.quickeditor.ui.components.EmailLabel
60
58
import com.gravatar.quickeditor.ui.components.FailedAvatarUploadAlertDialog
61
59
import com.gravatar.quickeditor.ui.components.PermissionRationaleDialog
62
- import com.gravatar.quickeditor.ui.components.ProfileCard
63
- import com.gravatar.quickeditor.ui.components.QEPageDefault
64
60
import com.gravatar.quickeditor.ui.cropperlauncher.CropperLauncher
65
61
import com.gravatar.quickeditor.ui.cropperlauncher.UCropCropperLauncher
66
62
import com.gravatar.quickeditor.ui.editor.AvatarPickerContentLayout
@@ -75,7 +71,6 @@ import com.gravatar.quickeditor.ui.withPermission
75
71
import com.gravatar.restapi.models.Avatar
76
72
import com.gravatar.types.Email
77
73
import com.gravatar.ui.GravatarTheme
78
- import com.gravatar.ui.components.ComponentState
79
74
import com.yalantis.ucrop.UCrop
80
75
import kotlinx.coroutines.CoroutineScope
81
76
import kotlinx.coroutines.Dispatchers
@@ -89,8 +84,8 @@ internal fun AvatarPicker(
89
84
handleExpiredSession : Boolean ,
90
85
onAvatarSelected : () -> Unit ,
91
86
onSessionExpired : () -> Unit ,
92
- onDoneClicked : () -> Unit ,
93
87
onAltTextTapped : (email: String , avatarId: String ) -> Unit ,
88
+ onRefresh : () -> Unit ,
94
89
viewModel : AvatarPickerViewModel = viewModel(
95
90
factory = AvatarPickerViewModelFactory (gravatarQuickEditorParams, handleExpiredSession),
96
91
),
@@ -130,23 +125,23 @@ internal fun AvatarPicker(
130
125
}
131
126
}
132
127
133
- GravatarTheme {
134
- QEPageDefault (
135
- onDoneClicked = onDoneClicked,
136
- content = {
137
- Box (modifier = Modifier .wrapContentSize()) {
138
- AvatarPicker (
139
- uiState = uiState,
140
- onEvent = viewModel::onEvent,
141
- )
142
- QESnackbarHost (
143
- modifier = Modifier
144
- .align( Alignment . BottomStart ),
145
- hostState = snackState,
146
- )
147
- }
148
- },
149
- )
128
+ Surface {
129
+ Box (modifier = Modifier .wrapContentSize()) {
130
+ AvatarPicker (
131
+ uiState = uiState,
132
+ onEvent = { event ->
133
+ viewModel.onEvent(event)
134
+ if (event is AvatarPickerEvent . Refresh ) {
135
+ onRefresh()
136
+ }
137
+ },
138
+ )
139
+ QESnackbarHost (
140
+ modifier = Modifier
141
+ .align( Alignment . BottomStart ),
142
+ hostState = snackState,
143
+ )
144
+ }
150
145
}
151
146
}
152
147
@@ -199,31 +194,19 @@ internal fun AvatarPicker(uiState: AvatarPickerUiState, onEvent: (AvatarPickerEv
199
194
),
200
195
) {
201
196
Column {
202
- EmailLabel (
203
- email = uiState.email,
204
- modifier = Modifier
205
- .fillMaxWidth()
206
- .padding(bottom = 10 .dp),
207
- )
208
- ProfileCard (
209
- profile = uiState.profile,
210
- email = uiState.email,
211
- avatarCacheBuster = uiState.avatarCacheBuster.toString(),
212
- modifier = Modifier .padding(start = 16 .dp, end = 16 .dp, bottom = 16 .dp),
213
- )
214
197
AnimatedVisibility (visible = uiState.nonSelectedAvatarAlertVisible) {
215
198
AlertBanner (
216
199
message = stringResource(id = R .string.gravatar_qe_alert_banner_no_avatar_selected),
217
200
onClose = { onEvent(AvatarPickerEvent .AvatarDeleteAlertDismissed ) },
218
- modifier = Modifier .padding(horizontal = 16 .dp),
201
+ modifier = Modifier .padding(start = 16 .dp, end = 16 .dp, bottom = 8 .dp),
219
202
)
220
203
}
221
204
Box (
222
205
modifier = Modifier
223
206
.fillMaxWidth()
224
207
.animateContentSize(),
225
208
) {
226
- val sectionModifier = Modifier .padding(top = 16 .dp, bottom = 10 .dp)
209
+ val sectionModifier = Modifier .padding(top = 8 .dp, bottom = 10 .dp)
227
210
when {
228
211
uiState.isLoading -> Box (
229
212
modifier = sectionModifier
@@ -490,13 +473,6 @@ private fun AvatarPickerPreview() {
490
473
AvatarPicker (
491
474
uiState = AvatarPickerUiState (
492
475
email
= Email (
" [email protected] " ),
493
- profile = ComponentState .Loaded (
494
- defaultProfile(
495
- hash = " tetet" ,
496
- displayName = " Henry Wallace" ,
497
- location = " London, UK" ,
498
- ),
499
- ),
500
476
emailAvatars = EmailAvatars (
501
477
avatars = listOf (
502
478
Avatar {
@@ -523,7 +499,6 @@ private fun AvatarPickerLoadingPreview() {
523
499
AvatarPicker (
524
500
uiState = AvatarPickerUiState (
525
501
email
= Email (
" [email protected] " ),
526
- profile = ComponentState .Loading ,
527
502
isLoading = true ,
528
503
avatarPickerContentLayout = AvatarPickerContentLayout .Horizontal ,
529
504
emailAvatars = null ,
@@ -540,7 +515,6 @@ private fun AvatarPickerErrorPreview() {
540
515
AvatarPicker (
541
516
uiState = AvatarPickerUiState (
542
517
email
= Email (
" [email protected] " ),
543
- profile = null ,
544
518
isLoading = false ,
545
519
emailAvatars = null ,
546
520
error = SectionError .ServerError ,
0 commit comments