WIP add image to item
This commit is contained in:
@@ -2,21 +2,84 @@
|
||||
x:Class="Wallet.Avalonia.ItemHeaderView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ui="using:FluentAvalonia.UI.Controls"
|
||||
xmlns:vm="using:Wallet"
|
||||
x:DataType="vm:ItemHeaderViewModel">
|
||||
<UserControl.Resources>
|
||||
<x:Double x:Key="PersonPictureSize">144</x:Double>
|
||||
<x:Double x:Key="ButtonSize">36</x:Double>
|
||||
<x:Double x:Key="TextBoxMaxWidth">360</x:Double>
|
||||
<x:Double x:Key="TextBoxMinWidth">264</x:Double>
|
||||
<Thickness x:Key="ButtonMargin">0,0,6,6</Thickness>
|
||||
<CornerRadius x:Key="ButtonCornerRadius">18</CornerRadius>
|
||||
</UserControl.Resources>
|
||||
<StackPanel Grid.Column="1" Spacing="12">
|
||||
<PersonPicture
|
||||
Width="144"
|
||||
Height="144"
|
||||
DisplayName="{Binding Value}" />
|
||||
<Grid HorizontalAlignment="Center">
|
||||
<PersonPicture
|
||||
Width="{StaticResource PersonPictureSize}"
|
||||
Height="{StaticResource PersonPictureSize}"
|
||||
DisplayName="{Binding Value}"
|
||||
ProfilePicture="{Binding ImageDescriptor.Image}" />
|
||||
<DropDownButton
|
||||
Width="{StaticResource ButtonSize}"
|
||||
Height="{StaticResource ButtonSize}"
|
||||
Margin="{StaticResource ButtonMargin}"
|
||||
Padding="0"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom"
|
||||
HorizontalContentAlignment="Center"
|
||||
VerticalContentAlignment="Center"
|
||||
CornerRadius="{StaticResource ButtonCornerRadius}">
|
||||
<DropDownButton.Styles>
|
||||
<Style Selector="DropDownButton.Write">
|
||||
<Setter Property="IsVisible" Value="True" />
|
||||
</Style>
|
||||
<Style Selector="DropDownButton.Read">
|
||||
<Setter Property="IsVisible" Value="False" />
|
||||
</Style>
|
||||
<Style Selector="DropDownButton /template/ ui|FontIcon#DropDownGlyph">
|
||||
<Setter Property="IsVisible" Value="False" />
|
||||
</Style>
|
||||
</DropDownButton.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>
|
||||
<DropDownButton.Flyout>
|
||||
<MenuFlyout>
|
||||
<MenuItem Command="{Binding ImportCommand}" Header="Import image" />
|
||||
<MenuItem
|
||||
Command="{Binding RemoveCommand}"
|
||||
Header="Remove image"
|
||||
IsEnabled="{Binding ImageDescriptor, Converter={x:Static ObjectConverters.IsNotNull}}" />
|
||||
</MenuFlyout>
|
||||
</DropDownButton.Flyout>
|
||||
<TextBlock
|
||||
Margin="0,3,0,0"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="{DynamicResource FluentThemeFontFamily}"
|
||||
FontSize="18"
|
||||
Text="" />
|
||||
</DropDownButton>
|
||||
</Grid>
|
||||
<TextBox
|
||||
MaxWidth="360"
|
||||
MaxWidth="{StaticResource TextBoxMaxWidth}"
|
||||
Text="{Binding Value}"
|
||||
TextAlignment="Center"
|
||||
Watermark="Enter name">
|
||||
<TextBox.Styles>
|
||||
<Style Selector="TextBox.Write">
|
||||
<Setter Property="MinWidth" Value="264" />
|
||||
<Setter Property="MinWidth" Value="{StaticResource TextBoxMinWidth}" />
|
||||
</Style>
|
||||
<Style Selector="TextBox.Read">
|
||||
<Setter Property="MinWidth" Value="0" />
|
||||
|
||||
@@ -24,10 +24,6 @@ public partial class CreateWalletViewModel :
|
||||
[ObservableProperty]
|
||||
private string password;
|
||||
|
||||
[MaybeNull]
|
||||
[ObservableProperty]
|
||||
private string? repeatedPassword;
|
||||
|
||||
[ObservableProperty]
|
||||
private IValidation validation;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Wallet;
|
||||
@@ -16,6 +17,8 @@ public partial class ItemHeaderViewModel :
|
||||
[ObservableProperty]
|
||||
private string? category;
|
||||
|
||||
[ObservableProperty]
|
||||
private IImageDescriptor? imageDescriptor;
|
||||
[ObservableProperty]
|
||||
private ItemState state;
|
||||
|
||||
@@ -49,14 +52,6 @@ public partial class ItemHeaderViewModel :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
if (configuration is not null)
|
||||
{
|
||||
configuration.Name = Value;
|
||||
}
|
||||
}
|
||||
|
||||
public Task Handle(ConfirmEventArgs<Item> args)
|
||||
{
|
||||
Commit();
|
||||
@@ -75,4 +70,19 @@ public partial class ItemHeaderViewModel :
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
public async Task Import() => ImageDescriptor = await Mediator.Handle<CreateEventArgs<ProfileImage>,
|
||||
IImageDescriptor>(Create.As<ProfileImage>());
|
||||
|
||||
[RelayCommand]
|
||||
public void Remove() => ImageDescriptor = null;
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
if (configuration is not null)
|
||||
{
|
||||
configuration.Name = Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user