use waterui_core::metadata::MetadataKey;
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
#[allow(clippy::struct_excessive_bools)]
pub struct EdgeSet {
pub top: bool,
pub leading: bool,
pub bottom: bool,
pub trailing: bool,
}
impl EdgeSet {
pub const ALL: Self = Self {
top: true,
leading: true,
bottom: true,
trailing: true,
};
pub const NONE: Self = Self {
top: false,
leading: false,
bottom: false,
trailing: false,
};
pub const HORIZONTAL: Self = Self {
top: false,
leading: true,
bottom: false,
trailing: true,
};
pub const VERTICAL: Self = Self {
top: true,
leading: false,
bottom: true,
trailing: false,
};
pub const TOP: Self = Self {
top: true,
leading: false,
bottom: false,
trailing: false,
};
pub const BOTTOM: Self = Self {
top: false,
leading: false,
bottom: true,
trailing: false,
};
#[must_use]
#[allow(clippy::fn_params_excessive_bools)]
pub const fn new(top: bool, leading: bool, bottom: bool, trailing: bool) -> Self {
Self {
top,
leading,
bottom,
trailing,
}
}
#[must_use]
pub const fn any(&self) -> bool {
self.top || self.leading || self.bottom || self.trailing
}
#[must_use]
pub const fn all(&self) -> bool {
self.top && self.leading && self.bottom && self.trailing
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct IgnoreSafeArea {
pub edges: EdgeSet,
}
impl MetadataKey for IgnoreSafeArea {}
impl IgnoreSafeArea {
#[must_use]
pub const fn new(edges: EdgeSet) -> Self {
Self { edges }
}
#[must_use]
pub const fn all() -> Self {
Self {
edges: EdgeSet::ALL,
}
}
#[must_use]
pub const fn vertical() -> Self {
Self {
edges: EdgeSet::VERTICAL,
}
}
#[must_use]
pub const fn horizontal() -> Self {
Self {
edges: EdgeSet::HORIZONTAL,
}
}
}