Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unified design of the FeedBack category controls #532

Merged
merged 9 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 58 additions & 42 deletions demo/Ursa.Demo/Pages/BannerDemo.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,65 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pages="clr-namespace:Ursa.Demo.Pages"
xmlns:u="https://irihi.tech/ursa"
x:DataType="pages:BannerDemoViewModel"
xmlns:vm="clr-namespace:Ursa.Demo.ViewModels"
x:DataType="vm:BannerDemoViewModel"
mc:Ignorable="d">
<Design.DataContext>
<pages:BannerDemoViewModel />
<vm:BannerDemoViewModel />
</Design.DataContext>
<StackPanel Spacing="20">
<Grid ColumnDefinitions="*, 300">
<Grid Grid.Column="0">
<Border Margin="20">
<u:Banner
Classes.Bordered="{Binding Bordered}"
Content="This is the Demo of Ursa Banner. "
Header="Welcome to Ursa"
Type="{Binding SelectedType}" />
</Border>
</Grid>
<Border Grid.Column="1" VerticalAlignment="Top">
<Grid ColumnDefinitions="*, Auto" RowDefinitions="*, *">
<Label
Grid.Row="0"
Grid.Column="0"
VerticalAlignment="Center"
Content="Type" />
<ComboBox
Grid.Row="0"
Grid.Column="1"
MinWidth="200"
ItemsSource="{Binding Types}"
SelectedItem="{Binding SelectedType}" />
<Label
Grid.Row="1"
Grid.Column="0"
VerticalAlignment="Center"
Content="Bordered" />
<ToggleSwitch
Grid.Row="1"
Grid.Column="1"
VerticalAlignment="Center"
IsChecked="{Binding Bordered}" />
</Grid>
</Border>
</Grid>
</StackPanel>
</UserControl>
<ScrollViewer>
<StackPanel Spacing="20">
<u:Banner
Name="banner"
Classes.Bordered="{Binding Bordered}"
Header="{Binding Title}"
Content="{Binding Content}" />
<u:Form Width="500">
<TextBox
Classes="ClearButton"
IsEnabled="{Binding SetTitleNull}"
Text="{Binding Title}">
<u:FormItem.Label>
<StackPanel Orientation="Horizontal">
<CheckBox Content="Title" IsChecked="{Binding SetTitleNull}" />
</StackPanel>
</u:FormItem.Label>
</TextBox>
<TextBox
Classes="ClearButton TextArea"
IsEnabled="{Binding SetContentNull}"
Text="{Binding Content}"
TextWrapping="Wrap">
<u:FormItem.Label>
<CheckBox Content="Content" IsChecked="{Binding SetContentNull}" />
</u:FormItem.Label>
</TextBox>
<u:EnumSelector
u:FormItem.Label="NotificationType"
EnumType="NotificationType"
Value="{Binding #banner.Type}" />
<u:EnumSelector
u:FormItem.Label="HorizontalContentAlignment"
EnumType="HorizontalAlignment"
Value="{Binding #banner.HorizontalContentAlignment}" />
<ToggleSwitch
Theme="{StaticResource SimpleToggleSwitch}"
u:FormItem.Label="Bordered"
IsChecked="{Binding Bordered}" />
<ToggleSwitch
Theme="{StaticResource SimpleToggleSwitch}"
u:FormItem.Label="ShowIcon"
IsChecked="{Binding #banner.ShowIcon}" />
<ToggleSwitch
Theme="{StaticResource SimpleToggleSwitch}"
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>
43 changes: 0 additions & 43 deletions demo/Ursa.Demo/Pages/BannerDemo.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Collections.ObjectModel;
using Avalonia.Controls;
using Avalonia.Controls.Notifications;
using Avalonia.Markup.Xaml;
using Ursa.Demo.ViewModels;

namespace Ursa.Demo.Pages;
Expand All @@ -13,44 +10,4 @@ public BannerDemo()
InitializeComponent();
this.DataContext = new BannerDemoViewModel();
}

private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}

public class BannerDemoViewModel : ViewModelBase
{
private ObservableCollection<NotificationType>? _types;

public ObservableCollection<NotificationType>? Types
{
get => _types;
set => SetProperty(ref _types, value);
}

private NotificationType _selectedType;

public NotificationType SelectedType
{
get => _selectedType;
set => SetProperty(ref _selectedType, value);
}

private bool _bordered;

public bool Bordered
{
get => _bordered;
set => SetProperty(ref _bordered, value);
}

public BannerDemoViewModel()
{
Types = new ObservableCollection<NotificationType>()
{
NotificationType.Information, NotificationType.Success, NotificationType.Warning, NotificationType.Error
};
}
}
16 changes: 8 additions & 8 deletions demo/Ursa.Demo/Pages/MessageBoxDemo.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@
<UserControl.Styles>
<Style Selector="Button">
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="Margin" Value="8"></Setter>
<Setter Property="Margin" Value="8" />
</Style>
</UserControl.Styles>
<StackPanel HorizontalAlignment="Left">
<ComboBox ItemsSource="{Binding Icons}" SelectedItem="{Binding SelectedIcon}" />
<ToggleSwitch Content="Try Long Message" IsChecked="{Binding UseLong}"></ToggleSwitch>
<ToggleSwitch Content="Show Title" IsChecked="{Binding UseTitle}"></ToggleSwitch>
<ToggleSwitch Content="Overlay" IsChecked="{Binding UseOverlay}"></ToggleSwitch>
<ToggleSwitch Content="Try Long Message" IsChecked="{Binding UseLong}" />
<ToggleSwitch Content="Show Title" IsChecked="{Binding UseTitle}" />
<ToggleSwitch Content="Overlay" IsChecked="{Binding UseOverlay}" />
<Button Command="{Binding DefaultMessageBoxCommand}" Content="Default" />
<Button Command="{Binding OkCommand}" Content="OK" />
<Button Command="{Binding OkCancelCommand}" Content="OKCancel" />
<Button Command="{Binding YesNoCommand}" Content="YesNo" />
<Button Command="{Binding YesNoCancelCommand}" Content="YesNoCancel" />

<TextBlock>
<Run Text="Last Clicked Result: "></Run>
<Run Text="{Binding Result}"></Run>
<Run Text="Last Clicked Result: " />
<Run Text="{Binding Result}" />
</TextBlock>
</StackPanel>
</UserControl>
</UserControl>
39 changes: 37 additions & 2 deletions demo/Ursa.Demo/ViewModels/BannerDemoViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,41 @@
using CommunityToolkit.Mvvm.ComponentModel;

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;
}
}
}
45 changes: 45 additions & 0 deletions src/Ursa.Themes.Semi/Compatibles/Theme.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StaticResource x:Key="NotificationCloseButton" ResourceKey="OverlayCloseButton" />
<StaticResource x:Key="ToastCloseButton" ResourceKey="OverlayCloseButton" />

<ControlTheme x:Key="InnerPathIcon" TargetType="PathIcon">
<Setter Property="Height" Value="16" />
<Setter Property="Width" Value="16" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Template">
<ControlTemplate TargetType="PathIcon">
<Border Background="{TemplateBinding Background}">
<Viewbox
Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}">
<Path
Name="PART_Path"
Width="24"
Height="24"
Data="{TemplateBinding Data}"
Fill="{TemplateBinding Foreground}" />
</Viewbox>
</Border>
</ControlTemplate>
</Setter>
<Style Selector="^.Active /template/ Path#PART_Path">
<Setter Property="Fill" Value="{Binding BorderBrush,RelativeSource={RelativeSource TemplatedParent}}" />
</Style>
<Style Selector="^.ExtraSmall">
<Setter Property="Height" Value="8" />
<Setter Property="Width" Value="8" />
</Style>
<Style Selector="^.Small">
<Setter Property="Height" Value="12" />
<Setter Property="Width" Value="12" />
</Style>
<Style Selector="^.Large">
<Setter Property="Height" Value="20" />
<Setter Property="Width" Value="20" />
</Style>
<Style Selector="^.ExtraLarge">
<Setter Property="Height" Value="24" />
<Setter Property="Width" Value="24" />
</Style>
</ControlTheme>
</ResourceDictionary>
1 change: 1 addition & 0 deletions src/Ursa.Themes.Semi/Compatibles/_index.axaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceInclude Source="/Compatibles/Icon.axaml" />
<ResourceInclude Source="/Compatibles/Theme.axaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Loading
Loading