Rewriting with Iced
modified: Cargo.lock modified: Cargo.toml modified: src/main.rs deleted: src/view.rs deleted: src/window.rs
This commit is contained in:
parent
be46fe3584
commit
b89ab394ff
5089
Cargo.lock
generated
5089
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -6,4 +6,7 @@ edition = "2021"
|
||||
[dependencies]
|
||||
rusb = "0.9.4"
|
||||
regex = "1.11.1"
|
||||
cacao = "0.3.2"
|
||||
iced = { version = "0.13.1", features = ["tokio", "svg", "markdown", "highlighter", "system", "web-colors", "debug"] }
|
||||
|
||||
[build-dependencies]
|
||||
iced_fontello = "0.13"
|
107
src/main.rs
107
src/main.rs
@ -1,41 +1,88 @@
|
||||
use cacao::appkit::window::{TitleVisibility, Window, WindowConfig, WindowController};
|
||||
use cacao::appkit::{App, AppDelegate};
|
||||
use cacao::button::Button;
|
||||
use cacao::view::{SplitViewController, View, ViewDelegate};
|
||||
|
||||
use crate::view::details_view::Details;
|
||||
use crate::view::sidebar::MainSidebar;
|
||||
use crate::view::content_view::ScreenView;
|
||||
use crate::window::main_window::MainWindow;
|
||||
use iced::widget::button::{Status, Style};
|
||||
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, text, Column, Container, scrollable};
|
||||
|
||||
mod disk_util;
|
||||
mod ipod_util;
|
||||
|
||||
mod view;
|
||||
mod window;
|
||||
|
||||
const VENDOR_ID: u16 = 1452;
|
||||
const PRODUCT_ID: u16 = 4617;
|
||||
|
||||
struct ILoaderApp {
|
||||
window: WindowController<MainWindow>
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Message {
|
||||
ButtonPressed(u8),
|
||||
ChangeUI
|
||||
}
|
||||
struct State {
|
||||
}
|
||||
|
||||
impl AppDelegate for ILoaderApp {
|
||||
/// There should be stuff which loads underlying logic for communication with IPod
|
||||
fn will_finish_launching(&self) {}
|
||||
|
||||
fn did_finish_launching(&self) {
|
||||
App::activate();
|
||||
self.window.show();
|
||||
}
|
||||
|
||||
fn should_terminate_after_last_window_closed(&self) -> bool {
|
||||
true
|
||||
impl State {
|
||||
fn new() -> Self {
|
||||
Self { }
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
enum App {
|
||||
Preloaded,
|
||||
Loaded(State)
|
||||
}
|
||||
|
||||
impl App {
|
||||
pub fn new() -> (Self, Command<Message>) {
|
||||
(Self::Preloaded, Command::done(Message::ChangeUI))
|
||||
}
|
||||
|
||||
pub fn view(&self) -> Element<Message> {
|
||||
match self {
|
||||
App::Preloaded => {
|
||||
return container(text("Loading")).into();
|
||||
}
|
||||
App::Loaded(state) => {
|
||||
//return state.tab_panel.view();
|
||||
return container(action("Test!").style(transparent_button_theme)).into();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update(&mut self, message: Message) -> Command<Message> {
|
||||
match self {
|
||||
App::Preloaded => {
|
||||
*self = App::Loaded(State {});
|
||||
return Command::done(Message::ChangeUI);
|
||||
}
|
||||
App::Loaded(state) => {
|
||||
//state.tab_panel.update(message);
|
||||
}
|
||||
}
|
||||
Command::none()
|
||||
}
|
||||
|
||||
fn theme(&self) -> Theme {
|
||||
Theme::CatppuccinLatte
|
||||
}
|
||||
}
|
||||
|
||||
fn transparent_button_theme(theme: &Theme, _status: Status) -> Style {
|
||||
Style {
|
||||
background: Some(Background::Color(Color::BLACK)),
|
||||
text_color: theme.palette().text,
|
||||
border: Border {
|
||||
color: Color::TRANSPARENT,
|
||||
width: 0.0,
|
||||
radius: 10.0.into(),
|
||||
},
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
fn action(text: &str) -> button::Button<Message> {
|
||||
button(container(text).center_x(Fill)).width(100)
|
||||
}
|
||||
|
||||
fn main() -> iced::Result {
|
||||
/*for device in rusb::devices().unwrap().iter() {
|
||||
let device_desc = device.device_descriptor().unwrap();
|
||||
if VENDOR_ID == device_desc.vendor_id() && PRODUCT_ID == device_desc.product_id() {
|
||||
@ -43,9 +90,9 @@ fn main() {
|
||||
println!("{}", ipod_util::get_ipod_path().is_some());
|
||||
}
|
||||
}*/
|
||||
let config = WindowConfig::default();
|
||||
|
||||
App::new("com.alterdekim.iloader", ILoaderApp {
|
||||
window: WindowController::with(config, MainWindow::default())
|
||||
}).run();
|
||||
iced::application("iLoader", App::update, App::view)
|
||||
.theme(App::theme)
|
||||
.window_size((980.0, 700.0))
|
||||
.run_with(App::new)
|
||||
}
|
||||
|
60
src/view.rs
60
src/view.rs
@ -1,60 +0,0 @@
|
||||
|
||||
pub mod sidebar {
|
||||
use cacao::{appkit::FocusRingType, button::{BezelStyle, Button}, geometry::Rect, layout::Layout, text::Font, view::{View, ViewDelegate}};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct MainSidebar {
|
||||
|
||||
}
|
||||
|
||||
impl ViewDelegate for MainSidebar {
|
||||
const NAME: &'static str = "MainSidebar";
|
||||
|
||||
fn did_load(&mut self, view: View) {
|
||||
let mut btn = Button::new("testtesttest");
|
||||
btn.set_bezel_style(BezelStyle::TexturedRounded);
|
||||
btn.set_bordered(false);
|
||||
btn.set_font(Font::system(14.));
|
||||
btn.set_action(|| {
|
||||
println!("HEY");
|
||||
});
|
||||
view.add_subview(&btn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod content_view {
|
||||
use cacao::{button::Button, layout::Layout, view::{View, ViewDelegate}};
|
||||
|
||||
pub struct ScreenView {
|
||||
pub btn: Button
|
||||
}
|
||||
|
||||
impl Default for ScreenView {
|
||||
fn default() -> Self {
|
||||
let btn = Button::new("test");
|
||||
Self { btn }
|
||||
}
|
||||
}
|
||||
|
||||
impl ViewDelegate for ScreenView {
|
||||
const NAME: &'static str = "ScreenView";
|
||||
|
||||
fn did_load(&mut self, view: View) {
|
||||
view.add_subview(&self.btn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod details_view {
|
||||
use cacao::{button::Button, layout::Layout, view::{View, ViewDelegate}};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Details {
|
||||
|
||||
}
|
||||
|
||||
impl ViewDelegate for Details {
|
||||
const NAME: &'static str = "Details";
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
pub mod main_window {
|
||||
use cacao::{appkit::window::{TitleVisibility, Window, WindowDelegate}, view::SplitViewController};
|
||||
|
||||
use crate::view::{content_view::ScreenView, details_view::Details, sidebar::MainSidebar};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct MainWindow {
|
||||
split_view_controller: Option<SplitViewController<MainSidebar, ScreenView, Details>>
|
||||
}
|
||||
|
||||
impl WindowDelegate for MainWindow {
|
||||
const NAME: &'static str = "MainWindow";
|
||||
|
||||
fn did_load(&mut self, window: Window) {
|
||||
window.set_title("ILoader");
|
||||
window.set_title_visibility(TitleVisibility::Hidden);
|
||||
window.set_titlebar_appears_transparent(true);
|
||||
window.set_movable_by_background(true);
|
||||
window.set_autosave_name("CacaoILoader");
|
||||
window.set_minimum_content_size(980., 700.);
|
||||
|
||||
let split_view_controller = SplitViewController::new(MainSidebar::default(),
|
||||
ScreenView::default(),
|
||||
Some(Details::default())); // Some(DetailView::default())
|
||||
|
||||
window.set_content_view_controller(&split_view_controller);
|
||||
|
||||
self.split_view_controller = Some(split_view_controller);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user