I have downloaded a sample project at raywenderlich.com (https://www.raywenderlich.com/22408716-drag-and-drop-editable-lists-tutorial-for-swiftui). I am working on a project involving DropDelegate. And I have a question with this project to make my point.
In reference to the picture shown below, if I grab, drag and move Count Sheep, its preview picture will shrink. How could I prevent the preview picture from shrinking its size?
struct ContentView: View {
@EnvironmentObject private var todoList: TodoList
@State private var isShowingAddTodoView = false
@State private var editMode: EditMode = .inactive
@State private var focusId: Int?
func addTodo() {
isShowingAddTodoView = true
}
var body: some View {
NavigationView {
VStack {
FocusTodoView(focusId: focusId)
.padding()
.onDrop(
of: [TodoItem.typeIdentifier],
delegate: TodoDropDelegate(focusId: $focusId))
ScrollView {
ActiveTodoView()
CompletedTodoView()
.disabled(editMode.isEditing)
.onDrop(of: [TodoItem.typeIdentifier], isTargeted: nil) { itemProviders in
for itemProvider in itemProviders {
itemProvider.loadObject(ofClass: TodoItem.self) { todoItem, _ in
guard let todoItem = todoItem as? TodoItem else { return }
DispatchQueue.main.async {
todoList.updateTodo(withId: todoItem.id, isCompleted: true)
}
}
}
return true
}
}
.applyPlainListAppearance()
.navigationBarTitle("Drag Todo")
.toolbar {
ToolbarItemGroup(placement: .navigationBarTrailing) {
EditButton()
Button(action: addTodo) {
Image(systemName: "plus")
}
.disabled(editMode.isEditing)
}
}
.environment(\.editMode, $editMode)
.sheet(isPresented: $isShowingAddTodoView) {
AddTodoView()
}
}
}
.navigationViewStyle(StackNavigationViewStyle())
}
}
I wish I had a simpler sample. That's the only sample I have been able to find. Anyway, I've been asking Google all day about "SwiftUI DropDelegate preview" with no luck. Thanks.