Skip to content

Commit 180f510

Browse files
committed
🔨 iOS version bug fixes
1 parent d7480bf commit 180f510

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

‎.swiftpm/xcode/xcuserdata/benmyers.xcuserdatad/xcschemes/xcschememanagement.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<key>ShinySwiftUI.xcscheme_^#shared#^_</key>
88
<dict>
99
<key>isShown</key>
10-
<false/>
10+
<true/>
1111
<key>orderHint</key>
12-
<integer>1</integer>
12+
<integer>4</integer>
1313
</dict>
1414
</dict>
1515
<key>SuppressBuildableAutocreation</key>

‎Sources/ShinySwiftUI/Views/HoverView.swift

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import SwiftUI
99

10-
@available(macOS 11.0, *)
10+
@available(macOS 11.0, iOS 14.0, *)
1111
public struct HoverView<Content>: View where Content: View {
1212

1313
// MARK: - Public Wrapped Properties
@@ -24,32 +24,59 @@ public struct HoverView<Content>: View where Content: View {
2424

2525
/// The action to perform on click.
2626
public let action: () -> Void
27+
/// The action to perform on hover.
28+
public let onHover: (Bool) -> Void
2729

2830
// MARK: - Public Body View
2931

3032
public var body: some View {
3133
Button(action: action) {
32-
content(hover, clicked).onHover { hover = $0 }
34+
content(hover, clicked).onHover {
35+
hover = $0
36+
onHover($0)
37+
}
3338
}
3439
.buttonStyle(HoverButtonStyle(pressed: $clicked))
3540
}
3641

3742
// MARK: - Public Initalizers
3843

39-
public init(action: @escaping () -> Void = {}, content c: @escaping (Bool, Bool) -> Content) {
44+
public init(action: @escaping () -> Void = {}, onHover: @escaping (Bool) -> Void = { _ in }, content c: @escaping (Bool, Bool) -> Content) {
4045
self.action = action
46+
self.onHover = onHover
4147
self.content = c
4248
}
4349

44-
public init(action: @escaping () -> Void = {}, content c: @escaping (Bool) -> Content) {
50+
public init(action: @escaping () -> Void = {}, onHover: @escaping (Bool) -> Void = { _ in }, content c: @escaping (Bool) -> Content) {
4551
self.action = action
52+
self.onHover = onHover
4653
self.content = { (hover: Bool, click: Bool) in
4754
return c(hover)
4855
}
4956
}
57+
58+
// MARK: - Public Methods
59+
60+
/**
61+
Animates the `hover` property of the view.
62+
63+
- parameter animation: The Animation to use.
64+
*/
65+
public func animateHover(_ animation: Animation = .slickEaseOut) -> some View {
66+
return self.animation(animation, value: hover)
67+
}
68+
69+
/**
70+
Animates the `clicked` property of the view.
71+
72+
- parameter animation: The Animation to use.
73+
*/
74+
public func animateClicked(_ animation: Animation = .slickEaseOut) -> some View {
75+
return self.animation(animation, value: clicked)
76+
}
5077
}
5178

52-
@available(macOS 11.0, *)
79+
@available(macOS 11.0, iOS 14.0, *)
5380
fileprivate struct HoverButtonStyle: ButtonStyle {
5481
let pressed: Binding<Bool>
5582
func makeBody(configuration: Configuration) -> some View {

0 commit comments

Comments
 (0)