mirror of
https://github.com/laosb/CropImage.git
synced 2025-04-30 23:51:08 +00:00
fix: iOS 14 compatibility.
This commit is contained in:
parent
9ff52995b7
commit
b42b532ddb
1 changed files with 57 additions and 41 deletions
|
@ -16,10 +16,7 @@ public struct DefaultControlsView: View {
|
|||
@Binding var rotation: Angle
|
||||
var crop: () async -> Void
|
||||
|
||||
public var body: some View {
|
||||
VStack {
|
||||
Spacer()
|
||||
HStack {
|
||||
var rotateButton: some View {
|
||||
Button {
|
||||
let roundedAngle = Angle.degrees((rotation.degrees / 90).rounded() * 90)
|
||||
withAnimation {
|
||||
|
@ -39,7 +36,9 @@ public struct DefaultControlsView: View {
|
|||
}
|
||||
.buttonStyle(.plain)
|
||||
.padding()
|
||||
Spacer()
|
||||
}
|
||||
|
||||
var resetButton: some View {
|
||||
Button("Reset") {
|
||||
withAnimation {
|
||||
offset = .zero
|
||||
|
@ -47,9 +46,9 @@ public struct DefaultControlsView: View {
|
|||
rotation = .zero
|
||||
}
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
.buttonBorderShape(.roundedRectangle)
|
||||
Spacer()
|
||||
}
|
||||
|
||||
var cropButton: some View {
|
||||
Button { Task {
|
||||
await crop()
|
||||
} } label: {
|
||||
|
@ -65,6 +64,23 @@ public struct DefaultControlsView: View {
|
|||
.buttonStyle(.plain)
|
||||
.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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue