diff options
author | Justin Beharry <justin.beharry@livio.io> | 2022-07-29 10:08:12 -0400 |
---|---|---|
committer | Justin Beharry <justin.beharry@livio.io> | 2022-07-29 10:08:12 -0400 |
commit | dae71d440af8f796e2bce3be701dbc9b6204c75c (patch) | |
tree | 80bf03a90236319f2215b9336f882d476be10c43 | |
parent | 6da2aae218f6d5798f8c908086ad2f888063b2a9 (diff) | |
download | sdl_ios-dae71d440af8f796e2bce3be701dbc9b6204c75c.tar.gz |
Add temperature buttons to swift remote example
-rw-r--r-- | Example Apps/Example Swift/MenuManager.swift | 4 | ||||
-rw-r--r-- | RemoteControlManager.swift | 22 |
2 files changed, 23 insertions, 3 deletions
diff --git a/Example Apps/Example Swift/MenuManager.swift b/Example Apps/Example Swift/MenuManager.swift index 607ae8f21..943b9bc8b 100644 --- a/Example Apps/Example Swift/MenuManager.swift +++ b/Example Apps/Example Swift/MenuManager.swift @@ -218,7 +218,7 @@ private extension MenuManager { var submenuItems = [SDLMenuCell]() let errorMessage = "Changing the template failed" - /// Non-Media + /// Climate Control Menu let submenuTitleNonMedia = "Climate Control" submenuItems.append(SDLMenuCell(title: submenuTitleNonMedia, secondaryText: nil, tertiaryText: nil, icon: nil, secondaryArtwork: nil, voiceCommands: nil, handler: { (triggerSource) in manager.screenManager.changeLayout(SDLTemplateConfiguration(predefinedLayout: .nonMedia)) { err in @@ -226,7 +226,7 @@ private extension MenuManager { AlertManager.sendAlert(textField1: errorMessage, sdlManager: manager) return } - let remoteControlManager = RemoteControlManager(sdlManager: manager) + RemoteControlManager(sdlManager: manager) } })) diff --git a/RemoteControlManager.swift b/RemoteControlManager.swift index 5b6418a9b..6b11ce87a 100644 --- a/RemoteControlManager.swift +++ b/RemoteControlManager.swift @@ -120,7 +120,27 @@ class RemoteControlManager { self.turnOffAC() } - screenManager.softButtonObjects = [acOnButton, acOffButton] + let temperatureDecreaseButton = SDLSoftButtonObject(name: "Temperature Decrease", text: "Temperature -", artwork: nil) { (buttonPress, buttonEvent) in + guard buttonPress != nil else { return } + + let buttonPress = SDLButtonPress(buttonName: .tempDown, moduleType: .climate, moduleId: self.climateModuleId, buttonPressMode: .short) + + self.sdlManager.send(request: buttonPress) { (request, response, error) in + guard response?.success.boolValue == true else { return } + } + } + + let temperatureIncreaseButton = SDLSoftButtonObject(name: "Temperature Increase", text: "Temperature +", artwork: nil) { (buttonPress, buttonEvent) in + guard buttonPress != nil else { return } + + let buttonPress = SDLButtonPress(buttonName: .tempUp, moduleType: .climate, moduleId: self.climateModuleId, buttonPressMode: .short) + + self.sdlManager.send(request: buttonPress) { (request, response, error) in + guard response?.success.boolValue == true else { return } + } + } + + screenManager.softButtonObjects = [acOnButton, acOffButton, temperatureDecreaseButton, temperatureIncreaseButton] screenManager.endUpdates { error in if error != nil { |