TimePickerStyle.axaml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <ResourceDictionary xmlns="https://github.com/avaloniaui"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:icons="clr-namespace:SukiUI.Content"
  4. xmlns:sys="using:System"
  5. xmlns:suki="https://github.com/kikipoulet/SukiUI">
  6. <Design.PreviewWith>
  7. <Border Height="500" Padding="20">
  8. <StackPanel VerticalAlignment="Center" Spacing="20">
  9. <TimePicker />
  10. </StackPanel>
  11. </Border>
  12. </Design.PreviewWith>
  13. <!-- <x:Double x:Key="TimePickerFlyoutPresenterItemHeight">40</x:Double>
  14. <x:Double x:Key="TimePickerSpacerThemeWidth">1</x:Double>
  15. <Thickness x:Key="TimePickerBorderThemeThickness">1</Thickness>
  16. <x:Double x:Key="TimePickerFlyoutPresenterHighlightHeight">40</x:Double>
  17. <x:Double x:Key="TimePickerFlyoutPresenterAcceptDismissHostGridHeight">41</x:Double>
  18. <x:Double x:Key="TimePickerThemeMinWidth">242</x:Double>
  19. <x:Double x:Key="TimePickerThemeMaxWidth">456</x:Double>
  20. <Thickness x:Key="TimePickerFlyoutPresenterItemPadding">0,3,0,6</Thickness>
  21. <Thickness x:Key="TimePickerHostPadding">0,3,0,6</Thickness>
  22. <ControlTheme x:Key="SimpleTimePickerFlyoutButton" TargetType="Button">
  23. <Setter Property="RenderTransform" Value="none" />
  24. <Setter Property="Template">
  25. <ControlTemplate>
  26. <ContentPresenter Name="PART_ContentPresenter"
  27. HorizontalContentAlignment="Stretch"
  28. VerticalContentAlignment="Stretch"
  29. Background="{TemplateBinding Background}"
  30. BorderBrush="{TemplateBinding BorderBrush}"
  31. BorderThickness="{TemplateBinding BorderThickness}"
  32. Content="{TemplateBinding Content}"
  33. CornerRadius="{TemplateBinding CornerRadius}"
  34. Foreground="{TemplateBinding Foreground}" />
  35. </ControlTemplate>
  36. </Setter>
  37. <Style Selector="^:pointerover /template/ ContentPresenter#PART_ContentPresenter">
  38. <Setter Property="BorderBrush" Value="{DynamicResource ThemeControlHighBrush}" />
  39. <Setter Property="TextElement.Foreground" Value="{TemplateBinding Foreground}" />
  40. </Style>
  41. <Style Selector="^:pressed /template/ ContentPresenter#PART_ContentPresenter">
  42. <Setter Property="Background">
  43. <SolidColorBrush Opacity="0.6" Color="{DynamicResource ThemeControlMidHighColor}" />
  44. </Setter>
  45. <Setter Property="BorderBrush" Value="{DynamicResource ThemeControlLowBrush}" />
  46. <Setter Property="TextElement.Foreground" Value="{TemplateBinding Foreground}" />
  47. </Style>
  48. <Style Selector="^:disabled /template/ ContentPresenter#PART_ContentPresenter">
  49. <Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}" />
  50. </Style>
  51. </ControlTheme>
  52. <ControlTheme x:Key="{x:Type TimePicker}" TargetType="TimePicker">
  53. <Setter Property="FontSize" Value="{DynamicResource FontSizeNormal}" />
  54. <Setter Property="BorderThickness" Value="0,0,0,0" />
  55. <Setter Property="HorizontalAlignment" Value="Left" />
  56. <Setter Property="VerticalAlignment" Value="Center" />
  57. <Setter Property="BorderBrush" Value="{DynamicResource SukiMediumBorderBrush}" />
  58. <Setter Property="CornerRadius" Value="0" />
  59. <Setter Property="Background" Value="{DynamicResource SukiBackground}" />
  60. <Setter Property="Padding" Value="20,8" />
  61. <Setter Property="Height" Value="40" />
  62. <Setter Property="Template">
  63. <ControlTemplate>
  64. <DataValidationErrors>
  65. <Grid Name="LayoutRoot">
  66. <suki:GlassCard Height="{TemplateBinding Height}" CornerRadius="{DynamicResource SmallCornerRadius}" Classes="Discrete" >
  67. <Button x:Name="PART_FlyoutButton"
  68. MinWidth="{DynamicResource TimePickerThemeMinWidth}"
  69. MaxWidth="{DynamicResource TimePickerThemeMaxWidth}"
  70. HorizontalAlignment="Stretch"
  71. VerticalAlignment="Stretch"
  72. Background="{TemplateBinding Background}"
  73. BorderBrush="{TemplateBinding BorderBrush}"
  74. BorderThickness="{TemplateBinding BorderThickness}"
  75. CornerRadius="{TemplateBinding CornerRadius}"
  76. Foreground="{TemplateBinding Foreground}"
  77. IsEnabled="{TemplateBinding IsEnabled}"
  78. Theme="{StaticResource SimpleTimePickerFlyoutButton}">
  79. <DockPanel Margin="{TemplateBinding Padding}">
  80. <PathIcon Width="16"
  81. Height="16"
  82. Margin="12,0,0,0"
  83. HorizontalAlignment="Right"
  84. Data="{x:Static icons:Icons.Calendar}"
  85. DockPanel.Dock="Right"
  86. Foreground="{DynamicResource SukiLowText}" />
  87. <Grid Name="PART_FlyoutButtonContentGrid">
  88. <Border x:Name="PART_FirstPickerHost"
  89. Grid.Column="0"
  90. HorizontalAlignment="Stretch"
  91. VerticalAlignment="Stretch">
  92. <TextBlock x:Name="PART_HourTextBlock"
  93. Padding="{DynamicResource TimePickerHostPadding}"
  94. HorizontalAlignment="Center"
  95. FontFamily="{TemplateBinding FontFamily}"
  96. FontSize="{TemplateBinding FontSize}"
  97. FontWeight="{TemplateBinding FontWeight}" />
  98. </Border>
  99. <Rectangle Name="PART_FirstColumnDivider"
  100. Grid.Column="1"
  101. Width="1"
  102. HorizontalAlignment="Center"
  103. Fill="{DynamicResource SukiMediumBorderBrush}" />
  104. <Border x:Name="PART_SecondPickerHost"
  105. Grid.Column="2"
  106. HorizontalAlignment="Stretch"
  107. VerticalAlignment="Stretch">
  108. <TextBlock x:Name="PART_MinuteTextBlock"
  109. Padding="{DynamicResource TimePickerHostPadding}"
  110. HorizontalAlignment="Center"
  111. FontFamily="{TemplateBinding FontFamily}"
  112. FontSize="{TemplateBinding FontSize}"
  113. FontWeight="{TemplateBinding FontWeight}" />
  114. </Border>
  115. <Rectangle Name="PART_SecondColumnDivider"
  116. Grid.Column="3"
  117. Width="{DynamicResource TimePickerSpacerThemeWidth}"
  118. HorizontalAlignment="Center"
  119. Fill="{DynamicResource TimePickerSpacerFill}" />
  120. <Border x:Name="PART_ThirdPickerHost"
  121. Grid.Column="4"
  122. HorizontalAlignment="Stretch"
  123. VerticalAlignment="Stretch">
  124. <TextBlock x:Name="PART_PeriodTextBlock"
  125. Padding="{DynamicResource TimePickerHostPadding}"
  126. HorizontalAlignment="Center"
  127. FontFamily="{TemplateBinding FontFamily}"
  128. FontSize="{TemplateBinding FontSize}"
  129. FontWeight="{TemplateBinding FontWeight}" />
  130. </Border>
  131. </Grid>
  132. </DockPanel>
  133. </Button>
  134. </suki:GlassCard>
  135. <Popup Name="PART_Popup"
  136. IsLightDismissEnabled="True"
  137. Placement="Bottom"
  138. PlacementTarget="{TemplateBinding}"
  139. WindowManagerAddShadowHint="False">
  140. <TimePickerPresenter Name="PART_PickerPresenter" />
  141. </Popup>
  142. </Grid>
  143. </DataValidationErrors>
  144. </ControlTemplate>
  145. </Setter>
  146. <Style Selector="^:disabled /template/ Rectangle">
  147. <Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}" />
  148. </Style>
  149. <Style Selector="^:hasnotime /template/ Button#PART_FlyoutButton TextBlock">
  150. <Setter Property="Foreground" Value="{DynamicResource ThemeForegroundLowBrush}" />
  151. </Style>
  152. </ControlTheme>
  153. <ControlTheme x:Key="{x:Type TimePickerPresenter}" TargetType="TimePickerPresenter">
  154. <Setter Property="Width" Value="242" />
  155. <Setter Property="MinWidth" Value="242" />
  156. <Setter Property="MaxHeight" Value="398" />
  157. <Setter Property="FontWeight" Value="Normal" />
  158. <Setter Property="CornerRadius" Value="10" />
  159. <Setter Property="Background" Value="{DynamicResource SukiCardBackground}" />
  160. <Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}" />
  161. <Setter Property="BorderThickness" Value="0" />
  162. <Setter Property="Template">
  163. <ControlTemplate>
  164. <Border Name="Background"
  165. MaxHeight="398"
  166. Margin="15"
  167. Padding="{DynamicResource DateTimeFlyoutBorderPadding}"
  168. Background="{TemplateBinding Background}"
  169. BorderBrush="{TemplateBinding BorderBrush}"
  170. BorderThickness="{TemplateBinding BorderThickness}"
  171. BoxShadow="{DynamicResource SukiPopupShadow}"
  172. CornerRadius="{TemplateBinding CornerRadius}">
  173. <Border.Styles>
  174. <Style Selector="RepeatButton">
  175. <Setter Property="Background" Value="Transparent" />
  176. </Style>
  177. <Style Selector="RepeatButton:pointerover">
  178. <Setter Property="Background" Value="Transparent" />
  179. </Style>
  180. </Border.Styles>
  181. <Grid Name="ContentPanel" RowDefinitions="*,Auto">
  182. <Grid Name="PART_PickerContainer">
  183. <Grid.OpacityMask>
  184. <LinearGradientBrush StartPoint="48%,0%" EndPoint="50%,100%">
  185. <GradientStop Offset="0" />
  186. <GradientStop Offset="0.5" Color="Black" />
  187. <GradientStop Offset="1" />
  188. </LinearGradientBrush>
  189. </Grid.OpacityMask>
  190. <Grid.Styles>
  191. <Style Selector="ListBoxItem:selected TextBlock">
  192. <Setter Property="FontWeight" Value="Bold" />
  193. </Style>
  194. <Style Selector="DateTimePickerPanel &gt; ListBoxItem">
  195. <Setter Property="Background" Value="Transparent" />
  196. <Setter Property="Foreground" Value="{DynamicResource SukiText}" />
  197. <Setter Property="Padding" Value="4,2" />
  198. <Setter Property="Template">
  199. <ControlTemplate>
  200. <Border Margin="0,0,10,0"
  201. Padding="8,4"
  202. CornerRadius="6">
  203. <ContentPresenter Name="PART_ContentPresenter"
  204. Margin="0,0,0,0"
  205. Padding="{TemplateBinding Padding}"
  206. VerticalAlignment="Center"
  207. HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
  208. VerticalContentAlignment="Center"
  209. Background="Transparent"
  210. BorderBrush="Transparent"
  211. BorderThickness="{TemplateBinding BorderThickness}"
  212. Content="{TemplateBinding Content}"
  213. ContentTemplate="{TemplateBinding ContentTemplate}"
  214. CornerRadius="{TemplateBinding CornerRadius}" />
  215. </Border>
  216. </ControlTemplate>
  217. </Setter>
  218. </Style>
  219. </Grid.Styles>
  220. <Panel Name="PART_HourHost" Grid.Column="0">
  221. <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Hidden">
  222. <DateTimePickerPanel Name="PART_HourSelector"
  223. ItemHeight="{DynamicResource TimePickerFlyoutPresenterItemHeight}"
  224. PanelType="Hour"
  225. ShouldLoop="True" />
  226. </ScrollViewer>
  227. <RepeatButton Name="PART_HourUpButton" Theme="{StaticResource SimpleDateTimePickerUpButton}" />
  228. <RepeatButton Name="PART_HourDownButton" Theme="{StaticResource SimpleDateTimePickerDownButton}" />
  229. </Panel>
  230. <Panel Name="PART_MinuteHost" Grid.Column="2">
  231. <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Hidden">
  232. <DateTimePickerPanel Name="PART_MinuteSelector"
  233. ItemHeight="{DynamicResource TimePickerFlyoutPresenterItemHeight}"
  234. PanelType="Minute"
  235. ShouldLoop="True" />
  236. </ScrollViewer>
  237. <RepeatButton Name="PART_MinuteUpButton" Theme="{StaticResource SimpleDateTimePickerUpButton}" />
  238. <RepeatButton Name="PART_MinuteDownButton" Theme="{StaticResource SimpleDateTimePickerDownButton}" />
  239. </Panel>
  240. <Panel Name="PART_PeriodHost" Grid.Column="4">
  241. <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Hidden">
  242. <DateTimePickerPanel Name="PART_PeriodSelector"
  243. ItemHeight="{DynamicResource TimePickerFlyoutPresenterItemHeight}"
  244. PanelType="TimePeriod"
  245. ShouldLoop="False" />
  246. </ScrollViewer>
  247. <RepeatButton Name="PART_PeriodUpButton" Theme="{StaticResource SimpleDateTimePickerUpButton}" />
  248. <RepeatButton Name="PART_PeriodDownButton" Theme="{StaticResource SimpleDateTimePickerDownButton}" />
  249. </Panel>
  250. <Border x:Name="HighlightRect"
  251. Grid.Column="0"
  252. Grid.ColumnSpan="5"
  253. Height="{DynamicResource TimePickerFlyoutPresenterHighlightHeight}"
  254. Margin="5,0"
  255. VerticalAlignment="Center"
  256. Background="{DynamicResource SukiPrimaryColor5}"
  257. CornerRadius="10"
  258. ZIndex="-1" />
  259. <Rectangle Name="PART_FirstSpacer"
  260. Grid.Column="1"
  261. Width="{DynamicResource TimePickerSpacerThemeWidth}"
  262. HorizontalAlignment="Center">
  263. <Rectangle.Fill>
  264. <LinearGradientBrush StartPoint="48%,0%" EndPoint="50%,100%">
  265. <GradientStop Offset="0" Color="Transparent" />
  266. <GradientStop Offset="0.5" Color="{DynamicResource SukiMediumBorderBrush}" />
  267. <GradientStop Offset="1" Color="Transparent" />
  268. </LinearGradientBrush>
  269. </Rectangle.Fill>
  270. </Rectangle>
  271. <Rectangle Name="PART_SecondSpacer"
  272. Grid.Column="3"
  273. Width="{DynamicResource TimePickerSpacerThemeWidth}"
  274. HorizontalAlignment="Center"
  275. Fill="{DynamicResource ThemeControlMidHighBrush}" />
  276. </Grid>
  277. <Grid Name="AcceptDismissGrid"
  278. Grid.Row="1"
  279. ColumnDefinitions="*,*">
  280. <Rectangle Grid.ColumnSpan="2"
  281. Height="{DynamicResource TimePickerSpacerThemeWidth}"
  282. VerticalAlignment="Top"
  283. Fill="{DynamicResource ThemeControlMidHighBrush}"
  284. IsVisible="False" />
  285. <Button Name="PART_AcceptButton"
  286. Grid.Column="1"
  287. Height="{DynamicResource TimePickerFlyoutPresenterAcceptDismissHostGridHeight}"
  288. Margin="0,0,0,2"
  289. HorizontalAlignment="Stretch"
  290. VerticalAlignment="Stretch"
  291. Theme="{StaticResource SimpleDateTimePickerButton}">
  292. <StackPanel Margin="20,0" Orientation="Horizontal">
  293. <PathIcon Width="12"
  294. Height="12"
  295. Data="{x:Static icons:Icons.Check}"
  296. Foreground="{DynamicResource SukiPrimaryColor}" />
  297. <TextBlock Margin="10,0,0,0"
  298. FontSize="15"
  299. FontWeight="{DynamicResource DefaultDemiBold}"
  300. Foreground="{DynamicResource SukiPrimaryColor}"
  301. Text="Apply" />
  302. </StackPanel>
  303. </Button>
  304. <Button Name="PART_DismissButton"
  305. Grid.Column="1"
  306. Height="{DynamicResource TimePickerFlyoutPresenterAcceptDismissHostGridHeight}"
  307. HorizontalAlignment="Stretch"
  308. VerticalAlignment="Stretch"
  309. FontSize="16"
  310. Theme="{StaticResource SimpleDateTimePickerButton}">
  311. <Path Data="M2,2 14,14 M2,14 14 2"
  312. Stroke="{Binding $parent[Button].Foreground}"
  313. StrokeLineCap="Round"
  314. StrokeThickness="0.75" />
  315. </Button>
  316. </Grid>
  317. </Grid>
  318. </Border>
  319. </ControlTemplate>
  320. </Setter>
  321. <Style Selector="^ /template/ Panel">
  322. <Style Selector="^:pointerover RepeatButton">
  323. <Setter Property="IsVisible" Value="True" />
  324. </Style>
  325. </Style>
  326. </ControlTheme> -->
  327. </ResourceDictionary>