Skip to content

Commit

Permalink
Update floating bar width limit and margins on iPadOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoNatan committed Oct 25, 2024
1 parent 42c363f commit edb8e7b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions LNPopupController/LNPopupController/Private/LNPopupBar.mm
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ @interface MarqueeLabel () <__MarqueeLabelType> @end
const CGFloat LNPopupBarProminentImageWidth = 48.0;
const CGFloat LNPopupBarFloatingImageWidth = 40.0;
const CGFloat LNPopupBarFloatingPadImageWidth = 44.0;
const CGFloat LNPopupBarFloatingPadWidthLimit = 954.0;

static BOOL __animatesItemSetter = NO;

Expand Down Expand Up @@ -591,12 +592,12 @@ - (void)layoutSubviews
CGRect contentFrame;
if(isFloating)
{
CGFloat inset = self.traitCollection.horizontalSizeClass == UIUserInterfaceSizeClassRegular ? 30 : 12;
CGFloat inset = self.limitFloatingContentWidth || self.traitCollection.horizontalSizeClass == UIUserInterfaceSizeClassCompact ? 12 : 30;
contentFrame = UIEdgeInsetsInsetRect(frame, UIEdgeInsetsMake(4, MAX(self.safeAreaInsets.left + 12, inset), 4, MAX(self.safeAreaInsets.right + 12, inset)));
if(self.limitFloatingContentWidth == YES && contentFrame.size.width > 818 && UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad)
if(self.limitFloatingContentWidth == YES && contentFrame.size.width > LNPopupBarFloatingPadWidthLimit && UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad)
{
//On iPadOS, constrain floating bar width to 818pt.
CGFloat d = (contentFrame.size.width - 818) / 2;
CGFloat d = (contentFrame.size.width - LNPopupBarFloatingPadWidthLimit) / 2;
contentFrame = UIEdgeInsetsInsetRect(contentFrame, UIEdgeInsetsMake(0, d, 0, d));
}
contentFrame = CGRectOffset(contentFrame, 0, -2);
Expand Down

0 comments on commit edb8e7b

Please sign in to comment.