<SettingsExpander
    x:Class="Wallet.Avalonia.DateEntryView"
    xmlns="https://github.com/avaloniaui"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:vm="using:Wallet"
    x:DataType="vm:DateEntryViewModel"
    Header="{Binding Key}"
    IsExpanded="False">
    <SettingsExpander.Resources>
		<ResourceDictionary>
			<ResourceDictionary.ThemeDictionaries>
				<ResourceDictionary x:Key="Light">
					<StaticResource x:Key="DatePickerButtonBorderBrush" ResourceKey="ControlStrokeColorDefaultBrush" />
					<StaticResource x:Key="DatePickerButtonBorderBrushPointerOver" ResourceKey="ControlStrokeColorDefaultBrush" />
				</ResourceDictionary>
				<ResourceDictionary x:Key="Dark">
					<StaticResource x:Key="DatePickerButtonBorderBrush" ResourceKey="SubtleFillColorTransparentBrush" />
					<StaticResource x:Key="DatePickerButtonBorderBrushPointerOver" ResourceKey="SubtleFillColorTransparentBrush" />
				</ResourceDictionary>
			</ResourceDictionary.ThemeDictionaries>
		</ResourceDictionary>
        <Thickness x:Key="TextControlMargin">0</Thickness>
        <Thickness x:Key="TextControlCompactPadding">0</Thickness>
        <Thickness x:Key="TextControlCompactMargin">0,-3,0,0</Thickness>
        <Thickness x:Key="DatePickerHostPadding">0,5,0,6</Thickness>
        <Thickness x:Key="DatePickerHostMonthPadding">9,5,0,6</Thickness>
    </SettingsExpander.Resources>
    <SettingsExpander.Action>
        <ItemEntryActionView />
    </SettingsExpander.Action>
    <SettingsExpander.Footer>
        <Grid>
            <DatePicker SelectedDate="{Binding Value}">
                <DatePicker.Styles>
                    <Style Selector="DatePicker.Write">
                        <Setter Property="MaxWidth" Value="{Binding Width}" />
                        <Setter Property="MinWidth" Value="{Binding Width}" />
                        <Setter Property="IsVisible" Value="True" />
                        <Setter Property="Height" Value="32" />
                    </Style>
                    <Style Selector="DatePicker.Read">
                        <Setter Property="MinWidth" Value="0" />
                        <Setter Property="MinHeight" Value="0" />
                        <Setter Property="IsVisible" Value="False" />
                    </Style>
                </DatePicker.Styles>
                <Interaction.Behaviors>
                    <DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.Read}">
                        <AddClassAction ClassName="Read" RemoveIfExists="True" />
                        <RemoveClassAction ClassName="Write" />
                    </DataTriggerBehavior>
                    <DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.New}">
                        <AddClassAction ClassName="Write" RemoveIfExists="True" />
                        <RemoveClassAction ClassName="Read" />
                    </DataTriggerBehavior>
                    <DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.Write}">
                        <AddClassAction ClassName="Write" RemoveIfExists="True" />
                        <RemoveClassAction ClassName="Read" />
                    </DataTriggerBehavior>
                </Interaction.Behaviors>
            </DatePicker>
            <TextBox Text="{Binding Value, StringFormat=d}">
                <TextBox.Styles>
                    <Style Selector="TextBox.Write">
                        <Setter Property="IsVisible" Value="False" />
                    </Style>
                    <Style Selector="TextBox.Read">
                        <Setter Property="MinWidth" Value="0" />
                        <Setter Property="IsReadOnly" Value="True" />
                        <Setter Property="BorderBrush" Value="Transparent" />
                        <Setter Property="Background" Value="Transparent" />
                        <Setter Property="IsVisible" Value="True" />
                        <Setter Property="Margin" Value="{StaticResource TextControlCompactMargin}" />
                        <Setter Property="Padding" Value="{StaticResource TextControlCompactPadding}" />
                        <Setter Property="MinHeight" Value="0" />
                        <Setter Property="Foreground">
                            <Setter.Value>
                                <SolidColorBrush Opacity="0.7" Color="{DynamicResource TextFillColorPrimary}" />
                            </Setter.Value>
                        </Setter>
                        <Style Selector="^:pointerover">
                            <Setter Property="Foreground">
                                <Setter.Value>
                                    <SolidColorBrush Opacity="0.7" Color="{DynamicResource TextFillColorPrimary}" />
                                </Setter.Value>
                            </Setter>
                            <Style Selector="^ /template/ Border#PART_BorderElement">
                                <Setter Property="BorderBrush" Value="Transparent" />
                                <Setter Property="Background" Value="Transparent" />
                            </Style>
                        </Style>
                        <Style Selector="^:focus">
                            <Setter Property="Foreground">
                                <Setter.Value>
                                    <SolidColorBrush Opacity="0.7" Color="{DynamicResource TextFillColorPrimary}" />
                                </Setter.Value>
                            </Setter>
                            <Style Selector="^ /template/ Border#PART_BorderElement">
                                <Setter Property="Background" Value="Transparent" />
                                <Setter Property="BorderBrush" Value="Transparent" />
                            </Style>
                        </Style>
                    </Style>
                </TextBox.Styles>
                <Interaction.Behaviors>
                    <DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.Read}">
                        <AddClassAction ClassName="Read" RemoveIfExists="True" />
                        <RemoveClassAction ClassName="Write" />
                    </DataTriggerBehavior>
                    <DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.New}">
                        <AddClassAction ClassName="Write" RemoveIfExists="True" />
                        <RemoveClassAction ClassName="Read" />
                    </DataTriggerBehavior>
                    <DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.Write}">
                        <AddClassAction ClassName="Write" RemoveIfExists="True" />
                        <RemoveClassAction ClassName="Read" />
                    </DataTriggerBehavior>
                </Interaction.Behaviors>
            </TextBox>
        </Grid>
    </SettingsExpander.Footer>
</SettingsExpander>
