Skip to content

Commit

Permalink
Pass SearchParameters to SearchResults VC and display a label for now
Browse files Browse the repository at this point in the history
  • Loading branch information
kenstir committed Jun 28, 2018
1 parent 5ecf9dd commit 33a9ede
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
3 changes: 2 additions & 1 deletion Source/Scenes/Checkouts/CheckoutsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ extension CheckoutsViewController: UITableViewDataSource {
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let vc = segue.destination
if let detailsVC = vc as? DetailsViewController,
let mvrObj = selectedItem?.mvrObj {
let mvrObj = selectedItem?.mvrObj
{
let record = MBRecord(mvrObj: mvrObj)
detailsVC.item = record
} else {
Expand Down
6 changes: 3 additions & 3 deletions Source/Scenes/Search/Results.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="blah de blah blah" textAlignment="natural" lineBreakMode="wordWrap" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jYh-2p-sC8">
<rect key="frame" x="16" y="36" width="343" height="20.5"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="TopLeft" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="blah de blah blah" lineBreakMode="wordWrap" numberOfLines="7" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jYh-2p-sC8">
<rect key="frame" x="16" y="36" width="343" height="203"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
Expand All @@ -39,7 +39,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="RsD-gI-UQR" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2047" y="-548"/>
<point key="canvasLocation" x="2045.5999999999999" y="-548.27586206896558"/>
</scene>
</scenes>
</document>
13 changes: 12 additions & 1 deletion Source/Scenes/Search/ResultsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ResultsViewController: UIViewController {

@IBOutlet weak var searchParametersLabel: UILabel!

var searchParameters: SearchParameters?
var resultIDs: [Int] = []
var records: [String] = []

Expand All @@ -41,10 +42,20 @@ class ResultsViewController: UIViewController {
//MARK: - Functions

func setupViews() {
searchParametersLabel.text = """
var label: String
if let sp = searchParameters {
label = "You searched for:\n"
label += "\n"
label += "\(sp.scope):\(sp.text)\n"
label += "search_format(\(sp.format!))\n"
label += "site(\(sp.location!))\n"
} else {
label = """
The engravings translate to
'This space intentionally left blank'.
"""
}
searchParametersLabel.text = label
}
}

17 changes: 12 additions & 5 deletions Source/Scenes/Search/SearchViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,18 @@ class SearchViewController: UIViewController {
locationPicker?.text = selections[0]!
}
}

@IBAction func buttonPressed(sender: UIButton) {
print("xxx button pressed - \(sender)")

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let vc = segue.destination
if let resultsVC = vc as? ResultsViewController,
let searchText = searchBar.text
{
let params = SearchParameters(text: searchText, scope: scopes[scopeControl.selectedSegmentIndex], format: formatPicker.text, location: locationPicker.text)
resultsVC.searchParameters = params
} else {
print("Uh oh!")
}

}
}

Expand All @@ -108,8 +117,6 @@ extension SearchViewController: UISearchBarDelegate {
self.showAlert(title: "", message: "Search words cannot be empty")
return
}
let params = SearchParameters(text: searchText, scope: scopes[scopeControl.selectedSegmentIndex], format: formatPicker.text, location: locationPicker.text)
debugPrint(params)
print("xxx searchBarSearchButtonClicked")
self.performSegue(withIdentifier: "ShowBogusSegue", sender: nil)
}
Expand Down

0 comments on commit 33a9ede

Please sign in to comment.