feat: make drawer api similar to dialog.
This commit is contained in:
@@ -23,13 +23,13 @@
|
||||
OffContent="Local"
|
||||
OnContent="Global" />
|
||||
<ToggleSwitch
|
||||
Content="ShowMask"
|
||||
IsChecked="{Binding ShowMask}"
|
||||
Content="Modal"
|
||||
IsChecked="{Binding IsModal}"
|
||||
OffContent="No"
|
||||
OnContent="Yes" />
|
||||
<ToggleSwitch
|
||||
Content="ClickOnMaskToClose"
|
||||
IsChecked="{Binding CanCloseMaskToClose}"
|
||||
Content="CanLightDismiss"
|
||||
IsChecked="{Binding CanLightDismiss}"
|
||||
OffContent="No"
|
||||
OnContent="Yes" />
|
||||
<StackPanel Orientation="Horizontal">
|
||||
@@ -56,13 +56,13 @@
|
||||
OffContent="Local"
|
||||
OnContent="Global" />
|
||||
<ToggleSwitch
|
||||
Content="ClickOnMaskToClose"
|
||||
IsChecked="{Binding CanCloseMaskToClose}"
|
||||
Content="CanLightDismiss"
|
||||
IsChecked="{Binding CanLightDismiss}"
|
||||
OffContent="No"
|
||||
OnContent="Yes" />
|
||||
<ToggleSwitch
|
||||
Content="ShowMask"
|
||||
IsChecked="{Binding ShowMask}"
|
||||
Content="Modal"
|
||||
IsChecked="{Binding IsModal}"
|
||||
OffContent="No"
|
||||
OnContent="Yes" />
|
||||
<Button Command="{Binding ShowCustomDialogCommand}" Content="Show Custom Drawer" />
|
||||
|
||||
@@ -20,10 +20,10 @@ public partial class DrawerDemoViewModel: ObservableObject
|
||||
[ObservableProperty] private Position _selectedPosition;
|
||||
[ObservableProperty] private DialogButton _selectedButton;
|
||||
[ObservableProperty] private bool _isGlobal;
|
||||
[ObservableProperty] private bool _canCloseMaskToClose;
|
||||
[ObservableProperty] private bool _canLightDismiss;
|
||||
[ObservableProperty] private DialogResult? _defaultResult;
|
||||
[ObservableProperty] private bool _result;
|
||||
[ObservableProperty] private bool _showMask;
|
||||
[ObservableProperty] private bool _isModal;
|
||||
[ObservableProperty] private DateTime? _date;
|
||||
|
||||
|
||||
@@ -36,32 +36,60 @@ public partial class DrawerDemoViewModel: ObservableObject
|
||||
private async Task ShowDefaultDialog()
|
||||
{
|
||||
var vm = new PlainDialogViewModel();
|
||||
DefaultResult = await Drawer.Show<PlainDialog, PlainDialogViewModel>(
|
||||
vm,
|
||||
IsGlobal ? null : "LocalHost",
|
||||
new DefaultDrawerOptions()
|
||||
{
|
||||
Title = "Please select a date",
|
||||
Position = SelectedPosition,
|
||||
Buttons = SelectedButton,
|
||||
CanClickOnMaskToClose = CanCloseMaskToClose,
|
||||
ShowMask = ShowMask,
|
||||
});
|
||||
Date = vm.Date;
|
||||
if (IsModal)
|
||||
{
|
||||
DefaultResult = await Drawer.ShowModal<PlainDialog, PlainDialogViewModel>(
|
||||
vm,
|
||||
IsGlobal ? null : "LocalHost",
|
||||
new DrawerOptions()
|
||||
{
|
||||
Title = "Please select a date",
|
||||
Position = SelectedPosition,
|
||||
Buttons = SelectedButton,
|
||||
CanLightDismiss = CanLightDismiss,
|
||||
});
|
||||
Date = vm.Date;
|
||||
}
|
||||
else
|
||||
{
|
||||
Drawer.Show<PlainDialog, PlainDialogViewModel>(
|
||||
vm,
|
||||
IsGlobal ? null : "LocalHost",
|
||||
new DrawerOptions()
|
||||
{
|
||||
Title = "Please select a date",
|
||||
Position = SelectedPosition,
|
||||
Buttons = SelectedButton,
|
||||
CanLightDismiss = CanLightDismiss,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ShowCustomDrawer()
|
||||
{
|
||||
var vm = new DialogWithActionViewModel();
|
||||
Result = await Drawer.ShowCustom<DialogWithAction, DialogWithActionViewModel, bool>(
|
||||
vm,
|
||||
IsGlobal ? null : "LocalHost",
|
||||
new CustomDrawerOptions()
|
||||
{
|
||||
Position = SelectedPosition,
|
||||
CanClickOnMaskToClose = CanCloseMaskToClose,
|
||||
ShowMask = ShowMask,
|
||||
});
|
||||
Date = vm.Date;
|
||||
if (IsModal)
|
||||
{
|
||||
Result = await Drawer.ShowCustomModal<DialogWithAction, DialogWithActionViewModel, bool>(
|
||||
vm,
|
||||
IsGlobal ? null : "LocalHost",
|
||||
new DrawerOptions()
|
||||
{
|
||||
Position = SelectedPosition,
|
||||
CanLightDismiss = CanLightDismiss,
|
||||
});
|
||||
Date = vm.Date;
|
||||
}
|
||||
else
|
||||
{
|
||||
Drawer.ShowCustom<DialogWithAction, DialogWithActionViewModel>(
|
||||
vm,
|
||||
IsGlobal ? null : "LocalHost",
|
||||
new DrawerOptions()
|
||||
{
|
||||
Position = SelectedPosition,
|
||||
CanLightDismiss = CanLightDismiss,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,8 @@
|
||||
Title="Ursa.PrismDialogDemo">
|
||||
<Grid>
|
||||
<StackPanel>
|
||||
<Button Click="Button_OnClick">Show Dialog</Button>
|
||||
<Button Click="DialogButton_OnClick">Show Dialog</Button>
|
||||
<Button Click="DrawerButton_OnClick"></Button>
|
||||
</StackPanel>
|
||||
<u:OverlayDialogHost/>
|
||||
</Grid>
|
||||
|
||||
@@ -7,15 +7,22 @@ namespace Ursa.PrismDialogDemo;
|
||||
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private IUrsaOverlayDialogService _ursa;
|
||||
public MainWindow(IUrsaOverlayDialogService ursa)
|
||||
private IUrsaOverlayDialogService _dialogService;
|
||||
private IUrsaDrawerService _drawerService;
|
||||
public MainWindow(IUrsaOverlayDialogService dialogService, IUrsaDrawerService drawerService)
|
||||
{
|
||||
InitializeComponent();
|
||||
_ursa = ursa;
|
||||
_dialogService = dialogService;
|
||||
_drawerService = drawerService;
|
||||
}
|
||||
|
||||
private void Button_OnClick(object? sender, RoutedEventArgs e)
|
||||
private void DialogButton_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
_ursa.ShowModal("Default", null, null, null);
|
||||
_dialogService.ShowModal("Default", null, null, null);
|
||||
}
|
||||
|
||||
private void DrawerButton_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
_drawerService.ShowModal("Default", null, null, null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user