Skip to content

Conversation

@JackEblan
Copy link
Owner

@JackEblan JackEblan commented Dec 31, 2025

Closes #453
Closes #448

This will remove widgets, shortcuts to be included in the folder. It will only accept 1x1 grid item.

This commit refactors the folder view from a full-screen implementation to a popup that appears on the home screen. The previous `FolderScreen` and `FolderDragScreen` composables have been removed from the main screen's navigation graph.

A new `FolderPopup.kt` has been introduced, which is responsible for displaying the folder's contents in a popup layout. This popup is positioned relative to the folder icon that was tapped.

### Core Changes:
*   **`FolderPopup.kt`**: New file containing the `FolderPopup` composable that displays the folder grid.
*   **`HorizontalPagerScreen.kt`**: Now invokes `FolderPopup` when a folder item is tapped, passing the necessary position and size data to correctly place the popup.
*   **`HomeScreen.kt` & `HomeViewModel.kt`**: References and transitions to the dedicated `Folder` and `FolderDrag` screens have been removed.
*   **`FolderScreen.kt`**: Refactored to be displayed within a `Surface` and sized dynamically based on its content, removing the full-screen layout and back-handling logic.
*   **`InteractiveGridItem.kt`**: The `onTapFolderGridItem` callback now provides the `IntOffset` of the tapped item to position the new popup.
This commit refactors the folder popup and drag-and-drop functionality to improve positioning and coordinate calculations.

The vertical positioning logic for the folder popup in `Popup.kt` has been updated to `coerceIn` the available space, preventing it from rendering off-screen.

The drag calculation within a folder has been significantly improved. `DragGridItemHelper.kt` now receives a relative `dragIntOffset` (pre-adjusted for the folder's position), which simplifies the logic by removing the need to manually subtract the folder's offset and padding. This ensures more accurate item placement during drag operations inside a folder.

Finally, a page indicator has been added to the bottom of the folder view in `FolderDragScreen.kt`, and the layout calculations have been adjusted to correctly account for its height, ensuring the drag grid area is sized appropriately.

### Core Changes:

*   **`Popup.kt`**:
    *   Simplified the `childY` calculation to ensure the folder popup always stays within the screen's vertical bounds.
*   **`DragGridItemHelper.kt`**:
    *   Removed manual offset and padding calculations for `dragX` and `dragY`.
    *   Now uses a pre-calculated relative `dragIntOffset` for more reliable drag coordinate mapping within the folder's grid.
    *   The folder's grid dimensions (`folderGridWidth`, `folderGridHeight`) are now passed directly, simplifying cell size calculations.
*   **`FolderDragScreen.kt` & `FolderScreen.kt`**:
    *   Added a `PageIndicator` to the folder view.
    *   Adjusted layout calculations to correctly handle the height of the new page indicator, ensuring the `HorizontalPager` containing the grid items is sized correctly.
*   **`DropGridItemHelper.kt`**:
    *   Removed complex boundary checks, as the improved drag logic now handles drops more predictably.
This commit introduces two main changes: it ensures the folder popup resets correctly when an item is dragged out of it, and it refactors the logic for dragging items outside a folder's bounds.

First, a new `resetFolder` function has been added to the `HomeViewModel`. This function clears the folder's internal state (`folderPopupType` and `foldersDataById`) and is now called when an item is moved out of a folder. This prevents the folder from incorrectly remaining open or displaying stale data after the drag operation.

Second, the drag detection logic in `DragGridItemHelper` for folders has been enhanced. It now correctly identifies when an item is dragged beyond the folder's grid boundaries and triggers the `onMoveGridItemOutsideFolder` action. Previously, this was not handled, and items could get stuck. The logic for determining folder grid size in `FolderScreen` and `FolderDragScreen` has also been corrected to use `homeSettings.folderColumns` and `homeSettings.folderRows` instead of dynamically calculating the span, ensuring consistent grid dimensions.

Additionally, the delay for auto-scrolling pages when dragging an item to the edge of the screen has been reduced from 1000ms to 500ms for a more responsive feel.
@JackEblan
Copy link
Owner Author

Use flow row

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windowed Folder Full screen folder or windowed folder

2 participants