Skip to content

Commit c2022bd

Browse files
bhavanesh2001PureWeen
authored andcommitted
remove unwanted null check (dotnet#29784)
1 parent 623ae7b commit c2022bd

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

src/Controls/src/Core/Handlers/Items2/CarouselViewHandler2.iOS.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,10 @@ protected override CarouselViewController2 CreateController(CarouselView newElem
3939

4040
protected override UICollectionViewLayout SelectLayout()
4141
{
42-
bool isHorizontal = VirtualView.ItemsLayout.Orientation == ItemsLayoutOrientation.Horizontal;
43-
var peekInsets = VirtualView.PeekAreaInsets;
44-
4542
var weakItemsView = new WeakReference<CarouselView>(ItemsView);
4643
var weakController = new WeakReference<CarouselViewController2>((CarouselViewController2)Controller);
4744

48-
return LayoutFactory2.CreateCarouselLayout(
49-
isHorizontal,
50-
peekInsets,
51-
weakItemsView,
52-
weakController);
45+
return LayoutFactory2.CreateCarouselLayout(weakItemsView,weakController);
5346
}
5447

5548
protected override void ScrollToRequested(object sender, ScrollToRequestEventArgs args)

src/Controls/src/Core/Handlers/Items2/iOS/LayoutFactory2.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,6 @@ public static UICollectionViewLayout CreateHorizontalGrid(GridItemsLayout gridIt
265265

266266
#nullable disable
267267
public static UICollectionViewLayout CreateCarouselLayout(
268-
bool isHorizontal,
269-
Thickness peekAreaInsets,
270268
WeakReference<CarouselView> weakItemsView,
271269
WeakReference<CarouselViewController2> weakController)
272270
{
@@ -279,11 +277,14 @@ public static UICollectionViewLayout CreateCarouselLayout(
279277

280278
var layout = new UICollectionViewCompositionalLayout((sectionIndex, environment) =>
281279
{
282-
if (!weakItemsView.TryGetTarget(out var itemsView) || !weakController.TryGetTarget(out var controller))
280+
if (!weakItemsView.TryGetTarget(out var itemsView))
283281
{
284282
return null;
285283
}
286284

285+
bool isHorizontal = itemsView.ItemsLayout.Orientation == ItemsLayoutOrientation.Horizontal;
286+
var peekAreaInsets = itemsView.PeekAreaInsets;
287+
287288
double sectionMargin = 0.0;
288289

289290
if (!isHorizontal)

0 commit comments

Comments
 (0)