Skip to content

Commit cdd1cc5

Browse files
lsecreaselsecrease
authored andcommitted
EditSpecials
1 parent aed6a0f commit cdd1cc5

File tree

6 files changed

+148
-12
lines changed

6 files changed

+148
-12
lines changed

Dindr.xcodeproj/project.pbxproj

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,24 @@
179179
name = Frameworks;
180180
sourceTree = "<group>";
181181
};
182+
284186771BF817250071DAB5 /* ManageAccount */ = {
183+
isa = PBXGroup;
184+
children = (
185+
28C5C2A61BF80204000647A5 /* ManageAccountViewController.swift */,
186+
);
187+
name = ManageAccount;
188+
sourceTree = "<group>";
189+
};
190+
284186781BF8173C0071DAB5 /* Perks */ = {
191+
isa = PBXGroup;
192+
children = (
193+
CEEF5DA31BA8B55F0077769E /* SpecialsTableViewController.swift */,
194+
CE2D49C01BE06D28007DCBE3 /* SpecialsTableViewCell.swift */,
195+
28C5C2A41BF7F0B2000647A5 /* EditSpecialsViewController.swift */,
196+
);
197+
name = Perks;
198+
sourceTree = "<group>";
199+
};
182200
CE46054B1BC33FAF007A2B7D /* Gallery */ = {
183201
isa = PBXGroup;
184202
children = (
@@ -282,13 +300,11 @@
282300
CE9C42F01BC1D36000504B69 /* Login */,
283301
CE9F9EEE1B802C1B0060D993 /* RestaurantDataViewController.swift */,
284302
CEEF5D9F1BA8A7610077769E /* RestCollectionViewCell.swift */,
285-
CEEF5DA31BA8B55F0077769E /* SpecialsTableViewController.swift */,
286-
CE2D49C01BE06D28007DCBE3 /* SpecialsTableViewCell.swift */,
287-
28C5C2A41BF7F0B2000647A5 /* EditSpecialsViewController.swift */,
303+
284186781BF8173C0071DAB5 /* Perks */,
288304
CE46054B1BC33FAF007A2B7D /* Gallery */,
289305
CEEF5DA11BA8A8BF0077769E /* DishModel.swift */,
290306
CEB40ED71BD6BCE700863F60 /* PreviewImageViewController.swift */,
291-
28C5C2A61BF80204000647A5 /* ManageAccountViewController.swift */,
307+
284186771BF817250071DAB5 /* ManageAccount */,
292308
CEC9F2101B7851B3000A74A9 /* Main.storyboard */,
293309
CEC9F2131B7851B3000A74A9 /* Images.xcassets */,
294310
CEC9F2151B7851B3000A74A9 /* LaunchScreen.xib */,

Dindr/Base.lproj/Main.storyboard

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -512,38 +512,90 @@
512512
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
513513
<subviews>
514514
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Tell Us more about your Perk!" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bnK-FD-NY6">
515-
<rect key="frame" x="59" y="178" width="257" height="25"/>
515+
<rect key="frame" x="59" y="115" width="257" height="25"/>
516516
<fontDescription key="fontDescription" name="AvenirNext-Bold" family="Avenir Next" pointSize="18"/>
517517
<nil key="highlightedColor"/>
518518
</label>
519-
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" misplaced="YES" text="This is the description of the Perk, etc., etc." textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="mug-WA-eKn">
520-
<rect key="frame" x="8" y="233" width="359" height="100"/>
519+
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" text="This is the description of the Perk, etc., etc." textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="mug-WA-eKn">
520+
<rect key="frame" x="16" y="148" width="343" height="150"/>
521521
<constraints>
522522
<constraint firstAttribute="height" constant="100" id="4VJ-8n-or3"/>
523+
<constraint firstAttribute="height" constant="150" id="fhQ-jz-8ec"/>
523524
</constraints>
524-
<fontDescription key="fontDescription" type="system" pointSize="14"/>
525+
<fontDescription key="fontDescription" name="AvenirNext-Regular" family="Avenir Next" pointSize="14"/>
525526
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
527+
<variation key="default">
528+
<mask key="constraints">
529+
<exclude reference="4VJ-8n-or3"/>
530+
</mask>
531+
</variation>
526532
</textView>
527533
</subviews>
528534
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
529535
<constraints>
536+
<constraint firstAttribute="trailingMargin" secondItem="mug-WA-eKn" secondAttribute="trailing" constant="-4" id="43m-uA-DUC"/>
537+
<constraint firstItem="mug-WA-eKn" firstAttribute="leading" secondItem="5b2-eD-Rvy" secondAttribute="leadingMargin" id="6Kc-io-NI2"/>
530538
<constraint firstItem="mug-WA-eKn" firstAttribute="top" secondItem="bnK-FD-NY6" secondAttribute="bottom" constant="30" id="7Aq-fm-fkr"/>
539+
<constraint firstItem="mug-WA-eKn" firstAttribute="centerX" secondItem="5b2-eD-Rvy" secondAttribute="centerX" id="Exd-pr-9TS"/>
540+
<constraint firstItem="mug-WA-eKn" firstAttribute="leading" secondItem="5b2-eD-Rvy" secondAttribute="leadingMargin" constant="-4" id="Gor-We-FKb"/>
541+
<constraint firstItem="bnK-FD-NY6" firstAttribute="top" secondItem="Tvj-yp-1jg" secondAttribute="bottom" constant="51" id="Ihw-uP-77U"/>
531542
<constraint firstItem="bnK-FD-NY6" firstAttribute="centerX" secondItem="5b2-eD-Rvy" secondAttribute="centerX" id="aKP-fQ-hMg"/>
543+
<constraint firstItem="mug-WA-eKn" firstAttribute="top" secondItem="bnK-FD-NY6" secondAttribute="bottom" constant="8" id="bMZ-ZU-FQK"/>
532544
<constraint firstAttribute="trailingMargin" secondItem="mug-WA-eKn" secondAttribute="trailing" constant="-12" id="cta-ME-3Gc"/>
545+
<constraint firstItem="ZUe-Zv-0bA" firstAttribute="top" secondItem="mug-WA-eKn" secondAttribute="bottom" constant="468" id="jpP-56-nM1"/>
533546
<constraint firstItem="bnK-FD-NY6" firstAttribute="top" secondItem="Tvj-yp-1jg" secondAttribute="bottom" constant="114" id="kfP-6t-Y0M"/>
547+
<constraint firstItem="mug-WA-eKn" firstAttribute="top" secondItem="bnK-FD-NY6" secondAttribute="bottom" constant="8" id="ocA-0y-zP4"/>
534548
<constraint firstItem="mug-WA-eKn" firstAttribute="leading" secondItem="5b2-eD-Rvy" secondAttribute="leadingMargin" constant="-12" id="ruf-rL-zQ6"/>
549+
<constraint firstItem="mug-WA-eKn" firstAttribute="top" secondItem="bnK-FD-NY6" secondAttribute="bottom" constant="8" symbolic="YES" id="zM6-dR-5pV"/>
550+
<constraint firstItem="mug-WA-eKn" firstAttribute="leading" secondItem="5b2-eD-Rvy" secondAttribute="leadingMargin" constant="-4" id="zdy-pM-2QC"/>
535551
</constraints>
552+
<variation key="default">
553+
<mask key="constraints">
554+
<exclude reference="kfP-6t-Y0M"/>
555+
<exclude reference="43m-uA-DUC"/>
556+
<exclude reference="7Aq-fm-fkr"/>
557+
<exclude reference="Gor-We-FKb"/>
558+
<exclude reference="bMZ-ZU-FQK"/>
559+
<exclude reference="cta-ME-3Gc"/>
560+
<exclude reference="ocA-0y-zP4"/>
561+
<exclude reference="ruf-rL-zQ6"/>
562+
<exclude reference="zdy-pM-2QC"/>
563+
<exclude reference="jpP-56-nM1"/>
564+
</mask>
565+
</variation>
536566
</view>
537567
<navigationItem key="navigationItem" title="Edit Perk" id="QVW-YV-wKd">
538568
<barButtonItem key="rightBarButtonItem" systemItem="save" id="JuL-pj-25H">
539569
<color key="tintColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
540570
</barButtonItem>
541571
</navigationItem>
542572
<connections>
573+
<outlet property="hideKeyboardInputAccessoryView" destination="I4k-Cd-4fq" id="OE7-gx-d1m"/>
543574
<outlet property="perkDescriptionTextView" destination="mug-WA-eKn" id="zrZ-y4-zJb"/>
544575
</connections>
545576
</viewController>
546577
<placeholder placeholderIdentifier="IBFirstResponder" id="4D9-gz-d43" userLabel="First Responder" sceneMemberID="firstResponder"/>
578+
<view contentMode="scaleToFill" id="I4k-Cd-4fq" userLabel="HideKeyboardInputAccessoryView">
579+
<rect key="frame" x="0.0" y="0.0" width="375" height="30"/>
580+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
581+
<subviews>
582+
<button opaque="NO" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="dgL-Nl-5gh">
583+
<rect key="frame" x="337" y="2" width="30" height="26"/>
584+
<constraints>
585+
<constraint firstAttribute="width" constant="30" id="O1M-GK-UcR"/>
586+
<constraint firstAttribute="height" constant="26" id="Oik-t1-wci"/>
587+
</constraints>
588+
<state key="normal" image="HideKeyboardButton"/>
589+
<connections>
590+
<action selector="hideKeyboard" destination="96o-aS-uNg" eventType="touchUpInside" id="81X-gf-j5r"/>
591+
</connections>
592+
</button>
593+
</subviews>
594+
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
595+
<constraints>
596+
<constraint firstAttribute="trailing" secondItem="dgL-Nl-5gh" secondAttribute="trailing" constant="8" id="Kr3-0P-gDh"/>
597+
</constraints>
598+
</view>
547599
</objects>
548600
<point key="canvasLocation" x="4460.5" y="1079.5"/>
549601
</scene>
@@ -792,6 +844,7 @@
792844
</scene>
793845
</scenes>
794846
<resources>
847+
<image name="HideKeyboardButton" width="53" height="55"/>
795848
<image name="cam-1" width="30" height="30"/>
796849
<image name="f1" width="924" height="693"/>
797850
<image name="f5" width="2048" height="1152"/>

Dindr/EditSpecialsViewController.swift

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,58 @@ class EditSpecialsViewController: UIViewController {
1212

1313
@IBOutlet weak var perkDescriptionTextView: UITextView!
1414

15+
@IBOutlet var hideKeyboardInputAccessoryView: UIView!
16+
17+
override func preferredStatusBarStyle() -> UIStatusBarStyle {
18+
return .LightContent
19+
}
1520

1621
override func viewDidLoad() {
1722
super.viewDidLoad()
23+
24+
perkDescriptionTextView.inputAccessoryView = hideKeyboardInputAccessoryView
1825

19-
// Do any additional setup after loading the view.
26+
perkDescriptionTextView.becomeFirstResponder()
27+
//perkDescriptionTextView.delegate = self
28+
29+
30+
// handle text view
31+
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillHide:", name: UIKeyboardWillHideNotification, object: nil)
32+
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillShow:", name: UIKeyboardWillShowNotification, object: nil)
33+
}
34+
35+
@IBAction func hideKeyboard()
36+
{
37+
if perkDescriptionTextView.isFirstResponder() {
38+
perkDescriptionTextView.resignFirstResponder()
39+
}
2040
}
2141

22-
override func didReceiveMemoryWarning() {
23-
super.didReceiveMemoryWarning()
24-
// Dispose of any resources that can be recreated.
42+
43+
// MARK: - Text View Handler
44+
45+
deinit {
46+
NSNotificationCenter.defaultCenter().removeObserver(self)
47+
}
48+
49+
func keyboardWillShow(notification: NSNotification)
50+
{
51+
let userInfo = notification.userInfo ?? [:]
52+
let keyboardSize = (userInfo[UIKeyboardFrameBeginUserInfoKey] as! NSValue).CGRectValue().size
53+
54+
self.perkDescriptionTextView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: keyboardSize.height, right: 0)
55+
self.perkDescriptionTextView.scrollIndicatorInsets = self.perkDescriptionTextView.contentInset
56+
}
57+
58+
func keyboardWillHide(notification: NSNotification)
59+
{
60+
self.perkDescriptionTextView.contentInset = UIEdgeInsetsZero
61+
self.perkDescriptionTextView.scrollIndicatorInsets = UIEdgeInsetsZero
2562
}
2663

2764

2865

2966
}
67+
68+
69+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"filename" : "HideKeyboardButton.png",
6+
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "universal",
10+
"scale" : "2x"
11+
},
12+
{
13+
"idiom" : "universal",
14+
"scale" : "3x"
15+
}
16+
],
17+
"info" : {
18+
"version" : 1,
19+
"author" : "xcode"
20+
}
21+
}
6.68 KB
Loading

0 commit comments

Comments
 (0)