11//! The elements for the clipboard history page
2- use iced:: widget:: {
3- Scrollable ,
4- image:: { Handle , Viewer } ,
5- scrollable:: { Direction , Scrollbar } ,
2+ use iced:: {
3+ ContentFit ,
4+ border:: Radius ,
5+ widget:: {
6+ Scrollable ,
7+ image:: { Handle , Viewer } ,
8+ scrollable:: { Direction , Scrollbar } ,
9+ } ,
610} ;
711
812use crate :: {
@@ -26,30 +30,51 @@ pub fn clipboard_view(
2630) -> Element < ' static , Message > {
2731 let theme_clone = theme. clone ( ) ;
2832 let theme_clone_2 = theme. clone ( ) ;
29- let viewport_content: Element < ' static , Message > =
30- match clipboard_content. get ( focussed_id as usize ) {
31- Some ( content) => match content {
32- ClipBoardContentType :: Text ( txt) => Text :: new ( txt. to_owned ( ) )
33+ let viewport_content: Element < ' static , Message > = match clipboard_content
34+ . get ( focussed_id as usize )
35+ {
36+ Some ( content) => match content {
37+ ClipBoardContentType :: Text ( txt) => Scrollable :: with_direction (
38+ Text :: new ( txt. to_owned ( ) )
3339 . height ( Length :: Fill )
3440 . width ( Length :: Fill )
3541 . align_x ( Alignment :: Start )
3642 . font ( theme. font ( ) )
37- . size ( 16 )
38- . into ( ) ,
43+ . size ( 16 ) ,
44+ Direction :: Both {
45+ vertical : Scrollbar :: new ( ) . scroller_width ( 0. ) . width ( 0. ) ,
46+ horizontal : Scrollbar :: new ( ) . scroller_width ( 0. ) . width ( 0. ) ,
47+ } ,
48+ )
49+ . into ( ) ,
3950
40- ClipBoardContentType :: Image ( data) => {
41- let bytes = data. to_owned_img ( ) . into_owned_bytes ( ) ;
51+ ClipBoardContentType :: Image ( data) => {
52+ let bytes = data. to_owned_img ( ) . into_owned_bytes ( ) ;
53+ container (
4254 Viewer :: new (
4355 Handle :: from_rgba ( data. width as u32 , data. height as u32 , bytes. to_vec ( ) )
4456 . clone ( ) ,
4557 )
46- . width ( 500 )
47- . height ( 500 )
48- . into ( )
49- }
50- } ,
51- None => Text :: new ( "" ) . into ( ) ,
52- } ;
58+ . content_fit ( ContentFit :: ScaleDown )
59+ . scale_step ( 0. )
60+ . max_scale ( 1. )
61+ . min_scale ( 1. ) ,
62+ )
63+ . padding ( 10 )
64+ . style ( |_| container:: Style {
65+ border : iced:: Border {
66+ color : iced:: Color :: WHITE ,
67+ width : 1. ,
68+ radius : Radius :: new ( 0. ) ,
69+ } ,
70+ ..Default :: default ( )
71+ } )
72+ . width ( Length :: Fill )
73+ . into ( )
74+ }
75+ } ,
76+ None => Text :: new ( "" ) . into ( ) ,
77+ } ;
5378 container ( Row :: from_vec ( vec ! [
5479 container(
5580 iced:: widget:: scrollable(
@@ -65,18 +90,12 @@ pub fn clipboard_view(
6590 . height( 10000 )
6691 . style( move |_| result_row_container_style( & theme_clone_2, false ) )
6792 . into( ) ,
68- container( Scrollable :: with_direction(
69- viewport_content,
70- Direction :: Both {
71- vertical: Scrollbar :: new( ) . scroller_width( 0. ) . width( 0. ) ,
72- horizontal: Scrollbar :: new( ) . scroller_width( 0. ) . width( 0. ) ,
73- } ,
74- ) )
75- . height( 10000 )
76- . padding( 10 )
77- . style( move |_| result_row_container_style( & theme_clone, false ) )
78- . width( ( WINDOW_WIDTH / 3. ) * 2. )
79- . into( ) ,
93+ container( viewport_content)
94+ . height( 10000 )
95+ . padding( 10 )
96+ . style( move |_| result_row_container_style( & theme_clone, false ) )
97+ . width( ( WINDOW_WIDTH / 3. ) * 2. )
98+ . into( ) ,
8099 ] ) )
81100 . height ( 280 )
82101 . into ( )
0 commit comments