refactor: border radius and padding

This commit is contained in:
Ashley Wulber 2023-01-13 18:58:28 -05:00 committed by Ashley Wulber
parent b224e4b3f4
commit ebe34377cb

View file

@ -1,17 +1,16 @@
use std::process; use std::process;
use cosmic::applet::CosmicAppletHelper; use cosmic::applet::{CosmicAppletHelper, APPLET_BUTTON_THEME};
use cosmic::iced::wayland::popup::{destroy_popup, get_popup}; use cosmic::iced::wayland::popup::{destroy_popup, get_popup};
use cosmic::iced::wayland::SurfaceIdWrapper; use cosmic::iced::wayland::SurfaceIdWrapper;
use cosmic::iced::widget::{self, Row};
use cosmic::iced_native::layout::Limits; use cosmic::iced_native::layout::Limits;
use cosmic::iced_native::widget::Space; use cosmic::iced_native::widget::Space;
use cosmic::widget::{horizontal_rule, icon}; use cosmic::widget::{button, horizontal_rule, icon};
use cosmic::Renderer; use cosmic::Renderer;
use cosmic::iced::{ use cosmic::iced::{
executor, executor,
widget::{button, column, row}, widget::{self, column, container, row, Row},
window, Alignment, Application, Command, Length, Subscription, window, Alignment, Application, Command, Length, Subscription,
}; };
use cosmic::iced_style::application::{self, Appearance}; use cosmic::iced_style::application::{self, Appearance};
@ -181,9 +180,13 @@ impl Application for Power {
let content = column![ let content = column![
settings, settings,
horizontal_rule(1), container(horizontal_rule(1))
.padding([0, 12])
.width(Length::Fill),
session, session,
horizontal_rule(1), container(horizontal_rule(1))
.padding([0, 12])
.width(Length::Fill),
power power
] ]
.align_items(Alignment::Start) .align_items(Alignment::Start)
@ -198,29 +201,24 @@ impl Application for Power {
// ### UI Helplers // ### UI Helplers
// todo put into libcosmic doing so will fix the row_button's boarder radius fn row_button(content: Vec<Element<Message>>) -> widget::Button<Message, Renderer> {
fn row_button(mut content: Vec<Element<Message>>) -> widget::Button<Message, Renderer> { button(APPLET_BUTTON_THEME)
content.insert(0, Space::with_width(Length::Units(24)).into()); .custom(vec![Row::with_children(content)
content.push(Space::with_width(Length::Units(24)).into()); .spacing(4)
.align_items(Alignment::Center)
button( .into()])
Row::with_children(content) .width(Length::Fill)
.spacing(5) .padding([8, 24])
.align_items(Alignment::Center),
)
.width(Length::Fill)
.height(Length::Units(35))
.style(theme::Button::Text)
} }
fn power_buttons<'a>(name: &'a str, text: &'a str) -> widget::Button<'a, Message, Renderer> { fn power_buttons<'a>(name: &'a str, text: &'a str) -> widget::Button<'a, Message, Renderer> {
button( widget::button(
column![text_icon(name, 40), text] column![text_icon(name, 40), text]
.spacing(5) .spacing(4)
.align_items(Alignment::Center), .align_items(Alignment::Center),
) )
.width(Length::Fill) .width(Length::Fill)
.height(Length::Units(75)) .height(Length::Units(76))
.style(theme::Button::Text) .style(theme::Button::Text)
} }