forked from shadowfacts/Tusker
Make poll options in Compose reorderable with drag/drop
This commit is contained in:
parent
001a73af3c
commit
810ae71832
|
@ -51,9 +51,20 @@ struct ComposePollView: View {
|
||||||
.hoverEffect()
|
.hoverEffect()
|
||||||
}
|
}
|
||||||
|
|
||||||
ForEach(Array(poll.options.enumerated()), id: \.element.id) { (e) in
|
List {
|
||||||
ComposePollOption(poll: poll, option: e.element, optionIndex: e.offset)
|
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) {
|
Button(action: self.addOption) {
|
||||||
Label("Add Option", systemImage: "plus")
|
Label("Add Option", systemImage: "plus")
|
||||||
|
|
Loading…
Reference in New Issue