Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions src/app/tile/elm.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
//! This module handles the logic for the new and view functions according to the elm
//! architecture. If the subscription function becomes too large, it should be moved to this file
use iced::border::Radius;
use iced::widget::scrollable::{Direction, Scrollbar};
use iced::widget::text::LineHeight;
use iced::widget::{Column, Scrollable, space};
use iced::window;
use iced::widget::{Column, Scrollable, container, space};
use iced::{Color, window};
use iced::{Element, Task};
use iced::{Length::Fill, widget::text_input};

use objc2::MainThreadMarker;

use rayon::{
iter::{IntoParallelRefIterator, ParallelIterator},
slice::ParallelSliceMut,
Expand Down Expand Up @@ -110,15 +113,15 @@ pub fn view(tile: &Tile, wid: window::Id) -> Element<'_, Message> {
} else {
Direction::Vertical(Scrollbar::hidden())
};
match tile.page {
let contents = match tile.page {
Page::Main => {
let mut search_results = Column::new();
for result in &tile.results {
search_results = search_results.push(result.render(&tile.config.theme));
}

let scrollable = Scrollable::with_direction(search_results, scrollbar_direction);
Column::new().push(title_input).push(scrollable).into()
Column::new().push(title_input).push(scrollable)
}
Page::ClipboardHistory => {
let mut clipboard_history = Column::new();
Expand All @@ -127,17 +130,32 @@ pub fn view(tile: &Tile, wid: window::Id) -> Element<'_, Message> {
.push(result.render_clipboard_item(tile.config.theme.clone()));
}
let scrollable = Scrollable::with_direction(clipboard_history, scrollbar_direction);
Column::new().push(title_input).push(scrollable).into()
Column::new().push(title_input).push(scrollable)
}
}
};

container(contents)
.style(|_| iced::widget::container::Style {
background: None,
text_color: None,
border: iced::Border {
color: tile.config.theme.text_color(1.),
width: 1.,
radius: Radius::new(0),
},
..Default::default()
})
.padding(0)
.clip(true)
.into()
} else {
space().into()
}
}

fn text_input_style(theme: &Theme) -> iced::widget::text_input::Style {
text_input::Style {
background: iced::Background::Color(theme.bg_color()),
background: iced::Background::Color(Color::TRANSPARENT),
border: iced::Border {
color: iced::Color {
r: 0.95,
Expand Down