GlassCard.axaml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <ResourceDictionary xmlns="https://github.com/avaloniaui"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:suki="clr-namespace:SukiUI.Controls">
  4. <ControlTheme x:Key="SukiGlassCardStyle" TargetType="suki:GlassCard">
  5. <Setter Property="BorderBrush" Value="{DynamicResource GlassBorderBrush}" />
  6. <Setter Property="Background" Value="{DynamicResource SukiGlassCardBackground}" />
  7. <Setter Property="Padding" Value="20" />
  8. <Setter Property="Template">
  9. <ControlTemplate>
  10. <Panel Name="RootPanel" Opacity="0">
  11. <Border Name="PART_BorderCard" RenderTransformOrigin="50%,50%"
  12. Background="{TemplateBinding Background}"
  13. BorderBrush="{TemplateBinding BorderBrush}"
  14. BorderThickness="{TemplateBinding BorderThickness}"
  15. ClipToBounds="{TemplateBinding ClipToBounds}"
  16. CornerRadius="{TemplateBinding CornerRadius}"
  17. Opacity="{DynamicResource GlassOpacity}">
  18. <Border.Transitions>
  19. <Transitions>
  20. <DoubleTransition Property="Width"
  21. Duration="0:0:0.5"
  22. Easing="QuadraticEaseOut" />
  23. <DoubleTransition Property="Height"
  24. Duration="0:0:0.5"
  25. Easing="QuadraticEaseOut" />
  26. </Transitions>
  27. </Border.Transitions>
  28. <Border.Transitions>
  29. <Transitions>
  30. <!-- <BrushTransition Property="Background" Duration="0:0:0.15" /> -->
  31. <BrushTransition Property="BorderBrush" Duration="0:0:0.15" />
  32. <DoubleTransition Property="Opacity" Duration="0:0:0.15" />
  33. </Transitions>
  34. </Border.Transitions>
  35. </Border>
  36. <Border Name="PART_ClipBorder"
  37. Background="{DynamicResource SukiPrimaryColor0}"
  38. BorderBrush="{DynamicResource SukiPrimaryColor0}"
  39. BorderThickness="{TemplateBinding BorderThickness}"
  40. ClipToBounds="{TemplateBinding ClipToBounds}"
  41. CornerRadius="{TemplateBinding CornerRadius}">
  42. <Border.Transitions>
  43. <Transitions>
  44. <BrushTransition Property="BorderBrush" Duration="0:0:0.15" />
  45. </Transitions>
  46. </Border.Transitions>
  47. <ContentPresenter Name="PART_CP" Margin="{TemplateBinding Padding}"
  48. Content="{TemplateBinding Content}" />
  49. </Border>
  50. </Panel>
  51. </ControlTemplate>
  52. </Setter>
  53. <Style Selector="^.Control">
  54. <Setter Property="IsAnimated" Value="False"></Setter>
  55. <Setter Property="Padding" Value="0"></Setter>
  56. </Style>
  57. <Style Selector="^.Discrete">
  58. <Setter Property="BorderBrush" Value="{DynamicResource SukiControlBorderBrush}" />
  59. <Setter Property="Padding" Value="0"></Setter>
  60. </Style>
  61. <Style Selector="^.Control /template/ Border#PART_BorderCard">
  62. <Setter Property="Background" Value="{DynamicResource ControlSukiGlassCardBackground}" />
  63. <Setter Property="Opacity" Value="{DynamicResource ControlGlassOpacity}" />
  64. </Style>
  65. <Style Selector="^.Discrete /template/ Border#PART_BorderCard">
  66. <Setter Property="Background" Value="{DynamicResource SukiGlassCardBackground}" />
  67. <Setter Property="Opacity" Value="{DynamicResource DiscreteControlGlassOpacity}" />
  68. </Style>
  69. <Style Selector="^.Primary /template/ Border#PART_ClipBorder">
  70. <Setter Property="BorderBrush" Value="{DynamicResource SukiAccentColor0}" />
  71. </Style>
  72. <Style Selector="^[IsOpaque=True] /template/ Border#PART_BorderCard">
  73. <Setter Property="Opacity" Value="1" />
  74. <Setter Property="Background" Value="{DynamicResource SukiGlassCardOpaqueBackground}" />
  75. </Style>
  76. <Style Selector="^[IsInteractive=True]:pointerover /template/ Border#PART_ClipBorder">
  77. <Setter Property="BorderBrush" Value="{DynamicResource SukiPrimaryColor50}" />
  78. </Style>
  79. <Style Selector="^.Primary[IsInteractive=True]:pointerover /template/ Border#PART_ClipBorder">
  80. <Setter Property="BorderBrush" Value="{DynamicResource SukiAccentColor50}" />
  81. </Style>
  82. <Style Selector="^[IsInteractive=True]:pointerdown /template/ Border#PART_ClipBorder">
  83. <Setter Property="BorderBrush" Value="{DynamicResource SukiPrimaryColor}" />
  84. </Style>
  85. <Style Selector="^.Primary[IsInteractive=True]:pointerdown /template/ Border#PART_ClipBorder">
  86. <Setter Property="BorderBrush" Value="{DynamicResource SukiAccentColor}" />
  87. </Style>
  88. <Style Selector="^.Accent /template/ Border#PART_BorderCard">
  89. <Setter Property="Background" Value="{DynamicResource SukiAccentColor25}" />
  90. </Style>
  91. <Style Selector="^.Primary /template/ Border#PART_BorderCard">
  92. <Setter Property="Background" Value="{DynamicResource SukiPrimaryColor25}" />
  93. </Style>
  94. <Style Selector="^.PrimaryOpaque /template/ Border#PART_BorderCard">
  95. <Setter Property="Opacity" Value="1" />
  96. <Setter Property="Background" Value="{DynamicResource SukiPrimaryColor}" />
  97. </Style>
  98. <Style Selector="^[IsVisible=True] /template/ Panel#RootPanel">
  99. <Setter Property="Opacity" Value="1" />
  100. </Style>
  101. <Style Selector="^[IsVisible=False] /template/ Panel#RootPanel">
  102. <Setter Property="Opacity" Value="0" />
  103. </Style>
  104. </ControlTheme>
  105. <ControlTheme x:Key="{x:Type suki:GlassCard}"
  106. BasedOn="{StaticResource SukiGlassCardStyle}"
  107. TargetType="suki:GlassCard" />
  108. </ResourceDictionary>