modified: Cargo.lock

modified:   Cargo.toml
	modified:   src/main.rs
	new file:   src/theme.rs
	new file:   src/widget.rs
This commit is contained in:
Michael Wain 2024-12-12 02:54:49 +03:00
parent b89ab394ff
commit ffd5eebfd2
5 changed files with 87 additions and 879 deletions

890
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -7,6 +7,4 @@ edition = "2021"
rusb = "0.9.4"
regex = "1.11.1"
iced = { version = "0.13.1", features = ["tokio", "svg", "markdown", "highlighter", "system", "web-colors", "debug"] }
[build-dependencies]
iced_fontello = "0.13"
iced_font_awesome = "0.2.0"

View File

@ -1,3 +1,4 @@
use iced::theme::Palette;
use iced::widget::button::{Status, Style};
use iced::{Background, Border, Color};
use iced::Length::Fill;
@ -7,6 +8,9 @@ use iced::widget::{button, column, pick_list, radio, text, Column, Container, sc
mod disk_util;
mod ipod_util;
mod theme;
mod widget;
const VENDOR_ID: u16 = 1452;
const PRODUCT_ID: u16 = 4617;
@ -16,6 +20,8 @@ pub enum Message {
ButtonPressed(u8),
ChangeUI
}
struct State {
}
@ -42,7 +48,7 @@ impl App {
}
App::Loaded(state) => {
//return state.tab_panel.view();
return container(action("Test!").style(transparent_button_theme)).into();
return container(widget::basic_btn("Test!")).into();
}
}
}
@ -61,27 +67,10 @@ impl App {
}
fn theme(&self) -> Theme {
Theme::CatppuccinLatte
theme::get_default_theme()
}
}
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();
@ -92,6 +81,7 @@ fn main() -> iced::Result {
}*/
iced::application("iLoader", App::update, App::view)
.exit_on_close_request(true)
.theme(App::theme)
.window_size((980.0, 700.0))
.run_with(App::new)

36
src/theme.rs Normal file
View File

@ -0,0 +1,36 @@
use iced::theme::Palette;
use iced::widget::button::{Status, Style};
use iced::{Background, Border, Color, Font};
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};
pub const SF_FONT: Font = Font {
family: iced::font::Family::Name("SF Pro Text"),
weight: iced::font::Weight::Medium,
stretch: iced::font::Stretch::Normal,
style: iced::font::Style::Normal
};
pub fn get_default_theme() -> Theme {
Theme::custom("Glossy".to_string(), Palette {
background: Color::from_rgb8(255, 255, 255),
text: Color::from_rgb8(0, 0, 0),
primary: Color::from_rgb8(0, 122, 255),
success: Color::from_rgb8(52, 199, 89),
danger: Color::from_rgb8(255, 59, 48),
})
}
pub fn basic_button_theme(theme: &Theme, _status: Status) -> Style {
Style {
background: Some(Background::Color(Color::from_rgb8(0, 122, 255))),
text_color: theme.palette().text,
border: Border {
color: Color::TRANSPARENT,
width: 0.0,
radius: 10.0.into(),
},
..Default::default()
}
}

8
src/widget.rs Normal file
View File

@ -0,0 +1,8 @@
use iced::{widget::{button, container, text}, Length::Fill};
use crate::{theme, Message};
pub fn basic_btn(str: &str) -> button::Button<Message> { // .font(theme::SF_FONT)
button(container(text(str).center().size(13).line_height(16.)).center_x(Fill)).width(109).height(22).style(theme::basic_button_theme)
}