From 84192c20d64c43765faf8609eb864277c72d4b6c Mon Sep 17 00:00:00 2001 From: Ethan Pippin Date: Tue, 16 May 2023 17:31:44 -0600 Subject: [PATCH] implement (#777) --- Swiftfin.xcodeproj/project.pbxproj | 4 +++ Swiftfin/Objects/ScalingButtonStyle.swift | 26 +++++++++++++++++++ Swiftfin/Views/FontPickerView.swift | 2 +- .../ExperimentalSettingsView.swift | 3 ++- .../LargePlaybackButtons.swift | 4 +++ .../Overlays/Components/TopBarView.swift | 2 ++ Swiftfin/Views/VideoPlayer/VideoPlayer.swift | 1 + 7 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 Swiftfin/Objects/ScalingButtonStyle.swift diff --git a/Swiftfin.xcodeproj/project.pbxproj b/Swiftfin.xcodeproj/project.pbxproj index 5b1da343..c1979396 100644 --- a/Swiftfin.xcodeproj/project.pbxproj +++ b/Swiftfin.xcodeproj/project.pbxproj @@ -463,6 +463,7 @@ E18A8E8128D6083700333B9A /* MediaSourceInfo+ItemVideoPlayerViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = E18A8E7F28D6083700333B9A /* MediaSourceInfo+ItemVideoPlayerViewModel.swift */; }; E18A8E8328D60BC400333B9A /* VideoPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = E18A8E8228D60BC400333B9A /* VideoPlayer.swift */; }; E18A8E8528D60D0000333B9A /* VideoPlayerCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = E18A8E8428D60D0000333B9A /* VideoPlayerCoordinator.swift */; }; + E18ACA8B2A14301800BB4F35 /* ScalingButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = E18ACA8A2A14301800BB4F35 /* ScalingButtonStyle.swift */; }; E18CE0AF28A222240092E7F1 /* PublicUserSignInView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E18CE0AE28A222240092E7F1 /* PublicUserSignInView.swift */; }; E18CE0B228A229E70092E7F1 /* UserDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = E18CE0B128A229E70092E7F1 /* UserDto.swift */; }; E18CE0B428A22EDA0092E7F1 /* RepeatingTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = E18CE0B328A22EDA0092E7F1 /* RepeatingTimer.swift */; }; @@ -1068,6 +1069,7 @@ E18A8E7F28D6083700333B9A /* MediaSourceInfo+ItemVideoPlayerViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MediaSourceInfo+ItemVideoPlayerViewModel.swift"; sourceTree = ""; }; E18A8E8228D60BC400333B9A /* VideoPlayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoPlayer.swift; sourceTree = ""; }; E18A8E8428D60D0000333B9A /* VideoPlayerCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoPlayerCoordinator.swift; sourceTree = ""; }; + E18ACA8A2A14301800BB4F35 /* ScalingButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScalingButtonStyle.swift; sourceTree = ""; }; E18CE0AE28A222240092E7F1 /* PublicUserSignInView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PublicUserSignInView.swift; sourceTree = ""; }; E18CE0B128A229E70092E7F1 /* UserDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDto.swift; sourceTree = ""; }; E18CE0B328A22EDA0092E7F1 /* RepeatingTimer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RepeatingTimer.swift; sourceTree = ""; }; @@ -2621,6 +2623,7 @@ children = ( E1FBDB6529D0F336003DD5E2 /* KeyCommandAction.swift */, E1E48CC8271E6D410021A2F9 /* RefreshHelper.swift */, + E18ACA8A2A14301800BB4F35 /* ScalingButtonStyle.swift */, ); path = Objects; sourceTree = ""; @@ -3263,6 +3266,7 @@ E18E0208288749200022598C /* BlurView.swift in Sources */, E18E01E7288747230022598C /* CollectionItemContentView.swift in Sources */, E1E1643F28BB075C00323B0A /* SelectorView.swift in Sources */, + E18ACA8B2A14301800BB4F35 /* ScalingButtonStyle.swift in Sources */, E17665D928E80F0F00130507 /* PosterButtonType.swift in Sources */, E18E01DF288747230022598C /* iPadOSMovieItemView.swift in Sources */, E168BD13289A4162001A6922 /* ContinueWatchingView.swift in Sources */, diff --git a/Swiftfin/Objects/ScalingButtonStyle.swift b/Swiftfin/Objects/ScalingButtonStyle.swift new file mode 100644 index 00000000..fa82c478 --- /dev/null +++ b/Swiftfin/Objects/ScalingButtonStyle.swift @@ -0,0 +1,26 @@ +// +// 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) 2023 Jellyfin & Jellyfin Contributors +// + +import SwiftUI + +struct ScalingButtonStyle: ButtonStyle { + + private let animation: Animation + private let scale: CGFloat + + init(scale: CGFloat = 0.8, animation: Animation = .linear(duration: 0.1)) { + self.animation = animation + self.scale = scale + } + + func makeBody(configuration: Configuration) -> some View { + configuration.label + .scaleEffect(configuration.isPressed ? scale : 1) + .animation(animation, value: configuration.isPressed) + } +} diff --git a/Swiftfin/Views/FontPickerView.swift b/Swiftfin/Views/FontPickerView.swift index 99d3fc2a..ffee4157 100644 --- a/Swiftfin/Views/FontPickerView.swift +++ b/Swiftfin/Views/FontPickerView.swift @@ -30,7 +30,7 @@ struct FontPickerView: View { ) .label { fontFamily in Text(fontFamily) - .foregroundColor(.white) + .foregroundColor(.primary) .font(.custom(fontFamily, size: 18)) } .onChange(of: updateSelection) { newValue in diff --git a/Swiftfin/Views/SettingsView/ExperimentalSettingsView.swift b/Swiftfin/Views/SettingsView/ExperimentalSettingsView.swift index 8e05dbed..f7db5c53 100644 --- a/Swiftfin/Views/SettingsView/ExperimentalSettingsView.swift +++ b/Swiftfin/Views/SettingsView/ExperimentalSettingsView.swift @@ -26,7 +26,8 @@ struct ExperimentalSettingsView: View { Toggle("Force Direct Play", isOn: $forceDirectPlay) -// Toggle("Sync Subtitles with Adjacent Episodes", isOn: $syncSubtitleStateWithAdjacent) + } header: { + Text("Video Player") } Section { diff --git a/Swiftfin/Views/VideoPlayer/Overlays/Components/PlaybackButtons/LargePlaybackButtons.swift b/Swiftfin/Views/VideoPlayer/Overlays/Components/PlaybackButtons/LargePlaybackButtons.swift index e77652a6..324619bc 100644 --- a/Swiftfin/Views/VideoPlayer/Overlays/Components/PlaybackButtons/LargePlaybackButtons.swift +++ b/Swiftfin/Views/VideoPlayer/Overlays/Components/PlaybackButtons/LargePlaybackButtons.swift @@ -40,6 +40,7 @@ extension VideoPlayer.Overlay { .contentShape(Rectangle()) } .contentShape(Rectangle()) + .buttonStyle(ScalingButtonStyle(scale: 0.9)) } @ViewBuilder @@ -66,9 +67,11 @@ extension VideoPlayer.Overlay { } .font(.system(size: 56, weight: .bold, design: .default)) .padding() + .transition(.opacity) .contentShape(Rectangle()) } .contentShape(Rectangle()) + .buttonStyle(ScalingButtonStyle(scale: 0.9)) } @ViewBuilder @@ -83,6 +86,7 @@ extension VideoPlayer.Overlay { .contentShape(Rectangle()) } .contentShape(Rectangle()) + .buttonStyle(ScalingButtonStyle(scale: 0.9)) } var body: some View { diff --git a/Swiftfin/Views/VideoPlayer/Overlays/Components/TopBarView.swift b/Swiftfin/Views/VideoPlayer/Overlays/Components/TopBarView.swift index 8c61e8c6..71e21abf 100644 --- a/Swiftfin/Views/VideoPlayer/Overlays/Components/TopBarView.swift +++ b/Swiftfin/Views/VideoPlayer/Overlays/Components/TopBarView.swift @@ -36,6 +36,7 @@ extension VideoPlayer.Overlay { Image(systemName: "xmark") .padding() } + .buttonStyle(ScalingButtonStyle(scale: 0.8)) Text(viewModel.item.displayTitle) .font(.title3) @@ -48,6 +49,7 @@ extension VideoPlayer.Overlay { Spacer() VideoPlayer.Overlay.BarActionButtons() + .buttonStyle(ScalingButtonStyle(scale: 0.8)) } .font(.system(size: 24)) .tint(Color.white) diff --git a/Swiftfin/Views/VideoPlayer/VideoPlayer.swift b/Swiftfin/Views/VideoPlayer/VideoPlayer.swift index 4cc3d188..7226f85a 100644 --- a/Swiftfin/Views/VideoPlayer/VideoPlayer.swift +++ b/Swiftfin/Views/VideoPlayer/VideoPlayer.swift @@ -201,6 +201,7 @@ struct VideoPlayer: View { playerView } else { LoadingView() + .transition(.opacity) } } .navigationBarHidden(true)