fix: iOS 14 compatibility.

This commit is contained in:
Shibo Lyu 2023-08-10 16:47:52 +08:00
parent 9ff52995b7
commit b42b532ddb

View file

@ -16,10 +16,7 @@ public struct DefaultControlsView: View {
@Binding var rotation: Angle @Binding var rotation: Angle
var crop: () async -> Void var crop: () async -> Void
public var body: some View { var rotateButton: some View {
VStack {
Spacer()
HStack {
Button { Button {
let roundedAngle = Angle.degrees((rotation.degrees / 90).rounded() * 90) let roundedAngle = Angle.degrees((rotation.degrees / 90).rounded() * 90)
withAnimation { withAnimation {
@ -39,7 +36,9 @@ public struct DefaultControlsView: View {
} }
.buttonStyle(.plain) .buttonStyle(.plain)
.padding() .padding()
Spacer() }
var resetButton: some View {
Button("Reset") { Button("Reset") {
withAnimation { withAnimation {
offset = .zero offset = .zero
@ -47,9 +46,9 @@ public struct DefaultControlsView: View {
rotation = .zero rotation = .zero
} }
} }
.buttonStyle(.bordered) }
.buttonBorderShape(.roundedRectangle)
Spacer() var cropButton: some View {
Button { Task { Button { Task {
await crop() await crop()
} } label: { } } label: {
@ -65,6 +64,23 @@ public struct DefaultControlsView: View {
.buttonStyle(.plain) .buttonStyle(.plain)
.padding() .padding()
} }
public var body: some View {
VStack {
Spacer()
HStack {
rotateButton
Spacer()
if #available(iOS 15.0, macOS 13.0, *) {
resetButton
.buttonStyle(.bordered)
.buttonBorderShape(.roundedRectangle)
} else {
resetButton
}
Spacer()
cropButton
}
} }
} }
} }