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(
|
tooltip::Tooltip::new(
|
||||||
Container::new(text::p2_regular(label))
|
Container::new(text::p2_regular(label))
|
||||||
.padding(10)
|
.padding(10)
|
||||||
.width(Length::Fill)
|
|
||||||
.center_x()
|
.center_x()
|
||||||
.style(theme::Container::Pill(theme::Pill::Simple)),
|
.style(theme::Container::Pill(theme::Pill::Simple)),
|
||||||
tooltip,
|
tooltip,
|
||||||
|
|||||||
@ -1,19 +1,28 @@
|
|||||||
use crate::{color, theme, widget::*};
|
use crate::{color, theme, widget::*};
|
||||||
use iced::widget::{button, container, row};
|
use iced::widget::{button, container, row};
|
||||||
use iced::{Alignment, Length};
|
use iced::Alignment;
|
||||||
|
|
||||||
use super::text::text;
|
use super::text::text;
|
||||||
|
|
||||||
pub fn menu<'a, T: 'a>(icon: Option<Text<'a>>, t: &'static str) -> Button<'a, T> {
|
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))
|
.style(theme::Button::Menu(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn menu_active<'a, T: 'a>(icon: Option<Text<'a>>, t: &'static str) -> Button<'a, T> {
|
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))
|
.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> {
|
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)
|
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> {
|
fn content<'a, T: 'a>(icon: Option<Text<'a>>, t: &'static str) -> Container<'a, T> {
|
||||||
match icon {
|
match icon {
|
||||||
None => container(text(t)).width(Length::Fill).center_x().padding(5),
|
None => container(text(t)).center_x().padding(5),
|
||||||
Some(i) => container(
|
Some(i) => container(row![i, text(t)].spacing(10).align_items(Alignment::Center))
|
||||||
row![i, text(t)]
|
.center_x()
|
||||||
.spacing(10)
|
.padding(5),
|
||||||
.width(iced::Length::Fill)
|
|
||||||
.align_items(Alignment::Center),
|
|
||||||
)
|
|
||||||
.width(iced::Length::Fill)
|
|
||||||
.center_x()
|
|
||||||
.padding(5),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user