Skip to content

Commit

Permalink
Merge pull request #19 from isavynskyi/feature/shake-gesture-polishing
Browse files Browse the repository at this point in the history
Polish new shake gesture trigger type
  • Loading branch information
isavynskyi authored Sep 29, 2019
2 parents 08fbae5 + 343d81f commit 14d4d5d
Show file tree
Hide file tree
Showing 28 changed files with 607 additions and 568 deletions.
4 changes: 3 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
- [ ] UI tests added
- [ ] Tests pass locally

Pod version update

## Versioning
Pod version updated in `LayoutInspector.podspec`
- [ ] Major
- [ ] Minor
- [ ] Patch
17 changes: 9 additions & 8 deletions Example/LayoutInspectorExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
371988C421E0151700639FDC /* TableDemoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 371988C321E0151700639FDC /* TableDemoViewController.swift */; };
3725F37621EB49780018C5DD /* AttributeViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3725F37521EB49780018C5DD /* AttributeViewModelTests.swift */; };
375F98442340BFE0005CE45D /* ChangeAutoTriggerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 375F98432340BFE0005CE45D /* ChangeAutoTriggerProtocol.swift */; };
3793D11021EA133A0045AD29 /* LayoutInspectorFacadeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3793D10F21EA133A0045AD29 /* LayoutInspectorFacadeTests.swift */; };
3793D11421EA1A160045AD29 /* HierarchyBuilderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3793D11321EA1A160045AD29 /* HierarchyBuilderTests.swift */; };
37F29E8D21EB5D5000421B97 /* LayoutInspectorContainerViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37F29E8C21EB5D5000421B97 /* LayoutInspectorContainerViewControllerTests.swift */; };
Expand Down Expand Up @@ -62,6 +63,7 @@
32F0EEC0FD002ACD0C0FD0E0 /* Pods-LayoutInspectorExampleUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LayoutInspectorExampleUITests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-LayoutInspectorExampleUITests/Pods-LayoutInspectorExampleUITests.debug.xcconfig"; sourceTree = "<group>"; };
371988C321E0151700639FDC /* TableDemoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableDemoViewController.swift; sourceTree = "<group>"; };
3725F37521EB49780018C5DD /* AttributeViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttributeViewModelTests.swift; sourceTree = "<group>"; };
375F98432340BFE0005CE45D /* ChangeAutoTriggerProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChangeAutoTriggerProtocol.swift; sourceTree = "<group>"; };
3793D10F21EA133A0045AD29 /* LayoutInspectorFacadeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LayoutInspectorFacadeTests.swift; sourceTree = "<group>"; };
3793D11321EA1A160045AD29 /* HierarchyBuilderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HierarchyBuilderTests.swift; sourceTree = "<group>"; };
37F29E8C21EB5D5000421B97 /* LayoutInspectorContainerViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LayoutInspectorContainerViewControllerTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -256,6 +258,7 @@
37F93C2121D28B41007CBE78 /* AppDelegate.swift */,
37F93C2321D28B41007CBE78 /* ControlsDemoViewController.swift */,
371988C321E0151700639FDC /* TableDemoViewController.swift */,
375F98432340BFE0005CE45D /* ChangeAutoTriggerProtocol.swift */,
37F93C2521D28B41007CBE78 /* Main.storyboard */,
37F93C2821D28B42007CBE78 /* Assets.xcassets */,
37F93C2A21D28B42007CBE78 /* LaunchScreen.storyboard */,
Expand Down Expand Up @@ -477,19 +480,16 @@
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-LayoutInspectorExample/Pods-LayoutInspectorExample-resources.sh",
"${PODS_ROOT}/../../LayoutInspector/Assets/LayoutInspectorAssets.xcassets",
"${PODS_ROOT}/../../LayoutInspector/LayoutInspector.storyboard",
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-LayoutInspectorExample/Pods-LayoutInspectorExample-resources-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Copy Pods Resources";
outputPaths = (
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Assets.car",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/LayoutInspector.storyboardc",
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-LayoutInspectorExample/Pods-LayoutInspectorExample-resources-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-LayoutInspectorExample/Pods-LayoutInspectorExample-resources.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-LayoutInspectorExample/Pods-LayoutInspectorExample-resources.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand Down Expand Up @@ -519,6 +519,7 @@
37F93C2421D28B41007CBE78 /* ControlsDemoViewController.swift in Sources */,
371988C421E0151700639FDC /* TableDemoViewController.swift in Sources */,
37F93C2221D28B41007CBE78 /* AppDelegate.swift in Sources */,
375F98442340BFE0005CE45D /* ChangeAutoTriggerProtocol.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
8 changes: 4 additions & 4 deletions Example/LayoutInspectorExample/Base.lproj/Main.storyboard
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="15400" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="rEm-3h-mxr">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14868" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="rEm-3h-mxr">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15404"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14824"/>
<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 @@ -385,7 +385,7 @@
<button key="customView" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="E7M-NO-FFq">
<rect key="frame" x="276" y="7" width="83" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="auto trigger"/>
<state key="normal" title="Auto trigger"/>
<connections>
<action selector="changeAutoTrigger:" destination="coi-Ui-IRU" eventType="touchUpInside" id="Tct-88-f0U"/>
</connections>
Expand Down Expand Up @@ -586,7 +586,7 @@
<button key="customView" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="bOB-au-7fF">
<rect key="frame" x="276" y="7" width="83" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="auto trigger"/>
<state key="normal" title="Auto trigger"/>
<connections>
<action selector="changeAutoTrigger:" destination="BYZ-38-t0r" eventType="touchUpInside" id="mdq-Me-cSo"/>
</connections>
Expand Down
29 changes: 29 additions & 0 deletions Example/LayoutInspectorExample/ChangeAutoTriggerProtocol.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// ChangeAutoTriggerProtocol.swift
// LayoutInspectorExample
//
// Created by Igor Savynskyi on 9/29/19.
// Copyright © 2019 Ihor Savynskyi. All rights reserved.
//

import Foundation
import UIKit
import LayoutInspector

protocol ChangeAutoTriggerProtocol {
func changeAutoTrigger()
}

extension ChangeAutoTriggerProtocol where Self: UIViewController {
func changeAutoTrigger() {
let alert = UIAlertController(title: nil, message: "Select auto trigger", preferredStyle: .actionSheet)
alert.addAction(UIAlertAction(title: "Screenshot", style: .default, handler: { (_) in
LayoutInspector.shared.setAutoTrigger(.screenshot)
}))
alert.addAction(UIAlertAction(title: "Shake", style: .default, handler: { (_) in
LayoutInspector.shared.setAutoTrigger(.shake)
}))
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
present(alert, animated: true, completion: nil)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import UIKit
import LayoutInspector

class ControlsDemoViewController: UIViewController {
class ControlsDemoViewController: UIViewController, ChangeAutoTriggerProtocol {

@IBAction private func inspectLayoutAction(_ sender: Any) {
LayoutInspector.shared.showLayout()
Expand Down
17 changes: 1 addition & 16 deletions Example/LayoutInspectorExample/TableDemoViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import UIKit
import LayoutInspector

class TableDemoViewController: UITableViewController {
class TableDemoViewController: UITableViewController, ChangeAutoTriggerProtocol {

@IBAction private func inspectAction(_ sender: Any) {
LayoutInspector.shared.showLayout()
Expand All @@ -19,18 +19,3 @@ class TableDemoViewController: UITableViewController {
changeAutoTrigger()
}
}

extension UIViewController {

func changeAutoTrigger() {
let alert = UIAlertController(title: nil, message: "select auto trigger", preferredStyle: .actionSheet)
alert.addAction(UIAlertAction(title: "screenshot", style: .default, handler: { (_) in
LayoutInspector.shared.setAutoTrigger(.screenshot)
}))
alert.addAction(UIAlertAction(title: "shake", style: .default, handler: { (_) in
LayoutInspector.shared.setAutoTrigger(.shake)
}))
alert.addAction(UIAlertAction(title: "cancel", style: .cancel, handler: nil))
present(alert, animated: true, completion: nil)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,4 @@ class LayoutInspectorFacadeTests: XCTestCase {
sharedInspectorUnderTest.setAutoTrigger(.screenshot)
XCTAssertTrue(notificationCenter.debugDescription.contains(screenshotNotificationName), "Screenshot notification should have subscribers")
}
func testSubscriptionForShake() {
// given
let sharedInspectorUnderTest = LayoutInspector.shared

// when, then
sharedInspectorUnderTest.setAutoTrigger(.none)
XCTAssertFalse(LayoutInspector.shared.motionManager.isAccelerometerActive)

sharedInspectorUnderTest.setAutoTrigger(.shake)
//this need to be tested in iOS device rather than simulator
XCTAssertTrue(LayoutInspector.shared.motionManager.isAccelerometerActive)
}
}
6 changes: 3 additions & 3 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- LayoutInspector (1.0.0)
- LayoutInspector (1.2.0)

DEPENDENCIES:
- LayoutInspector (from `../`)
Expand All @@ -9,8 +9,8 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
LayoutInspector: 4aca3ee20b9460cb1016aafe7ca25edb399b4d25
LayoutInspector: b50a2937f1497a5a116d8975ea24b219f7813024

PODFILE CHECKSUM: ceafd53887cd84376ba1b2a6cc02fd379b250eeb

COCOAPODS: 1.5.3
COCOAPODS: 1.7.5
9 changes: 5 additions & 4 deletions Example/Pods/Local Podspecs/LayoutInspector.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 14d4d5d

Please sign in to comment.