2022-03-07 08:09:49 -10:00
//
// H e l p e r B a r I t e m . s w i f t
// R e t r o A r c h i O S
//
// C r e a t e d b y Y o s h i S u g a w a r a o n 3 / 1 / 2 2 .
// C o p y r i g h t © 2 0 2 2 R e t r o A r c h . A l l r i g h t s r e s e r v e d .
//
2024-09-06 17:57:36 -04:00
@ available ( iOS 13 , * )
2022-03-07 08:09:49 -10:00
protocol HelperBarItem {
var image : UIImage ? { get }
var selectedImage : UIImage ? { get }
2023-08-21 20:05:34 -10:00
var tintColorOnSelection : UIColor ? { get }
2022-03-07 08:09:49 -10:00
var isSelected : Bool { get }
var shortDescription : String { get }
var longDescription : String ? { get }
func action ( )
}
2024-09-06 17:57:36 -04:00
@ available ( iOS 13 , * )
2023-08-21 20:05:34 -10:00
extension HelperBarItem {
var tintColorOnSelection : UIColor ? { nil }
}
2024-09-06 17:57:36 -04:00
@ available ( iOS 13 , * )
2022-03-07 08:09:49 -10:00
struct KeyboardBarItem : HelperBarItem {
let image = UIImage ( systemName : " keyboard " )
let selectedImage = UIImage ( systemName : " keyboard.fill " )
var isSelected : Bool { actionDelegate ? . isKeyboardEnabled ? ? false }
let shortDescription = Strings . shortDescription
let longDescription : String ? = Strings . longDescription
weak var actionDelegate : HelperBarActionDelegate ?
init ( actionDelegate : HelperBarActionDelegate ? ) {
self . actionDelegate = actionDelegate
}
func action ( ) {
actionDelegate ? . keyboardButtonTapped ( )
}
struct Strings {
static let shortDescription = NSLocalizedString ( " An on-screen keyboard " , comment : " Description for on-screen keyboard item on helper bar " )
static let longDescription = NSLocalizedString ( " An on-screen keyboard for cores that require keyboard input. " , comment : " Description for on-screen keyboard item on helper bar " )
}
}
2024-09-06 17:57:36 -04:00
@ available ( iOS 13 , * )
2022-03-07 08:09:49 -10:00
struct MouseBarItem : HelperBarItem {
let image = UIImage ( systemName : " computermouse " )
let selectedImage = UIImage ( systemName : " computermouse.fill " )
var isSelected : Bool { actionDelegate ? . isMouseEnabled ? ? false }
let shortDescription = NSLocalizedString ( " Use the touch screen for mouse input. " , comment : " Description for touch screen mouse item on helper bar " )
var longDescription : String ? { nil }
weak var actionDelegate : HelperBarActionDelegate ?
init ( actionDelegate : HelperBarActionDelegate ? ) {
self . actionDelegate = actionDelegate
}
func action ( ) {
actionDelegate ? . mouseButtonTapped ( )
}
}
2023-08-21 20:05:34 -10:00
2024-09-06 17:57:36 -04:00
@ available ( iOS 13 , * )
2023-08-21 20:05:34 -10:00
struct LockOrientationBarItem : HelperBarItem {
let image = UIImage ( systemName : " lock.rotation " )
let selectedImage = UIImage ( systemName : " lock.rotation " )
var tintColorOnSelection : UIColor ? { . red }
var isSelected : Bool { actionDelegate ? . isOrientationLocked ? ? false }
let shortDescription = NSLocalizedString ( " Lock the current screen orientation " , comment : " Description for orientation lock item on helper bar " )
var longDescription : String ? { nil }
weak var actionDelegate : HelperBarActionDelegate ?
init ( actionDelegate : HelperBarActionDelegate ? ) {
self . actionDelegate = actionDelegate
}
func action ( ) {
actionDelegate ? . orientationLockButtonTapped ( )
}
}