This commit is contained in:
parent
55c0912608
commit
f719983c62
2 changed files with 46 additions and 24 deletions
|
@ -25,7 +25,7 @@ use web_time::Instant;
|
|||
|
||||
use crate::app::{
|
||||
password_locker::PasswordLocker,
|
||||
weather_icon::{WeatherIcon, DAY_ICONS},
|
||||
weather_icon::{WeatherIcon, WEATHER_ICONS},
|
||||
};
|
||||
|
||||
mod password_locker;
|
||||
|
@ -143,7 +143,7 @@ impl<E: AppExecutor> App<E> {
|
|||
lon: -111.89066476757807,
|
||||
country: String::from("US"),
|
||||
},
|
||||
"metric".to_owned(),
|
||||
"imperial".to_owned(),
|
||||
dotenv!("OPENWEATHERMAP_API_KEY").to_owned(),
|
||||
);
|
||||
weather_client.get_current_weather().await.unwrap()
|
||||
|
@ -225,23 +225,42 @@ impl<E: AppExecutor> App<E> {
|
|||
|
||||
let layout = Layout::new(
|
||||
Direction::Vertical,
|
||||
[Constraint::Length(12), Constraint::Min(0)],
|
||||
[Constraint::Length(20), Constraint::Min(0)],
|
||||
)
|
||||
.split(weather_area.inner(Margin::new(2, 2)));
|
||||
|
||||
let layout_upper = Layout::new(
|
||||
Direction::Horizontal,
|
||||
[Constraint::Ratio(1, 2), Constraint::Ratio(1, 2)],
|
||||
if weather_area.width < (weather_area.height * 2) {
|
||||
Direction::Vertical
|
||||
} else {
|
||||
Direction::Horizontal
|
||||
},
|
||||
[
|
||||
Constraint::Length(if weather_area.width < (weather_area.height * 2) {
|
||||
28 / 2
|
||||
} else {
|
||||
28
|
||||
}),
|
||||
Constraint::Min(0),
|
||||
],
|
||||
)
|
||||
.split(layout[0]);
|
||||
|
||||
frame.render_widget(
|
||||
WeatherIcon(DAY_ICONS.get(&weather.weather[0].icon).unwrap()),
|
||||
WeatherIcon(
|
||||
WEATHER_ICONS
|
||||
.get(&weather.weather[0].icon[..weather.weather[0].icon.len() - 1])
|
||||
.unwrap(),
|
||||
weather.weather[0].icon[weather.weather[0].icon.len() - 1..]
|
||||
.bytes()
|
||||
.next()
|
||||
.unwrap(),
|
||||
),
|
||||
layout_upper[0],
|
||||
);
|
||||
frame.render_widget(
|
||||
Paragraph::new(format!(
|
||||
"{} {}°C\n~{}°C -{}°C +{}°C\n{} {} {}m/s SSE\nVisibility: {}km",
|
||||
"{} {}°F\n~{}°F -{}°F +{}°F\n{} {} {}mph\nVisibility: {}km",
|
||||
weather.name,
|
||||
weather.main.temp.unwrap_or(f64::NAN),
|
||||
weather.main.feels_like.unwrap_or(f64::NAN),
|
||||
|
@ -263,11 +282,7 @@ impl<E: AppExecutor> App<E> {
|
|||
))
|
||||
.fg(Color::Rgb(226, 190, 89))
|
||||
.bg(Color::Black),
|
||||
if weather_area.width < (weather_area.height * 2) {
|
||||
layout[1]
|
||||
} else {
|
||||
layout_upper[1]
|
||||
},
|
||||
layout_upper[1],
|
||||
);
|
||||
} else {
|
||||
frame.render_widget(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue