Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
Verified Commit 986c26bb authored by Ayush Singh's avatar Ayush Singh
Browse files

gui: Extract destination_selection page


Signed-off-by: Ayush Singh's avatarAyush Singh <ayush@beagleboard.org>
parent 740387f7
No related merge requests found
......@@ -351,7 +351,7 @@ impl BBImager {
Screen::Home => self.home_view(),
Screen::BoardSelection => self.board_selction_view(),
Screen::ImageSelection => self.image_selection_view(),
Screen::DestinationSelection => self.destination_selection_view(),
Screen::DestinationSelection => pages::destination_selection::view(self),
Screen::ExtraConfiguration => pages::configuration::view(self),
Screen::Flashing(s) => s.view(),
}
......@@ -603,48 +603,6 @@ impl BBImager {
.into()
}
fn destination_selection_view(&self) -> Element<BBImagerMessage> {
let items = self
.destinations
.iter()
.filter(|x| {
x.to_string()
.to_lowercase()
.contains(&self.search_bar.to_lowercase())
})
.map(|x| {
let mut row2 = widget::column![text(x.to_string())];
if let bb_imager::Destination::SdCard { size, .. } = x {
let s = (*size as f32) / (1024.0 * 1024.0 * 1024.0);
row2 = row2.push(text(format!("{:.2} GB", s)));
}
button(
widget::row![
widget::svg(widget::svg::Handle::from_memory(constants::USB_ICON))
.width(40),
row2
]
.align_y(iced::Alignment::Center)
.spacing(10),
)
.width(iced::Length::Fill)
.on_press(BBImagerMessage::SelectPort(x.clone()))
.style(widget::button::secondary)
})
.map(Into::into);
widget::column![
self.search_bar(Some(BBImagerMessage::RefreshDestinations)),
widget::horizontal_rule(2),
widget::scrollable(widget::column(items).spacing(10))
]
.spacing(10)
.padding(10)
.into()
}
fn search_bar(&self, refresh: Option<BBImagerMessage>) -> Element<BBImagerMessage> {
let mut row = widget::row![button(
widget::svg(widget::svg::Handle::from_memory(constants::ARROW_BACK_ICON)).width(22)
......
use iced::{
widget::{self, button, text},
Element,
};
use crate::{constants, BBImagerMessage};
pub fn view(bbimager: &crate::BBImager) -> Element<BBImagerMessage> {
let items = bbimager
.destinations
.iter()
.filter(|x| {
x.to_string()
.to_lowercase()
.contains(&bbimager.search_bar.to_lowercase())
})
.map(|x| {
let mut row2 = widget::column![text(x.to_string())];
if let bb_imager::Destination::SdCard { size, .. } = x {
let s = (*size as f32) / (1024.0 * 1024.0 * 1024.0);
row2 = row2.push(text(format!("{:.2} GB", s)));
}
button(
widget::row![
widget::svg(widget::svg::Handle::from_memory(constants::USB_ICON)).width(40),
row2
]
.align_y(iced::Alignment::Center)
.spacing(10),
)
.width(iced::Length::Fill)
.on_press(BBImagerMessage::SelectPort(x.clone()))
.style(widget::button::secondary)
})
.map(Into::into);
widget::column![
bbimager.search_bar(Some(BBImagerMessage::RefreshDestinations)),
widget::horizontal_rule(2),
widget::scrollable(widget::column(items).spacing(10))
]
.spacing(10)
.padding(10)
.into()
}
pub mod flash;
pub mod configuration;
pub mod destination_selection;
#[derive(Default, Debug, Clone)]
pub enum Screen {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment