feat: implement verificationcodeitem and corresponding delete operation.

This commit is contained in:
rabbitism
2024-03-09 17:20:24 +08:00
parent de0124eb8e
commit 27f613f4e4
8 changed files with 168 additions and 44 deletions

View File

@@ -1,34 +1,68 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:u="https://irihi.tech/ursa">
<!-- Add Resources Here -->
<ControlTheme TargetType="u:VerificationCode" x:Key="{x:Type u:VerificationCode}">
<ResourceDictionary
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:u="https://irihi.tech/ursa">
<Design.PreviewWith>
<u:VerificationCode Count="4" />
</Design.PreviewWith>
<!-- Add Resources Here -->
<ControlTheme x:Key="{x:Type u:VerificationCodeItem}" TargetType="u:VerificationCodeItem">
<Setter Property="Margin" Value="8" />
<Setter Property="FontSize" Value="20" />
<Setter Property="Focusable" Value="True" />
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Template">
<ControlTemplate>
<Border
Name="PART_Background"
Width="32"
Height="32"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{DynamicResource TextBoxDefaultBackground}"
CornerRadius="3">
<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}"></Setter>
</Style>
<Style Selector="^:focus /template/ Border#PART_Background">
<Setter Property="Background" Value="{DynamicResource TextBoxPointeroverBackground}"></Setter>
<Setter Property="BorderBrush" Value="{DynamicResource TextBoxFocusBorderBrush}"></Setter>
</Style>
</ControlTheme>
<ControlTheme x:Key="{x:Type u:VerificationCodeCollection}" TargetType="u:VerificationCodeCollection">
<Setter Property="Template">
<ControlTemplate TargetType="u:VerificationCodeCollection">
<ItemsPresenter ItemsPanel="{TemplateBinding ItemsPanel}" />
</ControlTemplate>
</Setter>
</ControlTheme>
<ControlTheme x:Key="{x:Type u:VerificationCode}" TargetType="u:VerificationCode">
<Setter Property="HorizontalAlignment" Value="Left"></Setter>
<Setter Property="Template">
<ControlTemplate TargetType="u:VerificationCode">
<u:VerificationCodeCollection Name="{x:Static u:VerificationCode.PART_ItemsControl}" ItemsSource="{TemplateBinding Digits}">
<u:VerificationCodeCollection.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="{TemplateBinding CountOfDigit}" Rows="1"></UniformGrid>
<UniformGrid Columns="{TemplateBinding Count}" Rows="1" />
</ItemsPanelTemplate>
</u:VerificationCodeCollection.ItemsPanel>
<u:VerificationCodeCollection.ItemContainerTheme>
<ControlTheme TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
<Setter Property="IsReadOnly" Value="True"></Setter>
<Setter Property="Focusable" Value="False"></Setter>
<Setter Property="Margin" Value="8"></Setter>
<Setter Property="PasswordChar" Value="{Binding $parent[u:VerificationCode].PasswordChar}"></Setter>
<ControlTheme BasedOn="{StaticResource {x:Type u:VerificationCodeItem}}" TargetType="u:VerificationCodeItem">
<Setter Property="PasswordChar" Value="{Binding $parent[u:VerificationCode].PasswordChar}" />
</ControlTheme>
</u:VerificationCodeCollection.ItemContainerTheme>
</u:VerificationCodeCollection>
</ControlTemplate>
</Setter>
</ControlTheme>
<ControlTheme TargetType="u:VerificationCodeCollection" x:Key="{x:Type u:VerificationCodeCollection}">
<Setter Property="Template">
<ControlTemplate TargetType="u:VerificationCodeCollection">
<ItemsPresenter ItemsPanel="{TemplateBinding ItemsPanel}"></ItemsPresenter>
</ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary>