Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use iced::window::{self, Id, Settings};
pub const WINDOW_WIDTH: f32 = 500.;

/// The default window height
pub const DEFAULT_WINDOW_HEIGHT: f32 = 80.;
pub const DEFAULT_WINDOW_HEIGHT: f32 = 100.;

/// The rustcast descriptor name to be put for all rustcast commands
pub const RUSTCAST_DESC_NAME: &str = "Utility";
Expand Down
51 changes: 25 additions & 26 deletions src/app/tile/elm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ pub fn new(hotkey: HotKey, config: &Config) -> (Tile, Task<Message>) {

pub fn view(tile: &Tile, wid: window::Id) -> Element<'_, Message> {
if tile.visible {
let round_bottom_edges = match &tile.page {
Page::Main | Page::EmojiSearch => tile.results.is_empty(),
Page::ClipboardHistory => tile.clipboard_content.is_empty(),
};
let title_input = text_input(tile.config.placeholder.as_str(), &tile.query)
.on_input(move |a| Message::SearchQueryChanged(a, wid))
.on_paste(move |a| Message::SearchQueryChanged(a, wid))
Expand All @@ -99,7 +95,7 @@ pub fn view(tile: &Tile, wid: window::Id) -> Element<'_, Message> {
.id("query")
.width(Fill)
.line_height(LineHeight::Relative(1.75))
.style(move |_, _| rustcast_text_input_style(&tile.config.theme, round_bottom_edges))
.style(move |_, _| rustcast_text_input_style(&tile.config.theme))
.padding(20);

let scrollbar_direction = if tile.config.theme.show_scroll_bar {
Expand All @@ -120,8 +116,6 @@ pub fn view(tile: &Tile, wid: window::Id) -> Element<'_, Message> {
tile.config.theme.clone(),
tile.focus_id,
)
} else if tile.results.is_empty() {
space().into()
} else if tile.page == Page::EmojiSearch {
emoji_page(
tile.config.theme.clone(),
Expand Down Expand Up @@ -157,14 +151,26 @@ pub fn view(tile: &Tile, wid: window::Id) -> Element<'_, Message> {
.id("results")
.height(height as u32);

let text = if !tile.query_lc.is_empty() {
if results_count == 1 {
"1 result found".to_string()
} else if results_count == 0 {
"No results found".to_string()
} else {
format!("{results_count} results found")
}
} else {
String::from("♥️ Rustcast")
};

let contents = container(
Column::new()
.push(title_input)
.push(scrollable)
.push(footer(
tile.config.theme.clone(),
results_count,
tile.current_mode.clone(),
text,
))
.spacing(0),
)
Expand All @@ -179,27 +185,15 @@ pub fn view(tile: &Tile, wid: window::Id) -> Element<'_, Message> {
..Default::default()
});

container(contents.clip(false))
container(contents)
.style(|_| contents_style(&tile.config.theme))
.into()
} else {
space().into()
}
}

fn footer(theme: Theme, results_count: usize, current_mode: String) -> Element<'static, Message> {
if results_count == 0 {
return space().into();
}

let text = if results_count == 1 {
"1 result found".to_string()
} else {
format!("{results_count} results found")
};

// “Liquid glass” parameters (match your other styles)
let focused = false;
fn footer(theme: Theme, current_mode: String, text: String) -> Element<'static, Message> {
let radius = 15.0;

let current_mode = format!(
Expand All @@ -215,6 +209,7 @@ fn footer(theme: Theme, results_count: usize, current_mode: String) -> Element<'
.height(30)
.color(theme.text_color(0.7))
.font(theme.font())
.align_y(Alignment::Center)
.align_x(Alignment::Center),
)
.push(
Expand All @@ -224,24 +219,28 @@ fn footer(theme: Theme, results_count: usize, current_mode: String) -> Element<'
.color(theme.text_color(0.7))
.font(theme.font())
.width(Fill)
.align_y(Alignment::Center)
.align_x(Alignment::End),
)
.align_y(Alignment::Center)
.padding(4)
.width(Fill)
.height(30),
.height(Fill),
)
.align_y(Alignment::Center)
.center(Length::Fill)
.width(WINDOW_WIDTH)
.padding(5)
.height(30)
.style(move |_| container::Style {
text_color: None,
background: Some(iced::Background::Color(glass_surface(
theme.bg_color(),
focused,
false,
))),
border: iced::Border {
color: glass_border(theme.text_color(1.0), focused),
width: 1.0,
color: glass_border(theme.text_color(1.0), false),
width: 0.,
radius: Radius::new(radius).top(0.0),
},

Expand Down
13 changes: 5 additions & 8 deletions src/styles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,16 @@ pub fn with_alpha(mut c: Color, a: f32) -> Color {
c.a = a;
c
}
pub fn rustcast_text_input_style(
theme: &ConfigTheme,
round_bottom_edges: bool,
) -> text_input::Style {
pub fn rustcast_text_input_style(theme: &ConfigTheme) -> text_input::Style {
let base = theme.bg_color();
let focused = false; // if you have state, pass it in and use it
let surface = glass_surface(base, focused);
text_input::Style {
background: Background::Color(surface),
border: Border {
color: glass_border(theme.text_color(1.0), focused),
width: 1.0,
radius: Radius::new(15.).bottom(if round_bottom_edges { 15. } else { 0. }),
width: 0.,
radius: Radius::new(15.).bottom(0.),
},
icon: theme.text_color(0.75),
placeholder: theme.text_color(0.50),
Expand All @@ -40,7 +37,7 @@ pub fn contents_style(theme: &ConfigTheme) -> container::Style {
text_color: None,
border: iced::Border {
color: theme.text_color(0.7),
width: 0.,
width: 0.4,
radius: Radius::new(14.0),
},
..Default::default()
Expand All @@ -58,7 +55,7 @@ pub fn result_row_container_style(tile: &ConfigTheme, focused: bool) -> containe
background: Some(Background::Color(glass_surface(tile.bg_color(), focused))),
border: Border {
color: glass_border(tile.text_color(1.), focused),
width: 1.,
width: 0.,
radius: Radius::new(0.0),
},
text_color: Some(tile.text_color(1.0)),
Expand Down