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(5)
|
||||||
.padding(edge, 2)
|
.padding(edge, 2)
|
||||||
.fontWeight(.light)
|
.fontWeight(.light)
|
||||||
.foregroundStyle(.white)
|
.foregroundStyle(Color.white.opacity(0.8))
|
||||||
.frame(width: 30, height: 30)
|
.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)
|
.padding(.bottom, 10)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Button(action: { showImagePicker = true }) {
|
HStack(spacing: 5) {
|
||||||
Image(systemSymbol: .plusCircleFill)
|
Button(action: shiftBack) {
|
||||||
.resizable()
|
NavigationIcon(symbol: .arrowTurnUpLeft, edge: .trailing)
|
||||||
.renderingMode(.template)
|
|
||||||
.foregroundStyle(.blue.opacity(0.7))
|
|
||||||
.frame(width: 30, height: 30)
|
|
||||||
.padding()
|
|
||||||
}
|
}
|
||||||
|
Button(action: shiftForward) {
|
||||||
|
NavigationIcon(symbol: .arrowTurnUpRight, edge: .leading)
|
||||||
|
}
|
||||||
|
Spacer()
|
||||||
|
Button(action: { showImagePicker = true }) {
|
||||||
|
NavigationIcon(symbol: .plus, edge: .all)
|
||||||
|
}
|
||||||
|
}.padding()
|
||||||
}
|
}
|
||||||
.buttonStyle(.plain)
|
.buttonStyle(.plain)
|
||||||
.foregroundStyle(.blue)
|
.foregroundStyle(.blue)
|
||||||
@ -100,6 +104,22 @@ struct PostImageGalleryView: View {
|
|||||||
currentIndex = 0
|
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)) {
|
#Preview(traits: .fixedLayout(width: 300, height: 250)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user