yattee/Shared/Constants.swift

168 lines
3.2 KiB
Swift
Raw Normal View History

2022-12-19 11:08:27 +00:00
import Defaults
2022-08-25 17:09:55 +00:00
import Foundation
import SwiftUI
2024-02-01 22:51:41 +00:00
enum Constants {
2022-08-25 17:09:55 +00:00
static let overlayAnimation = Animation.linear(duration: 0.2)
static let aspectRatio16x9 = 16.0 / 9.0
static let aspectRatio4x3 = 4.0 / 3.0
static var isAppleTV: Bool {
#if os(iOS)
UIDevice.current.userInterfaceIdiom == .tv
#else
false
#endif
}
static var isMac: Bool {
#if os(iOS)
UIDevice.current.userInterfaceIdiom == .mac
#else
false
#endif
}
2023-02-25 15:42:45 +00:00
static var isIPhone: Bool {
#if os(iOS)
UIDevice.current.userInterfaceIdiom == .phone
#else
false
#endif
}
2023-04-22 17:22:13 +00:00
static var isIPad: Bool {
#if os(iOS)
UIDevice.current.userInterfaceIdiom == .pad
#else
false
#endif
}
static var isTvOS: Bool {
#if os(tvOS)
true
#else
false
#endif
}
static var isMacOS: Bool {
#if os(macOS)
true
#else
false
#endif
}
static var isIOS: Bool {
#if os(iOS)
true
#else
false
#endif
}
static var detailsVisibility: Bool {
#if os(iOS)
false
#else
true
#endif
}
2022-12-10 02:01:59 +00:00
static var progressViewScale: Double {
#if os(macOS)
0.4
#else
0.6
#endif
}
static var channelThumbnailSize: Double {
#if os(tvOS)
50
#else
30
#endif
}
2022-12-15 21:41:42 +00:00
static var sidebarChannelThumbnailSize: Double {
2022-12-15 11:09:16 +00:00
#if os(macOS)
20
#else
30
#endif
}
static var channelDetailsStackSpacing: Double {
#if os(tvOS)
12
#else
6
#endif
}
2022-12-18 12:11:06 +00:00
static var contentViewMinWidth: Double {
#if os(macOS)
835
2022-12-18 12:11:06 +00:00
#else
0
2022-12-18 12:11:06 +00:00
#endif
}
2022-12-18 18:39:03 +00:00
2024-02-01 22:54:16 +00:00
static var deviceName: String {
#if os(macOS)
Host().localizedName ?? "Mac"
#else
UIDevice.current.name
#endif
}
static var platform: String {
#if os(macOS)
"macOS"
#elseif os(iOS)
"iOS"
#elseif os(tvOS)
"tvOS"
#else
"unknown"
#endif
}
2024-05-16 16:53:47 +00:00
static var defaultNavigationStyle: NavigationStyle {
#if os(macOS)
return .sidebar
#elseif os(iOS)
if isIPad {
return .sidebar
}
return .tab
2024-05-16 16:53:47 +00:00
#else
return .tab
#endif
}
2022-12-19 11:08:27 +00:00
static func seekIcon(_ type: String, _ interval: TimeInterval) -> String {
let interval = Int(interval)
let allVersions = [10, 15, 30, 45, 60, 75, 90]
let iOS15 = [5]
2022-12-19 11:08:27 +00:00
let iconName = "go\(type).\(interval)"
if #available(iOS 15, macOS 12, *) {
if iOS15.contains(interval) {
return iconName
}
}
2022-12-19 11:08:27 +00:00
if allVersions.contains(interval) {
return iconName
}
let sign = type == "forward" ? "plus" : "minus"
return "go\(type).\(sign)"
}
2022-08-25 17:09:55 +00:00
}