From b41e31b4be367e73dc37fbe2071a6c5e023f5c5d Mon Sep 17 00:00:00 2001 From: "alterwain@protonmail.com" Date: Sun, 15 Dec 2024 18:44:50 +0300 Subject: [PATCH] modified: src/main.rs modified: src/widget.rs --- src/main.rs | 18 +++++++++--------- src/widget.rs | 21 ++++++++++++++++----- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/main.rs b/src/main.rs index e8c5b86..e729d71 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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 { match self { App::Preloaded => { - *self = App::Loaded(State {}); + *self = App::Loaded( + State { + split_view: SplitView::new() + } + ); return Command::done(Message::ChangeUI); } App::Loaded(state) => { diff --git a/src/widget.rs b/src/widget.rs index 384fcfc..66a76a4 100644 --- a/src/widget.rs +++ b/src/widget.rs @@ -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 where T: ActionWindow { +pub struct SplitView { sidebar: Vec, selected: Option<(SidebarTab, Box)> } -impl SplitView { +impl SplitView { pub fn view(&self) -> Element { - + 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 { - + if self.selected.is_some() { + let a = &mut self.selected.as_mut().unwrap().1; + return a.update(message); + } + Command::none() } pub fn new() -> Self {