use objc::{msg_send, sel, sel_impl};
use crate::foundation::id;
use crate::layout::{LayoutAnchorDimension, LayoutAnchorX, LayoutAnchorY};
use crate::utils::os;
#[derive(Clone, Debug)]
pub struct SafeAreaLayoutGuide {
pub top: LayoutAnchorY,
pub leading: LayoutAnchorX,
pub left: LayoutAnchorX,
pub trailing: LayoutAnchorX,
pub right: LayoutAnchorX,
pub bottom: LayoutAnchorY,
pub width: LayoutAnchorDimension,
pub height: LayoutAnchorDimension,
pub center_x: LayoutAnchorX,
pub center_y: LayoutAnchorY
}
impl SafeAreaLayoutGuide {
pub fn new(view: id) -> Self {
let guide: id = match os::is_minimum_version(11) {
true => unsafe { msg_send![view, layoutMarginsGuide] },
false => view
};
Self {
top: LayoutAnchorY::top(guide),
left: LayoutAnchorX::left(guide),
leading: LayoutAnchorX::leading(guide),
right: LayoutAnchorX::right(guide),
trailing: LayoutAnchorX::trailing(guide),
bottom: LayoutAnchorY::bottom(guide),
width: LayoutAnchorDimension::width(guide),
height: LayoutAnchorDimension::height(guide),
center_x: LayoutAnchorX::center(guide),
center_y: LayoutAnchorY::center(guide)
}
}
}