Skip to content

Commit 0a76412

Browse files
author
Josip Ćaleta
committed
Add properties for SwipeLeftCommand, SwipeRightCommand, SwipeToChangeMonthEnabled, rename SwipeUpActionEnabled (#14)
1 parent 70df314 commit 0a76412

File tree

2 files changed

+60
-12
lines changed

2 files changed

+60
-12
lines changed

src/Calendar.Plugin.Sample/SampleApp/MainPage.xaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,13 @@
5858
<!-- Swipe handling
5959
6060
DisableSwipeDetection="False"
61-
SwipeUpActionEnabled="False"
62-
SwipeUpCommand="{Binding SwipeUpCommand}"-->
61+
62+
SwipeLeftCommand="{Binding SwipeLeftCommand}"
63+
SwipeRightCommand="{Binding SwipeRightCommand}"
64+
SwipeUpCommand="{Binding SwipeUpCommand}"
65+
66+
SwipeUpToHideEnabled="False"
67+
SwipeToChangeMonthEnabled="False"-->
6368

6469
<!-- Customizations
6570

src/Calendar.Plugin/Shared/Controls/Calendar.xaml.cs

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ public Style DaysTitleLabelStyle
319319
/// <summary>
320320
/// <para> Disables the swipe detection (needs testing on iOS) </para>
321321
/// Could be useful if your superview has its own swipe-detection logic.
322-
/// Also see if <seealso cref="SwipeUpCommand"/>, <seealso cref="SwipeUpActionEnabled"/> is useful to you.
322+
/// Also see if <seealso cref="SwipeUpCommand"/>, <seealso cref="SwipeUpToHideEnabled"/>, <seealso cref="SwipeLeftCommand"/>, <seealso cref="SwipeRightCommand"/> or <seealso cref="SwipeToChangeMonthEnabled"/> is useful to you.
323323
/// </summary>
324324
public bool DisableSwipeDetection
325325
{
@@ -338,15 +338,48 @@ public ICommand SwipeUpCommand
338338
set => SetValue(SwipeUpCommandProperty, value);
339339
}
340340

341-
/// <summary> Bindable property for SwipeUpActionEnabled </summary>
342-
public static readonly BindableProperty SwipeUpActionEnabledProperty =
343-
BindableProperty.Create(nameof(SwipeUpActionEnabled), typeof(bool), typeof(Calendar), true);
341+
/// <summary> Bindable property for SwipeUpToHideEnabled </summary>
342+
public static readonly BindableProperty SwipeUpToHideEnabledProperty =
343+
BindableProperty.Create(nameof(SwipeUpToHideEnabled), typeof(bool), typeof(Calendar), true);
344344

345345
/// <summary> Enable/disable default swipe-up action for showing/hiding calendar </summary>
346-
public bool SwipeUpActionEnabled
346+
public bool SwipeUpToHideEnabled
347347
{
348-
get => (bool)GetValue(SwipeUpActionEnabledProperty);
349-
set => SetValue(SwipeUpActionEnabledProperty, value);
348+
get => (bool)GetValue(SwipeUpToHideEnabledProperty);
349+
set => SetValue(SwipeUpToHideEnabledProperty, value);
350+
}
351+
352+
/// <summary> Bindable property for SwipeLeftCommand </summary>
353+
public static readonly BindableProperty SwipeLeftCommandProperty =
354+
BindableProperty.Create(nameof(SwipeLeftCommand), typeof(ICommand), typeof(Calendar), null);
355+
356+
/// <summary> Activated when user swipes-left over days view </summary>
357+
public ICommand SwipeLeftCommand
358+
{
359+
get => (ICommand)GetValue(SwipeLeftCommandProperty);
360+
set => SetValue(SwipeLeftCommandProperty, value);
361+
}
362+
363+
/// <summary> Bindable property for SwipeRightCommand </summary>
364+
public static readonly BindableProperty SwipeRightCommandProperty =
365+
BindableProperty.Create(nameof(SwipeRightCommand), typeof(ICommand), typeof(Calendar), null);
366+
367+
/// <summary> Activated when user swipes-right over days view </summary>
368+
public ICommand SwipeRightCommand
369+
{
370+
get => (ICommand)GetValue(SwipeRightCommandProperty);
371+
set => SetValue(SwipeRightCommandProperty, value);
372+
}
373+
374+
/// <summary> Bindable property for SwipeToChangeMonthEnabled </summary>
375+
public static readonly BindableProperty SwipeToChangeMonthEnabledProperty =
376+
BindableProperty.Create(nameof(SwipeToChangeMonthEnabled), typeof(bool), typeof(Calendar), true);
377+
378+
/// <summary> Enable/disable default swipe actions for changing months </summary>
379+
public bool SwipeToChangeMonthEnabled
380+
{
381+
get => (bool)GetValue(SwipeToChangeMonthEnabledProperty);
382+
set => SetValue(SwipeToChangeMonthEnabledProperty, value);
350383
}
351384

352385
#endregion
@@ -498,16 +531,26 @@ private void OnCalendarContainerSizeChanged(object sender, EventArgs e)
498531
}
499532

500533
private void OnSwipedRight(object sender, EventArgs e)
501-
=> PrevMonth();
534+
{
535+
SwipeRightCommand?.Execute(null);
536+
537+
if (SwipeToChangeMonthEnabled)
538+
PrevMonth();
539+
}
502540

503541
private void OnSwipedLeft(object sender, EventArgs e)
504-
=> NextMonth();
542+
{
543+
SwipeLeftCommand?.Execute(null);
544+
545+
if (SwipeToChangeMonthEnabled)
546+
NextMonth();
547+
}
505548

506549
private void OnSwipedUp(object sender, EventArgs e)
507550
{
508551
SwipeUpCommand?.Execute(null);
509552

510-
if (SwipeUpActionEnabled)
553+
if (SwipeUpToHideEnabled)
511554
ToggleCalendarSectionVisibility();
512555
}
513556

0 commit comments

Comments
 (0)