Skip to content

Commit

Permalink
Merge pull request #19 from PavloLukianets/dev/cleanup_handlers_net8
Browse files Browse the repository at this point in the history
net8 + handlers + cleanup
  • Loading branch information
AndreiMisiukevich authored Dec 5, 2023
2 parents 0190e5f + 5ef6fb9 commit 76d23e1
Show file tree
Hide file tree
Showing 58 changed files with 292 additions and 394 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,6 @@ MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/

# Rider
.idea/
21 changes: 8 additions & 13 deletions PanCardView/Common/AppBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using Microsoft.Maui.Controls.Compatibility.Hosting;
using PanCardView;
using PanCardView.Controls;
using PanCardView.Controls;
#if ANDROID
using PanCardView.Utility;
using CarouselView = PanCardView.CarouselView;

#endif

namespace PanCardView
{
Expand All @@ -24,15 +22,12 @@ public static MauiAppBuilder UseCardsView(this MauiAppBuilder builder)
TabsControl.Preserve();

#if ANDROID
DependencyService.RegisterSingleton<IAnimationsChecker>(new PanCardView.Droid.AnimationsChecker());
#endif

return builder.UseMauiCompatibility().ConfigureMauiHandlers((handlers) => {
#if ANDROID
handlers.AddCompatibilityRenderer(typeof(CardsView), typeof(PanCardView.Droid.CardsViewRenderer));
DependencyService.RegisterSingleton<IAnimationsChecker>(new Droid.AnimationsChecker());
#endif
#if IOS
handlers.AddCompatibilityRenderer(typeof(CardsView), typeof(PanCardView.iOS.CardsViewRenderer));
return builder.ConfigureMauiHandlers(handlers =>
{
#if ANDROID || IOS
handlers.AddHandler(typeof(CardsView), typeof(CardsViewHandler));
#endif
});
}
Expand Down
4 changes: 1 addition & 3 deletions PanCardView/Common/Behaviors/ContextAssignedBehavior.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Microsoft.Maui;

namespace PanCardView.Behaviors
namespace PanCardView.Behaviors
{
public sealed class ContextAssignedBehavior : Behavior<View>
{
Expand Down
4 changes: 1 addition & 3 deletions PanCardView/Common/Behaviors/ProtectedControlBehavior.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Microsoft.Maui;

namespace PanCardView.Behaviors
namespace PanCardView.Behaviors
{
public sealed class ProtectedControlBehavior : Behavior<View>
{
Expand Down
11 changes: 1 addition & 10 deletions PanCardView/Common/CardsView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,15 @@
using PanCardView.Extensions;
using PanCardView.Processors;
using PanCardView.Utility;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Input;
using Microsoft.Maui;
using static System.Math;
using System.Threading;
using System.Runtime.CompilerServices;
using PanCardView.EventArgs;
using PanCardView.Delegates;
using System.ComponentModel;
using Microsoft.Maui.Layouts;

using AbsoluteLayout = Microsoft.Maui.Controls.Compatibility.AbsoluteLayout;

namespace PanCardView
{
public class CardsView : AbsoluteLayout
Expand Down Expand Up @@ -1720,7 +1711,7 @@ private void SendChildToBackIfNeeded(View view, View topView)

if (currentIndex < backIndex)
{
ExecutePreventException(() => LowerChild(view));
ExecutePreventException(() => view.ZIndex--);
}
}

Expand Down
18 changes: 18 additions & 0 deletions PanCardView/Common/CardsViewHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Microsoft.Maui.Handlers;

namespace PanCardView;

public partial class CardsViewHandler : LayoutHandler
{
public static IPropertyMapper<CardsView, LayoutHandler> PropertyMapper = new PropertyMapper<CardsView, LayoutHandler>(Mapper)
{
#if IOS
[nameof(CardsView.IsVerticalSwipeEnabled)] = MapIsVerticalSwipeEnabled,
[nameof(CardsView.IsUserInteractionEnabled)] = MapIsUserInteractionEnabled
#endif
};

public CardsViewHandler() : base(PropertyMapper)
{
}
}
7 changes: 1 addition & 6 deletions PanCardView/Common/Controls/ArrowControl.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
using Microsoft.Maui;
using PanCardView.Behaviors;
using System.Threading;
using PanCardView.Behaviors;
using PanCardView.Extensions;
using PanCardView.Utility;
using System.Threading.Tasks;
using System.ComponentModel;
using Microsoft.Maui.Layouts;

using AbsoluteLayout = Microsoft.Maui.Controls.Compatibility.AbsoluteLayout;

namespace PanCardView.Controls
{
public class ArrowControl : ContentView
Expand Down
21 changes: 10 additions & 11 deletions PanCardView/Common/Controls/CircleFrame.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.ComponentModel;
using System.ComponentModel;
using PanCardView.Extensions;
using Microsoft.Maui;
using static System.Math;
using static System.Math;

namespace PanCardView.Controls
{
Expand Down Expand Up @@ -29,11 +28,11 @@ public double Size
{
get => (double)GetValue(SizeProperty);
set => SetValue(SizeProperty, value);
}

}

protected override void OnSizeAllocated(double width, double height)
{
base.OnSizeAllocated(width, height);
base.OnSizeAllocated(width, height);
if(width > 0 && height > 0)
{
SetCornerRadius(Min(width, height));
Expand All @@ -42,11 +41,11 @@ protected override void OnSizeAllocated(double width, double height)

protected void OnSizeUpdated()
{
var size = Size;
var size = Size;
if(size < 0)
{
return;
}
}

try
{
Expand All @@ -59,9 +58,9 @@ protected void OnSizeUpdated()
{
BatchCommit();
}
}

private void SetCornerRadius(double size)
}

private void SetCornerRadius(double size)
=> CornerRadius = (float)size / 2;
}
}
6 changes: 0 additions & 6 deletions PanCardView/Common/Controls/IndicatorsControl.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
using PanCardView.Behaviors;
using PanCardView.Extensions;
using System.Collections;
using System.Linq;
using Microsoft.Maui;
using static PanCardView.Controls.Styles.DefaultIndicatorItemStyles;
using System.Threading.Tasks;
using System.Threading;
using PanCardView.Utility;
using System.ComponentModel;
using System.Collections.Specialized;
using Microsoft.Maui.Layouts;

using AbsoluteLayout = Microsoft.Maui.Controls.Compatibility.AbsoluteLayout;

namespace PanCardView.Controls
{
public class IndicatorsControl : StackLayout
Expand Down
15 changes: 6 additions & 9 deletions PanCardView/Common/Controls/LeftArrowControl.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
using System.ComponentModel;
using Microsoft.Maui;
using System.ComponentModel;
using static PanCardView.Resources.ResourcesInfo;

using AbsoluteLayout = Microsoft.Maui.Controls.Compatibility.AbsoluteLayout;

namespace PanCardView.Controls
{
public class LeftArrowControl : ArrowControl
{
public LeftArrowControl()
{
{
IsRight = false;
AbsoluteLayout.SetLayoutBounds(this, new Rect(0, .5, -1, -1));
}

protected override ImageSource DefaultImageSource => WhiteLeftArrowImageSource;
protected override ImageSource DefaultImageSource => WhiteLeftArrowImageSource;

[EditorBrowsable(EditorBrowsableState.Never)]
public new static void Preserve()
{
[EditorBrowsable(EditorBrowsableState.Never)]
public new static void Preserve()
{
}
}
}
5 changes: 1 addition & 4 deletions PanCardView/Common/Controls/RightArrowControl.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using Microsoft.Maui;
using System.ComponentModel;
using System.ComponentModel;
using static PanCardView.Resources.ResourcesInfo;

using AbsoluteLayout = Microsoft.Maui.Controls.Compatibility.AbsoluteLayout;

namespace PanCardView.Controls
{
public class RightArrowControl : ArrowControl
Expand Down
8 changes: 1 addition & 7 deletions PanCardView/Common/Controls/TabsControl.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
using System;
using System.Collections;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Threading;
using System.Threading.Tasks;
using PanCardView.Behaviors;
using PanCardView.Enums;
using PanCardView.Extensions;
using PanCardView.Utility;
using Microsoft.Maui;
using static System.Math;
using Microsoft.Maui.Layouts;

using AbsoluteLayout = Microsoft.Maui.Controls.Compatibility.AbsoluteLayout;

namespace PanCardView.Controls
{
public class TabsControl : AbsoluteLayout
Expand Down
62 changes: 30 additions & 32 deletions PanCardView/Common/CoverFlowView.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using System.Collections.Specialized;
using System.Collections.Specialized;
using System.ComponentModel;
using PanCardView.Extensions;
using PanCardView.Extensions;
using PanCardView.Processors;
using Microsoft.Maui;
using static System.Math;

namespace PanCardView
Expand All @@ -18,8 +16,8 @@ public class CoverFlowView : CarouselView
public static readonly BindableProperty PositionShiftValueProperty = BindableProperty.Create(nameof(PositionShiftValue), typeof(double), typeof(CoverFlowView), .0, propertyChanged: (bindable, oldValue, newValue) =>
{
bindable.AsCardsView().ForceRedrawViews();
});

});

private bool _shouldForceHardSetCurrentView;

public CoverFlowView() : this(new CoverFlowProcessor())
Expand All @@ -30,53 +28,53 @@ public CoverFlowView(IProcessor processor) : base(processor)
{
}

/// <summary>
/// Shift to current view percentage (percengate of CoverFlowView Size)
/// </summary>
/// <summary>
/// Shift to current view percentage (percengate of CoverFlowView Size)
/// </summary>
/// <value>The position shift value.</value>
public double PositionShiftPercentage
{
get => (double)GetValue(PositionShiftPercentageProperty);
set => SetValue(PositionShiftPercentageProperty, value);
}

/// <summary>
/// Shift to current view in absolute points
/// </summary>

/// <summary>
/// Shift to current view in absolute points
/// </summary>
/// <value>The position shift value.</value>
public double PositionShiftValue
{
get => (double)GetValue(PositionShiftValueProperty);
set => SetValue(PositionShiftValueProperty, value);
}

[EditorBrowsable(EditorBrowsableState.Never)]
public new static void Preserve()
{
[EditorBrowsable(EditorBrowsableState.Never)]
public new static void Preserve()
{
}

protected override int DefaultBackViewsDepth => 2;

protected override int DefaultMaxChildrenCount => 17;

protected override int DefaultDesiredMaxChildrenCount => 12;

protected override int DefaultBackViewsDepth => 2;

protected override int DefaultMaxChildrenCount => 17;

protected override int DefaultDesiredMaxChildrenCount => 12;

protected override void OnObservableCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
{
if (sender != null)
{
{
_shouldForceHardSetCurrentView = true;
}
base.OnObservableCollectionChanged(sender, e);
}

}

protected override bool CheckIsHardSetCurrentView()
{
{
if (_shouldForceHardSetCurrentView)
{
{
_shouldForceHardSetCurrentView = false;
return true;
}
}

var oldIndex = OldIndex;
var index = SelectedIndex;
Expand All @@ -86,10 +84,10 @@ protected override bool CheckIsHardSetCurrentView()
{
oldIndex = oldIndex.ToCyclicalIndex(ItemsCount);
index = index.ToCyclicalIndex(ItemsCount);
}
}

var hasFirstElement = Min(oldIndex, index) == 0;
var hasLastElement = Max(oldIndex, index) == ItemsCount - 1;
var hasFirstElement = Min(oldIndex, index) == 0;
var hasLastElement = Max(oldIndex, index) == ItemsCount - 1;

return Abs(index - oldIndex) > 1 && (!isCyclical || !hasFirstElement || !hasLastElement);
}
Expand Down
3 changes: 1 addition & 2 deletions PanCardView/Common/CubeView.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.ComponentModel;
using System.ComponentModel;
using PanCardView.Processors;

namespace PanCardView
Expand Down
4 changes: 1 addition & 3 deletions PanCardView/Common/Enums/InteractionState.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace PanCardView.Enums
namespace PanCardView.Enums
{
[Flags]
public enum InteractionState
Expand Down
4 changes: 1 addition & 3 deletions PanCardView/Common/Enums/InteractionType.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace PanCardView.Enums
namespace PanCardView.Enums
{
[Flags]
public enum InteractionType
Expand Down
Loading

0 comments on commit 76d23e1

Please sign in to comment.