refactor(locker): scrollable menu in locker
This commit is contained in:
parent
abc591db6d
commit
b740ad246b
3 changed files with 18 additions and 5 deletions
|
|
@ -17,6 +17,8 @@ use cosmic_greeter_daemon::{BgSource, CosmicCompConfig, UserData};
|
|||
use std::{collections::HashMap, sync::Arc};
|
||||
use wayland_client::protocol::wl_output::WlOutput;
|
||||
|
||||
pub const DEFAULT_MENU_ITEM_HEIGHT: f32 = 36.;
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
pub struct ActiveLayout {
|
||||
pub layout: String,
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ use wayland_client::{Proxy, protocol::wl_output::WlOutput};
|
|||
use zbus::{Connection, proxy};
|
||||
|
||||
use crate::{
|
||||
common::{self, Common},
|
||||
common::{self, Common, DEFAULT_MENU_ITEM_HEIGHT},
|
||||
fl,
|
||||
};
|
||||
|
||||
|
|
@ -381,7 +381,6 @@ pub struct App {
|
|||
|
||||
impl App {
|
||||
fn menu(&self, id: SurfaceId) -> Element<Message> {
|
||||
const DEFAULT_MENU_ITEM_HEIGHT: f32 = 36.;
|
||||
let window_width = self
|
||||
.common
|
||||
.window_size
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ use tokio::{sync::mpsc, task};
|
|||
use wayland_client::{Proxy, protocol::wl_output::WlOutput};
|
||||
|
||||
use crate::{
|
||||
common::{self, Common},
|
||||
common::{self, Common, DEFAULT_MENU_ITEM_HEIGHT},
|
||||
fl,
|
||||
};
|
||||
|
||||
|
|
@ -293,8 +293,20 @@ impl App {
|
|||
.on_press(message),
|
||||
)
|
||||
};
|
||||
let dropdown_menu = |items| {
|
||||
widget::container(widget::column::with_children(items))
|
||||
let dropdown_menu = |items: Vec<_>| {
|
||||
let item_cnt = items.len();
|
||||
|
||||
let items = widget::column::with_children(items);
|
||||
let items = if item_cnt > 7 {
|
||||
Element::from(
|
||||
widget::scrollable(items)
|
||||
.height(Length::Fixed(DEFAULT_MENU_ITEM_HEIGHT * 7.)),
|
||||
)
|
||||
} else {
|
||||
Element::from(items)
|
||||
};
|
||||
|
||||
widget::container(items)
|
||||
.padding(1)
|
||||
//TODO: move style to libcosmic
|
||||
.class(theme::Container::custom(|theme| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue