Skip to content
Open
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
14 changes: 14 additions & 0 deletions src/ShadUI.Demo/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,20 @@
</Viewbox>
</shadui:SidebarItem.Icon>
</shadui:SidebarItem>
<shadui:SidebarItem
Command="{Binding OpenProgressBarCommand}"
Content="Progress Bar"
Route="progressBar"
ToolTip.Tip="{Binding $parent[shadui:Sidebar].Expanded, Converter={x:Static converters:BooleanConverters.NullOrString}, ConverterParameter='Sliders'}">
<shadui:SidebarItem.Icon>
<Viewbox>
<TextBlock
Classes="LucideIcon"
Foreground="{DynamicResource ForegroundColor}"
Text="&#xe61d;;" />
</Viewbox>
</shadui:SidebarItem.Icon>
</shadui:SidebarItem>
<shadui:SidebarItem
Command="{Binding OpenSwitchCommand}"
Content="Switch"
Expand Down
9 changes: 9 additions & 0 deletions src/ShadUI.Demo/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public sealed partial class MainWindowViewModel : ViewModelBase
private readonly ComboBoxViewModel _comboBoxViewModel;
private readonly SidebarViewModel _sidebarViewModel;
private readonly SliderViewModel _sliderViewModel;
private readonly ProgressBarViewModel _progressBarViewModel;
private readonly SwitchViewModel _switchViewModel;
private readonly ToastViewModel _toastViewModel;
private readonly ToggleViewModel _toggleViewModel;
Expand Down Expand Up @@ -65,6 +66,7 @@ public MainWindowViewModel(
ComboBoxViewModel comboBoxViewModel,
SidebarViewModel sidebarViewModel,
SliderViewModel sliderViewModel,
ProgressBarViewModel progressBarViewModel,
SwitchViewModel switchViewModel,
TimeViewModel timeViewModel,
ToastViewModel toastViewModel,
Expand Down Expand Up @@ -95,6 +97,7 @@ public MainWindowViewModel(
_comboBoxViewModel = comboBoxViewModel;
_sidebarViewModel = sidebarViewModel;
_sliderViewModel = sliderViewModel;
_progressBarViewModel = progressBarViewModel;
_switchViewModel = switchViewModel;
_timeViewModel = timeViewModel;
_toastViewModel = toastViewModel;
Expand Down Expand Up @@ -250,6 +253,12 @@ private void OpenSliders()
SwitchPage(_sliderViewModel);
}

[RelayCommand]
private void OpenProgressBar()
{
SwitchPage(_progressBarViewModel);
}

[RelayCommand]
private void OpenSwitch()
{
Expand Down
1 change: 1 addition & 0 deletions src/ShadUI.Demo/ServiceProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ namespace ShadUI.Demo;
[Transient<ListBoxViewModel>]
[Transient<SidebarViewModel>]
[Transient<SliderViewModel>]
[Transient<ProgressBarViewModel>]
[Transient<SwitchViewModel>]
[Transient<TabControlViewModel>]
[Transient<TimeViewModel>]
Expand Down
51 changes: 51 additions & 0 deletions src/ShadUI.Demo/ViewModels/ProgressBarViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System;
using System.IO;

namespace ShadUI.Demo.ViewModels;

[Page("progressBar")]
public sealed partial class ProgressBarViewModel : ViewModelBase, INavigable
{
private readonly PageManager _pageManager;

public ProgressBarViewModel(PageManager pageManager)
{
_pageManager = pageManager;

var xamlPath = Path.Combine(AppContext.BaseDirectory, "views", "ProgressBarPage.axaml");
DefaultProgressBar = xamlPath.ExtractByLineRange(58, 66).CleanIndentation();
SuccessProgressBar = xamlPath.ExtractByLineRange(72, 81).CleanIndentation();
InfoProgressBar = xamlPath.ExtractByLineRange(87, 96).CleanIndentation();
WarningProgressBar = xamlPath.ExtractByLineRange(102, 111).CleanIndentation();
DangerProgressBar = xamlPath.ExtractByLineRange(117, 126).CleanIndentation();
}

[RelayCommand]
private void BackPage()
{
_pageManager.Navigate<SidebarViewModel>();
}

[RelayCommand]
private void NextPage()
{
_pageManager.Navigate<SwitchViewModel>();
}

[ObservableProperty]
private string _defaultProgressBar = string.Empty;

[ObservableProperty]
private string _successProgressBar = string.Empty;

[ObservableProperty]
private string _infoProgressBar = string.Empty;

[ObservableProperty]
private string _warningProgressBar = string.Empty;

[ObservableProperty]
private string _dangerProgressBar = string.Empty;
}
31 changes: 28 additions & 3 deletions src/ShadUI.Demo/ViewModels/ToastViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System;
using System.Collections.ObjectModel;
using System.IO;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System.Threading.Tasks;

namespace ShadUI.Demo.ViewModels;

Expand All @@ -26,6 +27,7 @@ public ToastViewModel(PageManager pageManager, ToastManager toastManager)
WarningToastCode = WrapCode(path.ExtractByLineRange(122, 129).CleanIndentation());
ErrorToastCode = WrapCode(path.ExtractByLineRange(134, 141).CleanIndentation());
DynamicToastCode = WrapCode(path.ExtractByLineRange(148, 173).CleanIndentation());
DynamicToastCodeWithProgressBar = WrapCode(path.ExtractByLineRange(175, 197).CleanIndentation());
}

[RelayCommand]
Expand Down Expand Up @@ -170,4 +172,27 @@ private void ShowToastWithType()
.DismissOnClick()
.Show(SelectedNotification);
}

[ObservableProperty]
private Notification _selectedNotificationWithProgressBar;

[ObservableProperty]
private bool _isProgressIndeterminate = true;

[ObservableProperty]
private int _progressValue = 30;

[ObservableProperty]
private string _dynamicToastCodeWithProgressBar = string.Empty;

[RelayCommand]
private async Task ShowToastWithProgressBar()
{
_toastManager.CreateToast("Your message has been sent.")
.WithContent($"{DateTime.Now:dddd, MMMM d 'at' h:mm tt}")
.WithAction("Retry", () => _toastManager.CreateToast("Retry clicked").Show(Notification.Success))
.DismissOnClick()
.WithProgressBar(IsProgressIndeterminate, ProgressValue)
.Show(SelectedNotificationWithProgressBar);
}
}
132 changes: 132 additions & 0 deletions src/ShadUI.Demo/Views/ProgressBarPage.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<UserControl x:Class="ShadUI.Demo.Views.ProgressBarPage"
xmlns="https://github.com/avaloniaui"
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:viewModels="clr-namespace:ShadUI.Demo.ViewModels"
d:DesignHeight="2250"
d:DesignWidth="800"
x:DataType="viewModels:ProgressBarViewModel"
xmlns:controls="clr-namespace:ShadUI.Demo.Controls"
xmlns:shadui="clr-namespace:ShadUI;assembly=ShadUI">
<DockPanel LastChildFill="True">
<StackPanel
MaxWidth="{StaticResource PageMaxWidth}"
Margin="{StaticResource PageMargin}"
DockPanel.Dock="Top"
Spacing="4">
<Grid ColumnDefinitions="* Auto">
<TextBlock Classes="h2" Text="ProgressBar" />
<StackPanel
Grid.Column="1"
Orientation="Horizontal"
Spacing="8">
<Button
Width="28"
Height="28"
Background="{DynamicResource GhostHoverColor}"
Classes="Icon"
Command="{Binding BackPageCommand}">
<Viewbox Margin="6">
<TextBlock Classes="LucideIcon" Text="&#57420;" />
</Viewbox>
</Button>
<Button
Width="28"
Height="28"
Background="{DynamicResource GhostHoverColor}"
Classes="Icon"
Command="{Binding NextPageCommand}">
<Viewbox Margin="6">
<TextBlock Classes="LucideIcon" Text="&#57421;" />
</Viewbox>
</Button>
</StackPanel>
</Grid>
<TextBlock
Classes="p"
Text="Loading slider to notify users."
TextWrapping="Wrap" />
</StackPanel>
<ScrollViewer>
<StackPanel
MaxWidth="{StaticResource PageMaxWidth}"
Margin="{StaticResource PageMargin}"
Spacing="32">
<controls:ControlBlock Title="Default ProgressBar" Xaml="{Binding DefaultProgressBar}">
<StackPanel Spacing="15">
<ProgressBar ShowProgressText="True"
Width="300"
Maximum="100"
Minimum="0"
Value="90"/>

<ProgressBar ShowProgressText="False"
IsIndeterminate="True"
Width="300"/>
</StackPanel>
</controls:ControlBlock>

<controls:ControlBlock Title="Success ProgressBar" Xaml="{Binding SuccessProgressBar}">
<StackPanel Spacing="15">
<ProgressBar ShowProgressText="False"
Classes="Success"
Width="300"
Maximum="100"
Minimum="0"
Value="40"/>

<ProgressBar ShowProgressText="False"
IsIndeterminate="True"
Width="300" Classes="Success"/>
</StackPanel>
</controls:ControlBlock>

<controls:ControlBlock Title="Information ProgressBar" Xaml="{Binding InfoProgressBar}">
<StackPanel Spacing="15">
<ProgressBar ShowProgressText="False"
Classes="Info"
Width="300"
Maximum="100"
Minimum="0"
Value="50"/>

<ProgressBar ShowProgressText="False"
IsIndeterminate="True"
Width="300" Classes="Info"/>
</StackPanel>
</controls:ControlBlock>

<controls:ControlBlock Title="Warning ProgressBar" Xaml="{Binding WarningProgressBar}">
<StackPanel Spacing="15">
<ProgressBar ShowProgressText="True"
Classes="Warning"
Width="300"
Maximum="100"
Minimum="0"
Value="60"/>

<ProgressBar ShowProgressText="False"
IsIndeterminate="True"
Width="300" Classes="Warning"/>
</StackPanel>
</controls:ControlBlock>

<controls:ControlBlock Title="Error ProgressBar" Xaml="{Binding DangerProgressBar}">
<StackPanel Spacing="15">
<ProgressBar ShowProgressText="False"
Classes="Error"
Width="300"
Maximum="100"
Minimum="0"
Value="70"/>

<ProgressBar ShowProgressText="False"
IsIndeterminate="True"
Width="300" Classes="Error"/>
</StackPanel>
</controls:ControlBlock>
</StackPanel>
</ScrollViewer>
</DockPanel>
</UserControl>
11 changes: 11 additions & 0 deletions src/ShadUI.Demo/Views/ProgressBarPage.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Avalonia.Controls;

namespace ShadUI.Demo.Views;

public partial class ProgressBarPage : UserControl
{
public ProgressBarPage()
{
InitializeComponent();
}
}
33 changes: 32 additions & 1 deletion src/ShadUI.Demo/Views/ToastPage.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:shadui="clr-namespace:ShadUI;assembly=ShadUI"
xmlns:viewModels="clr-namespace:ShadUI.Demo.ViewModels"
d:DesignHeight="450"
d:DesignHeight="4250"
d:DesignWidth="800"
x:DataType="viewModels:ToastViewModel"
mc:Ignorable="d">
Expand Down Expand Up @@ -204,6 +204,37 @@
</shadui:Card.Footer>
</shadui:Card>
</controls:ControlBlock>
<controls:ControlBlock Title="Toast with ProgressBar" CSharp="{Binding DynamicToastCodeWithProgressBar}">
<shadui:Card HorizontalAlignment="Center">
<shadui:Card.Header>
<StackPanel>
<shadui:CardTitle>Notification</shadui:CardTitle>
<shadui:CardDescription>Send a notification to the client with progress bar</shadui:CardDescription>
</StackPanel>
</shadui:Card.Header>
<StackPanel Spacing="15" HorizontalAlignment="Center">
<StackPanel Spacing="10">
<CheckBox Content="Enable Progress Indeterminate"
IsChecked="{Binding IsProgressIndeterminate}"/>

<TextBox Watermark="Enter progress value" UseFloatingWatermark="True"
Text="{Binding ProgressValue}"/>
</StackPanel>

<ComboBox Width="225"
shadui:ControlAssist.Label="Selected Notification"
ItemsSource="{Binding NotificationsCollection, Mode=OneWay}"
SelectedItem="{Binding SelectedNotificationWithProgressBar, Mode=TwoWay}" />
</StackPanel>
<shadui:Card.Footer>
<Button
HorizontalAlignment="Right"
Classes="Primary"
Command="{Binding ShowToastWithProgressBarCommand}"
Content="Submit" />
</shadui:Card.Footer>
</shadui:Card>
</controls:ControlBlock>
</StackPanel>
</ScrollViewer>
</DockPanel>
Expand Down
Loading