mirror of
https://github.com/yattee/yattee.git
synced 2026-02-20 01:39:46 +00:00
Yattee v2 rewrite
This commit is contained in:
50
Yattee/Models/PlayerControls/VisibilityMode.swift
Normal file
50
Yattee/Models/PlayerControls/VisibilityMode.swift
Normal file
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// VisibilityMode.swift
|
||||
// Yattee
|
||||
//
|
||||
// Defines visibility modes for control buttons based on device orientation.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
/// Controls when a button is visible based on device orientation.
|
||||
enum VisibilityMode: String, Codable, Hashable, Sendable, CaseIterable {
|
||||
/// Button is visible in both portrait and landscape orientations.
|
||||
case both
|
||||
|
||||
/// Button is only visible in portrait orientation.
|
||||
case portraitOnly
|
||||
|
||||
/// Button is only visible in landscape/wide orientation.
|
||||
case wideOnly
|
||||
|
||||
// MARK: - Display
|
||||
|
||||
/// Localized display name for the visibility mode.
|
||||
var displayName: String {
|
||||
switch self {
|
||||
case .both:
|
||||
return String(localized: "controls.visibility.both")
|
||||
case .portraitOnly:
|
||||
return String(localized: "controls.visibility.portraitOnly")
|
||||
case .wideOnly:
|
||||
return String(localized: "controls.visibility.wideOnly")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Visibility Check
|
||||
|
||||
/// Returns whether the button should be visible for the given layout state.
|
||||
/// - Parameter isWideLayout: True if the current layout is wide/landscape.
|
||||
/// - Returns: True if the button should be visible.
|
||||
func isVisible(isWideLayout: Bool) -> Bool {
|
||||
switch self {
|
||||
case .both:
|
||||
return true
|
||||
case .portraitOnly:
|
||||
return !isWideLayout
|
||||
case .wideOnly:
|
||||
return isWideLayout
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user