feat: rename to PinCode, add styles for size.
This commit is contained in:
88
src/Ursa.Themes.Semi/Controls/PinCode.axaml
Normal file
88
src/Ursa.Themes.Semi/Controls/PinCode.axaml
Normal file
@@ -0,0 +1,88 @@
|
||||
<ResourceDictionary
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:u="https://irihi.tech/ursa">
|
||||
<Design.PreviewWith>
|
||||
<u:PinCode Count="4" />
|
||||
</Design.PreviewWith>
|
||||
<!-- Add Resources Here -->
|
||||
<ControlTheme x:Key="{x:Type u:PinCodeItem}" TargetType="u:PinCodeItem">
|
||||
<Setter Property="Focusable" Value="True" />
|
||||
<Setter Property="Height" Value="{DynamicResource TextBoxDefaultHeight}" />
|
||||
<Setter Property="Width" Value="{DynamicResource TextBoxDefaultHeight}" />
|
||||
<Setter Property="CornerRadius" Value="{DynamicResource TextBoxDefaultCornerRadius}" />
|
||||
<Setter Property="BorderThickness" Value="{DynamicResource TextBoxBorderThickness}" />
|
||||
<Setter Property="Background" Value="{DynamicResource TextBoxDefaultBackground}"></Setter>
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<Border
|
||||
Name="PART_Background"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}">
|
||||
<TextPresenter
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
PasswordChar="{TemplateBinding PasswordChar}"
|
||||
Text="{TemplateBinding Text}"
|
||||
TextElement.FontSize="{TemplateBinding FontSize}" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
<Style Selector="^:pointerover /template/ Border#PART_Background">
|
||||
<Setter Property="Background" Value="{DynamicResource TextBoxPointeroverBackground}" />
|
||||
</Style>
|
||||
<Style Selector="^:focus /template/ Border#PART_Background">
|
||||
<Setter Property="Background" Value="{DynamicResource TextBoxPointeroverBackground}" />
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource TextBoxFocusBorderBrush}" />
|
||||
</Style>
|
||||
<Style Selector="^:error /template/ Border#PART_Background">
|
||||
<Setter Property="Background" Value="{DynamicResource DataValidationErrorsSelectedBackground}" />
|
||||
</Style>
|
||||
<Style Selector="^:focus:error /template/ Border#PART_Background">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource DataValidationErrorsSelectedBorderBrush}" />
|
||||
</Style>
|
||||
<Style Selector="^.Large">
|
||||
<Setter Property="Height" Value="{DynamicResource TextBoxLargeHeight}" />
|
||||
<Setter Property="Width" Value="{DynamicResource TextBoxLargeHeight}" />
|
||||
</Style>
|
||||
<Style Selector="^.Small">
|
||||
<Setter Property="Height" Value="{DynamicResource TextBoxSmallHeight}" />
|
||||
<Setter Property="Width" Value="{DynamicResource TextBoxSmallHeight}" />
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="{x:Type u:PinCodeCollection}" TargetType="u:PinCodeCollection">
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="u:PinCodeCollection">
|
||||
<ItemsPresenter ItemsPanel="{TemplateBinding ItemsPanel}" />
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="{x:Type u:PinCode}" TargetType="u:PinCode">
|
||||
<Setter Property="HorizontalAlignment" Value="Left" />
|
||||
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="u:PinCode">
|
||||
<DataValidationErrors>
|
||||
<u:PinCodeCollection HorizontalAlignment="Left" Name="{x:Static u:PinCode.PART_ItemsControl}" ItemsSource="{TemplateBinding Digits}">
|
||||
<u:PinCodeCollection.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Horizontal" />
|
||||
</ItemsPanelTemplate>
|
||||
</u:PinCodeCollection.ItemsPanel>
|
||||
<u:PinCodeCollection.ItemContainerTheme>
|
||||
<ControlTheme BasedOn="{StaticResource {x:Type u:PinCodeItem}}" TargetType="u:PinCodeItem">
|
||||
<Setter Property="PasswordChar" Value="{Binding $parent[u:PinCode].PasswordChar}" />
|
||||
<Setter Property="DataValidationErrors.Errors" Value="{Binding $parent[u:PinCode].(DataValidationErrors.Errors)}" />
|
||||
</ControlTheme>
|
||||
</u:PinCodeCollection.ItemContainerTheme>
|
||||
</u:PinCodeCollection>
|
||||
</DataValidationErrors>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user