Skip to content

Commit 2555603

Browse files
committed
Add initial implementation of search control view
1 parent 79a3d46 commit 2555603

File tree

4 files changed

+84
-6
lines changed

4 files changed

+84
-6
lines changed

DevDocs.xcodeproj/project.pbxproj

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
06B5A73621D36637007823B2 /* DefaultsKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 06B5A73421D36637007823B2 /* DefaultsKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
2121
06B5A73921D3665C007823B2 /* DefaultsKit.framework.dSYM in CopyFiles */ = {isa = PBXBuildFile; fileRef = 06B5A73821D3665C007823B2 /* DefaultsKit.framework.dSYM */; };
2222
06B5A73B21D36680007823B2 /* Storage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B5A73A21D36680007823B2 /* Storage.swift */; };
23+
06CAA19D230D11EA00BBC1DE /* SearchControlView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 06CAA19C230D11EA00BBC1DE /* SearchControlView.xib */; };
24+
06CAA19F230D15B800BBC1DE /* SearchControlViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06CAA19E230D15B800BBC1DE /* SearchControlViewController.swift */; };
2325
06CAA897223E6ACB00B296AC /* URLEventHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06CAA896223E6ACB00B296AC /* URLEventHandler.swift */; };
2426
06EAE7ED21D0CB3D00F7C921 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06EAE7EC21D0CB3D00F7C921 /* AppDelegate.swift */; };
2527
06EAE7EF21D0CB3E00F7C921 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 06EAE7EE21D0CB3E00F7C921 /* Assets.xcassets */; };
@@ -68,6 +70,8 @@
6870
06B5A73421D36637007823B2 /* DefaultsKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DefaultsKit.framework; path = Carthage/Build/Mac/DefaultsKit.framework; sourceTree = "<group>"; };
6971
06B5A73821D3665C007823B2 /* DefaultsKit.framework.dSYM */ = {isa = PBXFileReference; lastKnownFileType = wrapper.dsym; name = DefaultsKit.framework.dSYM; path = Carthage/Build/Mac/DefaultsKit.framework.dSYM; sourceTree = "<group>"; };
7072
06B5A73A21D36680007823B2 /* Storage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Storage.swift; sourceTree = "<group>"; };
73+
06CAA19C230D11EA00BBC1DE /* SearchControlView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SearchControlView.xib; sourceTree = "<group>"; };
74+
06CAA19E230D15B800BBC1DE /* SearchControlViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchControlViewController.swift; sourceTree = "<group>"; };
7175
06CAA896223E6ACB00B296AC /* URLEventHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLEventHandler.swift; sourceTree = "<group>"; };
7276
06EAE7E921D0CB3D00F7C921 /* DevDocs.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DevDocs.app; sourceTree = BUILT_PRODUCTS_DIR; };
7377
06EAE7EC21D0CB3D00F7C921 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
@@ -133,15 +137,17 @@
133137
06EAE7FE21D0FA4000F7C921 /* DocumentationViewController.swift */,
134138
06EAE7FA21D0CD8F00F7C921 /* DocumentationWindow.xib */,
135139
06EAE7FC21D0CE3E00F7C921 /* DocumentationWindowController.swift */,
136-
06996D3A223DEF54001507AD /* PreferencesWindowController.swift */,
137-
06996D3B223DEF54001507AD /* PreferencesWindowController.xib */,
138140
06B5A73021D354FC007823B2 /* DocumentationWindows.swift */,
139141
06EAE7F321D0CB3E00F7C921 /* Info.plist */,
140142
06EAE7F021D0CB3E00F7C921 /* MainMenu.xib */,
141-
06B5A71921D2013D007823B2 /* user-scripts */,
143+
06996D3A223DEF54001507AD /* PreferencesWindowController.swift */,
144+
06996D3B223DEF54001507AD /* PreferencesWindowController.xib */,
145+
06CAA19C230D11EA00BBC1DE /* SearchControlView.xib */,
146+
06CAA19E230D15B800BBC1DE /* SearchControlViewController.swift */,
142147
06B5A73A21D36680007823B2 /* Storage.swift */,
143148
06996D2C223DDBEB001507AD /* Summoner.swift */,
144149
06CAA896223E6ACB00B296AC /* URLEventHandler.swift */,
150+
06B5A71921D2013D007823B2 /* user-scripts */,
145151
);
146152
path = "devdocs-macos";
147153
sourceTree = "<group>";
@@ -213,6 +219,7 @@
213219
6F4E7DD5223DBDB70074E6F1 /* MASShortcut.framework.dSYM in Resources */,
214220
06B5A71A21D2013D007823B2 /* user-scripts in Resources */,
215221
06EAE7F221D0CB3E00F7C921 /* MainMenu.xib in Resources */,
222+
06CAA19D230D11EA00BBC1DE /* SearchControlView.xib in Resources */,
216223
);
217224
runOnlyForDeploymentPostprocessing = 0;
218225
};
@@ -223,6 +230,7 @@
223230
isa = PBXSourcesBuildPhase;
224231
buildActionMask = 2147483647;
225232
files = (
233+
06CAA19F230D15B800BBC1DE /* SearchControlViewController.swift in Sources */,
226234
06996D2D223DDBEB001507AD /* Summoner.swift in Sources */,
227235
06EAE7FF21D0FA4000F7C921 /* DocumentationViewController.swift in Sources */,
228236
06996D3C223DEF54001507AD /* PreferencesWindowController.swift in Sources */,

devdocs-macos/DocumentationWindow.xib

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
33
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14460.31"/>
4+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
55
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
66
</dependencies>
77
<objects>
@@ -17,7 +17,7 @@
1717
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
1818
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
1919
<rect key="contentRect" x="196" y="240" width="800" height="600"/>
20-
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
20+
<rect key="screenRect" x="0.0" y="0.0" width="1280" height="777"/>
2121
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
2222
<rect key="frame" x="0.0" y="0.0" width="800" height="600"/>
2323
<autoresizingMask key="autoresizingMask"/>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
3+
<dependencies>
4+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
5+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
6+
</dependencies>
7+
<objects>
8+
<customObject id="-2" userLabel="File's Owner" customClass="SearchControlViewController" customModule="DevDocs" customModuleProvider="target">
9+
<connections>
10+
<outlet property="searchField" destination="Sob-7j-rmS" id="63N-X7-5xX"/>
11+
</connections>
12+
</customObject>
13+
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
14+
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
15+
<customView id="c22-O7-iKe">
16+
<rect key="frame" x="0.0" y="0.0" width="376" height="19"/>
17+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
18+
<subviews>
19+
<searchField wantsLayer="YES" verticalHuggingPriority="750" fixedFrame="YES" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Sob-7j-rmS">
20+
<rect key="frame" x="0.0" y="0.0" width="309" height="19"/>
21+
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
22+
<searchFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" borderStyle="bezel" usesSingleLineMode="YES" bezelStyle="round" sendsSearchStringImmediately="YES" sendsWholeSearchString="YES" id="p9W-s3-2vm">
23+
<font key="font" metaFont="smallSystem"/>
24+
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
25+
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
26+
</searchFieldCell>
27+
<connections>
28+
<action selector="performSearchWithSender:" target="-2" id="qdb-CE-9Q0"/>
29+
</connections>
30+
</searchField>
31+
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="NIJ-J2-h3b">
32+
<rect key="frame" x="317.5" y="0.0" width="60" height="19"/>
33+
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
34+
<buttonCell key="cell" type="roundTextured" title="Done" bezelStyle="texturedRounded" alignment="center" controlSize="small" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="HKN-5M-iIK">
35+
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
36+
<font key="font" metaFont="smallSystem"/>
37+
</buttonCell>
38+
<connections>
39+
<action selector="dismissSearchWithSender:" target="-2" id="wRM-kj-W9W"/>
40+
</connections>
41+
</button>
42+
</subviews>
43+
<point key="canvasLocation" x="80" y="58"/>
44+
</customView>
45+
</objects>
46+
</document>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import Cocoa
2+
3+
class SearchControlViewController: NSViewController {
4+
@IBOutlet weak var searchField: NSSearchField?
5+
weak var delegate: SearchControlDelegate?
6+
7+
@IBAction func performSearch(sender: Any) {
8+
let searchTerm = (searchField?.stringValue ?? "")
9+
.trimmingCharacters(in: .whitespacesAndNewlines)
10+
if (searchTerm.isEmpty) {
11+
return
12+
}
13+
delegate?.search(term: searchTerm)
14+
}
15+
16+
@IBAction func dismissSearch(sender: Any) {
17+
delegate?.dismiss()
18+
}
19+
}
20+
21+
protocol SearchControlDelegate: class {
22+
func search(term: String)
23+
func dismiss()
24+
}

0 commit comments

Comments
 (0)