Files
Semi.Avalonia/src/Semi.Avalonia/Controls/DrawerPage.axaml

231 lines
14 KiB
XML

<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith>
<DrawerPage Width="400" Height="300" />
</Design.PreviewWith>
<ControlTheme x:Key="{x:Type DrawerPage}" TargetType="DrawerPage">
<Setter Property="Background" Value="{DynamicResource DrawerPageBackground}" />
<Setter Property="Foreground" Value="{DynamicResource DrawerPageForeground}" />
<Setter Property="Template">
<ControlTemplate TargetType="DrawerPage">
<SplitView
Name="PART_SplitView"
CompactPaneLength="{TemplateBinding CompactDrawerLength}"
DisplayMode="{TemplateBinding DisplayMode}"
IsPaneOpen="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
OpenPaneLength="{TemplateBinding DrawerLength}"
PaneBackground="{Binding DrawerBackground, RelativeSource={RelativeSource TemplatedParent}}">
<SplitView.Pane>
<DockPanel Background="{TemplateBinding DrawerBackground}">
<!-- Compact-mode toggle: visible only in CompactOverlay/CompactInline. -->
<ToggleButton
Name="PART_CompactPaneToggle"
DockPanel.Dock="Top"
AutomationProperties.Name="Toggle navigation drawer"
ToolTip.Tip="{DynamicResource STRING_DRAWERPAGE_TOGGLE_NAVIGATION_DRAWER}"
Width="{DynamicResource ButtonDefaultHeight}"
Height="{DynamicResource ButtonDefaultHeight}"
HorizontalAlignment="Left"
Background="Transparent"
IsChecked="{Binding #PART_SplitView.IsPaneOpen, Mode=TwoWay}"
IsVisible="False">
<Panel>
<PathIcon
Data="{DynamicResource DrawerPageMenuGlyph}"
Foreground="{DynamicResource DrawerPagePaneButtonForeground}"
IsVisible="{TemplateBinding DrawerIcon, Converter={x:Static ObjectConverters.IsNull}}"
Theme="{DynamicResource InnerPathIcon}" />
<ContentPresenter
Name="PART_CompactPaneIconPresenter"
Content="{TemplateBinding DrawerIcon}"
ContentTemplate="{TemplateBinding DrawerIconTemplate}"
Foreground="{DynamicResource DrawerPagePaneButtonForeground}"
IsVisible="{TemplateBinding DrawerIcon, Converter={x:Static ObjectConverters.IsNotNull}}" />
</Panel>
</ToggleButton>
<ContentPresenter
Name="PART_DrawerHeader"
DockPanel.Dock="Top"
Background="{TemplateBinding DrawerHeaderBackground}"
Content="{TemplateBinding DrawerHeader}"
ContentTemplate="{TemplateBinding DrawerHeaderTemplate}"
IsVisible="{TemplateBinding DrawerHeader, Converter={x:Static ObjectConverters.IsNotNull}}" />
<ContentPresenter
Name="PART_DrawerFooter"
DockPanel.Dock="Bottom"
Background="{TemplateBinding DrawerFooterBackground}"
Content="{TemplateBinding DrawerFooter}"
ContentTemplate="{TemplateBinding DrawerFooterTemplate}"
IsVisible="{TemplateBinding DrawerFooter, Converter={x:Static ObjectConverters.IsNotNull}}" />
<ContentPresenter
Name="PART_DrawerPresenter"
Content="{TemplateBinding Drawer}"
ContentTemplate="{TemplateBinding DrawerTemplate}" />
</DockPanel>
</SplitView.Pane>
<Panel>
<DockPanel Name="PART_ContentDock">
<Border
Name="PART_TopBar"
DockPanel.Dock="Top"
Height="{DynamicResource DrawerPageTopBarMinHeight}"
Background="{DynamicResource DrawerPageTopBarBackground}">
<DockPanel>
<ToggleButton
Name="PART_PaneButton"
DockPanel.Dock="Left"
AutomationProperties.Name="Toggle navigation drawer"
ToolTip.Tip="{DynamicResource STRING_DRAWERPAGE_TOGGLE_NAVIGATION_DRAWER}"
Width="{DynamicResource ButtonDefaultHeight}"
Height="{DynamicResource ButtonDefaultHeight}"
Background="Transparent"
IsChecked="{Binding #PART_SplitView.IsPaneOpen, Mode=TwoWay}">
<Panel>
<PathIcon
Data="{DynamicResource DrawerPageMenuGlyph}"
Foreground="{DynamicResource DrawerPagePaneButtonForeground}"
IsVisible="{TemplateBinding DrawerIcon, Converter={x:Static ObjectConverters.IsNull}}"
Theme="{DynamicResource InnerPathIcon}" />
<ContentPresenter
Name="PART_PaneIconPresenter"
Content="{TemplateBinding DrawerIcon}"
ContentTemplate="{TemplateBinding DrawerIconTemplate}"
Foreground="{DynamicResource DrawerPagePaneButtonForeground}"
IsVisible="{TemplateBinding DrawerIcon, Converter={x:Static ObjectConverters.IsNotNull}}" />
</Panel>
</ToggleButton>
<ContentPresenter
Name="PART_TitlePresenter"
Margin="8,0,0,0"
Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
FontSize="{DynamicResource DrawerPageTitleFontSize}"
FontWeight="{DynamicResource DrawerPageTitleFontWeight}"
IsVisible="{TemplateBinding Header, Converter={x:Static ObjectConverters.IsNotNull}}" />
</DockPanel>
</Border>
<Border
Name="PART_BottomBar"
DockPanel.Dock="Bottom"
Height="{DynamicResource DrawerPageTopBarMinHeight}"
Background="{DynamicResource DrawerPageTopBarBackground}"
IsVisible="False">
<DockPanel>
<ToggleButton
Name="PART_BottomPaneButton"
DockPanel.Dock="Left"
AutomationProperties.Name="Toggle navigation drawer"
ToolTip.Tip="{DynamicResource STRING_DRAWERPAGE_TOGGLE_NAVIGATION_DRAWER}"
Background="Transparent"
IsChecked="{Binding #PART_SplitView.IsPaneOpen, Mode=TwoWay}">
<Panel>
<PathIcon
Data="{DynamicResource DrawerPaneButtonIcon}"
IsVisible="{TemplateBinding DrawerIcon, Converter={x:Static ObjectConverters.IsNull}}"
Theme="{DynamicResource InnerPathIcon}" />
<ContentPresenter
Name="PART_BottomPaneIconPresenter"
Content="{TemplateBinding DrawerIcon}"
ContentTemplate="{TemplateBinding DrawerIconTemplate}"
IsVisible="{TemplateBinding DrawerIcon, Converter={x:Static ObjectConverters.IsNotNull}}" />
</Panel>
</ToggleButton>
<ContentPresenter
Name="PART_BottomTitlePresenter"
Margin="8,0,0,0"
Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
FontSize="{DynamicResource DrawerPageTitleFontSize}"
FontWeight="{DynamicResource DrawerPageTitleFontWeight}"
IsVisible="{TemplateBinding Header, Converter={x:Static ObjectConverters.IsNotNull}}" />
</DockPanel>
</Border>
<ContentPresenter
Name="PART_ContentPresenter"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
CornerRadius="{TemplateBinding CornerRadius}" />
</DockPanel>
<Border
Name="PART_Backdrop"
Background="{TemplateBinding BackdropBrush}"
IsHitTestVisible="False"
IsVisible="False" />
</Panel>
</SplitView>
</ControlTemplate>
</Setter>
<Style Selector="^:placement-right /template/ ToggleButton#PART_PaneButton">
<Setter Property="DockPanel.Dock" Value="Right" />
</Style>
<!-- Bottom placement: swap top bar for bottom bar -->
<Style Selector="^:placement-bottom /template/ Border#PART_TopBar">
<Setter Property="IsVisible" Value="False" />
</Style>
<Style Selector="^:placement-bottom /template/ Border#PART_BottomBar">
<Setter Property="IsVisible" Value="True" />
</Style>
<!-- Bottom placement + compact modes: pane compact strip provides toggle, hide bottom bar -->
<Style Selector="^:placement-bottom[DisplayMode=CompactOverlay] /template/ Border#PART_BottomBar">
<Setter Property="IsVisible" Value="False" />
</Style>
<Style Selector="^:placement-bottom[DisplayMode=CompactInline] /template/ Border#PART_BottomBar">
<Setter Property="IsVisible" Value="False" />
</Style>
<!-- Horizontal pane (Bottom/Top): compact toggle must dock Left so drawer content can fill the rest -->
<Style Selector="^:placement-bottom /template/ ToggleButton#PART_CompactPaneToggle">
<Setter Property="DockPanel.Dock" Value="Left" />
</Style>
<Style Selector="^:placement-top /template/ ToggleButton#PART_CompactPaneToggle">
<Setter Property="DockPanel.Dock" Value="Left" />
</Style>
<Style Selector="^[DrawerBehavior=Locked] /template/ Border#PART_TopBar">
<Setter Property="IsVisible" Value="False" />
</Style>
<Style Selector="^[DrawerBehavior=Disabled] /template/ Border#PART_TopBar">
<Setter Property="IsVisible" Value="False" />
</Style>
<Style Selector="^:detail-is-navpage /template/ Border#PART_TopBar">
<Setter Property="IsVisible" Value="False" />
</Style>
<Style Selector="^[DisplayMode=CompactOverlay] /template/ Border#PART_TopBar">
<Setter Property="IsVisible" Value="False" />
</Style>
<Style Selector="^[DisplayMode=CompactOverlay] /template/ ToggleButton#PART_CompactPaneToggle">
<Setter Property="IsVisible" Value="True" />
</Style>
<Style Selector="^[DisplayMode=CompactInline] /template/ Border#PART_TopBar">
<Setter Property="IsVisible" Value="False" />
</Style>
<Style Selector="^[DisplayMode=CompactInline] /template/ ToggleButton#PART_CompactPaneToggle">
<Setter Property="IsVisible" Value="True" />
</Style>
<Style Selector="^[IsInNavigationPage=True] /template/ Border#PART_TopBar">
<Setter Property="IsVisible" Value="False" />
</Style>
<!-- NavigationPage already hosts a hamburger toggle — suppress the compact pane toggle. -->
<Style Selector="^:detail-is-navpage /template/ ToggleButton#PART_CompactPaneToggle">
<Setter Property="IsVisible" Value="False" />
</Style>
</ControlTheme>
</ResourceDictionary>