use std::any::Any;
use crate::hooks::Context;
use crate::{Component, View};
pub type NativeHandle = Box<dyn Any>;
pub trait Renderer {
fn create_component(&mut self, native_type: &NativeType, component: &View) -> NativeHandle;
fn append_child(
&mut self,
parent_type: &NativeType,
parent_handle: &mut NativeHandle,
child_type: &NativeType,
child_handle: &NativeHandle,
);
fn insert_child(
&mut self,
parent_type: &NativeType,
parent_handle: &mut NativeHandle,
index: usize,
child_type: &NativeType,
child_handle: &NativeHandle,
);
fn replace_child(
&mut self,
parent_type: &NativeType,
parent_handle: &mut NativeHandle,
index: usize,
child_type: &NativeType,
child_handle: &NativeHandle,
);
fn swap_children(
&mut self,
parent_type: &NativeType,
parent_handle: &mut NativeHandle,
a: usize,
b: usize,
);
fn move_child(
&mut self,
parent_type: &NativeType,
parent_handle: &mut NativeHandle,
old: usize,
new: usize,
);
fn remove_child(
&mut self,
parent_type: &NativeType,
parent_handle: &mut NativeHandle,
index: usize,
);
fn update_component(
&mut self,
native_type: &NativeType,
native_handle: &mut NativeHandle,
component: &View,
);
fn log(&self, _string: &str) {}
}
pub trait Scheduler {
fn schedule_on_ui_thread(&mut self, f: Box<dyn FnOnce()>);
}
#[derive(Copy, Clone)]
pub struct NativeType {
pub handler: &'static str,
pub name: &'static str,
}
#[derive(Clone, Default)]
pub struct HasChildrenMarker {
pub children: Vec<View>,
}
impl Component for HasChildrenMarker {
type Builder = ();
fn render(&self, _: Context) -> View {
unreachable!()
}
fn updated(&self) -> bool {
unimplemented!()
}
}
#[doc(inline)]
pub use crate::vdom::Root;