Skip to content

Commit 23db47e

Browse files
committed
Made all cells work
1 parent 58cd5f9 commit 23db47e

9 files changed

+54
-49
lines changed

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

+17-4
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@
166166
<constraint firstAttribute="width" constant="30" id="e9d-e3-sAe"/>
167167
<constraint firstAttribute="height" constant="30" id="xxx-h0-TRp"/>
168168
</constraints>
169-
<state key="normal">
169+
<state key="normal" title="">
170170
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
171171
</state>
172172
</button>
@@ -179,14 +179,17 @@
179179
<state key="normal">
180180
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
181181
</state>
182+
<connections>
183+
<action selector="colorButtonPressed:" destination="n6i-xP-mqM" eventType="touchUpInside" id="E2V-fJ-h4T"/>
184+
</connections>
182185
</button>
183186
<button opaque="NO" tag="701" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="vxc-Zw-Oyh" customClass="UICircleButton" customModule="openHAB">
184187
<rect key="frame" x="288" y="7" width="30" height="30"/>
185188
<constraints>
186189
<constraint firstAttribute="height" constant="30" id="6LY-s0-Idb"/>
187190
<constraint firstAttribute="width" constant="30" id="pMB-mJ-lDb"/>
188191
</constraints>
189-
<state key="normal">
192+
<state key="normal" title="">
190193
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
191194
</state>
192195
</button>
@@ -211,6 +214,11 @@
211214
<accessibility key="accessibilityConfiguration">
212215
<accessibilityTraits key="traits" notEnabled="YES"/>
213216
</accessibility>
217+
<connections>
218+
<outlet property="colorButton" destination="JzN-PF-zeJ" id="q22-iL-Tqd"/>
219+
<outlet property="downButton" destination="vxc-Zw-Oyh" id="wmx-Ah-YGw"/>
220+
<outlet property="upButton" destination="OR4-bR-Ekg" id="F4j-67-AmO"/>
221+
</connections>
214222
</tableViewCell>
215223
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="SliderWidgetCell" rowHeight="44" id="S22-0C-9Sl" customClass="SliderUITableViewCell" customModule="openHAB">
216224
<rect key="frame" x="0.0" y="233" width="414" height="44"/>
@@ -276,6 +284,10 @@
276284
<accessibility key="accessibilityConfiguration">
277285
<accessibilityTraits key="traits" notEnabled="YES"/>
278286
</accessibility>
287+
<connections>
288+
<outlet property="customDetailTextLabel" destination="Adh-o9-6Qx" id="uUe-4v-wLl"/>
289+
<outlet property="customTextLabel" destination="hd9-I4-GIr" id="N3i-yD-fxt"/>
290+
</connections>
279291
</tableViewCell>
280292
<tableViewCell autoresizesSubviews="NO" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="SegmentedWidgetCell" rowHeight="44" id="IBt-aJ-0VH" customClass="SegmentedUITableViewCell" customModule="openHAB">
281293
<rect key="frame" x="0.0" y="321" width="414" height="44"/>
@@ -310,6 +322,7 @@
310322
<accessibilityTraits key="traits" notEnabled="YES"/>
311323
</accessibility>
312324
<connections>
325+
<outlet property="customTextLabel" destination="dGQ-sz-j4J" id="PBo-Lj-28S"/>
313326
<outlet property="widgetSegmentControl" destination="QBf-tO-eE0" id="SaO-tM-Eh5"/>
314327
</connections>
315328
</tableViewCell>
@@ -336,7 +349,7 @@
336349
<constraint firstAttribute="height" constant="30" id="M2m-p5-D0f"/>
337350
<constraint firstAttribute="width" constant="30" id="Was-wR-0wt"/>
338351
</constraints>
339-
<state key="normal">
352+
<state key="normal" title="">
340353
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
341354
</state>
342355
</button>
@@ -346,7 +359,7 @@
346359
<constraint firstAttribute="width" constant="30" id="LaN-EA-e8o"/>
347360
<constraint firstAttribute="height" constant="30" id="iup-nQ-ZD5"/>
348361
</constraints>
349-
<state key="normal">
362+
<state key="normal" title="">
350363
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
351364
</state>
352365
</button>

Diff for: openHAB/ColorPickerUITableViewCell.swift

+12-29
Original file line numberDiff line numberDiff line change
@@ -13,63 +13,46 @@
1313
}
1414

1515
class ColorPickerUITableViewCell: GenericUITableViewCell {
16-
var upButton: UICircleButton?
17-
var colorButton: UICircleButton?
18-
var downButton: UICircleButton?
16+
@IBOutlet weak var upButton: UICircleButton!
17+
@IBOutlet weak var colorButton: UICircleButton!
18+
@IBOutlet weak var downButton: UICircleButton!
19+
20+
@IBAction func colorButtonPressed(_ sender: Any) {
21+
delegate?.didPressColorButton(self)
22+
}
1923
@objc weak var delegate: ColorPickerUITableViewCellDelegate?
2024

2125
required init?(coder: NSCoder) {
2226
print("RollershutterUITableViewCell initWithCoder")
2327
super.init(coder: coder)
2428

25-
// upButton = viewWithTag(701) as? UICircleButton
26-
// colorButton = viewWithTag(702) as? UICircleButton
27-
// downButton = viewWithTag(703) as? UICircleButton
28-
29-
upButton?.setTitle("", for: .normal)
30-
downButton?.setTitle("", for: .normal)
31-
3229
upButton?.addTarget(self, action: #selector(ColorPickerUITableViewCell.upButtonPressed), for: .touchUpInside)
33-
colorButton?.addTarget(self, action: #selector(ColorPickerUITableViewCell.colorButtonPressed), for: .touchUpInside)
3430
downButton?.addTarget(self, action: #selector(ColorPickerUITableViewCell.downButtonPressed), for: .touchUpInside)
35-
selectionStyle = UITableViewCell.SelectionStyle.none
36-
separatorInset = UIEdgeInsets.zero
31+
selectionStyle = .none
32+
separatorInset = .zero
3733

3834
}
3935

4036
override init (style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
4137
super.init(style: style, reuseIdentifier: reuseIdentifier)
4238

43-
// upButton = viewWithTag(701) as? UICircleButton
44-
// colorButton = viewWithTag(702) as? UICircleButton
45-
// downButton = viewWithTag(703) as? UICircleButton
46-
47-
upButton?.setTitle("", for: .normal)
48-
downButton?.setTitle("", for: .normal)
49-
5039
upButton?.addTarget(self, action: #selector(ColorPickerUITableViewCell.upButtonPressed), for: .touchUpInside)
51-
colorButton?.addTarget(self, action: #selector(ColorPickerUITableViewCell.colorButtonPressed), for: .touchUpInside)
5240
downButton?.addTarget(self, action: #selector(ColorPickerUITableViewCell.downButtonPressed), for: .touchUpInside)
53-
selectionStyle = UITableViewCell.SelectionStyle.none
54-
separatorInset = UIEdgeInsets.zero
41+
selectionStyle = .none
42+
separatorInset = .zero
5543

5644
}
5745

5846
override func displayWidget() {
5947
customTextLabel?.text = widget.labelText()
48+
6049
colorButton?.backgroundColor = widget.item.stateAsUIColor()
6150
}
6251

6352
@objc func upButtonPressed() {
6453
widget.sendCommand("ON")
6554
}
6655

67-
@objc func colorButtonPressed() {
68-
if delegate != nil {
69-
delegate?.didPressColorButton(self)
70-
}
71-
}
72-
7356
@objc func downButtonPressed() {
7457
widget.sendCommand("OFF")
7558
}

Diff for: openHAB/OpenHABSelectionTableViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import UIKit
5252

5353
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
5454
var cell: UITableViewCell = tableView.dequeueReusableCell(withIdentifier: OpenHABSelectionTableViewController.tableViewCellIdentifier, for: indexPath)
55-
cell = UITableViewCell(style: .default, reuseIdentifier: OpenHABSelectionTableViewController.tableViewCellIdentifier)
55+
//cell = UITableViewCell(style: .default, reuseIdentifier: OpenHABSelectionTableViewController.tableViewCellIdentifier)
5656
let mapping = mappings[indexPath.row] as? OpenHABWidgetMapping
5757
cell.textLabel?.text = mapping?.label
5858
if selectionItem?.state == mapping?.command {

Diff for: openHAB/OpenHABViewController.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ class OpenHABViewController: UIViewController, UITableViewDelegate, UITableViewD
354354
cell = (tableView.dequeueReusableCell(withIdentifier: "FrameWidgetCell") as? FrameUITableViewCell)!
355355
case "Switch":
356356
if widget?.mappings.count ?? 0 > 0 {
357-
cell = tableView.dequeueReusableCell(for: indexPath) as SegmentedUITableViewCell
357+
//cell = tableView.dequeueReusableCell(for: indexPath) as SegmentedUITableViewCell
358+
cell = (tableView.dequeueReusableCell(withIdentifier: "SegmentedWidgetCell") as? SegmentedUITableViewCell)!
358359
//RollershutterItem changed to Rollershutter in later builds of OH2
359360
} else if (widget?.item.type == "RollershutterItem") || (widget?.item.type == "Rollershutter") || ((widget?.item.type == "Group") && (widget?.item.groupType == "Rollershutter")) {
360361
//cell = tableView.dequeueReusableCell(for: indexPath) as RollershutterUITableViewCell

Diff for: openHAB/RollershutterUITableViewCell.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ class RollershutterUITableViewCell: GenericUITableViewCell {
3636
print("RollershutterUITableViewCell initWithCoder")
3737
super.init(style: style, reuseIdentifier: reuseIdentifier)
3838

39-
upButton?.setTitle("", for: .normal)
40-
stopButton?.setTitle("", for: .normal)
41-
downButton?.setTitle("", for: .normal)
39+
// upButton?.setTitle("▲", for: .normal)
40+
// stopButton?.setTitle("■", for: .normal)
41+
// downButton?.setTitle("▼", for: .normal)
4242

4343
upButton?.addTarget(self, action: #selector(RollershutterUITableViewCell.upButtonPressed), for: .touchUpInside)
4444
stopButton?.addTarget(self, action: #selector(RollershutterUITableViewCell.stopButtonPressed), for: .touchUpInside)

Diff for: openHAB/SegmentedUITableViewCell.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
class SegmentedUITableViewCell: GenericUITableViewCell {
1212

13+
//@IBOutlet weak var customTextLabel: UILabel!
1314
@IBOutlet weak var widgetSegmentControl: UISegmentedControl!
1415
required init?(coder: NSCoder) {
1516
super.init(coder: coder)
@@ -22,14 +23,13 @@ class SegmentedUITableViewCell: GenericUITableViewCell {
2223
override init (style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
2324
super.init(style: style, reuseIdentifier: reuseIdentifier)
2425

25-
widgetSegmentControl = viewWithTag(500) as? UISegmentedControl
2626
selectionStyle = UITableViewCell.SelectionStyle.none
2727
separatorInset = UIEdgeInsets.zero
2828

2929
}
3030

3131
override func displayWidget() {
32-
customTextLabel?.text = widget.labelText()
32+
self.customTextLabel?.text = widget.labelText()
3333
widgetSegmentControl?.apportionsSegmentWidthsByContent = true
3434
widgetSegmentControl?.removeAllSegments()
3535
widgetSegmentControl?.apportionsSegmentWidthsByContent = true

Diff for: openHAB/SelectionUITableViewCell.swift

+15-6
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,27 @@
99
//
1010

1111
class SelectionUITableViewCell: GenericUITableViewCell {
12-
func setWidget(_ widget: OpenHABWidget?) {
13-
super.widget = widget
14-
accessoryType = UITableViewCell.AccessoryType.disclosureIndicator
15-
selectionStyle = UITableViewCell.SelectionStyle.blue
12+
13+
//@IBOutlet weak var customTextLabel: UILabel!
14+
//@IBOutlet weak var customDetailTextLabel: UILabel!
15+
16+
@objc override var widget: OpenHABWidget! {
17+
get {
18+
return super.widget
19+
}
20+
set(widget) {
21+
super.widget = widget
22+
accessoryType = .disclosureIndicator
23+
selectionStyle = .blue
24+
}
1625
}
1726

1827
override func displayWidget() {
19-
customTextLabel?.text = widget.labelText()
28+
super.customTextLabel?.text = widget.labelText()
2029
let selectedMapping = widget.mappingIndex(byCommand: widget.item.state)
2130
if selectedMapping != NSNotFound {
2231
if let widgetMapping = widget?.mappings[Int(selectedMapping)] as? OpenHABWidgetMapping {
23-
detailTextLabel?.text = widgetMapping.label
32+
customDetailTextLabel?.text = widgetMapping.label
2433
}
2534
}
2635

Diff for: openHAB/SwitchUITableViewCell.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ class SwitchUITableViewCell: GenericUITableViewCell {
3535
state = widget.item.state
3636
}
3737
if widget.labelValue() != nil {
38-
detailTextLabel?.text = widget.labelValue()
38+
customDetailTextLabel?.text = widget.labelValue()
3939
} else {
40-
detailTextLabel?.text = nil
40+
customDetailTextLabel?.text = nil
4141
}
4242
if state == "ON" {
4343
widgetSwitch?.isOn = true

Diff for: openHAB/UICircleButton.swift

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ var normalTextColor: UIColor?
1515

1616
class UICircleButton: UIButton {
1717
required init?(coder: NSCoder) {
18-
// NSLog(@"UICircleButton initWithCoder");
1918
super.init(coder: coder)
2019

2120
if let font = UIFont(name: "HelveticaNeue-Light", size: 20) {

0 commit comments

Comments
 (0)