Allow reordering of post images
This commit is contained in:
parent
a35c2d669e
commit
7e91b4b08c
@ -14,9 +14,9 @@ private struct NavigationIcon: View {
|
||||
.padding(5)
|
||||
.padding(edge, 2)
|
||||
.fontWeight(.light)
|
||||
.foregroundStyle(.white)
|
||||
.foregroundStyle(Color.white.opacity(0.8))
|
||||
.frame(width: 30, height: 30)
|
||||
.background(Color.black.opacity(0.6).clipShape(Circle()))
|
||||
.background(Color.black.opacity(0.7).clipShape(Circle()))
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,14 +49,18 @@ struct PostImageGalleryView: View {
|
||||
.padding(.bottom, 10)
|
||||
}
|
||||
}
|
||||
Button(action: { showImagePicker = true }) {
|
||||
Image(systemSymbol: .plusCircleFill)
|
||||
.resizable()
|
||||
.renderingMode(.template)
|
||||
.foregroundStyle(.blue.opacity(0.7))
|
||||
.frame(width: 30, height: 30)
|
||||
.padding()
|
||||
}
|
||||
HStack(spacing: 5) {
|
||||
Button(action: shiftBack) {
|
||||
NavigationIcon(symbol: .arrowTurnUpLeft, edge: .trailing)
|
||||
}
|
||||
Button(action: shiftForward) {
|
||||
NavigationIcon(symbol: .arrowTurnUpRight, edge: .leading)
|
||||
}
|
||||
Spacer()
|
||||
Button(action: { showImagePicker = true }) {
|
||||
NavigationIcon(symbol: .plus, edge: .all)
|
||||
}
|
||||
}.padding()
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.foregroundStyle(.blue)
|
||||
@ -100,6 +104,22 @@ struct PostImageGalleryView: View {
|
||||
currentIndex = 0
|
||||
}
|
||||
}
|
||||
|
||||
private func shiftBack() {
|
||||
guard currentIndex > 0 else {
|
||||
return
|
||||
}
|
||||
post.images.swapAt(currentIndex, currentIndex-1)
|
||||
currentIndex -= 1
|
||||
}
|
||||
|
||||
private func shiftForward() {
|
||||
guard currentIndex < post.images.count - 1 else {
|
||||
return
|
||||
}
|
||||
post.images.swapAt(currentIndex, currentIndex+1)
|
||||
currentIndex += 1
|
||||
}
|
||||
}
|
||||
|
||||
#Preview(traits: .fixedLayout(width: 300, height: 250)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user