1
+ using CommunityToolkit . Maui . Core ;
1
2
using CommunityToolkit . Maui . Sample . Models ;
2
3
using CommunityToolkit . Maui . Sample . ViewModels . Views ;
3
4
using CommunityToolkit . Maui . Sample . Views . Popups ;
@@ -7,70 +8,59 @@ namespace CommunityToolkit.Maui.Sample.Pages.Views;
7
8
8
9
public partial class MultiplePopupPage : BasePage < MultiplePopupViewModel >
9
10
{
10
- readonly PopupSizeConstants popupSizeConstants ;
11
+ readonly IPopupService popupService ;
11
12
12
- public MultiplePopupPage ( PopupSizeConstants popupSizeConstants ,
13
- MultiplePopupViewModel multiplePopupViewModel )
13
+ public MultiplePopupPage ( MultiplePopupViewModel multiplePopupViewModel , IPopupService popupService )
14
14
: base ( multiplePopupViewModel )
15
15
{
16
+ this . popupService = popupService ;
16
17
InitializeComponent ( ) ;
17
-
18
- this . popupSizeConstants = popupSizeConstants ;
19
18
}
20
19
21
20
async void HandleSimplePopupButtonClicked ( object sender , EventArgs e )
22
21
{
23
- var simplePopup = new SimplePopup ( popupSizeConstants ) ;
24
- await this . ShowPopupAsync ( simplePopup , CancellationToken . None ) ;
22
+ await popupService . ShowPopupAsync < SimplePopup > ( new PopupOptions ( ) , CancellationToken . None ) ;
25
23
}
26
24
27
25
async void HandleButtonPopupButtonClicked ( object sender , EventArgs e )
28
26
{
29
- var buttonPopup = new ButtonPopup ( popupSizeConstants ) ;
30
- await this . ShowPopupAsync ( buttonPopup , CancellationToken . None ) ;
27
+ await popupService . ShowPopupAsync < ButtonPopup > ( new PopupOptions ( ) , CancellationToken . None ) ;
31
28
}
32
29
33
30
async void HandleMultipleButtonPopupButtonClicked ( object sender , EventArgs e )
34
31
{
35
- var multipleButtonPopup = new MultipleButtonPopup ( popupSizeConstants ) ;
36
- await this . ShowPopupAsync ( multipleButtonPopup , CancellationToken . None ) ;
32
+ await popupService . ShowPopupAsync < MultipleButtonPopup > ( new PopupOptions ( ) , CancellationToken . None ) ;
37
33
}
38
34
39
35
async void HandleNoOutsideTapDismissPopupClicked ( object sender , EventArgs e )
40
36
{
41
- var noOutsideTapDismissPopup = new NoOutsideTapDismissPopup ( popupSizeConstants ) ;
42
- await this . ShowPopupAsync ( noOutsideTapDismissPopup , CancellationToken . None ) ;
37
+ await popupService . ShowPopupAsync < NoOutsideTapDismissPopup > ( new PopupOptions ( ) { CanBeDismissedByTappingOutsideOfPopup = false } , CancellationToken . None ) ;
43
38
}
44
39
45
40
async void HandleToggleSizePopupButtonClicked ( object sender , EventArgs e )
46
41
{
47
- var toggleSizePopup = new ToggleSizePopup ( popupSizeConstants ) ;
48
- await this . ShowPopupAsync ( toggleSizePopup , CancellationToken . None ) ;
42
+ await popupService . ShowPopupAsync < ToggleSizePopup > ( new PopupOptions ( ) , CancellationToken . None ) ;
49
43
}
50
44
51
45
async void HandleTransparentPopupButtonClicked ( object sender , EventArgs e )
52
46
{
53
- var transparentPopup = new TransparentPopup ( ) ;
54
- await this . ShowPopupAsync ( transparentPopup , CancellationToken . None ) ;
47
+ await popupService . ShowPopupAsync < TransparentPopup > ( new PopupOptions ( ) , CancellationToken . None ) ;
55
48
}
56
49
57
50
async void HandleOpenedEventSimplePopupButtonClicked ( object sender , EventArgs e )
58
51
{
59
- var openedEventSimplePopup = new OpenedEventSimplePopup ( popupSizeConstants ) ;
60
- await this . ShowPopupAsync ( openedEventSimplePopup , CancellationToken . None ) ;
52
+ await popupService . ShowPopupAsync < OpenedEventSimplePopup > ( new PopupOptions ( ) , CancellationToken . None ) ;
61
53
}
62
54
63
55
async void HandleReturnResultPopupButtonClicked ( object sender , EventArgs e )
64
56
{
65
- var returnResultPopup = new ReturnResultPopup ( popupSizeConstants ) ;
66
- var result = await this . ShowPopupAsync ( returnResultPopup , CancellationToken . None ) ;
57
+ var result = await popupService . ShowPopupAsync < ReturnResultPopup , bool > ( new PopupOptions ( ) , CancellationToken . None ) ;
67
58
68
- await DisplayAlert ( "Pop Result Returned" , $ "Result: { result } ", "OK" ) ;
59
+ await DisplayAlert ( "Pop Result Returned" , $ "Result: { result . Result } ", "OK" ) ;
69
60
}
70
61
71
62
async void HandleXamlBindingPopupPopupButtonClicked ( object sender , EventArgs e )
72
63
{
73
- var xamlBindingPopup = new XamlBindingPopup ( popupSizeConstants ) ;
74
- await this . ShowPopupAsync ( xamlBindingPopup , CancellationToken . None ) ;
64
+ await popupService . ShowPopupAsync < XamlBindingPopup > ( new PopupOptions ( ) , CancellationToken . None ) ;
75
65
}
76
66
}
0 commit comments