summaryrefslogtreecommitdiff
path: root/Example Apps/Example Swift
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2021-05-17 15:20:52 -0400
committerGitHub <noreply@github.com>2021-05-17 15:20:52 -0400
commit5a2110494c891b48e2c7695ebdb133523f774de6 (patch)
treeeddd2fb00fc09591e01a70cd48108688638d9f22 /Example Apps/Example Swift
parent9c64c1de7d84f660b8026894e0b552668f3275b1 (diff)
parent53fe3f44847f24f77b1ccfc8195abc7aecc9bd43 (diff)
downloadsdl_ios-5a2110494c891b48e2c7695ebdb133523f774de6.tar.gz
Merge pull request #1992 from smartdevicelink/bugfix/issue-1991-example-apps-button-state-does-not-match-the-text-or-image-state-if-the-app-is-reopened
Fixed Example apps button state does not match the image/text state if the app is reopened after exiting
Diffstat (limited to 'Example Apps/Example Swift')
-rw-r--r--Example Apps/Example Swift/ButtonManager.swift12
1 files changed, 8 insertions, 4 deletions
diff --git a/Example Apps/Example Swift/ButtonManager.swift b/Example Apps/Example Swift/ButtonManager.swift
index 02d3f7962..197b13e74 100644
--- a/Example Apps/Example Swift/ButtonManager.swift
+++ b/Example Apps/Example Swift/ButtonManager.swift
@@ -63,7 +63,8 @@ extension ButtonManager {
private var softButtonAlert: SDLSoftButtonObject {
let imageAndTextState = SDLSoftButtonState(stateName: AlertSoftButtonImageAndTextState, text: AlertSoftButtonText, image: UIImage(named: AlertBWIconName)?.withRenderingMode(.alwaysTemplate))
let textState = SDLSoftButtonState(stateName: AlertSoftButtonTextState, text: AlertSoftButtonText, image: nil)
- return SDLSoftButtonObject(name: AlertSoftButton, states: [imageAndTextState, textState], initialStateName: imageAndTextState.name) { [weak self] (buttonPress, buttonEvent) in
+ let initialButtonStateName = self.imagesEnabled ? imageAndTextState.name : textState.name
+ return SDLSoftButtonObject(name: AlertSoftButton, states: [imageAndTextState, textState], initialStateName: initialButtonStateName) { [weak self] (buttonPress, buttonEvent) in
guard let self = self, buttonPress != nil else { return }
if (self.isAlertAllowed) {
@@ -80,7 +81,8 @@ extension ButtonManager {
private var softButtonSubtleAlert: SDLSoftButtonObject {
let imageAndTextState = SDLSoftButtonState(stateName: SubtleAlertSoftButtonImageAndTextState, text: SubtleAlertSoftButtonText, image: UIImage(named: BatteryFullBWIconName)?.withRenderingMode(.alwaysTemplate))
let textState = SDLSoftButtonState(stateName: SubtleAlertSoftButtonTextState, text: SubtleAlertSoftButtonText, image: nil)
- return SDLSoftButtonObject(name: SubtleAlertSoftButton, states: [imageAndTextState, textState], initialStateName: imageAndTextState.name) { [weak self] (buttonPress, buttonEvent) in
+ let initialButtonStateName = self.imagesEnabled ? imageAndTextState.name : textState.name
+ return SDLSoftButtonObject(name: SubtleAlertSoftButton, states: [imageAndTextState, textState], initialStateName: initialButtonStateName) { [weak self] (buttonPress, buttonEvent) in
guard let self = self, buttonPress != nil else { return }
if (self.isSubtleAlertAllowed) {
@@ -97,7 +99,8 @@ extension ButtonManager {
private var softButtonTextVisible: SDLSoftButtonObject {
let textVisibleState = SDLSoftButtonState(stateName: TextVisibleSoftButtonTextOnState, text: TextVisibleSoftButtonTextOnText, artwork: nil)
let textNotVisibleState = SDLSoftButtonState(stateName: TextVisibleSoftButtonTextOffState, text: TextVisibleSoftButtonTextOffText, image: nil)
- return SDLSoftButtonObject(name: TextVisibleSoftButton, states: [textVisibleState, textNotVisibleState], initialStateName: textVisibleState.name) { [unowned self] (buttonPress, buttonEvent) in
+ let initialButtonStateName = self.textEnabled ? textVisibleState.name : textNotVisibleState.name
+ return SDLSoftButtonObject(name: TextVisibleSoftButton, states: [textVisibleState, textNotVisibleState], initialStateName: initialButtonStateName) { [unowned self] (buttonPress, buttonEvent) in
guard buttonPress != nil else { return }
self.textEnabled = !self.textEnabled
@@ -111,7 +114,8 @@ extension ButtonManager {
private var softButtonImagesVisible: SDLSoftButtonObject {
let imagesVisibleState = SDLSoftButtonState(stateName: ImagesVisibleSoftButtonImageOnState, text: ImagesVisibleSoftButtonImageOnText, image: nil)
let imagesNotVisibleState = SDLSoftButtonState(stateName: ImagesVisibleSoftButtonImageOffState, text: ImagesVisibleSoftButtonImageOffText, image: nil)
- return SDLSoftButtonObject(name: ImagesVisibleSoftButton, states: [imagesVisibleState, imagesNotVisibleState], initialStateName: imagesVisibleState.name) { [weak self] (buttonPress, buttonEvent) in
+ let initialButtonStateName = self.imagesEnabled ? imagesVisibleState.name : imagesNotVisibleState.name
+ return SDLSoftButtonObject(name: ImagesVisibleSoftButton, states: [imagesVisibleState, imagesNotVisibleState], initialStateName: initialButtonStateName) { [weak self] (buttonPress, buttonEvent) in
guard let self = self, let sdlManager = self.sdlManager, buttonPress != nil else { return }
self.imagesEnabled = !self.imagesEnabled