forked from jellyfin/Swiftfin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tvOS - Show and interact with the video menu (jellyfin#1066)
* Made the menu accessable and fixed visual padding bug * Moved away from .onExitCommand etc * Minor refactoring * wip * Update Overlay.swift --------- Co-authored-by: Ethan Pippin <[email protected]>
- Loading branch information
Showing
7 changed files
with
183 additions
and
33 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
34 changes: 34 additions & 0 deletions
34
PreferencesView/Sources/PreferencesView/PressCommandAction.swift
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,34 @@ | ||
// | ||
// Swiftfin is subject to the terms of the Mozilla Public | ||
// License, v2.0. If a copy of the MPL was not distributed with this | ||
// file, you can obtain one at https://mozilla.org/MPL/2.0/. | ||
// | ||
// Copyright (c) 2024 Jellyfin & Jellyfin Contributors | ||
// | ||
|
||
import Foundation | ||
import SwiftUI | ||
|
||
public struct PressCommandAction { | ||
|
||
let title: String | ||
let press: UIPress.PressType | ||
let action: () -> Void | ||
|
||
public init( | ||
title: String, | ||
press: UIPress.PressType, | ||
action: @escaping () -> Void | ||
) { | ||
self.title = title | ||
self.press = press | ||
self.action = action | ||
} | ||
} | ||
|
||
extension PressCommandAction: Equatable { | ||
|
||
public static func == (lhs: PressCommandAction, rhs: PressCommandAction) -> Bool { | ||
lhs.press == rhs.press | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
PreferencesView/Sources/PreferencesView/PressCommandBuilder.swift
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,37 @@ | ||
// | ||
// Swiftfin is subject to the terms of the Mozilla Public | ||
// License, v2.0. If a copy of the MPL was not distributed with this | ||
// file, you can obtain one at https://mozilla.org/MPL/2.0/. | ||
// | ||
// Copyright (c) 2024 Jellyfin & Jellyfin Contributors | ||
// | ||
|
||
import Foundation | ||
|
||
@resultBuilder | ||
public enum PressCommandsBuilder { | ||
|
||
public static func buildBlock(_ components: [PressCommandAction]...) -> [PressCommandAction] { | ||
components.flatMap { $0 } | ||
} | ||
|
||
public static func buildExpression(_ expression: PressCommandAction) -> [PressCommandAction] { | ||
[expression] | ||
} | ||
|
||
public static func buildOptional(_ component: [PressCommandAction]?) -> [PressCommandAction] { | ||
component ?? [] | ||
} | ||
|
||
public static func buildEither(first component: [PressCommandAction]) -> [PressCommandAction] { | ||
component | ||
} | ||
|
||
public static func buildEither(second component: [PressCommandAction]) -> [PressCommandAction] { | ||
component | ||
} | ||
|
||
public static func buildArray(_ components: [[PressCommandAction]]) -> [PressCommandAction] { | ||
components.flatMap { $0 } | ||
} | ||
} |
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
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