Skip to content

Commit

Permalink
Make CrowdCountMac app because playgrounds are so fickle
Browse files Browse the repository at this point in the history
  • Loading branch information
dimroc committed Aug 12, 2018
1 parent d409503 commit 3003191
Show file tree
Hide file tree
Showing 15 changed files with 680 additions and 7 deletions.
231 changes: 231 additions & 0 deletions ios/CrowdCount.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions ios/CrowdCountApi/PredictionStrategy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extension PredictionStrategy {
public var friendlyName: String {
return String(describing: self)
.replacingOccurrences(of: "CrowdCountApi.", with: "")
.replacingOccurrences(of: "CrowdCountApiMac.", with: "")
.replacingOccurrences(of: "PredictionStrategy", with: "")
}

Expand Down
2 changes: 2 additions & 0 deletions ios/CrowdCountApi/Utils/Duration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ public class Duration {
private let depth: Int
private var timingStack = [(startTime:Double, name:String, reported:Bool)]()

@discardableResult
public static func measure(_ name: String, depth: Int = 0, block: () -> Void) -> Double {
let duration = Duration(depth)
duration.startMeasurement(name)
block()
return duration.stopMeasurement()
}

@discardableResult
public static func measureAndReturn<T>(_ name: String, depth: Int = 0, block: () -> T) -> T {
let duration = Duration(depth)
duration.startMeasurement(name)
Expand Down
26 changes: 26 additions & 0 deletions ios/CrowdCountMac/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// AppDelegate.swift
// CrowdCountMac
//
// Created by Dimitri Roche on 8/12/18.
// Copyright © 2018 Dimitri Roche. All rights reserved.
//

import Cocoa
import Cartography

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

@IBOutlet weak var window: NSWindow!
let vc = DragDropViewController()

func applicationDidFinishLaunching(_ aNotification: Notification) {
window.contentViewController = vc
}

func applicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
}

}
58 changes: 58 additions & 0 deletions ios/CrowdCountMac/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"images" : [
{
"idiom" : "mac",
"size" : "16x16",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "16x16",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "32x32",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "32x32",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "128x128",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "128x128",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "256x256",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "256x256",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "512x512",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "512x512",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
6 changes: 6 additions & 0 deletions ios/CrowdCountMac/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
102 changes: 102 additions & 0 deletions ios/CrowdCountMac/Base.lproj/DragDropViewController.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14313.3.2" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14313.3.2"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="DragDropViewController" customModule="Crowd_Count" customModuleProvider="target">
<connections>
<outlet property="imageWell" destination="tmM-56-WMo" id="FSD-w9-Q8d"/>
<outlet property="predictionLabel" destination="for-DB-XJS" id="aXl-64-5ke"/>
<outlet property="stackView" destination="ZgG-JC-WHg" id="KPO-sN-qh5"/>
<outlet property="view" destination="c22-O7-iKe" id="Tih-bX-s0g"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="c22-O7-iKe">
<rect key="frame" x="0.0" y="0.0" width="600" height="475"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES"/>
<subviews>
<scrollView horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="q7e-VA-Hkc">
<rect key="frame" x="0.0" y="0.0" width="600" height="475"/>
<clipView key="contentView" id="PEj-yI-RqR">
<rect key="frame" x="1" y="1" width="598" height="473"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView distribution="fillProportionally" orientation="vertical" alignment="centerX" spacing="20" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ZgG-JC-WHg">
<rect key="frame" x="0.0" y="-2" width="598" height="475"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" tag="1" translatesAutoresizingMaskIntoConstraints="NO" id="IDJ-z3-Nuh">
<rect key="frame" x="116" y="416" width="366" height="39"/>
<constraints>
<constraint firstAttribute="height" constant="39" id="Z7z-a6-UOs"/>
</constraints>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="Drag in an image of a crowd" id="M7n-nN-27S">
<font key="font" metaFont="systemUltraLight" size="32"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" tag="2" translatesAutoresizingMaskIntoConstraints="NO" id="tmM-56-WMo">
<rect key="frame" x="74" y="61" width="450" height="338"/>
<constraints>
<constraint firstAttribute="width" constant="444" id="lX5-rT-MFp"/>
<constraint firstAttribute="height" constant="332" id="vPX-Mc-68A"/>
</constraints>
<imageCell key="cell" selectable="YES" editable="YES" alignment="left" imageScaling="proportionallyDown" imageFrameStyle="grayBezel" id="ZzE-tp-Vg1"/>
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" tag="3" translatesAutoresizingMaskIntoConstraints="NO" id="for-DB-XJS">
<rect key="frame" x="219" y="20" width="161" height="24"/>
<constraints>
<constraint firstAttribute="height" constant="24" id="jlF-8x-hc0"/>
</constraints>
<textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="Pending Prediction" placeholderString="Pending Prediction" id="Nvr-56-Phb">
<font key="font" metaFont="systemUltraLight" size="20"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<edgeInsets key="edgeInsets" left="0.0" right="0.0" top="20" bottom="20"/>
<visibilityPriorities>
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
</visibilityPriorities>
<customSpacing>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
</customSpacing>
</stackView>
</subviews>
<constraints>
<constraint firstItem="ZgG-JC-WHg" firstAttribute="top" secondItem="PEj-yI-RqR" secondAttribute="top" id="7Af-uz-aMi"/>
<constraint firstItem="ZgG-JC-WHg" firstAttribute="leading" secondItem="PEj-yI-RqR" secondAttribute="leading" id="FtZ-3c-S7X"/>
<constraint firstItem="ZgG-JC-WHg" firstAttribute="width" secondItem="PEj-yI-RqR" secondAttribute="width" id="LfP-IO-XrI"/>
</constraints>
</clipView>
<scroller key="horizontalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="pK8-I7-7nX">
<rect key="frame" x="1" y="458" width="598" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="oJV-K4-ewE">
<rect key="frame" x="583" y="1" width="16" height="473"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
</subviews>
<constraints>
<constraint firstItem="q7e-VA-Hkc" firstAttribute="top" secondItem="c22-O7-iKe" secondAttribute="top" id="07R-kP-oTx"/>
<constraint firstAttribute="trailing" secondItem="q7e-VA-Hkc" secondAttribute="trailing" id="0hh-Go-EMX"/>
<constraint firstItem="q7e-VA-Hkc" firstAttribute="width" secondItem="c22-O7-iKe" secondAttribute="width" id="47P-4Q-lK3"/>
<constraint firstItem="q7e-VA-Hkc" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" id="g9P-Df-0ux"/>
<constraint firstAttribute="bottom" secondItem="q7e-VA-Hkc" secondAttribute="bottom" id="qza-iQ-MA0"/>
</constraints>
<point key="canvasLocation" x="222" y="667.5"/>
</customView>
<userDefaultsController representsSharedInstance="YES" id="6y6-34-9ce"/>
</objects>
</document>
81 changes: 81 additions & 0 deletions ios/CrowdCountMac/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14313.3.2" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14313.3.2"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
<connections>
<outlet property="delegate" destination="Voe-Tx-rLC" id="GzC-gU-4Uq"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application"/>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="CrowdCountMac" customModuleProvider="target">
<connections>
<outlet property="window" destination="QvC-M9-y7g" id="gIp-Ho-8D9"/>
</connections>
</customObject>
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
<menu title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
<items>
<menuItem title="Crowd Count" id="1Xt-HY-uBw">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Crowd Count" systemMenu="apple" id="uQy-DD-JDr">
<items>
<menuItem title="About CrowdCountMac" id="5kV-Vb-QxS">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="orderFrontStandardAboutPanel:" target="-1" id="Exp-CZ-Vem"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/>
<menuItem title="Preferences…" keyEquivalent="," id="BOF-NM-1cW"/>
<menuItem isSeparatorItem="YES" id="wFC-TO-SCJ"/>
<menuItem title="Services" id="NMo-om-nkz">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Services" systemMenu="services" id="hz9-B4-Xy5"/>
</menuItem>
<menuItem isSeparatorItem="YES" id="4je-JR-u6R"/>
<menuItem title="Hide CrowdCountMac" keyEquivalent="h" id="Olw-nP-bQN">
<connections>
<action selector="hide:" target="-1" id="PnN-Uc-m68"/>
</connections>
</menuItem>
<menuItem title="Hide Others" keyEquivalent="h" id="Vdr-fp-XzO">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="hideOtherApplications:" target="-1" id="VT4-aY-XCT"/>
</connections>
</menuItem>
<menuItem title="Show All" id="Kd2-mp-pUS">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="unhideAllApplications:" target="-1" id="Dhg-Le-xox"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="kCx-OE-vgT"/>
<menuItem title="Quit CrowdCountMac" keyEquivalent="q" id="4sb-4s-VLi">
<connections>
<action selector="terminate:" target="-1" id="Te7-pn-YzF"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
</items>
<point key="canvasLocation" x="-15" y="-324"/>
</menu>
<window title="Crowd Count" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="335" y="390" width="400" height="400"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="400" height="400"/>
<autoresizingMask key="autoresizingMask"/>
</view>
</window>
</objects>
</document>
10 changes: 10 additions & 0 deletions ios/CrowdCountMac/CrowdCountMac.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict>
</plist>
Loading

0 comments on commit 3003191

Please sign in to comment.