summaryrefslogtreecommitdiff
path: root/Jel/Models
diff options
context:
space:
mode:
Diffstat (limited to 'Jel/Models')
-rw-r--r--Jel/Models/JellyfinKitExtensions.swift28
-rw-r--r--Jel/Models/ViewOffsetKey.swift17
2 files changed, 45 insertions, 0 deletions
diff --git a/Jel/Models/JellyfinKitExtensions.swift b/Jel/Models/JellyfinKitExtensions.swift
new file mode 100644
index 0000000..197731c
--- /dev/null
+++ b/Jel/Models/JellyfinKitExtensions.swift
@@ -0,0 +1,28 @@
+//
+// JellyfinKitExtensions.swift
+// Jel
+//
+// Created by zerocool on 12/24/23.
+//
+
+import Foundation
+import JellyfinKit
+
+extension BaseItemDto {
+ func getRuntime() -> String? {
+ let formatter: DateComponentsFormatter = {
+ let localFormatter = DateComponentsFormatter()
+ localFormatter.unitsStyle = .brief
+ localFormatter.allowedUnits = [.hour, .minute]
+
+ return localFormatter
+ }()
+
+ if let runTimeTicks = self.runTimeTicks {
+ let text = formatter.string(from: Double(runTimeTicks / 10_000_000))
+ return text
+ }
+
+ return nil
+ }
+}
diff --git a/Jel/Models/ViewOffsetKey.swift b/Jel/Models/ViewOffsetKey.swift
new file mode 100644
index 0000000..b118478
--- /dev/null
+++ b/Jel/Models/ViewOffsetKey.swift
@@ -0,0 +1,17 @@
+//
+// ViewOffsetKey.swift
+// Jel
+//
+// Created by zerocool on 12/24/23.
+//
+
+import SwiftUI
+
+/// A preference key to store ScrollView offset
+public struct ViewOffsetKey: PreferenceKey {
+ public typealias Value = CGFloat
+ public static var defaultValue = CGFloat.zero
+ public static func reduce(value: inout Value, nextValue: () -> Value) {
+ value += nextValue()
+ }
+}