@@ -57,6 +57,8 @@ import com.gravatar.quickeditor.ui.editor.GravatarQuickEditorDismissReason
57
57
import com.gravatar.quickeditor.ui.editor.GravatarQuickEditorPage
58
58
import com.gravatar.quickeditor.ui.editor.GravatarQuickEditorParams
59
59
import com.gravatar.quickeditor.ui.editor.GravatarUiMode
60
+ import com.gravatar.quickeditor.ui.editor.QuickEditorPage
61
+ import com.gravatar.quickeditor.ui.editor.QuickEditorScopeOption
60
62
import com.gravatar.quickeditor.ui.editor.UpdateHandler
61
63
import com.gravatar.ui.GravatarTheme
62
64
import com.gravatar.ui.LocalGravatarTheme
@@ -87,7 +89,7 @@ public fun GravatarQuickEditorBottomSheet(
87
89
authenticationMethod = authenticationMethod,
88
90
updateHandler = updateHandler,
89
91
onDismiss = onDismiss,
90
- modalDetents = gravatarQuickEditorParams.scopeOption.avatarPickerContentLayout. modalDetents(),
92
+ modalDetents = gravatarQuickEditorParams.scopeOption.modalDetents(),
91
93
)
92
94
}
93
95
@@ -123,7 +125,7 @@ public fun GravatarQuickEditorBottomSheet(
123
125
}
124
126
},
125
127
onDismiss = onDismiss,
126
- modalDetents = gravatarQuickEditorParams.scopeOption.avatarPickerContentLayout. modalDetents(),
128
+ modalDetents = gravatarQuickEditorParams.scopeOption.modalDetents(),
127
129
)
128
130
}
129
131
@@ -316,34 +318,63 @@ private fun GravatarModalBottomSheet(
316
318
}
317
319
}
318
320
321
+ private val peek = SheetDetent (identifier = " peek" ) { containerHeight, _ ->
322
+ containerHeight * 0.6f
323
+ }
324
+
319
325
@Composable
320
- internal fun AvatarPickerContentLayout.modalDetents (): ModalDetents {
321
- val peek = SheetDetent (identifier = " peek" ) { containerHeight, sheetHeight ->
322
- containerHeight * 0.6f
323
- }
326
+ internal fun QuickEditorScopeOption.modalDetents (): ModalDetents {
324
327
val windowHeightSizeClass = currentWindowAdaptiveInfo().windowSizeClass.windowHeightSizeClass
325
- val initialDetent = if (windowHeightSizeClass == WindowHeightSizeClass .COMPACT ) {
326
- FullyExpanded
327
- } else {
328
- when (this ) {
329
- AvatarPickerContentLayout .Horizontal -> FullyExpanded
330
- AvatarPickerContentLayout .Vertical -> peek
331
- }
332
- }
333
328
334
- val detents = buildList {
335
- add(Hidden )
336
- if (this @modalDetents == AvatarPickerContentLayout .Horizontal ) {
337
- add(FullyExpanded )
338
- } else {
329
+ val detents = buildDetentsList()
330
+ val initialDetent = initialDetent(windowHeightSizeClass)
331
+
332
+ return ModalDetents (
333
+ initialDetent = if (detents.contains(initialDetent)) initialDetent else detents.last(),
334
+ detents = detents,
335
+ )
336
+ }
337
+
338
+ private fun QuickEditorScopeOption.buildDetentsList (): List <SheetDetent > {
339
+ return when (this .scope) {
340
+ is QuickEditorScopeOption .Scope .AvatarPickerAndAboutEditor ,
341
+ is QuickEditorScopeOption .Scope .AboutEditor ,
342
+ -> buildList {
343
+ add(Hidden )
339
344
add(peek)
340
345
add(FullyExpanded )
341
346
}
347
+
348
+ is QuickEditorScopeOption .Scope .AvatarPicker -> buildList {
349
+ add(Hidden )
350
+ if (avatarPickerContentLayout == AvatarPickerContentLayout .Vertical ) {
351
+ add(peek)
352
+ }
353
+ add(FullyExpanded )
354
+ }
355
+ }
356
+ }
357
+
358
+ private fun QuickEditorScopeOption.initialDetent (windowHeightSizeClass : WindowHeightSizeClass ): SheetDetent {
359
+ return if (windowHeightSizeClass == WindowHeightSizeClass .COMPACT ) {
360
+ FullyExpanded
361
+ } else {
362
+ when (this .scope) {
363
+ is QuickEditorScopeOption .Scope .AboutEditor -> peek
364
+ is QuickEditorScopeOption .Scope .AvatarPickerAndAboutEditor ,
365
+ is QuickEditorScopeOption .Scope .AvatarPicker ,
366
+ -> {
367
+ if (
368
+ this .avatarPickerContentLayout == AvatarPickerContentLayout .Horizontal &&
369
+ this .initialPage == QuickEditorPage .AvatarPicker
370
+ ) {
371
+ FullyExpanded
372
+ } else {
373
+ peek
374
+ }
375
+ }
376
+ }
342
377
}
343
- return ModalDetents (
344
- initialDetent = initialDetent,
345
- detents = detents,
346
- )
347
378
}
348
379
349
380
internal data class ModalDetents (
0 commit comments