https://github.com/lawlabs/rectselectanddragdemo
An educational SwiftUI demo showcasing rectangular selection, object highlighting, and drag-and-drop functionality.
https://github.com/lawlabs/rectselectanddragdemo
drag-and-drop gestures interaction lawlabs legaltech selection swiftui
Last synced: 6 months ago
JSON representation
An educational SwiftUI demo showcasing rectangular selection, object highlighting, and drag-and-drop functionality.
- Host: GitHub
- URL: https://github.com/lawlabs/rectselectanddragdemo
- Owner: lawlabs
- Created: 2024-11-29T08:27:57.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-11-30T07:20:54.000Z (10 months ago)
- Last Synced: 2025-04-12T21:09:25.723Z (6 months ago)
- Topics: drag-and-drop, gestures, interaction, lawlabs, legaltech, selection, swiftui
- Language: Swift
- Homepage: https://lawlabs.ru/
- Size: 28.3 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SwiftUI Rectangle Selection and Object Manipulation
This project demonstrates a simple SwiftUI-based application for selecting and manipulating objects (squares). It's designed as an educational resource, showcasing how to implement key features like rectangle selection, dragging, and updating object states dynamically.
## Features
1. **Rectangle Selection**: Click and drag to draw a selection rectangle. Any squares intersecting the rectangle are highlighted.
2. **Drag-and-Drop**: Selected squares can be dragged to a new position by holding and moving the mouse.
3. **Dynamic Updates**: The positions of squares update in real-time during drag-and-drop interactions.
4. **Interactive Feedback**: Squares change color to indicate their selection status.## How to Use
1. Clone the repository and run the project in Xcode.
2. Drag within the green area to select squares.
3. Drag the selected squares to move them.## Demo Screenshots
### Initial State
### Rectangle Selection
### Drag-and-Drop
https://github.com/user-attachments/assets/04fb861b-2b64-46bb-afac-224776f9d2c1
## Code Overview
- **`ContentView.swift`**: Contains all logic for selection and manipulation.
- **`generateRandomSquares`**: Randomly generates square positions.
- **`updateSelectedSquares`**: Updates the selection status of squares based on their intersection with the selection rectangle.
- **`moveSelectedSquares`**: Updates the positions of selected squares after a drag operation.## Prerequisites
- Xcode 14 or later
- macOS 13 or later## Contributions
Feel free to fork this repository, submit pull requests, or suggest improvements!### О проекте на русском языке
ООО "Лаборатория юридических исследований" и АБ "КАиП" готовят к выпуску приложение для визуализации прохождения судебных дел по всем стадиям, включая промежуточные обжалования обеспечительных мер, определения о приостановке рассмотрения дела в связи с назначением экспертизы, определения о взыскании судебных расходов и другие процессы.
В этом приложении графические изображения стадий можно будет выделять мышкой и оперировать выделенными стадиями:
- Перемещать их (например, с одного уровня инстанций на другой),
- Изменять даты и время,
- Выполнять другие действия с выбранными стадиями.В рамках подготовки к реализации этих возможностей мы тестируем различные подходы и техники работы с выделением и манипуляцией объектов в **SwiftUI**. Этот проект — результат одной из таких проб. Мы надеемся, что он станет полезным примером для интересующихся разработчиков.