File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using Windows . UI . Xaml ;
3
+
4
+ namespace Uno . UI . Xaml . Media
5
+ {
6
+ internal static partial class ThemeShadowManager
7
+ {
8
+ static partial void UnsetShadow ( UIElement uiElement )
9
+ {
10
+ var translation = uiElement . Translation ;
11
+
12
+ #if __MACOS__
13
+ if ( uiElement is AppKit . NSView view )
14
+ #else
15
+ if ( uiElement is UIKit . UIView view )
16
+ #endif
17
+ {
18
+ view . Layer . ShadowOpacity = 0 ;
19
+ }
20
+ }
21
+
22
+ static partial void SetShadow ( UIElement uiElement )
23
+ {
24
+ var translation = uiElement . Translation ;
25
+
26
+ #if __MACOS__
27
+ if ( uiElement is AppKit . NSView view )
28
+ #else
29
+ if ( uiElement is UIKit . UIView view )
30
+ #endif
31
+ {
32
+ // Values for 1dp elevation according to https://material.io/guidelines/resources/shadows.html#shadows-illustrator
33
+ const float x = 0.25f ;
34
+ const float y = 0.92f * 0.5f ; // Looks more accurate than the recommended 0.92f.
35
+ const float blur = 0.5f ;
36
+
37
+ #if __MACOS__
38
+ view . WantsLayer = true ;
39
+ view . Shadow ??= new AppKit . NSShadow ( ) ;
40
+ #endif
41
+ view . Layer . MasksToBounds = false ;
42
+ view . Layer . ShadowOpacity = 1 ;
43
+ #if __MACOS__
44
+ view . Layer . ShadowColor = AppKit . NSColor . Black . CGColor ;
45
+ #else
46
+ view . Layer . ShadowColor = UIKit . UIColor . Black . CGColor ;
47
+ #endif
48
+ view . Layer . ShadowRadius = ( nfloat ) ( blur * translation . Z ) ;
49
+ view . Layer . ShadowOffset = new CoreGraphics . CGSize ( x * translation . Z , y * translation . Z ) ;
50
+ //view.Layer.ShadowPath = path; - needed for rounded corners?
51
+ }
52
+ }
53
+ }
54
+ }
You can’t perform that action at this time.
0 commit comments