Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
DnD in Compose
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
punchdrunker
April 04, 2025
0
290
DnD in Compose
punchdrunker
April 04, 2025
Tweet
Share
More Decks by punchdrunker
See All by punchdrunker
Kotlin2.0以降の新機能
punchdrunker
0
28
what's new in Material Design で気になったトピック
punchdrunker
1
630
7カ国語に対応したサービスでの翻訳管理システムの改善事例
punchdrunker
1
1.3k
Java Bytecode Vertical Tasting
punchdrunker
2
1.4k
getting started with dark theme
punchdrunker
2
1.1k
Practical Activity Transition in Android
punchdrunker
0
1.2k
今時のProgress indicator / Replacing ProgressDialog with ProgressBar
punchdrunker
0
720
レビュー評価4.7の秘密 / The Secret To A Better Reputation
punchdrunker
2
2.1k
Dynamic Feature Modules 入門
punchdrunker
2
2.7k
Featured
See All Featured
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
130
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.8k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
61
49k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
580
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
1
110
Java REST API Framework Comparison - PWX 2021
mraible
34
9.1k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.3k
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
Mind Mapping
helmedeiros
PRO
0
73
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
94
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
240
Transcript
DnD in Compose @punchdrunker 2025/4/4
自己紹介 - 2010〜 Android / iOS Dev - Director of
DroidKaigi Association - MNG - Tamagotchi Connect
ComposeでもDnD(ドラッグアンドドロップ)できる? - Jetpack Compose 1.6からDnDサポート追加 - 具体的には dragAndDropSource と dragAndDropTarget
を使う - Viewベースと同じく ClipData でデータを渡せる
最小限の実装の流れ 構成 - Modifier.dragAndDropSource → ドラッグしたいもの - ClipDataで中身を渡す - Modifier.dragAndDropTarget
→ ドロップ先 - DragAndDropEventでイベント受け取り 📦 データの受け渡しは ClipData.newPlainText("label", "value") みたいな感じ
example: dragAndDropSource
example: dragAndDropTarget 1/2
example: dragAndDropTarget 2/2 onDropだけ 実装必須
example: DragAndDropEvent - DragAndDropEvent - mimeType - DragEvent - Offset
- ClipData - …(たくさん)
まとめ まとめ: - ComposeでもDnDができるようになった - Modifierベースで導入も簡単 - ClipDataとDragAndDropEventの理解がポイント - 外部アプリからのDnD対応もできそうなのでやってみたい
- ファイルDnDなども試す予定!
Resources - actual code: https://github.com/punchdrunker/compose-drag-and-drop/blob/main/app/src/ main/java/com/example/myapplication/MainActivity.kt - overview: https://developer.android.com/reference/kotlin/androidx/compose/foundation/d raganddrop/package-summary
-