Im making an app that uses drag&drop but, it doesn't work.
This is made with Swift Playground.
If you can find a solution, please let me know.
Here is the code.
//MARK: Drop Area
@ViewBuilder
func DropAera()->some View{
VStack(spacing: 12){
ForEach($rows,id:\.self){$row in
HStack(spacing: 10){
ForEach($row){$item in
Text(item.value)
.font(.system(size: item.fontSize))
.padding(.vertical,5)
.padding(.horizontal,item.padding)
.opacity(item.isShowing ? 1 : 0)
.background{
RoundedRectangle(cornerRadius: 6, style: .continuous)
.fill(item.isShowing ? .clear : .gray.opacity(0.25))
}
.background{
// If Item is Dropped into Correct Plase
RoundedRectangle(cornerRadius: 6, style: .continuous)
.stroke(.gray)
.opacity(item.isShowing ? 1 : 0)
}
// MARK: Adding Drop Operation
// MARK: Adding Drag Drop Operation
.onDrop(of: [.url], isTargeted: .constant(false)) {
providers in
if let first = providers.first{
let _ = first.loadObject(ofClass: URL.self) {
value,error in
guard let url = value else{return}
if item.id == "\(url)"{
droppedCount += 1
let progress = (droppedCount / CGFloat(characters.count))
withAnimation{
item.isShowing = true
updateShuffledArray(character: item)
self.progress = progress
}
}
else{
//Animating When Wrong text
animateView()
}
}
}
return false
}
}
}
if rows.last != row{
Divider()
}
}
}
}
@ViewBuilder
func DragArea()->some View{
VStack(spacing: 12){
ForEach(shuffledRows,id: \.self){row in
HStack(spacing: 10){
ForEach(row){item in
Text(item.value)
.font(.system(size: item.fontSize))
.padding(.vertical,5)
.padding(.horizontal,item.padding)
.background{
RoundedRectangle(cornerRadius: 6, style: .continuous)
.stroke(.gray)
}
// MARK: Adding Drag Drop Operation
.onDrag{
// Returning ID to find whitch Item is Moving
return .init(contentsOf: URL(string: item.id))!
}
.opacity(item.isShowing ? 0 : 1)
.background{
RoundedRectangle(cornerRadius: 6, style: .continuous)
.fill(item.isShowing ? .gray.opacity(0.25) : .clear)
}
}
}
if shuffledRows.last != row{
Divider()
}
}
}
}
Post
Replies
Boosts
Views
Activity
I have a few questions about the Swift Student Challenge development tools.
What is the difference between swift playground and Xcode playground?
Also, is it possible to develop vision OS in the playground?
If I am a member of the Apple Developer Program, can I participate in the in-person Apple Vision Pro Developer Lab under "Meet With Apple Experts " regardless of my age or app release history?
I am currently a high school student and have a little experience with visionOS development. I also have knowledge of iOS development and have worked on several apps.
I am not currently in the Apple Developer Program yet, but would like to be if possible.
Hello, I am new to ARkit.
I have tried to program to display a cube using ARkit and Realitykit in various articles using Xcode, but none of them worked. How can I display a 3Dcube in AR ?????
What I tried, roughly speaking, was to open the xcode iOS, AR progect file and run the program that is included by default.
If you can answer in Japanese, please do so.
I don't really understand the exact meaning of "Build your app playground" on the Apple Swift Student Challenge home page. Does it mean to build a game app with a normal Xcode SwiftUI project?
Or is there a platform called "App Playground"?
So we cannot make an app that is not a game or an app that is not made with a platform called "App Playground" ?????????
I'm confused.
If you can use Japanese, it would be helpful to answer in Japanese.