Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
## Next

- Add SwiftUI extension `View+FrameSize` ([#153](https://github.com/AckeeCZ/ACKategories/pull/153), kudos to @lukashromadnik)
- Add SwiftUI extension `View+endEditingOnTap` ([#152](https://github.com/AckeeCZ/ACKategories/pull/152), kudos to @lukashromadnik)
- Add `readSize` and `readFrame` to SwiftUI views ([#150](https://github.com/AckeeCZ/ACKategories/pull/150), kudos to @olejnjak)
- Add `WithLayoutMargins` to SwiftUI extensions ([#150](https://github.com/AckeeCZ/ACKategories/pull/151), kudos to @komkovla)
- Add `WithLayoutMargins` to SwiftUI extensions ([#151](https://github.com/AckeeCZ/ACKategories/pull/151), kudos to @komkovla)

## 6.15.0

Expand Down
22 changes: 22 additions & 0 deletions Sources/ACKategories/SwiftUIExtensions/View+endEditingOnTap.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#if canImport(UIKit) && !os(watchOS)
import SwiftUI

@available(iOS 13.0, *)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The availability should be fixed for other platforms, probably check other extensions that are SwiftUI specific. That should fix the CI build.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say, that having #if canImport(UIKit) && !os(watchOS) and then limit availability only to iOS feels weird, doesn't it? This would work on macOS, wouldn't it? Not sure about tvOS, but I would say so.

public extension View {

@available(iOSApplicationExtension, unavailable)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can move this availability clause to the extension itself so it is at one place.

func endEditingOnTap(
_ action: (() -> Void)? = nil
) -> some View {
onTapGesture {
UIApplication.shared.sendAction(
#selector(UIResponder.resignFirstResponder),
to: nil,
from: nil,
for: nil
)
action?()
}
}
}
#endif