Skip to content

Commit

Permalink
Merge pull request #415 from squidowl/update-iced
Browse files Browse the repository at this point in the history
Update iced
  • Loading branch information
casperstorm authored Jul 15, 2024
2 parents f8fd1a8 + df04250 commit 5c597db
Show file tree
Hide file tree
Showing 27 changed files with 159 additions and 166 deletions.
21 changes: 11 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ embed-resource = "2.1.1"
members = ["data", "ipc", "irc", "irc/proto"]

[patch.crates-io]
iced = { git = "https://github.com/iced-rs/iced", rev = "19db068bbbebcda1756720525da247f35bd3a5e0" }
iced_core = { git = "https://github.com/iced-rs/iced", rev = "19db068bbbebcda1756720525da247f35bd3a5e0" }
iced = { git = "https://github.com/iced-rs/iced", rev = "bdf0430880f5c29443f5f0a0ae4895866dfef4c6" }
iced_core = { git = "https://github.com/iced-rs/iced", rev = "bdf0430880f5c29443f5f0a0ae4895866dfef4c6" }
2 changes: 1 addition & 1 deletion data/src/stream.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use chrono::{DateTime, Utc};
use futures::never::Never;
use std::time::Duration;

use futures::channel::mpsc;
use futures::never::Never;
use futures::{future, stream, FutureExt, SinkExt, StreamExt};
use irc::proto::{self, command, Command};
use irc::{codec, connection, Connection};
Expand Down
17 changes: 8 additions & 9 deletions src/buffer/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use data::user::Nick;
use data::User;
use data::{channel, history, message, Config};
use iced::widget::{column, container, row};
use iced::{Length, Task};
use iced::{padding, Length, Task};

use super::{input_view, scroll_view, user_context};
use crate::theme;
Expand Down Expand Up @@ -189,7 +189,7 @@ pub fn view<'a>(
container(body)
.width(Length::Fill)
.height(Length::Fill)
.padding([4, 8, 8, 8])
.padding(padding::all(8).top(4))
.into()
}

Expand Down Expand Up @@ -326,13 +326,12 @@ mod nick_list {
.spacing(1);

container(
Scrollable::with_direction(
column,
scrollable::Direction::Vertical(
scrollable::Properties::new().width(1).scroller_width(1),
),
)
.style(theme::scrollable::hidden),
Scrollable::new(column)
.direction(scrollable::Direction::Vertical {
scrollbar: scrollable::Scrollbar::new().width(1).scroller_width(1),
spacing: None,
})
.style(theme::scrollable::hidden),
)
.width(Length::Shrink)
.max_width(120)
Expand Down
11 changes: 6 additions & 5 deletions src/buffer/channel/topic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ pub fn view<'a>(
let content = column![selectable_text(text).style(theme::selectable_text::transparent)]
.push_maybe(set_by);

let scrollable = Scrollable::with_direction(
container(content).width(Length::Fill).padding(padding()),
scrollable::Direction::Vertical(scrollable::Properties::new().width(1).scroller_width(1)),
)
.style(theme::scrollable::hidden);
let scrollable = Scrollable::new(container(content).width(Length::Fill).padding(padding()))
.direction(scrollable::Direction::Vertical {
scrollbar: scrollable::Scrollbar::new().width(1).scroller_width(1),
spacing: None,
})
.style(theme::scrollable::hidden);

// Use double pass to limit layout to `max_lines` of text
column![
Expand Down
2 changes: 1 addition & 1 deletion src/buffer/empty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub fn view<'a, Message: 'a>() -> Element<'a, Message> {

let content = column![]
.push(text("⟵ select buffer").shaping(text::Shaping::Advanced))
.align_items(iced::Alignment::Center);
.align_x(iced::Alignment::Center);

container(content)
.align_x(alignment::Horizontal::Center)
Expand Down
25 changes: 12 additions & 13 deletions src/buffer/file_transfers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn view<'a>(
text("No transfers found").style(theme::text::transparent)
]
.spacing(8)
.align_items(iced::Alignment::Center),
.align_x(iced::Alignment::Center),
))
.into();
}
Expand All @@ -42,13 +42,12 @@ pub fn view<'a>(
.padding([0, 2]);

container(
Scrollable::with_direction(
column,
scrollable::Direction::Vertical(
scrollable::Properties::new().width(1).scroller_width(1),
),
)
.style(theme::scrollable::hidden),
Scrollable::new(column)
.direction(scrollable::Direction::Vertical {
scrollbar: scrollable::Scrollbar::new().width(1).scroller_width(1),
spacing: None,
})
.style(theme::scrollable::hidden),
)
.width(Length::Fill)
.height(Length::Fill)
Expand Down Expand Up @@ -105,7 +104,7 @@ mod transfer_row {
use bytesize::ByteSize;
use data::file_transfer::{self, FileTransfer};
use iced::widget::{column, container, progress_bar, row, text};
use iced::{alignment, Length};
use iced::{alignment, padding, Length};

use crate::buffer::file_transfers::row_button;
use crate::widget::Element;
Expand Down Expand Up @@ -216,11 +215,11 @@ mod transfer_row {
let file_size = ByteSize::b(transfer.size);
let filename = container(text(format!("{} ({file_size})", transfer.filename)));

let mut buttons = row![].align_items(iced::Alignment::Center).spacing(2);
let mut buttons = row![].align_y(iced::Alignment::Center).spacing(2);
let content = column![filename, status]
// Add 1 padding to make container odd sized
// for proper icon centering
.padding([1, 0, 0, 0])
.padding(padding::top(1))
.width(Length::Fill)
.spacing(0);

Expand All @@ -245,10 +244,10 @@ mod transfer_row {

let row = row![content, buttons]
.spacing(6)
.align_items(iced::Alignment::Center);
.align_y(iced::Alignment::Center);

container(row)
.padding([6, 4, 6, 8])
.padding(padding::top(6).bottom(6).right(4).left(8))
.width(Length::Fill)
.align_y(alignment::Vertical::Center)
.style(move |theme| theme::container::table_row(theme, idx))
Expand Down
2 changes: 1 addition & 1 deletion src/buffer/input_view/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ impl Command {
Element::from(row![
text(" "),
tooltip(
row![content, tooltip_indicator].align_items(iced::Alignment::Start),
row![content, tooltip_indicator].align_y(iced::Alignment::Start),
container(text(arg_tooltip.clone()).style(move |theme| {
if index == active_arg {
theme::text::transparent_accent(theme)
Expand Down
59 changes: 29 additions & 30 deletions src/buffer/scroll_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use data::server::Server;
use data::user::Nick;
use data::{history, time, Config};
use iced::widget::{column, container, horizontal_rule, row, scrollable, text, Scrollable};
use iced::{Length, Task};
use iced::{padding, Length, Task};

use super::user_context;
use crate::theme;
Expand Down Expand Up @@ -86,40 +86,39 @@ pub fn view<'a>(
let divider = row![
container(horizontal_rule(1))
.width(Length::Fill)
.padding([0, 6, 0, 0]),
.padding(padding::right(6)),
text("backlog")
.size(font_size)
.style(theme::text::transparent),
container(horizontal_rule(1))
.width(Length::Fill)
.padding([0, 0, 0, 6])
.padding(padding::left(6))
]
.padding(2)
.align_items(iced::Alignment::Center);
.align_y(iced::Alignment::Center);

column![column(old), divider, column(new)]
} else {
column![column(old), column(new)]
};

Scrollable::with_direction(
container(content).width(Length::Fill).padding([0, 8]),
scrollable::Direction::Vertical(
scrollable::Properties::default()
.alignment(status.alignment())
Scrollable::new(container(content).width(Length::Fill).padding([0, 8]))
.direction(scrollable::Direction::Vertical {
scrollbar: scrollable::Scrollbar::default()
.anchor(status.alignment())
.width(5)
.scroller_width(5),
),
)
.on_scroll(move |viewport| Message::Scrolled {
count,
remaining,
oldest,
status,
viewport,
})
.id(state.scrollable.clone())
.into()
spacing: None,
})
.on_scroll(move |viewport| Message::Scrolled {
count,
remaining,
oldest,
status,
viewport,
})
.id(state.scrollable.clone())
.into()
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -263,16 +262,16 @@ impl Status {
}
}

fn alignment(self) -> scrollable::Alignment {
fn alignment(self) -> scrollable::Anchor {
match self {
Status::Idle(anchor) => match anchor {
Anchor::Top => scrollable::Alignment::Start,
Anchor::Bottom => scrollable::Alignment::End,
Anchor::Top => scrollable::Anchor::Start,
Anchor::Bottom => scrollable::Anchor::End,
},
Status::Unlocked(_) => scrollable::Alignment::Start,
Status::Unlocked(_) => scrollable::Anchor::Start,
Status::Loading(anchor) => match anchor {
Anchor::Top => scrollable::Alignment::Start,
Anchor::Bottom => scrollable::Alignment::End,
Anchor::Top => scrollable::Anchor::Start,
Anchor::Bottom => scrollable::Anchor::End,
},
}
}
Expand All @@ -293,15 +292,15 @@ impl Status {

fn is_top(self, relative_offset: f32) -> bool {
match self.alignment() {
scrollable::Alignment::Start => relative_offset == 0.0,
scrollable::Alignment::End => relative_offset == 1.0,
scrollable::Anchor::Start => relative_offset == 0.0,
scrollable::Anchor::End => relative_offset == 1.0,
}
}

fn is_bottom(self, relative_offset: f32) -> bool {
match self.alignment() {
scrollable::Alignment::Start => relative_offset == 1.0,
scrollable::Alignment::End => relative_offset == 0.0,
scrollable::Anchor::Start => relative_offset == 1.0,
scrollable::Anchor::End => relative_offset == 0.0,
}
}

Expand Down
Loading

0 comments on commit 5c597db

Please sign in to comment.