This repository was archived by the owner on Jun 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ambience is now able to switch states and have a forced state
- Loading branch information
Tiago Mergulhão
committed
Jan 3, 2018
1 parent
218c696
commit 26c4990
Showing
5 changed files
with
131 additions
and
5 deletions.
There are no files selected for viewing
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
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,29 @@ | ||
// | ||
// AmbienceLabel.swift | ||
// Ambience | ||
// | ||
// Created by Tiago Mergulhão on 03/01/2018. | ||
// | ||
|
||
import UIKit | ||
|
||
public class AmbienceLabel : UILabel { | ||
|
||
override public func ambience(_ notification: Notification) { | ||
|
||
super.ambience(notification) | ||
|
||
guard let currentState = notification.userInfo?["currentState"] as? AmbienceState else { return } | ||
|
||
text = { | ||
|
||
let aditionalText = Ambience.forcedState == nil ? "" : " (Forced)" | ||
|
||
switch currentState { | ||
case .contrast: return "Contrast" + aditionalText | ||
case .invert: return "Invert" + aditionalText | ||
case .regular: return "Regular" + aditionalText | ||
} | ||
}() | ||
} | ||
} |
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,45 @@ | ||
// | ||
// AmbienceObject.swift | ||
// Ambience | ||
// | ||
// Created by Tiago Mergulhão on 03/01/2018. | ||
// | ||
|
||
import UIKit | ||
|
||
class AmbienceObject : NSObject { | ||
|
||
@IBOutlet weak var viewController : UIViewController? | ||
|
||
@IBAction func switchAmbience (_ sender : AnyObject) { | ||
let actionSheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) | ||
|
||
let switchToInvert = UIAlertAction(title: "Invert", style: .default) { | ||
_ in | ||
Ambience.forcedState = .invert | ||
} | ||
let switchToContrast = UIAlertAction(title: "Contrast", style: .default) { | ||
_ in | ||
Ambience.forcedState = .contrast | ||
} | ||
let switchToRegular = UIAlertAction(title: "Regular", style: .default) { | ||
_ in | ||
Ambience.forcedState = .regular | ||
} | ||
|
||
let switchToAuto = UIAlertAction(title: "Auto", style: .default) { | ||
_ in | ||
Ambience.forcedState = nil | ||
} | ||
|
||
let cancel = UIAlertAction(title: "Cancel", style: .cancel) | ||
|
||
actionSheet.addAction(switchToInvert) | ||
actionSheet.addAction(switchToContrast) | ||
actionSheet.addAction(switchToRegular) | ||
actionSheet.addAction(switchToAuto) | ||
actionSheet.addAction(cancel) | ||
|
||
viewController?.present(actionSheet, animated: true) | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.