mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-29 08:04:32 +00:00
Restored files from old Mac, force pushing
This commit is contained in:
parent
5dd95228b8
commit
5040381840
126 changed files with 10431 additions and 67 deletions
70
DynamicIsland/components/Shelf/AirDropView.swift
Normal file
70
DynamicIsland/components/Shelf/AirDropView.swift
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
//
|
||||
// AirDrop+View.swift
|
||||
// NotchDrop
|
||||
//
|
||||
// Created by 秋星桥 on 2024/7/8.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
struct AirDropView: View {
|
||||
@EnvironmentObject var vm: DynamicIslandViewModel
|
||||
|
||||
@State var trigger: UUID = .init()
|
||||
@State var targeting = false
|
||||
|
||||
var body: some View {
|
||||
dropArea
|
||||
.onDrop(of: [.data], isTargeted: $vm.dropZoneTargeting) { providers in
|
||||
trigger = .init()
|
||||
vm.dropEvent = true
|
||||
DispatchQueue.global().async { beginDrop(providers) }
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
var dropArea: some View {
|
||||
Rectangle()
|
||||
.fill(.white.opacity(0.1))
|
||||
.opacity(0.5)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 10))
|
||||
.overlay { dropLabel }
|
||||
.aspectRatio(1, contentMode: .fit)
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
|
||||
var dropLabel: some View {
|
||||
VStack(spacing: 8) {
|
||||
Image(systemName: "airplayaudio")
|
||||
Text("AirDrop")
|
||||
}
|
||||
.foregroundStyle(.gray)
|
||||
.font(.system(.headline, design: .rounded))
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
trigger = .init()
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
let picker = NSOpenPanel()
|
||||
picker.allowsMultipleSelection = true
|
||||
picker.canChooseDirectories = true
|
||||
picker.canChooseFiles = true
|
||||
picker.begin { response in
|
||||
if response == .OK {
|
||||
let drop = AirDrop(files: picker.urls)
|
||||
drop.begin()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func beginDrop(_ providers: [NSItemProvider]) {
|
||||
assert(!Thread.isMainThread)
|
||||
guard let urls = providers.interfaceConvert() else { return }
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
let drop = AirDrop(files: urls)
|
||||
drop.begin()
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue