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 @@ -275,6 +275,20 @@
</Viewbox>
</shadui:SidebarItem.Icon>
</shadui:SidebarItem>
<shadui:SidebarItem
Command="{Binding OpenPoupMaskCommand}"
Content="PopupMask"
Route="dialog"
ToolTip.Tip="{Binding $parent[shadui:Sidebar].Expanded, Converter={x:Static converters:BooleanConverters.NullOrString}, ConverterParameter='PopupMask'}">
<shadui:SidebarItem.Icon>
<Viewbox>
<TextBlock
Classes="LucideIcon"
Foreground="{DynamicResource ForegroundColor}"
Text="&#57627;" />
</Viewbox>
</shadui:SidebarItem.Icon>
</shadui:SidebarItem>
<shadui:SidebarItem
Command="{Binding OpenInputsCommand}"
Content="Input"
Expand Down
13 changes: 13 additions & 0 deletions src/ShadUI.Demo/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public sealed partial class MainWindowViewModel : ViewModelBase
private readonly DateViewModel _dateViewModel;
private readonly CheckBoxViewModel _checkBoxViewModel;
private readonly DialogViewModel _dialogViewModel;
private readonly PoupMaskViewModel _poupMaskViewModel;
private readonly TimeViewModel _timeViewModel;
private readonly InputViewModel _inputViewModel;
private readonly NumericViewModel _numericViewModel;
Expand Down Expand Up @@ -55,6 +56,7 @@ public MainWindowViewModel(
DateViewModel dateViewModel,
CheckBoxViewModel checkBoxViewModel,
DialogViewModel dialogViewModel,
PoupMaskViewModel poupMaskViewModel,
InputViewModel inputViewModel,
NumericViewModel numericViewModel,
MenuViewModel menuViewModel,
Expand Down Expand Up @@ -85,6 +87,7 @@ public MainWindowViewModel(
_dateViewModel = dateViewModel;
_checkBoxViewModel = checkBoxViewModel;
_dialogViewModel = dialogViewModel;
_poupMaskViewModel= poupMaskViewModel;
_inputViewModel = inputViewModel;
_numericViewModel = numericViewModel;
_menuViewModel = menuViewModel;
Expand Down Expand Up @@ -192,6 +195,16 @@ private void OpenDialogs()
{
SwitchPage(_dialogViewModel);
}
[RelayCommand]
private void OpenPoupMask()
{
SwitchPage(_poupMaskViewModel);
}
[RelayCommand]
private void OpenPopupMask()
{
SwitchPage(_dialogViewModel);
}

[RelayCommand]
private void OpenInputs()
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 @@ -34,6 +34,7 @@ namespace ShadUI.Demo;
[Transient<ColorViewModel>]
[Transient<DashboardViewModel>]
[Transient<DialogViewModel>]
[Transient<PoupMaskViewModel>]
[Transient<InputViewModel>]
[Transient<FormInputViewModel>]
[Transient<NumericViewModel>]
Expand Down
18 changes: 12 additions & 6 deletions src/ShadUI.Demo/ShadUI.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,29 @@
<ProjectReference Include="..\ShadUI\ShadUI.csproj"/>
</ItemGroup>

<ItemGroup>
<Compile Update="Views\PoupMaskPage.axaml.cs">
<DependentUpon>PoupMaskPage.axaml</DependentUpon>
</Compile>
</ItemGroup>

<Target Name="GenerateXamlTextCopies" BeforeTargets="PrepareForRun">
<ItemGroup>
<XamlFiles Include="Views\**\*.axaml"/>
</ItemGroup>

<Copy SourceFiles="@(XamlFiles)"
DestinationFiles="@(XamlFiles->'$(OutDir)views/%(RecursiveDir)%(Filename).axaml')"
SkipUnchangedFiles="true"/>
<Copy SourceFiles="@(XamlFiles)"
DestinationFiles="@(XamlFiles->'$(OutDir)views/%(RecursiveDir)%(Filename).axaml')"
SkipUnchangedFiles="true"/>
</Target>

<Target Name="GenerateCSharpTextCopies" BeforeTargets="PrepareForRun">
<ItemGroup>
<CSharpFiles Include="ViewModels\**\*.cs" Exclude="ViewModels\ViewModelBase.cs"/>
</ItemGroup>

<Copy SourceFiles="@(CSharpFiles)"
DestinationFiles="@(CSharpFiles->'$(OutDir)viewModels/%(RecursiveDir)%(Filename).cs')"
SkipUnchangedFiles="true"/>
<Copy SourceFiles="@(CSharpFiles)"
DestinationFiles="@(CSharpFiles->'$(OutDir)viewModels/%(RecursiveDir)%(Filename).cs')"
SkipUnchangedFiles="true"/>
</Target>
</Project>
128 changes: 128 additions & 0 deletions src/ShadUI.Demo/ViewModels/PoupMaskViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ShadUI.Demo.ViewModels
{
[Page("poupmask")]
public sealed partial class PoupMaskViewModel : ViewModelBase, INavigable
{
private readonly PageManager _pageManager;

private readonly ToastManager _toastManager;
private readonly LoginViewModel _loginViewModel;

public PoupMaskViewModel(
PageManager pageManager,
ToastManager toastManager,
LoginViewModel loginViewModel)
{
_pageManager = pageManager;
_userControlManager = new DialogManager();
_toastManager = toastManager;
_loginViewModel = loginViewModel;

var path = Path.Combine(AppContext.BaseDirectory, "viewModels", "DialogViewModel.cs");
AlertDialogCode = WrapCode(path.ExtractByLineRange(62, 78).CleanIndentation());
DestructiveAlertDialogCode = WrapCode(path.ExtractByLineRange(83, 100).CleanIndentation());
CustomDialogCode = WrapCode(path.ExtractByLineRange(105, 122).CleanIndentation());
}

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

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

private string WrapCode(string code)
{
return $"""
using CommunityToolkit.Mvvm.Input;

//..other code

{code}

//..rest of the code

""";
}

[ObservableProperty]
private string _alertDialogCode = string.Empty;
[ObservableProperty]
private DialogManager _userControlManager;

[RelayCommand]
private void ShowDialog()
{
_userControlManager
.CreateDialog(
"Are you absolutely sure?",
"This action cannot be undone. This will permanently delete your account and remove your data from our servers.")
.WithPrimaryButton("Continue",
() => _toastManager.CreateToast("Delete account")
.WithContent("Account deleted successfully!")
.DismissOnClick()
.ShowSuccess())
.WithCancelButton("Cancel")
.WithMaxWidth(512)
.Dismissible().Show();
}

[ObservableProperty]
private string _destructiveAlertDialogCode = string.Empty;

[RelayCommand]
private void ShowDestructiveStyleDialog()
{
_userControlManager
.CreateDialog(
"Are you absolutely sure?",
"This action cannot be undone. This will permanently delete your account and remove your data from our servers.")
.WithPrimaryButton("Continue",
() => _toastManager.CreateToast("Delete account")
.WithContent("Account deleted successfully!")
.DismissOnClick()
.ShowSuccess()
, DialogButtonStyle.Destructive)
.WithCancelButton("Cancel")
.WithMaxWidth(512)
.Dismissible()
.Show();
}

[ObservableProperty]
private string _customDialogCode = string.Empty;

[RelayCommand]
private void ShowCustomDialog()
{
_loginViewModel.Initialize();
_userControlManager.CreateDialog(_loginViewModel)
.Dismissible()
.WithSuccessCallback(vm =>
_toastManager.CreateToast("Sign in successful")
.WithContent($"Hi {vm.Email}, welcome back!")
.DismissOnClick()
.ShowSuccess())
.WithCancelCallback(() =>
_toastManager.CreateToast("Sign in cancelled")
.WithContent("Please sign in to continue.")
.DismissOnClick()
.ShowWarning())
.Show();
}
}
}
Loading