Skip to content

Commit 4971e77

Browse files
committed
- added add category/button
- added edit category/button
1 parent 1d90d2a commit 4971e77

File tree

10 files changed

+411
-136
lines changed

10 files changed

+411
-136
lines changed

Diff for: JacobsVoice.xcodeproj/project.pbxproj

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
C415E33220EACB61007683BE /* UIColorExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C415E33120EACB61007683BE /* UIColorExtension.swift */; };
1818
C415E33420EACC5C007683BE /* CategoryModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C415E33320EACC5C007683BE /* CategoryModel.swift */; };
1919
C415E33620EACEBA007683BE /* UIButtonExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C415E33520EACEBA007683BE /* UIButtonExtension.swift */; };
20+
C43A649020F289060007A8BF /* ButtonAddCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43A648F20F289060007A8BF /* ButtonAddCell.swift */; };
21+
C43A649220F295230007A8BF /* CategoryAddCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43A649120F295230007A8BF /* CategoryAddCell.swift */; };
2022
C4B5C45B1B07F6A900732A2A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4B5C45A1B07F6A900732A2A /* AppDelegate.swift */; };
2123
C4B5C45D1B07F6A900732A2A /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4B5C45C1B07F6A900732A2A /* ViewController.swift */; };
2224
C4B5C4601B07F6A900732A2A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C4B5C45E1B07F6A900732A2A /* Main.storyboard */; };
@@ -53,6 +55,8 @@
5355
C415E33120EACB61007683BE /* UIColorExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIColorExtension.swift; sourceTree = "<group>"; };
5456
C415E33320EACC5C007683BE /* CategoryModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CategoryModel.swift; sourceTree = "<group>"; };
5557
C415E33520EACEBA007683BE /* UIButtonExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIButtonExtension.swift; sourceTree = "<group>"; };
58+
C43A648F20F289060007A8BF /* ButtonAddCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonAddCell.swift; sourceTree = "<group>"; };
59+
C43A649120F295230007A8BF /* CategoryAddCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CategoryAddCell.swift; sourceTree = "<group>"; };
5660
C4B5C4551B07F6A900732A2A /* JacobsVoice.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = JacobsVoice.app; sourceTree = BUILT_PRODUCTS_DIR; };
5761
C4B5C4591B07F6A900732A2A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
5862
C4B5C45A1B07F6A900732A2A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
@@ -144,7 +148,9 @@
144148
isa = PBXGroup;
145149
children = (
146150
C415E32020E6E30C007683BE /* ButtonCell.swift */,
151+
C43A648F20F289060007A8BF /* ButtonAddCell.swift */,
147152
C415E32320E6FB56007683BE /* CategoryCell.swift */,
153+
C43A649120F295230007A8BF /* CategoryAddCell.swift */,
148154
C4B5C45C1B07F6A900732A2A /* ViewController.swift */,
149155
C415E32620E78D94007683BE /* SettingsController.swift */,
150156
);
@@ -389,11 +395,13 @@
389395
buildActionMask = 2147483647;
390396
files = (
391397
C415E32720E78D94007683BE /* SettingsController.swift in Sources */,
398+
C43A649020F289060007A8BF /* ButtonAddCell.swift in Sources */,
392399
C415E33420EACC5C007683BE /* CategoryModel.swift in Sources */,
393400
C4B5C45D1B07F6A900732A2A /* ViewController.swift in Sources */,
394401
C4B5C45B1B07F6A900732A2A /* AppDelegate.swift in Sources */,
395402
C4B5C4821B08096D00732A2A /* SpeechHelper.swift in Sources */,
396403
C415E32420E6FB56007683BE /* CategoryCell.swift in Sources */,
404+
C43A649220F295230007A8BF /* CategoryAddCell.swift in Sources */,
397405
C4F1ABBA1C7A2489000D5773 /* DatabaseHelper.swift in Sources */,
398406
C4C0AB4A1B0845F400AB7EE0 /* Constants.swift in Sources */,
399407
C415E33620EACEBA007683BE /* UIButtonExtension.swift in Sources */,

Diff for: JacobsVoice/Base.lproj/Main.storyboard

+158-54
Large diffs are not rendered by default.

Diff for: JacobsVoice/ButtonAddCell.swift

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// ButtonAddCell.swift
3+
// JacobsVoice
4+
//
5+
// Created by Klemen Kastelic on 08/07/2018.
6+
// Copyright © 2018 Klemen Kastelic. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
class ButtonAddCell: UICollectionViewCell {
12+
@IBOutlet weak var mainButton: UIButton!
13+
}

Diff for: JacobsVoice/ButtonCell.swift

+2-38
Original file line numberDiff line numberDiff line change
@@ -10,52 +10,16 @@ import UIKit
1010

1111

1212
class ButtonCell: UICollectionViewCell {
13-
@IBOutlet weak var mainView: UIView!
1413
@IBOutlet weak var mainButton: UIButton!
14+
@IBOutlet weak var label: UILabel!
1515
public var button: Button?
1616

17-
18-
1917
public func set(_ button: Button){
2018
self.button = button
19+
self.label.text = self.button?.name
2120
self.mainButton.setTitle(self.button?.name, for: .normal)
22-
//self.mainButton.addTarget(self, action: #selector(self.buttonClicked(sender:)), for: .touchUpInside)
2321

2422
let color = UIColor(hexString: self.button?.color ?? "cccccc")
2523
self.mainButton.borderColor = color
26-
//self.mainButton.setBackgroundColor(color, forState: .highlighted)
27-
}
28-
29-
30-
func longPressed(longPress: UIGestureRecognizer) {
31-
var inputTextField: UITextField?
32-
if (longPress.state == UIGestureRecognizerState.ended) {
33-
// Gesture ended
34-
let button = longPress.view as? UIButton
35-
button!.backgroundColor = UIColor(red:1.0, green:1.0,blue:1.0,alpha:1.0)
36-
37-
if let someLabel = longPress.view as? UIButton {
38-
let alert = UIAlertController(title: "Edit button", message: "New value:", preferredStyle: UIAlertControllerStyle.alert)
39-
alert.addTextField(configurationHandler: {(textField: UITextField) in
40-
textField.placeholder = someLabel.titleLabel?.text
41-
//textField.secureTextEntry = false
42-
inputTextField = textField
43-
})
44-
alert.addAction(UIAlertAction(title: "Ok", style: .default, handler:{ (alertAction:UIAlertAction) in
45-
// Text was changed
46-
someLabel.setTitle(inputTextField!.text, for: UIControlState.normal);
47-
let text = inputTextField!.text ?? ""
48-
print(text)
49-
}))
50-
alert.addAction(UIAlertAction(title: "Cancel", style: .default, handler:{ (alertAction:UIAlertAction) in
51-
// Nothing
52-
}))
53-
UIApplication.shared.keyWindow?.rootViewController?.present(alert, animated: true, completion: nil)
54-
55-
}
56-
57-
} else if (longPress.state == UIGestureRecognizerState.began) {
58-
// Gesture began
59-
}
6024
}
6125
}

Diff for: JacobsVoice/CategoryAddCell.swift

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// CategoryCell.swift
3+
// JacobsVoice
4+
//
5+
// Created by Klemen Kastelic on 30/06/2018.
6+
// Copyright © 2018 Klemen Kastelic. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
class CategoryAddCell: UICollectionViewCell {
12+
@IBOutlet weak var mainButton: UIButton!
13+
}

Diff for: JacobsVoice/CategoryCell.swift

+2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ import UIKit
1010

1111
class CategoryCell: UICollectionViewCell {
1212
@IBOutlet weak var mainButton: UIButton!
13+
@IBOutlet weak var label: UILabel!
1314
public var category: Category?
1415

1516
public func set(_ category: Category){
1617
self.category = category
1718
self.mainButton.setTitle(self.category?.name, for: .normal)
19+
self.label.text = self.category?.name
1820
}
1921
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"filename" : "trash-red.pdf"
6+
}
7+
],
8+
"info" : {
9+
"version" : 1,
10+
"author" : "xcode"
11+
},
12+
"properties" : {
13+
"compression-type" : "lossless",
14+
"preserves-vector-representation" : true
15+
}
16+
}
Binary file not shown.

Diff for: JacobsVoice/Launch Screen.storyboard

+4-15
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
<dependencies>
77
<deployment identifier="iOS"/>
88
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
9-
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
109
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
1110
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
1211
</dependencies>
@@ -20,33 +19,23 @@
2019
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
2120
<subviews>
2221
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Copyright © 2018 Klemen Kastelic. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="obG-Y5-kRd">
23-
<rect key="frame" x="0.0" y="727.5" width="1024" height="20.5"/>
24-
<fontDescription key="fontDescription" type="system" pointSize="17"/>
25-
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
26-
<nil key="highlightedColor"/>
27-
</label>
28-
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="JacobsVoice" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="GJd-Yh-RWb">
29-
<rect key="frame" x="0.0" y="235.5" width="1024" height="43"/>
30-
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
31-
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
22+
<rect key="frame" x="0.0" y="731" width="1024" height="17"/>
23+
<fontDescription key="fontDescription" type="boldSystem" pointSize="14"/>
3224
<nil key="highlightedColor"/>
3325
</label>
3426
</subviews>
3527
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
3628
<constraints>
3729
<constraint firstItem="Bcu-3y-fUS" firstAttribute="centerX" secondItem="obG-Y5-kRd" secondAttribute="centerX" id="5cz-MP-9tL"/>
38-
<constraint firstItem="Bcu-3y-fUS" firstAttribute="centerX" secondItem="GJd-Yh-RWb" secondAttribute="centerX" id="Q3B-4B-g5h"/>
39-
<constraint firstItem="obG-Y5-kRd" firstAttribute="leading" secondItem="Bcu-3y-fUS" secondAttribute="leading" constant="20" symbolic="YES" id="SfN-ll-jLj"/>
30+
<constraint firstItem="obG-Y5-kRd" firstAttribute="leading" secondItem="Bcu-3y-fUS" secondAttribute="leading" symbolic="YES" id="SfN-ll-jLj"/>
4031
<constraint firstAttribute="bottom" secondItem="obG-Y5-kRd" secondAttribute="bottom" constant="20" id="Y44-ml-fuU"/>
41-
<constraint firstItem="GJd-Yh-RWb" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="bottom" multiplier="1/3" constant="1" id="moa-c2-u7t"/>
42-
<constraint firstItem="GJd-Yh-RWb" firstAttribute="leading" secondItem="Bcu-3y-fUS" secondAttribute="leading" constant="20" symbolic="YES" id="x7j-FC-K8j"/>
4332
</constraints>
4433
<viewLayoutGuide key="safeArea" id="Bcu-3y-fUS"/>
4534
</view>
4635
</viewController>
4736
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
4837
</objects>
49-
<point key="canvasLocation" x="53" y="375"/>
38+
<point key="canvasLocation" x="52.734375" y="375"/>
5039
</scene>
5140
</scenes>
5241
</document>

0 commit comments

Comments
 (0)