Rename S
type to V
This commit is contained in:
parent
8a70ef3e8f
commit
1887f3b594
34 changed files with 140 additions and 152 deletions
|
@ -50,23 +50,23 @@ impl ButtonVariant {
|
|||
|
||||
pub type ClickHandler<S> = Arc<dyn Fn(&mut S, &mut ViewContext<S>) + Send + Sync>;
|
||||
|
||||
struct ButtonHandlers<S: 'static> {
|
||||
click: Option<ClickHandler<S>>,
|
||||
struct ButtonHandlers<V: 'static> {
|
||||
click: Option<ClickHandler<V>>,
|
||||
}
|
||||
|
||||
unsafe impl<S> Send for ButtonHandlers<S> {}
|
||||
unsafe impl<S> Sync for ButtonHandlers<S> {}
|
||||
|
||||
impl<S: 'static> Default for ButtonHandlers<S> {
|
||||
impl<V: 'static> Default for ButtonHandlers<V> {
|
||||
fn default() -> Self {
|
||||
Self { click: None }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct Button<S: 'static> {
|
||||
pub struct Button<V: 'static> {
|
||||
disabled: bool,
|
||||
handlers: ButtonHandlers<S>,
|
||||
handlers: ButtonHandlers<V>,
|
||||
icon: Option<Icon>,
|
||||
icon_position: Option<IconPosition>,
|
||||
label: SharedString,
|
||||
|
@ -74,7 +74,7 @@ pub struct Button<S: 'static> {
|
|||
width: Option<DefiniteLength>,
|
||||
}
|
||||
|
||||
impl<S: 'static> Button<S> {
|
||||
impl<V: 'static> Button<V> {
|
||||
pub fn new(label: impl Into<SharedString>) -> Self {
|
||||
Self {
|
||||
disabled: false,
|
||||
|
@ -114,7 +114,7 @@ impl<S: 'static> Button<S> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn on_click(mut self, handler: ClickHandler<S>) -> Self {
|
||||
pub fn on_click(mut self, handler: ClickHandler<V>) -> Self {
|
||||
self.handlers.click = Some(handler);
|
||||
self
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ impl<S: 'static> Button<S> {
|
|||
self.icon.map(|i| IconElement::new(i).color(icon_color))
|
||||
}
|
||||
|
||||
pub fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
pub fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let icon_color = self.icon_color();
|
||||
|
||||
let mut button = h_stack()
|
||||
|
|
|
@ -7,7 +7,7 @@ pub struct Details<V: 'static> {
|
|||
actions: Option<ButtonGroup<V>>,
|
||||
}
|
||||
|
||||
impl<S: 'static> Details<S> {
|
||||
impl<V: 'static> Details<V> {
|
||||
pub fn new(text: &'static str) -> Self {
|
||||
Self {
|
||||
text,
|
||||
|
@ -21,12 +21,12 @@ impl<S: 'static> Details<S> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn actions(mut self, actions: ButtonGroup<S>) -> Self {
|
||||
pub fn actions(mut self, actions: ButtonGroup<V>) -> Self {
|
||||
self.actions = Some(actions);
|
||||
self
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let theme = theme(cx);
|
||||
|
||||
v_stack()
|
||||
|
|
|
@ -56,7 +56,7 @@ impl Input {
|
|||
self
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let (input_bg, input_hover_bg, input_active_bg) = match self.variant {
|
||||
|
|
|
@ -138,12 +138,12 @@ impl Player {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn cursor_color<S: 'static>(&self, cx: &mut ViewContext<S>) -> Hsla {
|
||||
pub fn cursor_color<V: 'static>(&self, cx: &mut ViewContext<V>) -> Hsla {
|
||||
let theme = theme(cx);
|
||||
theme.players[self.index].cursor
|
||||
}
|
||||
|
||||
pub fn selection_color<S: 'static>(&self, cx: &mut ViewContext<S>) -> Hsla {
|
||||
pub fn selection_color<V: 'static>(&self, cx: &mut ViewContext<V>) -> Hsla {
|
||||
let theme = theme(cx);
|
||||
theme.players[self.index].selection
|
||||
}
|
||||
|
|
|
@ -14,18 +14,18 @@ pub trait Stack: Styled + Sized {
|
|||
}
|
||||
}
|
||||
|
||||
impl<S: 'static> Stack for Div<S> {}
|
||||
impl<V: 'static> Stack for Div<V> {}
|
||||
|
||||
/// Horizontally stacks elements.
|
||||
///
|
||||
/// Sets `flex()`, `flex_row()`, `items_center()`
|
||||
pub fn h_stack<S: 'static>() -> Div<S> {
|
||||
pub fn h_stack<V: 'static>() -> Div<V> {
|
||||
div().h_stack()
|
||||
}
|
||||
|
||||
/// Vertically stacks elements.
|
||||
///
|
||||
/// Sets `flex()`, `flex_col()`
|
||||
pub fn v_stack<S: 'static>() -> Div<S> {
|
||||
pub fn v_stack<V: 'static>() -> Div<V> {
|
||||
div().v_stack()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue