Skip to content

Commit

Permalink
Move DeviceRotation into separate library
Browse files Browse the repository at this point in the history
  • Loading branch information
Brianna Doubt committed Oct 22, 2021
1 parent 5ec0ecb commit 811b0b4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 22 deletions.
5 changes: 1 addition & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import PackageDescription

let package = Package(
name: "KeyWindow",
platforms: [
.iOS(.v13),
.macOS(.v10_15)
],
platforms: [.iOS(.v13)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
Expand Down
18 changes: 0 additions & 18 deletions Sources/KeyWindow/KeyWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,3 @@ public extension View {
UIScreen.main.bounds
}
}

public struct DeviceRotationViewModifier: ViewModifier {
public let action: (UIDeviceOrientation) -> Void

public func body(content: Content) -> some View {
content
.onAppear()
.onReceive(NotificationCenter.default.publisher(for: UIDevice.orientationDidChangeNotification)) { _ in
action(UIDevice.current.orientation)
}
}
}

public extension View {
func onRotate(perform action: @escaping (UIDeviceOrientation) -> Void) -> some View {
self.modifier(DeviceRotationViewModifier(action: action))
}
}

0 comments on commit 811b0b4

Please sign in to comment.