Faster fill
This commit is contained in:
@ -7,8 +7,8 @@ use embedded_graphics::prelude::*;
|
||||
use profont::PROFONT_18_POINT;
|
||||
use profont::PROFONT_24_POINT;
|
||||
|
||||
use crate::AppState;
|
||||
use crate::MenuIndicatorType;
|
||||
use crate::MeasurementType;
|
||||
use crate::Tendencies;
|
||||
use crate::Tendency;
|
||||
use crate::colors::FRAME_BACKGROUD_COLOR;
|
||||
use crate::colors::FRAME_STROKE;
|
||||
@ -16,18 +16,19 @@ use crate::colors::FRAME_STROKE_COLOR;
|
||||
use crate::colors::MAIN_TEXT_COLOR;
|
||||
use crate::colors::SUB_TEXT_COLOR;
|
||||
use crate::get_image;
|
||||
use crate::sampler::Sample;
|
||||
use crate::views::icon::icon_box_view;
|
||||
|
||||
pub fn menu_view(app_state: AppState) -> impl View<Rgb565> {
|
||||
pub fn menu_view(sample: Sample, tendencies: Tendencies) -> impl View<Rgb565> {
|
||||
VStack::new((
|
||||
HStack::new((
|
||||
main_menu_indicator(MenuIndicatorType::Temperature, app_state),
|
||||
main_menu_indicator(MenuIndicatorType::Humidity, app_state),
|
||||
main_menu_indicator(MeasurementType::Temperature, tendencies, sample),
|
||||
main_menu_indicator(MeasurementType::Humidity, tendencies, sample),
|
||||
))
|
||||
.with_spacing(2),
|
||||
HStack::new((
|
||||
main_menu_indicator(MenuIndicatorType::Co2, app_state),
|
||||
main_menu_indicator(MenuIndicatorType::Voc, app_state),
|
||||
main_menu_indicator(MeasurementType::ECo2, tendencies, sample),
|
||||
main_menu_indicator(MeasurementType::TVoc, tendencies, sample),
|
||||
))
|
||||
.with_spacing(2),
|
||||
))
|
||||
@ -35,8 +36,9 @@ pub fn menu_view(app_state: AppState) -> impl View<Rgb565> {
|
||||
}
|
||||
|
||||
fn main_menu_indicator(
|
||||
indicator_type: MenuIndicatorType,
|
||||
app_state: AppState,
|
||||
indicator_type: MeasurementType,
|
||||
tendencies: Tendencies,
|
||||
sample: Sample,
|
||||
) -> impl View<Rgb565> {
|
||||
Rectangle
|
||||
.corner_radius(5)
|
||||
@ -55,8 +57,8 @@ fn main_menu_indicator(
|
||||
)),
|
||||
HStack::new((
|
||||
Spacer::default(),
|
||||
tendency_indicator(indicator_type.get_tendency(&app_state)),
|
||||
Text::new(indicator_type.get_value_str(&app_state), &PROFONT_24_POINT)
|
||||
tendency_indicator(indicator_type.get_tendency(tendencies)),
|
||||
Text::new(indicator_type.get_value_str(sample), &PROFONT_24_POINT)
|
||||
.foreground_color(MAIN_TEXT_COLOR),
|
||||
Text::new(
|
||||
indicator_type.get_corresponding_unit_string(),
|
||||
@ -76,7 +78,7 @@ fn main_menu_indicator(
|
||||
})
|
||||
}
|
||||
|
||||
fn tendency_indicator(tendency: Tendency) -> impl View<Rgb565> {
|
||||
pub fn tendency_indicator(tendency: Tendency) -> impl View<Rgb565> {
|
||||
HStack::new((
|
||||
Image::new(get_image!(tendency.get_corresponding_icon()))
|
||||
.flex_frame()
|
||||
|
||||
Reference in New Issue
Block a user