Skip to content

Commit

Permalink
Merge pull request #220 from rowungiles/master
Browse files Browse the repository at this point in the history
Instantiate Column and Row with children
  • Loading branch information
hecrj authored Mar 17, 2020
2 parents e143877 + 99b5212 commit 9da6ce4
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
11 changes: 10 additions & 1 deletion native/src/widget/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ impl<'a, Message, Renderer> Column<'a, Message, Renderer> {
///
/// [`Column`]: struct.Column.html
pub fn new() -> Self {
Self::with_children(Vec::new())
}

/// Creates a [`Column`] with the given elements.
///
/// [`Column`]: struct.Column.html
pub fn with_children(
children: Vec<Element<'a, Message, Renderer>>,
) -> Self {
Column {
spacing: 0,
padding: 0,
Expand All @@ -38,7 +47,7 @@ impl<'a, Message, Renderer> Column<'a, Message, Renderer> {
max_width: u32::MAX,
max_height: u32::MAX,
align_items: Align::Start,
children: Vec::new(),
children,
}
}

Expand Down
11 changes: 10 additions & 1 deletion native/src/widget/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ impl<'a, Message, Renderer> Row<'a, Message, Renderer> {
///
/// [`Row`]: struct.Row.html
pub fn new() -> Self {
Self::with_children(Vec::new())
}

/// Creates a [`Row`] with the given elements.
///
/// [`Row`]: struct.Row.html
pub fn with_children(
children: Vec<Element<'a, Message, Renderer>>,
) -> Self {
Row {
spacing: 0,
padding: 0,
Expand All @@ -38,7 +47,7 @@ impl<'a, Message, Renderer> Row<'a, Message, Renderer> {
max_width: u32::MAX,
max_height: u32::MAX,
align_items: Align::Start,
children: Vec::new(),
children,
}
}

Expand Down
9 changes: 8 additions & 1 deletion web/src/widget/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ impl<'a, Message> Column<'a, Message> {
///
/// [`Column`]: struct.Column.html
pub fn new() -> Self {
Self::with_children(Vec::new())
}

/// Creates a [`Column`] with the given elements.
///
/// [`Column`]: struct.Column.html
pub fn with_children(children: Vec<Element<'a, Message>>) -> Self {
Column {
spacing: 0,
padding: 0,
Expand All @@ -33,7 +40,7 @@ impl<'a, Message> Column<'a, Message> {
max_width: u32::MAX,
max_height: u32::MAX,
align_items: Align::Start,
children: Vec::new(),
children,
}
}

Expand Down
9 changes: 8 additions & 1 deletion web/src/widget/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ impl<'a, Message> Row<'a, Message> {
///
/// [`Row`]: struct.Row.html
pub fn new() -> Self {
Self::with_children(Vec::new())
}

/// Creates a [`Row`] with the given elements.
///
/// [`Row`]: struct.Row.html
pub fn with_children(children: Vec<Element<'a, Message>>) -> Self {
Row {
spacing: 0,
padding: 0,
Expand All @@ -33,7 +40,7 @@ impl<'a, Message> Row<'a, Message> {
max_width: u32::MAX,
max_height: u32::MAX,
align_items: Align::Start,
children: Vec::new(),
children,
}
}

Expand Down

0 comments on commit 9da6ce4

Please sign in to comment.