fix ui button and badge width
This commit is contained in:
parent
de37111637
commit
4920291d04
@ -108,7 +108,6 @@ pub fn badge_pill<'a, T: 'a>(label: &'a str, tooltip: &'a str) -> Container<'a,
|
||||
tooltip::Tooltip::new(
|
||||
Container::new(text::p2_regular(label))
|
||||
.padding(10)
|
||||
.width(Length::Fill)
|
||||
.center_x()
|
||||
.style(theme::Container::Pill(theme::Pill::Simple)),
|
||||
tooltip,
|
||||
|
||||
@ -1,19 +1,28 @@
|
||||
use crate::{color, theme, widget::*};
|
||||
use iced::widget::{button, container, row};
|
||||
use iced::{Alignment, Length};
|
||||
use iced::Alignment;
|
||||
|
||||
use super::text::text;
|
||||
|
||||
pub fn menu<'a, T: 'a>(icon: Option<Text<'a>>, t: &'static str) -> Button<'a, T> {
|
||||
button::Button::new(content(icon.map(|i| i.style(color::GREY_3)), t).padding(10))
|
||||
button::Button::new(content_menu(icon.map(|i| i.style(color::GREY_3)), t).padding(10))
|
||||
.style(theme::Button::Menu(false))
|
||||
}
|
||||
|
||||
pub fn menu_active<'a, T: 'a>(icon: Option<Text<'a>>, t: &'static str) -> Button<'a, T> {
|
||||
button::Button::new(content(icon.map(|i| i.style(color::GREY_3)), t).padding(10))
|
||||
button::Button::new(content_menu(icon.map(|i| i.style(color::GREY_3)), t).padding(10))
|
||||
.style(theme::Button::Menu(true))
|
||||
}
|
||||
|
||||
fn content_menu<'a, T: 'a>(icon: Option<Text<'a>>, t: &'static str) -> Container<'a, T> {
|
||||
match icon {
|
||||
None => container(text(t)).padding(5),
|
||||
Some(i) => {
|
||||
container(row![i, text(t)].spacing(10).align_items(Alignment::Center)).padding(5)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn alert<'a, T: 'a>(icon: Option<Text<'a>>, t: &'static str) -> Button<'a, T> {
|
||||
button::Button::new(content(icon, t)).style(theme::Button::Destructive)
|
||||
}
|
||||
@ -40,15 +49,9 @@ pub fn transparent_border<'a, T: 'a>(icon: Option<Text<'a>>, t: &'static str) ->
|
||||
|
||||
fn content<'a, T: 'a>(icon: Option<Text<'a>>, t: &'static str) -> Container<'a, T> {
|
||||
match icon {
|
||||
None => container(text(t)).width(Length::Fill).center_x().padding(5),
|
||||
Some(i) => container(
|
||||
row![i, text(t)]
|
||||
.spacing(10)
|
||||
.width(iced::Length::Fill)
|
||||
.align_items(Alignment::Center),
|
||||
)
|
||||
.width(iced::Length::Fill)
|
||||
.center_x()
|
||||
.padding(5),
|
||||
None => container(text(t)).center_x().padding(5),
|
||||
Some(i) => container(row![i, text(t)].spacing(10).align_items(Alignment::Center))
|
||||
.center_x()
|
||||
.padding(5),
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user