Add examples
This commit is contained in:
parent
e804bf8f74
commit
60e90e7c5c
|
@ -3,7 +3,7 @@
|
||||||
archiveVersion = 1;
|
archiveVersion = 1;
|
||||||
classes = {
|
classes = {
|
||||||
};
|
};
|
||||||
objectVersion = 50;
|
objectVersion = 52;
|
||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
|
@ -13,6 +13,8 @@
|
||||||
D6B0536323BD06D800A066FA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D6B0536123BD06D800A066FA /* Main.storyboard */; };
|
D6B0536323BD06D800A066FA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D6B0536123BD06D800A066FA /* Main.storyboard */; };
|
||||||
D6B0536523BD06DA00A066FA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D6B0536423BD06DA00A066FA /* Assets.xcassets */; };
|
D6B0536523BD06DA00A066FA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D6B0536423BD06DA00A066FA /* Assets.xcassets */; };
|
||||||
D6B0536823BD06DA00A066FA /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D6B0536623BD06DA00A066FA /* LaunchScreen.storyboard */; };
|
D6B0536823BD06DA00A066FA /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D6B0536623BD06DA00A066FA /* LaunchScreen.storyboard */; };
|
||||||
|
D6B0537123BD087000A066FA /* SheetController in Frameworks */ = {isa = PBXBuildFile; productRef = D6B0537023BD087000A066FA /* SheetController */; };
|
||||||
|
D6B0537423BD0AEE00A066FA /* ContentTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6B0537323BD0AEE00A066FA /* ContentTableViewController.swift */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
|
@ -24,6 +26,7 @@
|
||||||
D6B0536423BD06DA00A066FA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
D6B0536423BD06DA00A066FA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
D6B0536723BD06DA00A066FA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
D6B0536723BD06DA00A066FA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||||
D6B0536923BD06DA00A066FA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
D6B0536923BD06DA00A066FA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
|
D6B0537323BD0AEE00A066FA /* ContentTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentTableViewController.swift; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
|
@ -31,6 +34,7 @@
|
||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
D6B0537123BD087000A066FA /* SheetController in Frameworks */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
@ -42,6 +46,7 @@
|
||||||
children = (
|
children = (
|
||||||
D6B0535A23BD06D800A066FA /* SheetControllerExamples */,
|
D6B0535A23BD06D800A066FA /* SheetControllerExamples */,
|
||||||
D6B0535923BD06D800A066FA /* Products */,
|
D6B0535923BD06D800A066FA /* Products */,
|
||||||
|
D6B0537223BD099000A066FA /* Frameworks */,
|
||||||
);
|
);
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
@ -59,6 +64,7 @@
|
||||||
D6B0535B23BD06D800A066FA /* AppDelegate.swift */,
|
D6B0535B23BD06D800A066FA /* AppDelegate.swift */,
|
||||||
D6B0535D23BD06D800A066FA /* SceneDelegate.swift */,
|
D6B0535D23BD06D800A066FA /* SceneDelegate.swift */,
|
||||||
D6B0535F23BD06D800A066FA /* ViewController.swift */,
|
D6B0535F23BD06D800A066FA /* ViewController.swift */,
|
||||||
|
D6B0537323BD0AEE00A066FA /* ContentTableViewController.swift */,
|
||||||
D6B0536123BD06D800A066FA /* Main.storyboard */,
|
D6B0536123BD06D800A066FA /* Main.storyboard */,
|
||||||
D6B0536423BD06DA00A066FA /* Assets.xcassets */,
|
D6B0536423BD06DA00A066FA /* Assets.xcassets */,
|
||||||
D6B0536623BD06DA00A066FA /* LaunchScreen.storyboard */,
|
D6B0536623BD06DA00A066FA /* LaunchScreen.storyboard */,
|
||||||
|
@ -67,6 +73,13 @@
|
||||||
path = SheetControllerExamples;
|
path = SheetControllerExamples;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
D6B0537223BD099000A066FA /* Frameworks */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
);
|
||||||
|
name = Frameworks;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
/* End PBXGroup section */
|
/* End PBXGroup section */
|
||||||
|
|
||||||
/* Begin PBXNativeTarget section */
|
/* Begin PBXNativeTarget section */
|
||||||
|
@ -83,6 +96,9 @@
|
||||||
dependencies = (
|
dependencies = (
|
||||||
);
|
);
|
||||||
name = SheetControllerExamples;
|
name = SheetControllerExamples;
|
||||||
|
packageProductDependencies = (
|
||||||
|
D6B0537023BD087000A066FA /* SheetController */,
|
||||||
|
);
|
||||||
productName = SheetControllerExamples;
|
productName = SheetControllerExamples;
|
||||||
productReference = D6B0535823BD06D800A066FA /* SheetControllerExamples.app */;
|
productReference = D6B0535823BD06D800A066FA /* SheetControllerExamples.app */;
|
||||||
productType = "com.apple.product-type.application";
|
productType = "com.apple.product-type.application";
|
||||||
|
@ -111,6 +127,9 @@
|
||||||
Base,
|
Base,
|
||||||
);
|
);
|
||||||
mainGroup = D6B0534F23BD06D800A066FA;
|
mainGroup = D6B0534F23BD06D800A066FA;
|
||||||
|
packageReferences = (
|
||||||
|
D6B0536F23BD087000A066FA /* XCRemoteSwiftPackageReference "SheetController" */,
|
||||||
|
);
|
||||||
productRefGroup = D6B0535923BD06D800A066FA /* Products */;
|
productRefGroup = D6B0535923BD06D800A066FA /* Products */;
|
||||||
projectDirPath = "";
|
projectDirPath = "";
|
||||||
projectRoot = "";
|
projectRoot = "";
|
||||||
|
@ -140,6 +159,7 @@
|
||||||
files = (
|
files = (
|
||||||
D6B0536023BD06D800A066FA /* ViewController.swift in Sources */,
|
D6B0536023BD06D800A066FA /* ViewController.swift in Sources */,
|
||||||
D6B0535C23BD06D800A066FA /* AppDelegate.swift in Sources */,
|
D6B0535C23BD06D800A066FA /* AppDelegate.swift in Sources */,
|
||||||
|
D6B0537423BD0AEE00A066FA /* ContentTableViewController.swift in Sources */,
|
||||||
D6B0535E23BD06D800A066FA /* SceneDelegate.swift in Sources */,
|
D6B0535E23BD06D800A066FA /* SceneDelegate.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
@ -338,6 +358,25 @@
|
||||||
defaultConfigurationName = Release;
|
defaultConfigurationName = Release;
|
||||||
};
|
};
|
||||||
/* End XCConfigurationList section */
|
/* End XCConfigurationList section */
|
||||||
|
|
||||||
|
/* Begin XCRemoteSwiftPackageReference section */
|
||||||
|
D6B0536F23BD087000A066FA /* XCRemoteSwiftPackageReference "SheetController" */ = {
|
||||||
|
isa = XCRemoteSwiftPackageReference;
|
||||||
|
repositoryURL = "https://git.shadowfacts.net/shadowfacts/SheetController.git";
|
||||||
|
requirement = {
|
||||||
|
branch = master;
|
||||||
|
kind = branch;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/* End XCRemoteSwiftPackageReference section */
|
||||||
|
|
||||||
|
/* Begin XCSwiftPackageProductDependency section */
|
||||||
|
D6B0537023BD087000A066FA /* SheetController */ = {
|
||||||
|
isa = XCSwiftPackageProductDependency;
|
||||||
|
package = D6B0536F23BD087000A066FA /* XCRemoteSwiftPackageReference "SheetController" */;
|
||||||
|
productName = SheetController;
|
||||||
|
};
|
||||||
|
/* End XCSwiftPackageProductDependency section */
|
||||||
};
|
};
|
||||||
rootObject = D6B0535023BD06D800A066FA /* Project object */;
|
rootObject = D6B0535023BD06D800A066FA /* Project object */;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"object": {
|
||||||
|
"pins": [
|
||||||
|
{
|
||||||
|
"package": "SheetController",
|
||||||
|
"repositoryURL": "https://git.shadowfacts.net/shadowfacts/SheetController.git",
|
||||||
|
"state": {
|
||||||
|
"branch": "master",
|
||||||
|
"revision": "ca374422db48f381f46be8b5dae52c944e51daf0",
|
||||||
|
"version": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"version": 1
|
||||||
|
}
|
|
@ -1,7 +1,8 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
|
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
|
||||||
|
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
|
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
|
||||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -9,16 +10,56 @@
|
||||||
<!--View Controller-->
|
<!--View Controller-->
|
||||||
<scene sceneID="tne-QT-ifu">
|
<scene sceneID="tne-QT-ifu">
|
||||||
<objects>
|
<objects>
|
||||||
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
|
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="SheetControllerExamples" customModuleProvider="target" sceneMemberID="viewController">
|
||||||
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
|
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
<subviews>
|
||||||
|
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="zrK-bD-apM">
|
||||||
|
<rect key="frame" x="173" y="388" width="68" height="120"/>
|
||||||
|
<subviews>
|
||||||
|
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3JC-zs-cVL">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="68" height="30"/>
|
||||||
|
<state key="normal" title="Plain"/>
|
||||||
|
<connections>
|
||||||
|
<action selector="plainPressed:" destination="BYZ-38-t0r" eventType="touchUpInside" id="5ex-MR-MbN"/>
|
||||||
|
</connections>
|
||||||
|
</button>
|
||||||
|
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="N4f-c5-Nt3">
|
||||||
|
<rect key="frame" x="0.0" y="30" width="68" height="30"/>
|
||||||
|
<state key="normal" title="Table"/>
|
||||||
|
<connections>
|
||||||
|
<action selector="tablePressed:" destination="BYZ-38-t0r" eventType="touchUpInside" id="0Eg-vT-oaG"/>
|
||||||
|
</connections>
|
||||||
|
</button>
|
||||||
|
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Bqv-3e-HFh">
|
||||||
|
<rect key="frame" x="0.0" y="60" width="68" height="30"/>
|
||||||
|
<state key="normal" title="Nav"/>
|
||||||
|
<connections>
|
||||||
|
<action selector="navPressed:" destination="BYZ-38-t0r" eventType="touchUpInside" id="cWx-NQ-YlW"/>
|
||||||
|
</connections>
|
||||||
|
</button>
|
||||||
|
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="vKD-FG-w52">
|
||||||
|
<rect key="frame" x="0.0" y="90" width="68" height="30"/>
|
||||||
|
<state key="normal" title="Nav Table"/>
|
||||||
|
<connections>
|
||||||
|
<action selector="navTablePressed:" destination="BYZ-38-t0r" eventType="touchUpInside" id="ECd-TP-H0P"/>
|
||||||
|
</connections>
|
||||||
|
</button>
|
||||||
|
</subviews>
|
||||||
|
</stackView>
|
||||||
|
</subviews>
|
||||||
|
<color key="backgroundColor" systemColor="systemYellowColor" red="1" green="0.80000000000000004" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstItem="zrK-bD-apM" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="F2B-yb-fxd"/>
|
||||||
|
<constraint firstItem="zrK-bD-apM" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" id="PAc-uh-sPe"/>
|
||||||
|
</constraints>
|
||||||
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
|
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
|
||||||
</view>
|
</view>
|
||||||
</viewController>
|
</viewController>
|
||||||
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
|
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
|
||||||
</objects>
|
</objects>
|
||||||
|
<point key="canvasLocation" x="133" y="139"/>
|
||||||
</scene>
|
</scene>
|
||||||
</scenes>
|
</scenes>
|
||||||
</document>
|
</document>
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
//
|
||||||
|
// ContentTableViewController.swift
|
||||||
|
// SheetControllerExamples
|
||||||
|
//
|
||||||
|
// Created by Shadowfacts on 1/1/20.
|
||||||
|
// Copyright © 2020 Shadowfacts. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
class ContentTableViewController: UITableViewController {
|
||||||
|
|
||||||
|
init() {
|
||||||
|
super.init(style: .plain)
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder: NSCoder) {
|
||||||
|
fatalError()
|
||||||
|
}
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
|
||||||
|
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "testCell")
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Table view data source
|
||||||
|
|
||||||
|
override func numberOfSections(in tableView: UITableView) -> Int {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||||
|
return 40
|
||||||
|
}
|
||||||
|
|
||||||
|
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||||
|
let cell = tableView.dequeueReusableCell(withIdentifier: "testCell", for: indexPath)
|
||||||
|
|
||||||
|
cell.textLabel!.text = "\(indexPath.row)"
|
||||||
|
|
||||||
|
return cell
|
||||||
|
}
|
||||||
|
|
||||||
|
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||||
|
guard let navController = navigationController else { return }
|
||||||
|
|
||||||
|
navController.pushViewController(ContentTableViewController(), animated: true)
|
||||||
|
return
|
||||||
|
|
||||||
|
let vc = UIViewController()
|
||||||
|
vc.view.backgroundColor = .systemBackground
|
||||||
|
let label = UILabel()
|
||||||
|
label.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
label.text = "\(indexPath.row)"
|
||||||
|
vc.view.addSubview(label)
|
||||||
|
NSLayoutConstraint.activate([
|
||||||
|
label.centerXAnchor.constraint(equalTo: vc.view.centerXAnchor),
|
||||||
|
label.centerYAnchor.constraint(equalTo: vc.view.centerYAnchor)
|
||||||
|
])
|
||||||
|
|
||||||
|
navController.pushViewController(vc, animated: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -50,8 +50,6 @@
|
||||||
<key>UISupportedInterfaceOrientations</key>
|
<key>UISupportedInterfaceOrientations</key>
|
||||||
<array>
|
<array>
|
||||||
<string>UIInterfaceOrientationPortrait</string>
|
<string>UIInterfaceOrientationPortrait</string>
|
||||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
|
||||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
|
||||||
</array>
|
</array>
|
||||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||||
<array>
|
<array>
|
||||||
|
|
|
@ -7,14 +7,111 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
import SheetController
|
||||||
|
|
||||||
class ViewController: UIViewController {
|
class ViewController: UIViewController {
|
||||||
|
|
||||||
override func viewDidLoad() {
|
var sheet: SheetContainerViewController!
|
||||||
super.viewDidLoad()
|
|
||||||
// Do any additional setup after loading the view.
|
func showSheet(content: UIViewController) {
|
||||||
|
sheet = SheetContainerViewController(content: content)
|
||||||
|
sheet.delegate = self
|
||||||
|
sheet.detents = [.bottom, .middle, .top]
|
||||||
|
|
||||||
|
present(sheet, animated: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@IBAction func plainPressed(_ sender: Any) {
|
||||||
|
let content = UIViewController()
|
||||||
|
content.view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
|
||||||
|
let blurEffect = UIBlurEffect(style: .systemChromeMaterial)
|
||||||
|
let blurView = UIVisualEffectView(effect: blurEffect)
|
||||||
|
blurView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
let label = UILabel()
|
||||||
|
label.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
label.text = "Hello, sheet!"
|
||||||
|
blurView.contentView.addSubview(label)
|
||||||
|
content.view.addSubview(blurView)
|
||||||
|
NSLayoutConstraint.activate([
|
||||||
|
content.view.leadingAnchor.constraint(equalTo: blurView.contentView.leadingAnchor),
|
||||||
|
content.view.trailingAnchor.constraint(equalTo: blurView.contentView.trailingAnchor),
|
||||||
|
content.view.topAnchor.constraint(equalTo: blurView.contentView.topAnchor),
|
||||||
|
content.view.bottomAnchor.constraint(equalTo: blurView.contentView.bottomAnchor),
|
||||||
|
label.centerXAnchor.constraint(equalTo: blurView.contentView.centerXAnchor),
|
||||||
|
label.centerYAnchor.constraint(equalTo: blurView.contentView.centerYAnchor)
|
||||||
|
])
|
||||||
|
|
||||||
|
showSheet(content: content)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@IBAction func tablePressed(_ sender: Any) {
|
||||||
|
let content = ContentTableViewController()
|
||||||
|
content.view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
content.view.layer.masksToBounds = true
|
||||||
|
content.view.layer.cornerRadius = view.bounds.width * 0.02
|
||||||
|
|
||||||
|
showSheet(content: content)
|
||||||
|
}
|
||||||
|
@IBAction func navPressed(_ sender: Any) {
|
||||||
|
let root = UIViewController()
|
||||||
|
root.view.backgroundColor = .systemBackground
|
||||||
|
let label = UILabel()
|
||||||
|
label.text = "Root VC"
|
||||||
|
label.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
root.view.addSubview(label)
|
||||||
|
NSLayoutConstraint.activate([
|
||||||
|
label.centerXAnchor.constraint(equalTo: root.view.centerXAnchor),
|
||||||
|
label.centerYAnchor.constraint(equalTo: root.view.centerYAnchor)
|
||||||
|
])
|
||||||
|
|
||||||
|
let nav = UINavigationController(rootViewController: root)
|
||||||
|
nav.view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
nav.view.layer.masksToBounds = true
|
||||||
|
nav.view.layer.cornerRadius = view.bounds.width * 0.02
|
||||||
|
|
||||||
|
showSheet(content: nav)
|
||||||
|
}
|
||||||
|
@IBAction func navTablePressed(_ sender: Any) {
|
||||||
|
let table = ContentTableViewController()
|
||||||
|
|
||||||
|
let nav = UINavigationController(rootViewController: table)
|
||||||
|
nav.delegate = self
|
||||||
|
nav.view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
nav.view.layer.masksToBounds = true
|
||||||
|
nav.view.layer.cornerRadius = view.bounds.width * 0.02
|
||||||
|
|
||||||
|
showSheet(content: nav)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ViewController: SheetContainerViewControllerDelegate {
|
||||||
|
func sheetContainer(_ sheetContainer: SheetContainerViewController, willSnapToDetent detent: Detent) -> Bool {
|
||||||
|
if detent == .bottom {
|
||||||
|
sheetContainer.dismiss(animated: true)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
func sheetContainerContentScrollView(_ sheetContainer: SheetContainerViewController) -> UIScrollView? {
|
||||||
|
if let navController = sheetContainer.content as? UINavigationController,
|
||||||
|
let scrollView = navController.visibleViewController?.view as? UIScrollView {
|
||||||
|
return scrollView
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func sheetContainer(_ sheetContainer: SheetContainerViewController, topContentOffsetForScrollView scrollView: UIScrollView) -> CGFloat {
|
||||||
|
if let navController = sheetContainer.content as? UINavigationController {
|
||||||
|
return -navController.navigationBar.bounds.height
|
||||||
|
} else {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ViewController: UINavigationControllerDelegate {
|
||||||
|
func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {
|
||||||
|
sheet.contentScrollViewChanged()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue