-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #609 from NordicSemiconductor/feature/group-light-lc
Group controls for Light LC Server model
- Loading branch information
Showing
10 changed files
with
546 additions
and
46 deletions.
There are no files selected for viewing
Binary file added
BIN
+7.27 KB
...ts/ groups_light_lc_occupancy_mode.imageset/ groups_light_lc_occupancy_mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions
24
Example/Source/Images.xcassets/ groups_light_lc_occupancy_mode.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : " groups_light_lc_occupancy_mode.png", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"template-rendering-intent" : "template" | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
Example/Source/Images.xcassets/groups_light_lc_mode.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "groups_light_lc_mode.png", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"template-rendering-intent" : "template" | ||
} | ||
} |
Binary file added
BIN
+7.06 KB
...e/Source/Images.xcassets/groups_light_lc_mode.imageset/groups_light_lc_mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
Example/Source/View Controllers/Groups/Model/LightLCLightOnOffGroupCell.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright (c) 2019, Nordic Semiconductor | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without modification, | ||
* are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, this | ||
* list of conditions and the following disclaimer. | ||
* | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, this | ||
* list of conditions and the following disclaimer in the documentation and/or | ||
* other materials provided with the distribution. | ||
* | ||
* 3. Neither the name of the copyright holder nor the names of its contributors may | ||
* be used to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | ||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
import UIKit | ||
import NordicMesh | ||
|
||
class LightLCLightOnOffGroupCell: ModelGroupCell { | ||
|
||
// MARK: - Outlets and Actions | ||
|
||
@IBOutlet weak var icon: UIImageView! | ||
@IBOutlet weak var title: UILabel! | ||
|
||
@IBOutlet weak var onButton: UIButton! | ||
@IBAction func onTapped(_ sender: UIButton) { | ||
sendLightLCLightOnOffMessage(turnOn: true) | ||
} | ||
@IBOutlet weak var offButton: UIButton! | ||
@IBAction func offTapped(_ sender: UIButton) { | ||
sendLightLCLightOnOffMessage(turnOn: false) | ||
} | ||
|
||
// MARK: - Implementation | ||
|
||
override func reload() { | ||
// On iOS 12.x tinted icons are initially black. | ||
// Forcing adjustment mode fixes the bug. | ||
icon.tintAdjustmentMode = .normal | ||
|
||
let numberOfDevices = models.count | ||
if numberOfDevices == 1 { | ||
title.text = "1 device" | ||
} else { | ||
title.text = "\(numberOfDevices) devices" | ||
} | ||
|
||
let localProvisioner = MeshNetworkManager.instance.meshNetwork?.localProvisioner | ||
let isEnabled = localProvisioner?.hasConfigurationCapabilities ?? false | ||
|
||
onButton.isEnabled = isEnabled | ||
offButton.isEnabled = isEnabled | ||
} | ||
} | ||
|
||
private extension LightLCLightOnOffGroupCell { | ||
|
||
func sendLightLCLightOnOffMessage(turnOn: Bool) { | ||
let label = turnOn ? "Enabling occupancy sensor binging..." : "Disabling occupancy sensor binging..." | ||
delegate?.send(LightLCLightOnOffSetUnacknowledged(turnOn), | ||
description: label, using: applicationKey) | ||
} | ||
|
||
} |
80 changes: 80 additions & 0 deletions
80
Example/Source/View Controllers/Groups/Model/LightLCModeGroupCell.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright (c) 2019, Nordic Semiconductor | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without modification, | ||
* are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, this | ||
* list of conditions and the following disclaimer. | ||
* | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, this | ||
* list of conditions and the following disclaimer in the documentation and/or | ||
* other materials provided with the distribution. | ||
* | ||
* 3. Neither the name of the copyright holder nor the names of its contributors may | ||
* be used to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | ||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
import UIKit | ||
import NordicMesh | ||
|
||
class LightLCModeGroupCell: ModelGroupCell { | ||
|
||
// MARK: - Outlets and Actions | ||
|
||
@IBOutlet weak var icon: UIImageView! | ||
@IBOutlet weak var title: UILabel! | ||
|
||
@IBOutlet weak var onButton: UIButton! | ||
@IBAction func onTapped(_ sender: UIButton) { | ||
sendLightLCModeMessage(turnOn: true) | ||
} | ||
@IBOutlet weak var offButton: UIButton! | ||
@IBAction func offTapped(_ sender: UIButton) { | ||
sendLightLCModeMessage(turnOn: false) | ||
} | ||
|
||
// MARK: - Implementation | ||
|
||
override func reload() { | ||
// On iOS 12.x tinted icons are initially black. | ||
// Forcing adjustment mode fixes the bug. | ||
icon.tintAdjustmentMode = .normal | ||
|
||
let numberOfDevices = models.count | ||
if numberOfDevices == 1 { | ||
title.text = "1 device" | ||
} else { | ||
title.text = "\(numberOfDevices) devices" | ||
} | ||
|
||
let localProvisioner = MeshNetworkManager.instance.meshNetwork?.localProvisioner | ||
let isEnabled = localProvisioner?.hasConfigurationCapabilities ?? false | ||
|
||
onButton.isEnabled = isEnabled | ||
offButton.isEnabled = isEnabled | ||
} | ||
} | ||
|
||
private extension LightLCModeGroupCell { | ||
|
||
func sendLightLCModeMessage(turnOn: Bool) { | ||
let label = turnOn ? "Enabling binding..." : "Disabling binding..." | ||
delegate?.send(LightLCModeSetUnacknowledged(turnOn), | ||
description: label, using: applicationKey) | ||
} | ||
|
||
} |
80 changes: 80 additions & 0 deletions
80
Example/Source/View Controllers/Groups/Model/LightLCOccupancyModeGroupCell.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright (c) 2019, Nordic Semiconductor | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without modification, | ||
* are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, this | ||
* list of conditions and the following disclaimer. | ||
* | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, this | ||
* list of conditions and the following disclaimer in the documentation and/or | ||
* other materials provided with the distribution. | ||
* | ||
* 3. Neither the name of the copyright holder nor the names of its contributors may | ||
* be used to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | ||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
import UIKit | ||
import NordicMesh | ||
|
||
class LightLCOccupancyModeGroupCell: ModelGroupCell { | ||
|
||
// MARK: - Outlets and Actions | ||
|
||
@IBOutlet weak var icon: UIImageView! | ||
@IBOutlet weak var title: UILabel! | ||
|
||
@IBOutlet weak var onButton: UIButton! | ||
@IBAction func onTapped(_ sender: UIButton) { | ||
sendLightLCOccupancyModeMessage(turnOn: true) | ||
} | ||
@IBOutlet weak var offButton: UIButton! | ||
@IBAction func offTapped(_ sender: UIButton) { | ||
sendLightLCOccupancyModeMessage(turnOn: false) | ||
} | ||
|
||
// MARK: - Implementation | ||
|
||
override func reload() { | ||
// On iOS 12.x tinted icons are initially black. | ||
// Forcing adjustment mode fixes the bug. | ||
icon.tintAdjustmentMode = .normal | ||
|
||
let numberOfDevices = models.count | ||
if numberOfDevices == 1 { | ||
title.text = "1 device" | ||
} else { | ||
title.text = "\(numberOfDevices) devices" | ||
} | ||
|
||
let localProvisioner = MeshNetworkManager.instance.meshNetwork?.localProvisioner | ||
let isEnabled = localProvisioner?.hasConfigurationCapabilities ?? false | ||
|
||
onButton.isEnabled = isEnabled | ||
offButton.isEnabled = isEnabled | ||
} | ||
} | ||
|
||
private extension LightLCOccupancyModeGroupCell { | ||
|
||
func sendLightLCOccupancyModeMessage(turnOn: Bool) { | ||
let label = turnOn ? "Enabling occupancy sensor binging..." : "Disabling occupancy sensor binging..." | ||
delegate?.send(LightLCOccupancyModeSetUnacknowledged(turnOn), | ||
description: label, using: applicationKey) | ||
} | ||
|
||
} |
Oops, something went wrong.