@@ -252,6 +252,8 @@ private fun LazyStaggeredGridNotes(
252252 is MenuItemUi .FolderUi -> {
253253 FolderItem (
254254 menuItem,
255+ sharedTransitionScope = sharedTransitionScope,
256+ animatedVisibilityScope = animatedVisibilityScope,
255257 folderClick = folderClick,
256258 position = i,
257259 selectionListener = selectionListener,
@@ -328,6 +330,8 @@ private fun LazyGridNotes(
328330 is MenuItemUi .FolderUi -> {
329331 FolderItem (
330332 menuItem,
333+ sharedTransitionScope = sharedTransitionScope,
334+ animatedVisibilityScope = animatedVisibilityScope,
331335 folderClick = folderClick,
332336 moveRequest = moveRequest,
333337 selectionListener = selectionListener,
@@ -398,7 +402,9 @@ private fun LazyColumnNotes(
398402 is MenuItemUi .FolderUi -> {
399403 FolderItem (
400404 menuItem,
401- folderClick,
405+ sharedTransitionScope = sharedTransitionScope,
406+ animatedVisibilityScope = animatedVisibilityScope,
407+ folderClick = folderClick,
402408 selectionListener = selectionListener,
403409 moveRequest = moveRequest,
404410 changeIcon = { id, icon, tint ->
@@ -414,9 +420,12 @@ private fun LazyColumnNotes(
414420 )
415421}
416422
423+ @OptIn(ExperimentalSharedTransitionApi ::class )
417424@Composable
418425private fun FolderItem (
419426 folderUi : MenuItemUi .FolderUi ,
427+ sharedTransitionScope : SharedTransitionScope ,
428+ animatedVisibilityScope : AnimatedVisibilityScope ,
420429 folderClick : (String ) -> Unit ,
421430 position : Int ,
422431 moveRequest : (MenuItemUi , String ) -> Unit ,
@@ -425,108 +434,123 @@ private fun FolderItem(
425434 onDragIconClick : () -> Unit ,
426435 modifier : Modifier = Modifier ,
427436) {
428- Box (shadowModifier()) {
429- DropTarget { inBound, data ->
430- val menuItemUI = data?.info as ? MenuItemUi
431- if (inBound && menuItemUI != null ) {
432- LaunchedEffect (menuItemUI) {
433- moveRequest(menuItemUI, folderUi.documentId)
434- }
435- }
436-
437- val bgColor =
438- when {
439- inBound && menuItemUI?.id != folderUi.id -> WriteopiaTheme .colorScheme.highlight
440- folderUi.selected -> WriteopiaTheme .colorScheme.selectedBg
441- else -> WriteopiaTheme .colorScheme.cardBg
437+ sharedTransitionScope. run {
438+ Box (
439+ shadowModifier().sharedBounds(
440+ rememberSharedContentState(key = " folderTransition ${folderUi.documentId} " ),
441+ animatedVisibilityScope = animatedVisibilityScope,
442+ resizeMode = SharedTransitionScope . ResizeMode . RemeasureToBounds
443+ )
444+ ) {
445+ DropTarget { inBound, data ->
446+ val menuItemUI = data?.info as ? MenuItemUi
447+ if (inBound && menuItemUI != null ) {
448+ LaunchedEffect ( menuItemUI) {
449+ moveRequest(menuItemUI, folderUi.documentId)
450+ }
442451 }
443452
444- val textColor = WriteopiaTheme .colorScheme.textLight
453+ val bgColor =
454+ when {
455+ inBound && menuItemUI?.id != folderUi.id -> WriteopiaTheme .colorScheme.highlight
456+ folderUi.selected -> WriteopiaTheme .colorScheme.selectedBg
457+ else -> WriteopiaTheme .colorScheme.cardBg
458+ }
445459
446- SwipeBox (
447- modifier = modifier
448- .fillMaxWidth()
449- .background(WriteopiaTheme .colorScheme.cardPlaceHolderBackground)
450- .clip(MaterialTheme .shapes.large)
451- .clickable {
452- folderClick(folderUi.documentId)
460+ val textColor = WriteopiaTheme .colorScheme.textLight
461+
462+ SwipeBox (
463+ modifier = modifier
464+ .fillMaxWidth()
465+ .background(WriteopiaTheme .colorScheme.cardPlaceHolderBackground)
466+ .clip(MaterialTheme .shapes.large)
467+ .clickable {
468+ folderClick(folderUi.documentId)
469+ },
470+ isOnEditState = folderUi.selected,
471+ swipeListener = { state ->
472+ selectionListener(folderUi.documentId, state)
453473 },
454- isOnEditState = folderUi.selected,
455- swipeListener = { state ->
456- selectionListener(folderUi.documentId, state)
457- },
458- cornersShape = MaterialTheme .shapes.large,
459- defaultColor = WriteopiaTheme .colorScheme.cardBg,
460- activeColor = bgColor,
461- activeBorderColor = MaterialTheme .colorScheme.primary
462- ) {
463- DragCardTarget (
464- modifier = modifier.clip(MaterialTheme .shapes.large),
465- position = position,
466- dataToDrop = DropInfo (folderUi, position),
467- iconTintOnHover = MaterialTheme .colorScheme.onBackground,
468- onIconClick = onDragIconClick,
474+ cornersShape = MaterialTheme .shapes.large,
475+ defaultColor = WriteopiaTheme .colorScheme.cardBg,
476+ activeColor = bgColor,
477+ activeBorderColor = MaterialTheme .colorScheme.primary
469478 ) {
470- Column (
471- modifier = Modifier
472- .background(color = bgColor, shape = MaterialTheme .shapes.large)
473- .fillMaxWidth()
474- .padding(bottom = 26 .dp, top = 10 .dp)
475- .align(Alignment .Center ),
476- horizontalAlignment = Alignment .CenterHorizontally
479+ DragCardTarget (
480+ modifier = modifier.clip(MaterialTheme .shapes.large),
481+ position = position,
482+ dataToDrop = DropInfo (folderUi, position),
483+ iconTintOnHover = MaterialTheme .colorScheme.onBackground,
484+ onIconClick = onDragIconClick,
477485 ) {
478- var showIconsOptions by remember { mutableStateOf(false ) }
479- val tint = folderUi.icon?.tint?.let (::Color )
480- ? : MaterialTheme .colorScheme.primary
481-
482- Icon (
486+ Column (
483487 modifier = Modifier
484- .padding(6 .dp)
485- .clip(MaterialTheme .shapes.large)
486- .clickable { showIconsOptions = ! showIconsOptions }
487- .size(56 .dp)
488- .padding(6 .dp),
489- imageVector = folderUi.icon?.label?.let (WrIcons ::fromName) ? : folder,
490- contentDescription = " Folder" ,
491- tint = tint
492- )
493-
494- DropdownMenu (
495- expanded = showIconsOptions,
496- onDismissRequest = { showIconsOptions = false },
497- modifier = Modifier .background(WriteopiaTheme .colorScheme.cardBg),
488+ .background(color = bgColor, shape = MaterialTheme .shapes.large)
489+ .fillMaxWidth()
490+ .padding(bottom = 26 .dp, top = 10 .dp)
491+ .align(Alignment .Center ),
492+ horizontalAlignment = Alignment .CenterHorizontally
498493 ) {
499- IconsPicker (
500- iconSelect = { icon, tint -> changeIcon(folderUi.id, icon, tint) }
494+ var showIconsOptions by remember { mutableStateOf(false ) }
495+ val tint = folderUi.icon?.tint?.let (::Color )
496+ ? : MaterialTheme .colorScheme.primary
497+
498+ Icon (
499+ modifier = Modifier
500+ .padding(6 .dp)
501+ .clip(MaterialTheme .shapes.large)
502+ .clickable { showIconsOptions = ! showIconsOptions }
503+ .size(56 .dp)
504+ .padding(6 .dp),
505+ imageVector = folderUi.icon?.label?.let (WrIcons ::fromName)
506+ ? : folder,
507+ contentDescription = " Folder" ,
508+ tint = tint
501509 )
502- }
503510
504- Text (
505- modifier = Modifier .padding(horizontal = 12 .dp),
506- text = folderUi.title,
507- color = textColor,
508- fontWeight = FontWeight .Bold ,
509- maxLines = 1 ,
510- overflow = TextOverflow .Ellipsis
511- )
511+ DropdownMenu (
512+ expanded = showIconsOptions,
513+ onDismissRequest = { showIconsOptions = false },
514+ modifier = Modifier .background(WriteopiaTheme .colorScheme.cardBg),
515+ ) {
516+ IconsPicker (
517+ iconSelect = { icon, tint ->
518+ changeIcon(
519+ folderUi.id,
520+ icon,
521+ tint
522+ )
523+ }
524+ )
525+ }
512526
513- Spacer (modifier = Modifier .height(4 .dp))
527+ Text (
528+ modifier = Modifier .padding(horizontal = 12 .dp),
529+ text = folderUi.title,
530+ color = textColor,
531+ fontWeight = FontWeight .Bold ,
532+ maxLines = 1 ,
533+ overflow = TextOverflow .Ellipsis
534+ )
514535
515- Text (
516- text = " ${folderUi.itemsCount} items" ,
517- color = textColor,
518- style = MaterialTheme .typography.bodySmall
519- )
536+ Spacer (modifier = Modifier .height(4 .dp))
537+
538+ Text (
539+ text = " ${folderUi.itemsCount} items" ,
540+ color = textColor,
541+ style = MaterialTheme .typography.bodySmall
542+ )
543+ }
520544 }
521- }
522545
523- if (folderUi.isFavorite) {
524- Icon (
525- modifier = Modifier .align(Alignment .TopEnd ).size(40 .dp).padding(12 .dp),
526- imageVector = WrIcons .favorites,
527- contentDescription = " Favorite" ,
528- tint = MaterialTheme .colorScheme.onBackground
529- )
546+ if (folderUi.isFavorite) {
547+ Icon (
548+ modifier = Modifier .align(Alignment .TopEnd ).size(40 .dp).padding(12 .dp),
549+ imageVector = WrIcons .favorites,
550+ contentDescription = " Favorite" ,
551+ tint = MaterialTheme .colorScheme.onBackground
552+ )
553+ }
530554 }
531555 }
532556 }
0 commit comments