update struct constructor

This commit is contained in:
yggverse 2024-09-23 15:04:28 +03:00
parent b162682f51
commit 3d7be25c5f
3 changed files with 27 additions and 13 deletions

View file

@ -2,19 +2,29 @@ mod pin;
mod title; mod title;
mod widget; mod widget;
use std::sync::Arc;
pub struct Label { pub struct Label {
// Components
pin: Arc<pin::Pin>,
title: Arc<title::Title>,
// Extras
widget: widget::Label, widget: widget::Label,
} }
impl Label { impl Label {
// Construct // Construct
pub fn new() -> Label { pub fn new() -> Arc<Label> {
Self { // Init components
widget: widget::Label::new( let pin = pin::Pin::new();
pin::Pin::new().widget().image(), let title = title::Title::new();
title::Title::new().widget().label(),
), // Init extras
} let widget = widget::Label::new(pin.widget().image(), title.widget().label());
// Result
Arc::new(Self { pin, title, widget })
} }
// Getters // Getters

View file

@ -1,15 +1,17 @@
mod widget; mod widget;
use std::sync::Arc;
pub struct Pin { pub struct Pin {
widget: widget::Pin, widget: widget::Pin,
} }
impl Pin { impl Pin {
// Construct // Construct
pub fn new() -> Pin { pub fn new() -> Arc<Pin> {
Self { Arc::new(Self {
widget: widget::Pin::new(), widget: widget::Pin::new(),
} })
} }
// Getters // Getters

View file

@ -1,15 +1,17 @@
mod widget; mod widget;
use std::sync::Arc;
pub struct Title { pub struct Title {
widget: widget::Title, widget: widget::Title,
} }
impl Title { impl Title {
// Construct // Construct
pub fn new() -> Title { pub fn new() -> Arc<Title> {
Self { Arc::new(Self {
widget: widget::Title::new(), widget: widget::Title::new(),
} })
} }
// Getters // Getters