Skip to content

Commit

Permalink
Fix compilation issues for tvOS
Browse files Browse the repository at this point in the history
  • Loading branch information
dogo committed Sep 22, 2024
1 parent 5464a0b commit c42b247
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Sources/SketchKit/Constrainable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ extension View: Constrainable {
}

/// A layout guide that dynamically adjusts to the keyboard's frame.
#if os(iOS)
public var keyboardLayout: LayoutGuide {
return SketchKitDSL(constrainable: self).resolveKeyboardLayoutGuide()
}
#endif
}

/// LayoutGuide is an abstraction of Apple layout system
Expand Down
2 changes: 2 additions & 0 deletions Sources/SketchKit/KeyboardLayoutGuide.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ final class SKKeyboard {
}
}

#if os(iOS)
final class KeyboardLayoutGuide: LayoutGuide {

private var bottomConstraint: NSLayoutConstraint?
Expand Down Expand Up @@ -139,3 +140,4 @@ extension Notification {
return self.userInfo?[UIResponder.keyboardAnimationDurationUserInfoKey] as? CGFloat
}
}
#endif
2 changes: 2 additions & 0 deletions Sources/SketchKit/SketchKitDSL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class SketchKitDSL {
block(self.constrainable)
}

#if os(iOS)
func resolveKeyboardLayoutGuide() -> LayoutGuide {
guard let view = constrainable as? View else { return LayoutGuide() }

Expand All @@ -74,4 +75,5 @@ public class SketchKitDSL {

return keyboardLayoutGuide
}
#endif
}

0 comments on commit c42b247

Please sign in to comment.