@@ -1313,6 +1313,7 @@ impl Item {
1313
1313
}
1314
1314
1315
1315
fn preview < ' a > ( & ' a self , sizes : IconSizes ) -> Element < ' a , app:: Message > {
1316
+ let spacing = cosmic:: theme:: active ( ) . cosmic ( ) . spacing ;
1316
1317
// This loads the image only if thumbnailing worked
1317
1318
let icon = widget:: icon:: icon ( self . icon_handle_grid . clone ( ) )
1318
1319
. content_fit ( ContentFit :: Contain )
@@ -1333,10 +1334,16 @@ impl Item {
1333
1334
widget:: image ( handle. clone ( ) ) . into ( )
1334
1335
}
1335
1336
ItemThumbnail :: Svg ( handle) => widget:: svg ( handle. clone ( ) ) . into ( ) ,
1336
- ItemThumbnail :: Text ( content) => widget:: container ( widget:: text_editor ( content) )
1337
- . width ( Length :: Fixed ( THUMBNAIL_SIZE as f32 ) )
1338
- . height ( Length :: Fixed ( THUMBNAIL_SIZE as f32 ) )
1339
- . into ( ) ,
1337
+ ItemThumbnail :: Text ( content) => widget:: container (
1338
+ widget:: text_editor ( content)
1339
+ . class ( cosmic:: theme:: iced:: TextEditor :: Custom ( Box :: new (
1340
+ text_editor_class,
1341
+ ) ) )
1342
+ . padding ( spacing. space_xxs ) ,
1343
+ )
1344
+ . width ( Length :: Fixed ( THUMBNAIL_SIZE as f32 ) )
1345
+ . height ( Length :: Fixed ( THUMBNAIL_SIZE as f32 ) )
1346
+ . into ( ) ,
1340
1347
}
1341
1348
}
1342
1349
@@ -3101,7 +3108,14 @@ impl Tab {
3101
3108
) ;
3102
3109
}
3103
3110
ItemThumbnail :: Text ( text) => {
3104
- element_opt = Some ( widget:: text_editor ( text) . into ( ) )
3111
+ element_opt = Some (
3112
+ widget:: text_editor ( text)
3113
+ . padding ( space_xxs)
3114
+ . class ( cosmic:: theme:: iced:: TextEditor :: Custom ( Box :: new (
3115
+ text_editor_class,
3116
+ ) ) )
3117
+ . into ( ) ,
3118
+ )
3105
3119
}
3106
3120
}
3107
3121
}
@@ -4990,3 +5004,53 @@ impl<Message: 'static> From<ArcElementWrapper<Message>> for Element<'static, Mes
4990
5004
Element :: new ( wrapper)
4991
5005
}
4992
5006
}
5007
+
5008
+ fn text_editor_class (
5009
+ theme : & cosmic:: Theme ,
5010
+ status : cosmic:: widget:: text_editor:: Status ,
5011
+ ) -> cosmic:: iced_widget:: text_editor:: Style {
5012
+ let cosmic = theme. cosmic ( ) ;
5013
+ let container = theme. current_container ( ) ;
5014
+
5015
+ let mut background: cosmic:: iced:: Color = container. component . base . into ( ) ;
5016
+ background. a = 0.25 ;
5017
+ let selection = cosmic. accent . base . into ( ) ;
5018
+ let value = cosmic. palette . neutral_9 . into ( ) ;
5019
+ let mut placeholder = cosmic. palette . neutral_9 ;
5020
+ placeholder. alpha = 0.7 ;
5021
+ let placeholder = placeholder. into ( ) ;
5022
+ let icon = cosmic. background . on . into ( ) ;
5023
+
5024
+ match status {
5025
+ cosmic:: iced_widget:: text_editor:: Status :: Active
5026
+ | cosmic:: iced_widget:: text_editor:: Status :: Disabled => {
5027
+ cosmic:: iced_widget:: text_editor:: Style {
5028
+ background : background. into ( ) ,
5029
+ border : cosmic:: iced:: Border {
5030
+ radius : cosmic. corner_radii . radius_m . into ( ) ,
5031
+ width : 2.0 ,
5032
+ color : container. component . divider . into ( ) ,
5033
+ } ,
5034
+ icon,
5035
+ placeholder,
5036
+ value,
5037
+ selection,
5038
+ }
5039
+ }
5040
+ cosmic:: iced_widget:: text_editor:: Status :: Hovered
5041
+ | cosmic:: iced_widget:: text_editor:: Status :: Focused => {
5042
+ cosmic:: iced_widget:: text_editor:: Style {
5043
+ background : background. into ( ) ,
5044
+ border : cosmic:: iced:: Border {
5045
+ radius : cosmic. corner_radii . radius_m . into ( ) ,
5046
+ width : 2.0 ,
5047
+ color : cosmic:: iced:: Color :: from ( cosmic. accent . base ) ,
5048
+ } ,
5049
+ icon,
5050
+ placeholder,
5051
+ value,
5052
+ selection,
5053
+ }
5054
+ }
5055
+ }
5056
+ }
0 commit comments