feat: redesign banner demo.
This commit is contained in:
@@ -4,58 +4,65 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:pages="clr-namespace:Ursa.Demo.Pages"
|
|
||||||
xmlns:u="https://irihi.tech/ursa"
|
xmlns:u="https://irihi.tech/ursa"
|
||||||
x:DataType="pages:BannerDemoViewModel"
|
xmlns:vm="clr-namespace:Ursa.Demo.ViewModels"
|
||||||
|
x:DataType="vm:BannerDemoViewModel"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<Design.DataContext>
|
<Design.DataContext>
|
||||||
<pages:BannerDemoViewModel />
|
<vm:BannerDemoViewModel />
|
||||||
</Design.DataContext>
|
</Design.DataContext>
|
||||||
<StackPanel Spacing="20">
|
<ScrollViewer>
|
||||||
<Grid ColumnDefinitions="*, 300">
|
<StackPanel Spacing="20">
|
||||||
<u:Banner
|
<u:Banner
|
||||||
Margin="20"
|
Name="banner"
|
||||||
Grid.Column="0"
|
|
||||||
Classes.Bordered="{Binding Bordered}"
|
Classes.Bordered="{Binding Bordered}"
|
||||||
CanClose="{Binding CanClose}"
|
Header="{Binding Title}"
|
||||||
Content="This is the Demo of Ursa Banner. "
|
Content="{Binding Content}" />
|
||||||
Header="Welcome to Ursa"
|
<u:Form Width="500">
|
||||||
Type="{Binding SelectedType}" />
|
<TextBox
|
||||||
<Border Grid.Column="1" VerticalAlignment="Top">
|
Classes="ClearButton"
|
||||||
<Grid ColumnDefinitions="*, Auto" RowDefinitions="*, *, *">
|
IsEnabled="{Binding SetTitleNull}"
|
||||||
<Label
|
Text="{Binding Title}">
|
||||||
Grid.Row="0"
|
<u:FormItem.Label>
|
||||||
Grid.Column="0"
|
<StackPanel Orientation="Horizontal">
|
||||||
VerticalAlignment="Center"
|
<CheckBox Content="Title" IsChecked="{Binding SetTitleNull}" />
|
||||||
Content="Type" />
|
</StackPanel>
|
||||||
<u:EnumSelector
|
</u:FormItem.Label>
|
||||||
Grid.Row="0"
|
</TextBox>
|
||||||
Grid.Column="1"
|
<TextBox
|
||||||
Width="200"
|
Classes="ClearButton TextArea"
|
||||||
EnumType="NotificationType"
|
IsEnabled="{Binding SetContentNull}"
|
||||||
Value="{Binding SelectedType}" />
|
Text="{Binding Content}"
|
||||||
<Label
|
TextWrapping="Wrap">
|
||||||
Grid.Row="1"
|
<u:FormItem.Label>
|
||||||
Grid.Column="0"
|
<CheckBox Content="Content" IsChecked="{Binding SetContentNull}" />
|
||||||
VerticalAlignment="Center"
|
</u:FormItem.Label>
|
||||||
Content="Bordered" />
|
</TextBox>
|
||||||
<ToggleSwitch
|
<u:EnumSelector
|
||||||
Grid.Row="1"
|
u:FormItem.Label="NotificationType"
|
||||||
Grid.Column="1"
|
EnumType="NotificationType"
|
||||||
VerticalAlignment="Center"
|
Value="{Binding #banner.Type}" />
|
||||||
IsChecked="{Binding Bordered}" />
|
<u:EnumSelector
|
||||||
<Label
|
u:FormItem.Label="HorizontalContentAlignment"
|
||||||
Grid.Row="2"
|
EnumType="HorizontalAlignment"
|
||||||
Grid.Column="0"
|
Value="{Binding #banner.HorizontalContentAlignment}" />
|
||||||
VerticalAlignment="Center"
|
<ToggleSwitch
|
||||||
Content="CanClose" />
|
Theme="{StaticResource SimpleToggleSwitch}"
|
||||||
<ToggleSwitch
|
u:FormItem.Label="Bordered"
|
||||||
Grid.Row="2"
|
IsChecked="{Binding Bordered}" />
|
||||||
Grid.Column="1"
|
<ToggleSwitch
|
||||||
VerticalAlignment="Center"
|
Theme="{StaticResource SimpleToggleSwitch}"
|
||||||
IsChecked="{Binding CanClose}" />
|
u:FormItem.Label="ShowIcon"
|
||||||
</Grid>
|
IsChecked="{Binding #banner.ShowIcon}" />
|
||||||
</Border>
|
<ToggleSwitch
|
||||||
</Grid>
|
Theme="{StaticResource SimpleToggleSwitch}"
|
||||||
</StackPanel>
|
u:FormItem.Label="CanClose"
|
||||||
|
IsChecked="{Binding #banner.CanClose}" />
|
||||||
|
<ToggleSwitch
|
||||||
|
Theme="{StaticResource SimpleToggleSwitch}"
|
||||||
|
u:FormItem.Label="IsVisible"
|
||||||
|
IsChecked="{Binding #banner.IsVisible}" />
|
||||||
|
</u:Form>
|
||||||
|
</StackPanel>
|
||||||
|
</ScrollViewer>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@@ -1,7 +1,4 @@
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Controls.Notifications;
|
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
|
||||||
using Ursa.Demo.ViewModels;
|
using Ursa.Demo.ViewModels;
|
||||||
|
|
||||||
namespace Ursa.Demo.Pages;
|
namespace Ursa.Demo.Pages;
|
||||||
@@ -13,16 +10,4 @@ public partial class BannerDemo : UserControl
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.DataContext = new BannerDemoViewModel();
|
this.DataContext = new BannerDemoViewModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public partial class BannerDemoViewModel : ViewModelBase
|
|
||||||
{
|
|
||||||
[ObservableProperty] private NotificationType _selectedType;
|
|
||||||
[ObservableProperty] private bool _bordered;
|
|
||||||
[ObservableProperty] private bool _canClose;
|
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,41 @@
|
|||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
|
||||||
namespace Ursa.Demo.ViewModels;
|
namespace Ursa.Demo.ViewModels;
|
||||||
|
|
||||||
public class BannerDemoViewModel: ViewModelBase
|
public partial class BannerDemoViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
|
private string? _oldTitle = string.Empty;
|
||||||
|
private string? _oldContent = string.Empty;
|
||||||
|
[ObservableProperty] private string? _title = "Welcome to Ursa";
|
||||||
|
[ObservableProperty] private string? _content = "This is the Demo of Ursa Banner.";
|
||||||
|
[ObservableProperty] private bool _bordered;
|
||||||
|
|
||||||
|
[ObservableProperty] private bool _setTitleNull = true;
|
||||||
|
[ObservableProperty] private bool _setContentNull = true;
|
||||||
|
|
||||||
|
partial void OnSetTitleNullChanged(bool value)
|
||||||
|
{
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
Title = _oldTitle;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_oldTitle = Title;
|
||||||
|
Title = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
partial void OnSetContentNullChanged(bool value)
|
||||||
|
{
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
Content = _oldContent;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_oldContent = Content;
|
||||||
|
Content = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user