Skip to content

Commit

Permalink
Merge branch 'main' into delegates
Browse files Browse the repository at this point in the history
* main: (33 commits)
  Update FittedSheets.podspec.json
  Allow for intrinsic height to be recalculated
  Update FittedSheets.podspec.json
  Setup childForStatusBarStyle
  Fix storyboard class reference
  Correct typo
  Refactor demos (gordontucker#133)
  Updated how animateIn works to prevent confusion about having to add sheet as a child every time you display it
  Fixed bug with dismiss not working properly
  Fixed inline sheets not being reusable
  Bumped podspec
  Updated sheet to allow specifying width settings
  Update FittedSheets.podspec.json
  move overflowView.backgroundColor = self.childViewController.view.backgroundColor line after setupChildViewController in SheetContentViewController
  Update README.md
  Fixed version
  Fixed spacing and bumped version
  fixed a compile error due to incorrect swift code
  Minor change on Inline presentation code
  Finished the implementation to add bounce to the initial display of the fitted sheets.
  ...
  • Loading branch information
Neilfau committed Dec 1, 2021
2 parents c16fd4f + 65f9c93 commit a939026
Show file tree
Hide file tree
Showing 108 changed files with 2,750 additions and 1,987 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
369 changes: 369 additions & 0 deletions Demos/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="sbo-BB-anW">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Slide In Animation Bug118 View Controller-->
<scene sceneID="3HO-4W-IMU">
<objects>
<viewController storyboardIdentifier="AddTagsViewController" id="sbo-BB-anW" customClass="SlideInAnimationBug118ViewController" customModule="Demos" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ab1-Wx-ijV">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="1000" verticalCompressionResistancePriority="1000" text="Add Tags" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Qx9-Js-AXJ">
<rect key="frame" x="171.5" y="64" width="71" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="wX7-82-Vya">
<rect key="frame" x="0.0" y="109.5" width="414" height="752.5"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="100" id="uQH-sx-unA"/>
</constraints>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="4" id="uql-Ds-PX5">
<size key="itemSize" width="50" height="50"/>
<size key="headerReferenceSize" width="0.0" height="0.0"/>
<size key="footerReferenceSize" width="0.0" height="0.0"/>
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
</collectionViewFlowLayout>
<cells/>
<connections>
<outlet property="dataSource" destination="sbo-BB-anW" id="ZRF-o5-fZM"/>
<outlet property="delegate" destination="sbo-BB-anW" id="toH-8X-TDa"/>
</connections>
</collectionView>
</subviews>
<viewLayoutGuide key="safeArea" id="ISE-nA-WiB"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="wX7-82-Vya" firstAttribute="leading" secondItem="Ab1-Wx-ijV" secondAttribute="leading" id="Bsc-R5-sGU"/>
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="wX7-82-Vya" secondAttribute="bottom" priority="999" constant="25" id="GFd-Lp-IyE"/>
<constraint firstItem="ISE-nA-WiB" firstAttribute="bottom" secondItem="wX7-82-Vya" secondAttribute="bottom" priority="998" id="IZ7-1r-GEZ"/>
<constraint firstItem="Qx9-Js-AXJ" firstAttribute="top" secondItem="ISE-nA-WiB" secondAttribute="top" constant="20" id="TEQ-Jd-bDX"/>
<constraint firstItem="Qx9-Js-AXJ" firstAttribute="centerX" secondItem="ISE-nA-WiB" secondAttribute="centerX" id="WB7-9f-sp4"/>
<constraint firstAttribute="trailing" secondItem="wX7-82-Vya" secondAttribute="trailing" id="lVv-60-sJ2"/>
<constraint firstItem="wX7-82-Vya" firstAttribute="top" secondItem="Qx9-Js-AXJ" secondAttribute="bottom" constant="25" id="wzg-G8-4AB"/>
</constraints>
</view>
<connections>
<outlet property="collectionView" destination="wX7-82-Vya" id="Npr-22-Umb"/>
<outlet property="collectionViewHeightConstraint" destination="uQH-sx-unA" id="QbW-Gz-XA3"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dif-ad-bEw" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="971" y="94"/>
</scene>
</scenes>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// TagCollectionViewCell.swift
// Test
//
// Created by Jordan Hipwell on 1/4/21.
//

import UIKit

class SlideInAnimationBug118TagCell: UICollectionViewCell {
var button = UIButton(type: .system)

override init(frame: CGRect) {
super.init(frame: frame)

baseInit()
}

required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

private func baseInit() {
contentView.translatesAutoresizingMaskIntoConstraints = false

NSLayoutConstraint.activate([
contentView.leadingAnchor.constraint(equalTo: leadingAnchor),
contentView.trailingAnchor.constraint(equalTo: trailingAnchor),
contentView.topAnchor.constraint(equalTo: topAnchor),
contentView.bottomAnchor.constraint(equalTo: bottomAnchor)
])

button.translatesAutoresizingMaskIntoConstraints = false
button.setContentHuggingPriority(.required, for: .horizontal)
button.setContentCompressionResistancePriority(.required, for: .horizontal)

contentView.addSubview(button)

NSLayoutConstraint.activate([
button.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
button.trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
button.topAnchor.constraint(equalTo: contentView.topAnchor),
button.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
button.heightAnchor.constraint(equalToConstant: 32)
])
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
//
// AddTagsViewController.swift
// Test
//
// Created by Jordan Hipwell on 1/4/21.
//

import UIKit
import FittedSheets

class SlideInAnimationBug118ViewController: UIViewController, Demoable {
static var name: String { "#118 - Sweeping background animation bug" }

var selectedTags = [String]()

@IBOutlet private var collectionView: UICollectionView!

@IBOutlet private var collectionViewHeightConstraint: NSLayoutConstraint!

private let tags = ["Anger","Misery","Sadness","Happiness","Joy","Fear","Anticipation","Surprise","Shame","Envy","Indignation","Courage","Pride","Love","Confusion","Hope","Respect","Caution","Pain","Rage Melon"]

private var contentSizeObserverToken: NSKeyValueObservation? = nil

override func viewDidLoad() {
super.viewDidLoad()

collectionView.contentInset = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20)
collectionView.register(SlideInAnimationBug118TagCell.self, forCellWithReuseIdentifier: "cell")

let layout = collectionView.collectionViewLayout as! UICollectionViewFlowLayout
layout.estimatedItemSize = CGSize(width: 150, height: 32)

//keep the height of the collection view equal to the height of its content size
contentSizeObserverToken = collectionView.observe(\UICollectionView.contentSize, options: [.new]) { [weak self] (object, change) in
guard let selfie = self else { return }

let newHeight = selfie.collectionView.contentSize.height
if newHeight > 0 && newHeight != selfie.collectionViewHeightConstraint.constant {
//FIXME: Causes sheet dim overlay to animate strangely.
// Moving the
print(selfie.collectionView.contentSize.height)
UIView.performWithoutAnimation {
selfie.collectionViewHeightConstraint.constant = newHeight
}
}
}
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
/*
// By moving the section from viewDidLoad to the commented out code block below, the bug goes away.

contentSizeObserverToken?.invalidate()
contentSizeObserverToken = collectionView.observe(\UICollectionView.contentSize, options: [.new]) { [weak self] (object, change) in
guard let selfie = self else { return }

let newHeight = selfie.collectionView.contentSize.height
if newHeight > 0 && newHeight != selfie.collectionViewHeightConstraint.constant {
//FIXME: Causes sheet dim overlay to animate strangely.
// Moving the
print(selfie.collectionView.contentSize.height)
UIView.performWithoutAnimation {
selfie.collectionViewHeightConstraint.constant = newHeight
}
}
}
*/
}

static func openDemo(from parent: UIViewController, in view: UIView?) {
let addTags = UIStoryboard(name: "SlideInAnimationBug118", bundle: nil).instantiateInitialViewController()!

let sheetController = SheetViewController(
controller: addTags,
sizes: [.intrinsic],
options: SheetOptions(
pullBarHeight: 0,
shouldExtendBackground: true,
useFullScreenMode: false,
shrinkPresentingViewController: false))
parent.present(sheetController, animated: true, completion: nil)
}
}

extension SlideInAnimationBug118ViewController: UICollectionViewDataSource, UICollectionViewDelegate {

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return tags.count
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! SlideInAnimationBug118TagCell
let tag = tags[indexPath.item]

cell.button.setTitle(tag, for: .normal)
cell.button.contentEdgeInsets = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 10)

return cell
}

}
40 changes: 40 additions & 0 deletions Demos/BugVerificationsViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// InlineExamplesViewController.swift
// FittedSheets
//
// Created by Gordon Tucker on 8/5/20.
// Copyright © 2020 Gordon Tucker. All rights reserved.
//

import UIKit
import FittedSheets

class BugVerificationsViewController: UIViewController {

@IBOutlet var stackView: UIStackView!
@IBOutlet var containerView: UIView!

override func viewDidLoad() {
super.viewDidLoad()

self.addButton(for: SlideInAnimationBug118ViewController.self)
}

func addButton(for demo: (UIViewController & Demoable).Type, onTap: (() -> Void)? = nil) {
let button = UIButton()
button.setTitle(demo.name, for: .normal)
button.contentHorizontalAlignment = .left
button.backgroundColor = UIColor.black
button.setTitleColor(UIColor.white, for: .normal)
button.contentEdgeInsets = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20)
button.heightAnchor.constraint(equalToConstant: 44).isActive = true
button.layer.cornerRadius = 22
button.layer.masksToBounds = true

button.onTap { [unowned self] in
demo.openDemo(from: self, in: nil)
onTap?()
}
self.stackView.addArrangedSubview(button)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
//

import UIKit
import FittedSheetsPod
import FittedSheets

class BlurDemo: Demoable {
var name: String {
return "Blur Effect"
}
class BlurDemo: SimpleDemo {
override class var name: String { "Blur Effect" }

func buildDemo(useInlineMode: Bool) -> SheetViewController {
let controller = UIStoryboard(name: "ColorExample", bundle: nil).instantiateViewController(withIdentifier: "customize")
override class func openDemo(from parent: UIViewController, in view: UIView?) {
let useInlineMode = view != nil

let controller = ColorDemo()

var options = SheetOptions()
options.pullBarHeight = 30
Expand All @@ -26,6 +26,13 @@ class BlurDemo: Demoable {

sheet.cornerRadius = 30
sheet.gripSize = CGSize(width: 100, height: 12)
return sheet

addSheetEventLogging(to: sheet)

if let view = view {
sheet.animateIn(to: view, in: parent)
} else {
parent.present(sheet, animated: true, completion: nil)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
//

import UIKit
import FittedSheetsPod
import FittedSheets

class ClearPullBarDemo: Demoable {
var name: String {
return "Clear Pull Bar"
}

func buildDemo(useInlineMode: Bool) -> SheetViewController {
let controller = UIStoryboard(name: "ColorExample", bundle: nil).instantiateViewController(withIdentifier: "customize")
class ClearPullBarDemo: SimpleDemo {
override class var name: String { "Clear Pull Bar" }

override class func openDemo(from parent: UIViewController, in view: UIView?) {
let useInlineMode = view != nil
let controller = ColorDemo()

var options = SheetOptions()
options.pullBarHeight = 30
Expand All @@ -29,6 +29,13 @@ class ClearPullBarDemo: Demoable {
sheet.minimumSpaceAbovePullBar = 20
sheet.cornerRadius = 30
sheet.gripSize = CGSize(width: 100, height: 12)
return sheet

addSheetEventLogging(to: sheet)

if let view = view {
sheet.animateIn(to: view, in: parent)
} else {
parent.present(sheet, animated: true, completion: nil)
}
}
}
41 changes: 41 additions & 0 deletions Demos/DemoControllers/ColorDemo.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// FullScreenExampleViewController.swift
// FittedSheets
//
// Created by Gordon Tucker on 2/1/19.
// Copyright © 2019 Gordon Tucker. All rights reserved.
//

import UIKit
import FittedSheets

class ColorDemo: SimpleDemo {
override class var name: String { "Color Options" }

override class func openDemo(from parent: UIViewController, in view: UIView?) {
let useInlineMode = view != nil

let controller = ColorDemo()

var options = SheetOptions()
options.useInlineMode = useInlineMode
options.shouldExtendBackground = false

let sheet = SheetViewController(
controller: controller,
sizes: [.percent(0.25), .percent(0.75), .fullscreen],
options: options)
sheet.overlayColor = UIColor(red: 0.933, green: 0.314, blue: 0.349, alpha: 0.3)
sheet.gripColor = .purple
sheet.pullBarBackgroundColor = .yellow
sheet.cornerRadius = 40

addSheetEventLogging(to: sheet)

if let view = view {
sheet.animateIn(to: view, in: parent)
} else {
parent.present(sheet, animated: true, completion: nil)
}
}
}
Loading

0 comments on commit a939026

Please sign in to comment.