From 810ae718323e5266e9d9311026752a0f89dabeeb Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 20 Nov 2022 14:06:45 -0500 Subject: [PATCH] Make poll options in Compose reorderable with drag/drop --- Tusker/Screens/Compose/ComposePollView.swift | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Tusker/Screens/Compose/ComposePollView.swift b/Tusker/Screens/Compose/ComposePollView.swift index f1d9f8b5..ebc4526f 100644 --- a/Tusker/Screens/Compose/ComposePollView.swift +++ b/Tusker/Screens/Compose/ComposePollView.swift @@ -51,9 +51,20 @@ struct ComposePollView: View { .hoverEffect() } - ForEach(Array(poll.options.enumerated()), id: \.element.id) { (e) in - ComposePollOption(poll: poll, option: e.element, optionIndex: e.offset) + List { + ForEach(Array(poll.options.enumerated()), id: \.element.id) { (e) in + ComposePollOption(poll: poll, option: e.element, optionIndex: e.offset) + .frame(height: 36) + .listRowInsets(EdgeInsets(top: 4, leading: 0, bottom: 4, trailing: 0)) + .listRowSeparator(.hidden) + .listRowBackground(Color.clear) + } + .onMove { indices, newIndex in + poll.options.move(fromOffsets: indices, toOffset: newIndex) + } } + .listStyle(.plain) + .frame(height: 44 * CGFloat(poll.options.count)) Button(action: self.addOption) { Label("Add Option", systemImage: "plus")