modified: src/main.rs

modified:   src/widget.rs
This commit is contained in:
Michael Wain 2024-12-15 18:44:50 +03:00
parent 3d89e51418
commit b41e31b4be
2 changed files with 25 additions and 14 deletions

View File

@ -4,6 +4,7 @@ use iced::{Background, Border, Color};
use iced::Length::Fill;
use iced::{widget::container, window, Theme, Element, Settings, Task as Command};
use iced::widget::{button, column, pick_list, radio, row, scrollable, text, Column, Container};
use widget::SplitView;
mod disk_util;
mod ipod_util;
@ -23,12 +24,7 @@ pub enum Message {
struct State {
}
impl State {
fn new() -> Self {
Self { }
}
split_view: SplitView
}
enum App {
@ -48,8 +44,8 @@ impl App {
}
App::Loaded(state) => {
//return state.tab_panel.view();
return container(row![ widget::basic_btn("About iLoader") ]).into();
return state.split_view.view();
//return container(row![ widget::basic_btn("About iLoader") ]).into();
}
}
}
@ -57,7 +53,11 @@ impl App {
pub fn update(&mut self, message: Message) -> Command<Message> {
match self {
App::Preloaded => {
*self = App::Loaded(State {});
*self = App::Loaded(
State {
split_view: SplitView::new()
}
);
return Command::done(Message::ChangeUI);
}
App::Loaded(state) => {

View File

@ -1,4 +1,4 @@
use iced::{widget::{button, container, text}, Length::Fill, Padding, Task as Command, Element};
use iced::{widget::{button, column, container, row, text}, Element, Length::Fill, Padding, Task as Command};
use crate::{theme, Message};
@ -69,18 +69,29 @@ impl ActionWindow for YTWindow {
}
}
pub struct SplitView<T> where T: ActionWindow {
pub struct SplitView {
sidebar: Vec<SidebarGroup>,
selected: Option<(SidebarTab, Box<dyn ActionWindow>)>
}
impl<T: ActionWindow> SplitView<T> {
impl SplitView {
pub fn view(&self) -> Element<Message> {
if self.selected.is_none() {
return container("hey").into();
}
let a = &self.selected.as_ref().unwrap().1;
row![
column! [container("lol")],
if self.selected.is_some() { container(a.view()) } else { container(text!("None")) }
].into()
}
pub fn update(&mut self, message: Message) -> Command<Message> {
if self.selected.is_some() {
let a = &mut self.selected.as_mut().unwrap().1;
return a.update(message);
}
Command::none()
}
pub fn new() -> Self {