1
1
using System . Globalization ;
2
2
using Syncfusion . Maui . Toolkit . Calendar ;
3
3
using Syncfusion . Maui . Toolkit . Buttons ;
4
- using Syncfusion . Maui . Toolkit . Popup ;
5
4
using Color = Microsoft . Maui . Graphics . Color ;
6
5
7
6
namespace Syncfusion . Maui . ControlsGallery . Calendar . Calendar
@@ -28,13 +27,6 @@ public partial class AppointmentBooking : SampleView
28
27
public AppointmentBooking ( )
29
28
{
30
29
InitializeComponent ( ) ;
31
-
32
- if ( popUp != null )
33
- {
34
- popUp . FooterTemplate = GetFooterTemplate ( popUp ) ;
35
- popUp . ContentTemplate = GetContentTemplate ( popUp ) ;
36
- }
37
-
38
30
#if MACCATALYST
39
31
border . IsVisible = true ;
40
32
border . Stroke = Colors . Transparent ;
@@ -57,128 +49,6 @@ public AppointmentBooking()
57
49
#endif
58
50
}
59
51
60
- /// <summary>
61
- /// Method to get the dynamic color.
62
- /// </summary>
63
- /// <param name="resourceName">The resource name.</param>
64
- /// <returns>The color.</returns>
65
- Color GetDynamicColor ( string ? resourceName = null )
66
- {
67
- if ( resourceName != null && App . Current != null && App . Current . Resources . TryGetValue ( resourceName , out var colorValue ) && colorValue is Color color )
68
- {
69
- return color ;
70
- }
71
- else
72
- {
73
- if ( App . Current != null && App . Current . RequestedTheme == AppTheme . Light )
74
- {
75
- return Color . FromRgb ( 0xFF , 0xFF , 0xFF ) ;
76
- }
77
- else if ( App . Current != null && App . Current . RequestedTheme == AppTheme . Dark )
78
- {
79
- return Color . FromRgb ( 0x38 , 0x1E , 0x72 ) ;
80
- }
81
- }
82
-
83
- return Colors . Transparent ;
84
- }
85
-
86
- /// <summary>
87
- /// Method to get the Ok button style.
88
- /// </summary>
89
- /// <returns>The button style.</returns>
90
- Style GetOkButtonStyle ( )
91
- {
92
- return new Style ( typeof ( Button ) )
93
- {
94
- Setters =
95
- {
96
- new Setter { Property = Button . CornerRadiusProperty , Value = 15 } ,
97
- new Setter { Property = Button . BorderColorProperty , Value = Color . FromArgb ( "#6750A4" ) } ,
98
- new Setter { Property = Button . BorderWidthProperty , Value = 1 } ,
99
- new Setter { Property = Button . BackgroundColorProperty , Value = GetDynamicColor ( "SfCalendarTodayHighlightColor" ) } ,
100
- new Setter { Property = Button . TextColorProperty , Value = GetDynamicColor ( ) } ,
101
- new Setter { Property = Button . FontSizeProperty , Value = 14 } ,
102
- }
103
- } ;
104
- }
105
-
106
- /// <summary>
107
- /// Method to get the footer template.
108
- /// </summary>
109
- /// <param name="popup">The pop up.</param>
110
- /// <returns>The data template.</returns>
111
- DataTemplate GetFooterTemplate ( SfPopup popup )
112
- {
113
- var footerTemplate = new DataTemplate ( ( ) =>
114
- {
115
- var grid = new Grid
116
- {
117
- ColumnSpacing = 12 ,
118
- Padding = new Thickness ( 24 )
119
- } ;
120
- grid . ColumnDefinitions . Add ( new ColumnDefinition { Width = GridLength . Star } ) ;
121
- grid . ColumnDefinitions . Add ( new ColumnDefinition { Width = GridLength . Star } ) ;
122
- var oKButton = new Button
123
- {
124
- Text = "OK" ,
125
- Style = GetOkButtonStyle ( ) ,
126
- WidthRequest = 96 ,
127
- HeightRequest = 40
128
- } ;
129
- oKButton . Clicked += ( sender , args ) =>
130
- {
131
- popup . Dismiss ( ) ;
132
- } ;
133
- grid . Children . Add ( oKButton ) ;
134
- Grid . SetColumn ( oKButton , 1 ) ;
135
- return grid ;
136
- } ) ;
137
-
138
- return footerTemplate ;
139
- }
140
-
141
- /// <summary>
142
- /// Method to get the content template.
143
- /// </summary>
144
- /// <param name="popup">The pop up.</param>
145
- /// <returns>The data template.</returns>
146
- DataTemplate GetContentTemplate ( SfPopup popup )
147
- {
148
- var contentTemplate = new DataTemplate ( ( ) =>
149
- {
150
- var grid = new Grid ( ) ;
151
- grid . RowDefinitions . Add ( new RowDefinition { Height = GridLength . Star } ) ;
152
- grid . RowDefinitions . Add ( new RowDefinition { Height = new GridLength ( 0.1 , GridUnitType . Star ) } ) ;
153
- var label = new Label
154
- {
155
- LineBreakMode = LineBreakMode . WordWrap ,
156
- Padding = new Thickness ( 20 , 0 , 0 , 0 ) ,
157
- FontSize = 16 ,
158
- HorizontalOptions = LayoutOptions . Start ,
159
- HorizontalTextAlignment = TextAlignment . Start ,
160
- WidthRequest = 300 ,
161
- } ;
162
-
163
- label . BindingContext = popup ;
164
- label . SetBinding ( Label . TextProperty , "Message" ) ;
165
- var stackLayout = new StackLayout
166
- {
167
- Margin = new Thickness ( 0 , 2 , 0 , 0 ) ,
168
- HeightRequest = 1 ,
169
- } ;
170
-
171
- stackLayout . BackgroundColor = _isLightTheme ? Color . FromArgb ( "#611c1b1f" ) : Color . FromArgb ( "#61e6e1e5" ) ;
172
- grid . Children . Add ( label ) ;
173
- grid . Children . Add ( stackLayout ) ;
174
- Grid . SetRow ( label , 0 ) ;
175
- Grid . SetRow ( stackLayout , 1 ) ;
176
- return grid ;
177
- } ) ;
178
-
179
- return contentTemplate ;
180
- }
181
-
182
52
/// <summary>
183
53
/// Initialize the calendar.
184
54
/// </summary>
@@ -265,8 +135,6 @@ void AppointmentanBooking(object sender, EventArgs e)
265
135
BookAppointment ( mobileAppointmentBooking , mobileFlexLayout ) ;
266
136
}
267
137
#endif
268
-
269
- popUp . Show ( ) ;
270
138
}
271
139
272
140
/// <summary>
@@ -276,29 +144,22 @@ void AppointmentanBooking(object sender, EventArgs e)
276
144
/// <param name="buttonLayout">Time slot button layout.</param>
277
145
void BookAppointment ( SfCalendar calendar , FlexLayout buttonLayout )
278
146
{
279
- if ( popUp == null )
280
- {
281
- return ;
282
- }
283
-
284
147
if ( calendar . SelectedDate == null )
285
148
{
286
- popUp . HeaderTitle = "Alert !" ;
287
- popUp . Message = "Please select a date to book an appointment" ;
149
+ Application . Current ? . Windows [ 0 ] . Page ? . DisplayAlert ( "Alert !" , "Please select a date to book an appointment " , "Ok" ) ;
288
150
return ;
289
151
}
290
152
291
153
if ( _timeSlot == string . Empty )
292
154
{
293
- popUp . HeaderTitle = "Alert !" ;
294
- popUp . Message = "Please select a time to book an appointment" ;
155
+ Application . Current ? . Windows [ 0 ] . Page ? . DisplayAlert ( "Alert !" , "Please select a time to book an appointment " , "Ok" ) ;
295
156
return ;
296
157
}
297
158
298
- popUp . HeaderTitle = "Confirmation" ;
299
159
DateTime dateTime = calendar . SelectedDate . Value ;
300
160
string dayText = dateTime . ToString ( "MMMM" + " " + dateTime . Day . ToString ( ) + ", " + dateTime . ToString ( "yyyy" ) , CultureInfo . CurrentUICulture ) ;
301
- popUp . Message = "Appointment booked for " + dayText + " " + _timeSlot ;
161
+ string text = "Appointment booked for " + dayText + " " + _timeSlot ;
162
+ Application . Current ? . Windows [ 0 ] . Page ? . DisplayAlert ( "Confirmation" , text , "Ok" ) ;
302
163
calendar . SelectedDate = DateTime . Now . Date ;
303
164
calendar . DisplayDate = DateTime . Now . Date ;
304
165
_timeSlot = string . Empty ;
@@ -342,9 +203,7 @@ void UpdateTimeSlotSelection(SfCalendar calendar, SfButton selectedButton, FlexL
342
203
{
343
204
if ( calendar . SelectedDate == null )
344
205
{
345
- popUp . HeaderTitle = "Alert !" ;
346
- popUp . Message = "Please select a date to book an appointment " ;
347
- popUp . Show ( ) ;
206
+ Application . Current ? . Windows [ 0 ] . Page ? . DisplayAlert ( "Alert !" , "Please select a date to book an appointment " , "Ok" ) ;
348
207
return ;
349
208
}
350
209
0 commit comments