@@ -18,7 +18,7 @@ public PopoverGallery ()
18
18
layout . RowDefinitions . Add ( new RowDefinition { Height = GridLength . Star } ) ;
19
19
layout . RowDefinitions . Add ( new RowDefinition { Height = GridLength . Auto } ) ;
20
20
21
- var top = new StackLayout { Children = { PopoverWithLabel ( ) , PopoverWithLayout ( ) , TermsOfServicePopup ( ) } } ;
21
+ var top = new StackLayout { Children = { PopoverWithLabel ( ) , PopoverWithLayout ( ) , PopoverWithCloseButtonLayout ( ) , PopoverWithCloseButtonLayoutNoSize ( ) , TermsOfServicePopup ( ) } } ;
22
22
Grid . SetRow ( top , 0 ) ;
23
23
24
24
// Putting one of the buttons on the bottom so if we're on the iPad we can see the little popover arrows working
@@ -31,33 +31,31 @@ public PopoverGallery ()
31
31
Content = layout ;
32
32
}
33
33
34
- Button CreateButton ( string text , string automationId , View content )
34
+ Button CreateButton ( string text , string automationId , View content , Color color , bool isAnchored = false , Size size = default ( Size ) , Color border = default ( Color ) )
35
35
{
36
36
var button = new Button { Text = text , AutomationId = automationId } ;
37
37
button . Clicked += async ( sender , e ) =>
38
38
{
39
- var popover = new Popup ( content , text , anchor : button ) ;
39
+ var popover = isAnchored ?
40
+ new Popup ( content ) { Anchor = button , Size = size , Color = color , BorderColor = border } :
41
+ new Popup ( content ) { Size = size , Color = color , BorderColor = border } ;
40
42
41
43
var result = await Navigation . ShowPopup ( popover ) ;
42
44
43
- await DisplayAlert ( ResultTitle , result . ToString ( ) , DismissText ) ;
45
+ await DisplayAlert ( ResultTitle , "Popup Dismissed" , DismissText ) ;
44
46
} ;
45
47
46
48
return button ;
47
49
}
48
50
49
51
Button PopoverWithLabel ( )
50
52
{
51
- return CreateButton ( "Popup with Label" , "testPopupWithLabel" ,
52
- new Label
53
- {
54
- Text = "This is just a Label inside of a Popup. This is a basic popup which takes a View, and is only light-dismissable." ,
55
- LineBreakMode = LineBreakMode . WordWrap ,
56
- HorizontalTextAlignment = TextAlignment . Center ,
57
- VerticalTextAlignment = TextAlignment . Center ,
58
- HorizontalOptions = LayoutOptions . Fill ,
59
- VerticalOptions = LayoutOptions . Fill
60
- } ) ;
53
+ var button = new Button
54
+ {
55
+ Text = "Label Popovers"
56
+ } ;
57
+ button . Clicked += async ( s , e ) => await Navigation . PushAsync ( new PopupLabelGallery ( ) ) ;
58
+ return button ;
61
59
}
62
60
63
61
Button PopoverWithLayout ( )
@@ -73,7 +71,51 @@ Button PopoverWithLayout()
73
71
}
74
72
} ;
75
73
76
- return CreateButton ( "Popup with Layout" , "testPopupWithLayout" , content ) ;
74
+ return CreateButton ( "Popup with Layout" , "testPopupWithLayout" , content , Color . White , size : new Size ( 800 , 800 ) ) ;
75
+ }
76
+
77
+ Button PopoverWithCloseButtonLayout ( )
78
+ {
79
+ var content = new Grid
80
+ {
81
+ Margin = new Thickness ( 20 ) ,
82
+ Padding = new Thickness ( 20 ) ,
83
+ Children =
84
+ {
85
+ new Label { LineBreakMode = LineBreakMode . WordWrap , Text = Placeholder , BackgroundColor = Color . White } ,
86
+ new Frame
87
+ {
88
+ HorizontalOptions = new LayoutOptions ( LayoutAlignment . Center , true ) ,
89
+ VerticalOptions = new LayoutOptions ( LayoutAlignment . Start , true ) ,
90
+ Margin = new Thickness ( 0 , - 30 , 0 , 0 ) ,
91
+ BackgroundColor = Color . Orange
92
+ }
93
+ }
94
+ } ;
95
+
96
+ return CreateButton ( "Popup with Close Button Layout" , "testPopupWithCloseButtonLayout" , content , Color . Transparent , size : new Size ( 500 , 500 ) , border : Color . Transparent ) ;
97
+ }
98
+
99
+ Button PopoverWithCloseButtonLayoutNoSize ( )
100
+ {
101
+ var content = new Grid
102
+ {
103
+ Margin = new Thickness ( 20 ) ,
104
+ Padding = new Thickness ( 20 ) ,
105
+ Children =
106
+ {
107
+ new Label { LineBreakMode = LineBreakMode . WordWrap , Text = Placeholder , BackgroundColor = Color . White } ,
108
+ new Frame
109
+ {
110
+ HorizontalOptions = new LayoutOptions ( LayoutAlignment . Center , true ) ,
111
+ VerticalOptions = new LayoutOptions ( LayoutAlignment . Start , true ) ,
112
+ Margin = new Thickness ( 0 , - 30 , 0 , 0 ) ,
113
+ BackgroundColor = Color . Orange
114
+ }
115
+ }
116
+ } ;
117
+
118
+ return CreateButton ( "Popup with Close Button Layout No Size" , "testPopupWithCloseButtonLayout" , content , Color . Transparent , border : Color . Transparent ) ;
77
119
}
78
120
79
121
@@ -84,7 +126,7 @@ Button PopoverWithDatePicker()
84
126
button . Clicked += async ( sender , e ) =>
85
127
{
86
128
// Create a DateChooserPopup which uses DateChooserPopupControl as its content and is anchored to this button
87
- var popup = new DateChooserPopup ( new DateChooserPopupControl ( ) , "Select Date" , button ) ;
129
+ var popup = new DateChooserPopup ( new DateChooserPopupControl ( ) , button ) ;
88
130
89
131
// Show the popup and await the DateTime? result
90
132
DateTime ? result = await Navigation . ShowPopup ( popup ) ;
@@ -98,10 +140,11 @@ Button PopoverWithDatePicker()
98
140
99
141
class DateChooserPopup : Popup < DateTime ? >
100
142
{
101
- public DateChooserPopup ( IPopupView < DateTime ? > popupView , string title = null , View anchor = null )
102
- : base ( popupView , title , false , anchor )
143
+ public DateChooserPopup ( View popupView , View anchor = null , Size size = default ( Size ) )
103
144
{
104
- // Note that this popup is not light-dismissable
145
+ View = popupView ;
146
+ Anchor = anchor ;
147
+ Size = size ;
105
148
}
106
149
107
150
protected override DateTime ? OnLightDismissed ( )
@@ -148,6 +191,7 @@ public DateChooserPopupControl()
148
191
}
149
192
}
150
193
194
+ // TODO - This does not work in UWP for some reason, it needs more investigation
151
195
Button TermsOfServicePopup ( )
152
196
{
153
197
var button = new Button { Text = "Terms of Service Popup" } ;
@@ -160,13 +204,16 @@ Button TermsOfServicePopup()
160
204
+ string . Concat ( Enumerable . Repeat ( Placeholder + "\n " , 10 ) )
161
205
} ;
162
206
163
- var scrollView = new ScrollView { Content = tos , Margin = new Thickness ( 20 ) } ;
207
+ var scrollView = new ScrollView { Content = tos , Margin = new Thickness ( 20 ) , HorizontalOptions = new LayoutOptions ( LayoutAlignment . Center , true ) } ;
208
+
209
+
164
210
165
- // Create the popup, specifying the text for the buttons
166
- var tosPopup = new BinaryResultPopup ( scrollView , "Terms of Service" , anchor : button , affirmativeText : "Accept" , negativeText : "Reject" , size : new Size ( 400 , 500 ) ) ;
167
211
168
212
button . Clicked += async ( sender , args ) =>
169
213
{
214
+ // Create the popup, specifying the text for the buttons
215
+ var tosPopup = new BooleanPopup ( scrollView , anchor : button , affirmativeText : "Accept" , negativeText : "Reject" , size : new Size ( 800 , 400 ) ) ;
216
+
170
217
// Reset the popup in case we've already gotten a result from it
171
218
tosPopup . Reset ( ) ;
172
219
0 commit comments