mirror of
https://github.com/Death916/deathclock.git
synced 2026-04-10 03:04:40 -07:00
add internal pane config for layout
This commit is contained in:
parent
4560dbc4d3
commit
3fb205550d
1 changed files with 38 additions and 14 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
#![allow(dead_code)]
|
// #![allow(dead_code)]
|
||||||
|
|
||||||
mod sports;
|
mod sports;
|
||||||
use chrono::DateTime;
|
use chrono::DateTime;
|
||||||
|
|
@ -6,6 +6,7 @@ use chrono::Local;
|
||||||
use iced::Border;
|
use iced::Border;
|
||||||
use iced::Element;
|
use iced::Element;
|
||||||
use iced::Fill;
|
use iced::Fill;
|
||||||
|
use iced::widget::pane_grid::Configuration;
|
||||||
use iced::widget::{column, container, image, pane_grid, row, scrollable, text};
|
use iced::widget::{column, container, image, pane_grid, row, scrollable, text};
|
||||||
use sports::Game;
|
use sports::Game;
|
||||||
pub fn main() -> iced::Result {
|
pub fn main() -> iced::Result {
|
||||||
|
|
@ -95,6 +96,7 @@ impl State {
|
||||||
.into()
|
.into()
|
||||||
}))
|
}))
|
||||||
.padding(0)
|
.padding(0)
|
||||||
|
.width(50)
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
PaneType::NflPane => text("NFL").into(),
|
PaneType::NflPane => text("NFL").into(),
|
||||||
|
|
@ -139,19 +141,26 @@ impl State {
|
||||||
})))
|
})))
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
PaneType::Clock => text("clock").into(),
|
PaneType::Clock => container(row![
|
||||||
|
text(Local::now().format("%m/%d %H:%M:%S").to_string()).size(30),
|
||||||
|
])
|
||||||
|
.align_x(iced::Alignment::Center)
|
||||||
|
.into(),
|
||||||
PaneType::Weather => {
|
PaneType::Weather => {
|
||||||
let weather_img = image::Handle::from_bytes(state.weather.clone());
|
let weather_img = image::Handle::from_bytes(state.weather.clone());
|
||||||
let time = Local::now().format("%m/%d %H:%M:%S").to_string();
|
|
||||||
container(
|
container(
|
||||||
column![
|
column![
|
||||||
text(time).size(30),
|
|
||||||
text("Weather").size(50),
|
text("Weather").size(50),
|
||||||
image(weather_img).width(Fill),
|
image(weather_img).width(Fill),
|
||||||
text(state.location.clone()).size(30),
|
text(state.location.clone()).size(30),
|
||||||
]
|
]
|
||||||
.padding(5),
|
.padding(5)
|
||||||
|
.align_x(iced::Alignment::Center),
|
||||||
)
|
)
|
||||||
|
.width(Fill)
|
||||||
|
.height(Fill)
|
||||||
|
.center_x(Fill)
|
||||||
|
.center_y(Fill)
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -184,15 +193,30 @@ impl Default for State {
|
||||||
nba_scores: { sports::update_nba() },
|
nba_scores: { sports::update_nba() },
|
||||||
mlb_scores: { sports::update_mlb() },
|
mlb_scores: { sports::update_mlb() },
|
||||||
panes: {
|
panes: {
|
||||||
let (mut panes, nba) = pane_grid::State::new(PaneType::NbaPane);
|
let config = Configuration::Split {
|
||||||
let (weather, _) = panes
|
axis: pane_grid::Axis::Horizontal,
|
||||||
.split(pane_grid::Axis::Vertical, nba, PaneType::Weather)
|
ratio: 0.05,
|
||||||
.unwrap();
|
a: Box::new(Configuration::Pane(PaneType::Clock)),
|
||||||
let (mlb, _) = panes
|
b: Box::new(Configuration::Split {
|
||||||
.split(pane_grid::Axis::Vertical, weather, PaneType::MlbPane)
|
axis: pane_grid::Axis::Vertical,
|
||||||
.unwrap();
|
ratio: 0.3,
|
||||||
panes.split(pane_grid::Axis::Horizontal, mlb, PaneType::NflPane);
|
a: Box::new(Configuration::Pane(PaneType::NbaPane)),
|
||||||
panes
|
b: Box::new(Configuration::Split {
|
||||||
|
axis: pane_grid::Axis::Vertical,
|
||||||
|
ratio: 0.5,
|
||||||
|
a: Box::new(Configuration::Pane(PaneType::Weather)),
|
||||||
|
b: Box::new(Configuration::Split {
|
||||||
|
axis: pane_grid::Axis::Horizontal,
|
||||||
|
ratio: 0.5,
|
||||||
|
a: Box::new(Configuration::Pane(PaneType::MlbPane)),
|
||||||
|
b: Box::new(Configuration::Pane(PaneType::NflPane)),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
// panes
|
||||||
|
pane_grid::State::with_configuration(config)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue