use std::cell::Cell;
use std::rc::Rc;
use yew::html::ImplicitClone;
use yew::prelude::*;
use crate::utils::WeakScope;
#[derive(Clone, Default, Eq, PartialEq)]
pub struct ModalOrientation(Rc<Cell<bool>>);
impl ImplicitClone for ModalOrientation {}
impl ModalOrientation {
pub fn set(&self, value: bool) {
self.0.set(value);
}
}
impl From<ModalOrientation> for bool {
fn from(x: ModalOrientation) -> Self {
x.0.get()
}
}
pub trait ModalLink<T>
where
T: Component,
{
fn weak_link(&self) -> &'_ WeakScope<T>;
}
pub trait SetModalLink {
fn set_modal_link(&self);
}
impl<T> SetModalLink for &Context<T>
where
T: Component,
T::Properties: ModalLink<T>,
{
fn set_modal_link(&self) {
*self.props().weak_link().borrow_mut() = Some(self.link().clone());
}
}