[Draft] feat/add-drag-drop : Add Drag & Drop Functionality #52
[Draft] feat/add-drag-drop : Add Drag & Drop Functionality #52prateekbatra-g wants to merge 1 commit intomainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request implements drag and drop functionality for notes within the Cahier application. It enhances the user experience by allowing notes to be easily moved and reorganized. The changes include UI modifications to provide visual feedback during drag operations and updates to the underlying logic to handle the drag and drop events. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces drag-and-drop functionality to open notes in a new window. The implementation of the drag source appears correct. However, I've identified a critical issue in MainActivity.kt concerning state management on the drop target. The current implementation will not trigger a UI update when a note is dropped. I've provided a code suggestion to resolve this. Additionally, there's a minor opportunity to improve code clarity, for which I've also included a suggestion.
| var noteId = intent.getLongExtra(AppArgs.NOTE_ID_KEY, -1) | ||
| var noteType = IntentCompat.getParcelableExtra( | ||
| intent, | ||
| AppArgs.NOTE_TYPE_KEY, | ||
| NoteType::class.java | ||
| ) | ||
|
|
||
| setContent { | ||
| CahierAppTheme { |
There was a problem hiding this comment.
The variables noteId and noteType are updated in the onDrop callback, but since they are not Compose State objects, updating them will not trigger a recomposition. The UI will not reflect the new note when an item is dropped. To fix this, you should declare noteId and noteType as state variables inside the setContent block using remember { mutableStateOf(...) }. This will ensure that Compose observes changes to these variables and recomposes the UI accordingly.
setContent {
var noteId by remember { mutableStateOf(intent.getLongExtra(AppArgs.NOTE_ID_KEY, -1)) }
var noteType by remember {
mutableStateOf(
IntentCompat.getParcelableExtra(
intent,
AppArgs.NOTE_TYPE_KEY,
NoteType::class.java
)
)
}
CahierAppTheme {| shouldStartDragAndDrop = accept@{ | ||
| true | ||
| }, |
f7279b9 to
4c494b6
Compare
4c494b6 to
ee7d25e
Compare
No description provided.