Skip to content

Commit

Permalink
Fixes a popup bar layout issue for custom container.
Browse files Browse the repository at this point in the history
  • Loading branch information
iDevelopper committed Sep 29, 2024
1 parent 8504e60 commit 013bb81
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ id<UIViewControllerTransitionCoordinator> __pb_transitionCoordinator(UIViewContr

@end

@interface __LNFakeContext: NSObject
@interface __PBFakeContext: NSObject

@property(nonatomic, getter=isCancelled) BOOL cancelled;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ NSTimeInterval __pb_durationForTransition(UIViewController* vc, NSUInteger trans

@end

@implementation __LNFakeContext @end
@implementation __PBFakeContext @end
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,12 @@ public extension UIViewController
self.pb_viewDidLayoutSubviews()
if let rv = UIViewController.getAssociatedPopupBarFor(self) {
if !(self is UITabBarController) && !(self is UINavigationController) {
rv.backgroundView.alpha = rv.isFloating ? 0.0 : 1.0
if rv.isFloating {
rv.backgroundView.alpha = self.bottomBarIsHidden() ? 0.0 : 1.0
}
else {
rv.backgroundView.alpha = 1.0
}
}

if self is UITabBarController {
Expand Down Expand Up @@ -1243,7 +1248,7 @@ internal extension UIViewController
}

@objc func bottomBarIsHidden() -> Bool {
return self.bottomBar.isHidden
return self.bottomBar.isHidden || self.bottomBar.frame.height == 0.0
}

@objc func insetsForBottomBar() -> UIEdgeInsets
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22155" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="23502" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_5" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22131"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23504"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -300,26 +300,34 @@
</connections>
</button>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="oca-q2-ae6">
<rect key="frame" x="149.66666666666666" y="308" width="114.99999999999997" height="180"/>
<rect key="frame" x="123.00000000000001" y="281" width="168.33333333333337" height="234.33333333333337"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="yXj-mF-Sne">
<rect key="frame" x="0.0" y="0.0" width="168.33333333333334" height="34.333333333333336"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="Floating Popup Bar"/>
<connections>
<action selector="popupBarIsFloating:" destination="Oie-Fg-l06" eventType="touchUpInside" id="8k8-cT-NlA"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="kwq-he-J6V">
<rect key="frame" x="0.0" y="0.0" width="115" height="30"/>
<rect key="frame" x="0.0" y="54.333333333333314" width="168.33333333333334" height="30"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="15"/>
<state key="normal" title="Present"/>
<connections>
<action selector="presentPopupBar:" destination="Oie-Fg-l06" eventType="touchUpInside" id="YkH-th-eJ1"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="SQ3-dd-iFa">
<rect key="frame" x="0.0" y="50" width="115" height="30"/>
<rect key="frame" x="0.0" y="104.33333333333331" width="168.33333333333334" height="30"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="15"/>
<state key="normal" title="Present Custom"/>
<connections>
<action selector="presentCustomPopupBar:" destination="Oie-Fg-l06" eventType="touchUpInside" id="4cJ-5U-jy2"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="7oe-lJ-Slq">
<rect key="frame" x="0.0" y="100" width="115" height="30"/>
<rect key="frame" x="0.0" y="154.33333333333331" width="168.33333333333334" height="30"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="15"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title="Present Popup"/>
Expand All @@ -328,7 +336,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Wd7-fx-Vo3">
<rect key="frame" x="0.0" y="150" width="115" height="30"/>
<rect key="frame" x="0.0" y="204.33333333333331" width="168.33333333333334" height="30"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="15"/>
<state key="normal" title="Dismiss"/>
<connections>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ class DemoChildViewController: UIViewController {

// MARK: - Actions

@IBAction func popupBarIsFloating(_ sender: UIButton) {
if let containerVC = self.parent {
containerVC.popupBar.isFloating.toggle()
}
}

@IBAction func presentPopupBar(_ sender: UIButton) {
if let containerVC = self.parent {
containerVC.dismissPopupBar(animated: false) {
Expand Down Expand Up @@ -112,6 +118,7 @@ class DemoChildViewController: UIViewController {
if let containerVC = self.parent as? DemoContainerController {
containerVC.popupController.dataSource = containerVC
containerVC.popupController.delegate = containerVC
containerVC.popupBar.isFloating = true
containerVC.popupBar.inheritsVisualStyleFromBottomBar = false
containerVC.popupBar.backgroundEffect = containerVC.tabBar.standardAppearance.backgroundEffect
containerVC.popupBar.image = UIImage(named: "Cover22")
Expand Down

0 comments on commit 013bb81

Please sign in to comment.