wip: update to use cosmic-advanced-text

This commit is contained in:
Ashley Wulber 2023-05-08 18:22:10 -04:00
parent 98ec1bbd48
commit 5da0bef35e
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820
36 changed files with 367 additions and 282 deletions

View file

@ -4,9 +4,15 @@
use cosmic::{iced::Application, settings};
mod window;
use env_logger::Env;
pub use window::*;
pub fn main() -> cosmic::iced::Result {
let env = Env::default()
.filter_or("MY_LOG_LEVEL", "debug")
.write_style_or("MY_LOG_STYLE", "always");
env_logger::init_from_env(env);
settings::set_default_icon_theme("Pop");
let mut settings = settings();
settings.window.min_size = Some((600, 300));

View file

@ -1,25 +1,27 @@
/// Copyright 2022 System76 <info@system76.com>
// SPDX-License-Identifier: MPL-2.0
use cosmic::{
iced::widget::{self, button, column, container, horizontal_space, row, text},
iced::{self, Application, Command, Length, Subscription},
iced_native::{subscription, window},
iced_winit::window::{close, drag, minimize, toggle_maximize},
iced::{
subscription,
widget::{self, column, container, horizontal_space, row, text},
window::{self, close, drag, minimize, toggle_maximize},
},
keyboard_nav,
theme::{self, Theme, COSMIC_DARK, COSMIC_LIGHT},
theme::{self, Theme},
widget::{
header_bar, icon, list, nav_bar, nav_bar_toggle, scrollable, segmented_button, settings,
warning, IconSource,
},
Element, ElementExt,
};
use once_cell::sync::Lazy;
use std::{
sync::atomic::{AtomicU32, Ordering},
vec,
};
static BTN: Lazy<button::Id> = Lazy::new(button::Id::unique);
// XXX The use of button is removed because it assigns the same ID to multiple buttons, causing a crash when a11y is enabled...
// static BTN: Lazy<id::Id> = Lazy::new(|| id::Id::new("BTN"));
mod bluetooth;
@ -237,7 +239,7 @@ impl Window {
))
.padding(0)
.style(theme::Button::Link)
.id(BTN.clone())
// .id(BTN.clone())
.on_press(Message::from(page)),
row!(
text(sub_page.title()).size(30),
@ -282,7 +284,7 @@ impl Window {
.padding(0)
.style(theme::Button::Transparent)
.on_press(Message::from(sub_page.into_page()))
.id(BTN.clone())
// .id(BTN.clone())
.into()
}
@ -405,10 +407,10 @@ impl Application for Window {
Message::ToggleNavBarCondensed => {
self.nav_bar_toggled_condensed = !self.nav_bar_toggled_condensed
}
Message::Drag => return drag(window::Id::new(0)),
Message::Close => return close(window::Id::new(0)),
Message::Minimize => return minimize(window::Id::new(0), true),
Message::Maximize => return toggle_maximize(window::Id::new(0)),
Message::Drag => return drag(),
Message::Close => return close(),
Message::Minimize => return minimize(true),
Message::Maximize => return toggle_maximize(),
Message::InputChanged => {}
@ -553,7 +555,7 @@ impl Application for Window {
column(vec![
header,
warning,
iced::widget::vertical_space(Length::Units(12)).into(),
iced::widget::vertical_space(Length::Fixed(12.0)).into(),
content,
])
.into()

View file

@ -2,7 +2,7 @@ use apply::Apply;
use cosmic::{
cosmic_theme,
iced::widget::{checkbox, pick_list, progress_bar, radio, row, slider, text, text_input},
iced::{Alignment, Length},
iced::{id, Alignment, Length},
theme::{self, Button as ButtonTheme, Theme},
widget::{
button, container, icon, segmented_button, segmented_selection, settings, spin_button,
@ -29,7 +29,7 @@ pub enum MultiOption {
OptionD,
OptionE,
}
static INPUT_ID: Lazy<text_input::Id> = Lazy::new(text_input::Id::unique);
static INPUT_ID: Lazy<id::Id> = Lazy::new(id::Id::unique);
#[derive(Clone, Debug)]
pub enum Message {
@ -253,13 +253,13 @@ impl State {
.add(settings::item(
"Slider",
slider(0.0..=100.0, self.slider_value, Message::SliderChanged)
.width(Length::Units(250)),
.width(Length::Fixed(250.0)),
))
.add(settings::item(
"Progress",
progress_bar(0.0..=100.0, self.slider_value)
.width(Length::Units(250))
.height(Length::Units(4)),
.width(Length::Fixed(250.0))
.height(Length::Fixed(4.0)),
))
.add(settings::item_row(vec![checkbox(
"Checkbox",
@ -401,8 +401,8 @@ impl State {
text_input(
"Type to search apps or type “?” for more options...",
&self.entry_value,
Message::InputChanged,
)
.on_input(Message::InputChanged)
// .on_submit(Message::Activate(None))
.padding(8)
.size(20)

View file

@ -219,10 +219,10 @@ impl State {
for image_path in chunk.iter() {
image_row.push(if image_path.ends_with(".svg") {
svg(svg::Handle::from_path(image_path))
.width(Length::Units(150))
.width(Length::Fixed(150.0))
.into()
} else {
image(image_path).width(Length::Units(150)).into()
image(image_path).width(Length::Fixed(150.0)).into()
});
}
image_column.push(row(image_row).spacing(16).into());
@ -234,7 +234,7 @@ impl State {
horizontal_space(Length::Fill),
container(
image("/usr/share/backgrounds/pop/kate-hazen-COSMIC-desktop-wallpaper.png")
.width(Length::Units(300))
.width(Length::Fixed(300.0))
)
.padding(4)
.style(theme::Container::Background),

View file

@ -1,7 +1,6 @@
use apply::Apply;
use cosmic::iced::widget::{horizontal_space, row, scrollable};
use cosmic::iced::Length;
use cosmic::iced_winit::Alignment;
use cosmic::iced::{Alignment, Length};
use cosmic::widget::{button, segmented_button, view_switcher};
use cosmic::{theme, Element};
use slotmap::Key;