Skip to content

Commit

Permalink
Add example of gesture driven PopMenu presentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
raxityo authored and CaliCastle committed Apr 6, 2019
1 parent 64a9f61 commit 0e616fd
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
36 changes: 35 additions & 1 deletion Example/Example/Storyboards/Base.lproj/Main.storyboard
Expand Up @@ -19,7 +19,7 @@
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<color key="separatorColor" red="0.91400301399999995" green="0.91400301399999995" blue="0.91400301399999995" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
<imageView key="tableFooterView" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PopMenu_Logo" id="ezY-er-s3g">
<rect key="frame" x="0.0" y="1875" width="414" height="73"/>
<rect key="frame" x="0.0" y="1941" width="414" height="73"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<sections>
Expand Down Expand Up @@ -626,6 +626,34 @@
</subviews>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" textLabel="G9H-EY-2vQ" detailTextLabel="DG5-BV-Qsi" rowHeight="66" style="IBUITableViewCellStyleSubtitle" id="u6o-C6-Vxr">
<rect key="frame" x="0.0" y="1857.5" width="414" height="66"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="u6o-C6-Vxr" id="lZc-4X-TTd">
<rect key="frame" x="0.0" y="0.0" width="414" height="65.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Gesture Driven Positioning" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="G9H-EY-2vQ">
<rect key="frame" x="15" y="10" width="198" height="22"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" name="AvenirNext-DemiBold" family="Avenir Next" pointSize="16"/>
<color key="textColor" red="0.43137254899999999" green="0.64705882349999999" blue="0.45098039220000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Tap &amp; Hold anywhere on me to see the menu" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="DG5-BV-Qsi">
<rect key="frame" x="15" y="35" width="268.5" height="18"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" name="AvenirNext-Medium" family="Avenir Next" pointSize="13"/>
<color key="textColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<gestureRecognizers/>
<connections>
<outletCollection property="gestureRecognizers" destination="aVo-J5-Ye1" appends="YES" id="ala-ff-tOy"/>
</connections>
</tableViewCellContentView>
</tableViewCell>
</cells>
</tableViewSection>
</sections>
Expand All @@ -650,6 +678,12 @@
</navigationItem>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Si2-q7-t8X" userLabel="First Responder" sceneMemberID="firstResponder"/>
<pongPressGestureRecognizer allowableMovement="10" minimumPressDuration="0.5" id="aVo-J5-Ye1">
<connections>
<action selector="didLongPressWithSender:" destination="GCo-K4-qJH" id="rse-9R-hTt"/>
<outlet property="delegate" destination="GCo-K4-qJH" id="SJf-rT-vMu"/>
</connections>
</pongPressGestureRecognizer>
</objects>
<point key="canvasLocation" x="1218.840579710145" y="344.83695652173918"/>
</scene>
Expand Down
16 changes: 15 additions & 1 deletion Example/Example/View Controllers/RootViewController.swift
Expand Up @@ -98,7 +98,7 @@ class RootViewController: UITableViewController {
// MARK: - Table View Row Configuration

override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
guard indexPath != IndexPath(row: 0, section: 3) else { return 170 }
if (indexPath.section, indexPath.row) == (3, 2) { return 170 }
return 68
}

Expand Down Expand Up @@ -234,3 +234,17 @@ extension RootViewController {
}

}

extension RootViewController: UIGestureRecognizerDelegate {
@IBAction func didLongPress(sender: UIGestureRecognizer) {
guard sender.state == .began else { return }
let manager = PopMenuManager.default
manager.actions = [
PopMenuDefaultAction(title: "Save to List", image: #imageLiteral(resourceName: "Plus")),
PopMenuDefaultAction(title: "Favorite", image: #imageLiteral(resourceName: "Heart")),
PopMenuDefaultAction(title: "Add to Cart", image: #imageLiteral(resourceName: "Cart_Add")),
PopMenuDefaultAction(title: "Download", image: #imageLiteral(resourceName: "Download"))
]
manager.present(with: sender, on: self)
}
}

0 comments on commit 0e616fd

Please sign in to comment.