Skip to content

Commit

Permalink
fixed date_picker
Browse files Browse the repository at this point in the history
  • Loading branch information
genusistimelord committed Nov 7, 2023
1 parent 6c0365e commit 74579cf
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 159 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ default = [
"badge",
"card",
"number_input",
#"date_picker",
"date_picker",
"color_picker",
#"floating_element",
#"icon_text",
Expand Down Expand Up @@ -88,7 +88,7 @@ members = [
#"examples/cupertino/cupertino_button",
#"examples/cupertino/cupertino_spinner",
#"examples/cupertino/cupertino_switch",
#"examples/date_picker",
"examples/date_picker",
#"examples/floating_element",
#"examples/floating_element_anchors",
#"examples/grid",
Expand Down
6 changes: 4 additions & 2 deletions src/native/date_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,10 @@ where
self.underlay.as_widget().width()
}

fn layout(&self, renderer: &Renderer<Theme>, limits: &Limits) -> Node {
self.underlay.as_widget().layout(renderer, limits)
fn layout(&self, tree: &mut Tree, renderer: &Renderer<Theme>, limits: &Limits) -> Node {
self.underlay
.as_widget()
.layout(&mut tree.children[0], renderer, limits)
}

fn on_event(
Expand Down
2 changes: 1 addition & 1 deletion src/native/number_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ where
.center_x()
};

let mut element = if self.padding < DEFAULT_PADDING {
let element = if self.padding < DEFAULT_PADDING {
Element::new(
Row::<Message, Renderer>::new()
.spacing(1)
Expand Down
30 changes: 8 additions & 22 deletions src/native/overlay/color_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ use iced_widget::{
text::Renderer as _,
touch,
widget::{self, tree::Tree},
Alignment, Clipboard, Color, Element, Event, Layout, Length, Overlay, Padding, Pixels,
Point, Rectangle, Renderer as _, Shell, Size, Text, Vector, Widget,
Alignment, Clipboard, Color, Element, Event, Layout, Length, Overlay, Padding, Point,
Rectangle, Renderer as _, Shell, Size, Text, Vector, Widget,
},
graphics::geometry::Renderer as _,
renderer::Renderer,
Expand Down Expand Up @@ -938,24 +938,10 @@ where

let hex_text_limits = block2_limits;

let mut hex_text = Row::<Message, Renderer<Theme>>::new()
let mut hex_text_layout = Row::<Message, Renderer<Theme>>::new()
.width(Length::Fill)
.height(Length::Fixed(renderer.default_size().0 + 2.0 * PADDING));

let element: Element<Message, Renderer<Theme>> = Element::new(hex_text);
let mut rgba_tree = if let Some(child_tree) = color_picker.tree.children.get_mut(2) {
child_tree.diff(element.as_widget());
child_tree
} else {
let child_tree = Tree::new(element.as_widget());
color_picker.tree.children.insert(2, child_tree);
color_picker.tree.children.get_mut(2).unwrap()
};

let mut hex_text_layout =
element
.as_widget()
.layout(color_picker.tree, renderer, &hex_text_limits);
.height(Length::Fixed(renderer.default_size().0 + 2.0 * PADDING))
.layout(color_picker.tree, renderer, &hex_text_limits);

let block2_limits = block2_limits.shrink(Size::new(
0.0,
Expand Down Expand Up @@ -991,13 +977,13 @@ where
);
}
let element: Element<Message, Renderer<Theme>> = Element::new(rgba_colors);
let mut rgba_tree = if let Some(child_tree) = color_picker.tree.children.get_mut(3) {
let mut rgba_tree = if let Some(child_tree) = color_picker.tree.children.get_mut(2) {
child_tree.diff(element.as_widget());
child_tree
} else {
let child_tree = Tree::new(element.as_widget());
color_picker.tree.children.insert(3, child_tree);
color_picker.tree.children.get_mut(3).unwrap()
color_picker.tree.children.insert(2, child_tree);
&mut color_picker.tree.children[2]
};

let mut rgba_colors = element
Expand Down
Loading

0 comments on commit 74579cf

Please sign in to comment.