Update tvOS onChange (#1141)

This commit is contained in:
Ethan Pippin 2024-07-01 21:39:52 -06:00 committed by GitHub
parent 29b917ead0
commit 5ee2eac11d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
23 changed files with 32 additions and 34 deletions

View File

@ -22,7 +22,7 @@ struct CinematicBackgroundView<Item: Poster>: View {
var body: some View {
RotateContentView(proxy: proxy)
.onChange(of: viewModel.currentItem) { newItem in
.onChange(of: viewModel.currentItem) { _, newItem in
proxy.update {
ImageView(newItem?.cinematicImageSources(maxWidth: nil) ?? [])
.placeholder { _ in

View File

@ -86,7 +86,7 @@ struct CinematicItemSelector<Item: Poster>: View {
}
.frame(height: UIScreen.main.bounds.height - 75)
.frame(maxWidth: .infinity)
.onChange(of: focusedItem) { newValue in
.onChange(of: focusedItem) { _, newValue in
guard let newValue else { return }
viewModel.select(item: newValue)
}

View File

@ -196,7 +196,7 @@ struct PagingLibraryView<Element: Poster>: View {
viewModel.send(.refresh)
}
}
.onChange(of: focusedItem) { newValue in
.onChange(of: focusedItem) { _, newValue in
guard let newValue else {
withAnimation {
presentBackground = false

View File

@ -72,7 +72,7 @@ struct PosterButton<Item: Poster>: View {
.ifLet(onFocusChanged) { view, onFocusChanged in
view
.focused($isFocused)
.onChange(of: isFocused) { newValue in
.onChange(of: isFocused) { _, newValue in
onFocusChanged(newValue)
}
}

View File

@ -56,7 +56,7 @@ struct FocusGuideModifier: ViewModifier {
})
.focused($focusDirection, equals: .bottom)
}
.onChange(of: focusDirection) { focusDirection in
.onChange(of: focusDirection) { _, focusDirection in
guard let focusDirection = focusDirection else { return }
switch focusDirection {
case .top:
@ -70,7 +70,7 @@ struct FocusGuideModifier: ViewModifier {
case .content: ()
}
}
.onChange(of: focusGuide.focusedTag) { newTag in
.onChange(of: focusGuide.focusedTag) { _, newTag in
if newTag == focusConstructor.tag {
if let onContentFocus = onContentFocus {
onContentFocus()

View File

@ -78,10 +78,10 @@ extension SeriesEpisodeSelector {
onContentFocus: { focusedEpisodeID = lastFocusedEpisodeID },
top: "seasons"
)
.onChange(of: viewModel) { newValue in
.onChange(of: viewModel) { _, newValue in
lastFocusedEpisodeID = newValue.elements.first?.id
}
.onChange(of: focusedEpisodeID) { newValue in
.onChange(of: focusedEpisodeID) { _, newValue in
guard let newValue else { return }
lastFocusedEpisodeID = newValue
}

View File

@ -46,7 +46,7 @@ struct SeriesEpisodeSelector: View {
selection = viewModel.seasons.first
}
}
.onChange(of: selection) { newValue in
.onChange(of: selection) { _, newValue in
guard let newValue else { return }
if newValue.state == .initial {
@ -120,7 +120,7 @@ extension SeriesEpisodeSelector {
.frame(height: 20)
}
}
.onChange(of: focusedSeason) { newValue in
.onChange(of: focusedSeason) { _, newValue in
guard let newValue else { return }
selection.wrappedValue = newValue
}

View File

@ -146,7 +146,7 @@ extension EpisodeItemView.ContentView {
}
}
.padding(.horizontal, 50)
.onChange(of: focusedLayer) { layer in
.onChange(of: focusedLayer) { _, layer in
if layer == .top {
focusedLayer = .playButton
}

View File

@ -130,7 +130,7 @@ extension ItemView {
}
}
.padding(.horizontal, 50)
.onChange(of: focusedLayer) { layer in
.onChange(of: focusedLayer) { _, layer in
if layer == .top {
focusedLayer = .playButton
}

View File

@ -110,7 +110,7 @@ struct MediaSourceInfoView: View {
}
.frame(maxWidth: .infinity)
}
.onChange(of: selectedMediaStream) { newValue in
.onChange(of: selectedMediaStream) { _, newValue in
guard let newValue else { return }
lastSelectedMediaStream = newValue
}

View File

@ -107,7 +107,7 @@ extension MediaView {
}
.buttonStyle(.card)
.onFirstAppear(perform: setImageSources)
.onChange(of: useRandomImage) { _ in
.onChange(of: useRandomImage) { _, _ in
setImageSources()
}
}

View File

@ -133,7 +133,7 @@ struct SearchView: View {
.onFirstAppear {
viewModel.send(.getSuggestions)
}
.onChange(of: searchQuery) { newValue in
.onChange(of: searchQuery) { _, newValue in
viewModel.send(.search(query: newValue))
}
.searchable(text: $searchQuery, prompt: L10n.search)

View File

@ -137,7 +137,7 @@ struct SelectUserView: View {
}
}
.padding(EdgeInsets.edgePadding * 2.5)
.onChange(of: gridItemSize) { newValue in
.onChange(of: gridItemSize) { _, newValue in
let columns = Int(contentSize.width / (newValue.width + EdgeInsets.edgePadding))
padGridItemColumnCount = columns
@ -283,7 +283,7 @@ struct SelectUserView: View {
// }
// )
}
.onChange(of: serverSelection) { newValue in
.onChange(of: serverSelection) { _, newValue in
gridItems = makeGridItems(for: newValue)
splashScreenImageSource = makeSplashScreenImageSource(
@ -291,7 +291,7 @@ struct SelectUserView: View {
allServersSelection: .all
)
}
.onChange(of: viewModel.servers) { _ in
.onChange(of: viewModel.servers) { _, _ in
gridItems = makeGridItems(for: serverSelection)
splashScreenImageSource = makeSplashScreenImageSource(

View File

@ -106,7 +106,7 @@ extension LiveVideoPlayer.Overlay {
.foregroundColor(.white)
}
}
.onChange(of: isPresentingOverlay) { newValue in
.onChange(of: isPresentingOverlay) { _, newValue in
guard newValue else { return }
}
}

View File

@ -40,14 +40,14 @@ extension LiveVideoPlayer {
// .animation(.linear(duration: 0.1), value: currentOverlayType)
// .environment(\.currentOverlayType, $currentOverlayType)
// .environmentObject(overlayTimer)
// .onChange(of: currentOverlayType) { newValue in
// .onChange(of: currentOverlayType) { _, newValue in
// if [.smallMenu, .chapters].contains(newValue) {
// overlayTimer.pause()
// } else if isPresentingOverlay {
// overlayTimer.start(5)
// }
// }
// .onChange(of: overlayTimer.isActive) { isActive in
// .onChange(of: overlayTimer.isActive) { _, isActive in
// guard !isActive else { return }
//
// withAnimation(.linear(duration: 0.3)) {

View File

@ -49,14 +49,14 @@ extension LiveVideoPlayer {
.animation(.linear(duration: 0.1), value: currentOverlayType)
.environment(\.currentOverlayType, $currentOverlayType)
.environmentObject(overlayTimer)
.onChange(of: currentOverlayType) { newValue in
.onChange(of: currentOverlayType) { _, newValue in
if [.smallMenu, .chapters].contains(newValue) {
overlayTimer.pause()
} else if isPresentingOverlay {
overlayTimer.start(5)
}
}
.onChange(of: overlayTimer.isActive) { isActive in
.onChange(of: overlayTimer.isActive) { _, isActive in
guard !isActive else { return }
withAnimation(.linear(duration: 0.3)) {

View File

@ -71,7 +71,7 @@ struct LiveVideoPlayer: View {
.environment(\.isPresentingOverlay, $isPresentingOverlay)
.environment(\.isScrubbing, $isScrubbing)
}
.onChange(of: videoPlayerManager.currentProgressHandler.scrubbedProgress) { newValue in
.onChange(of: videoPlayerManager.currentProgressHandler.scrubbedProgress) { _, newValue in
guard !newValue.isNaN && !newValue.isInfinite else {
return
}
@ -99,7 +99,7 @@ struct LiveVideoPlayer: View {
}
}
.ignoresSafeArea()
.onChange(of: isScrubbing) { newValue in
.onChange(of: isScrubbing) { _, newValue in
guard !newValue else { return }
videoPlayerManager.proxy.setTime(.seconds(currentProgressHandler.scrubbedSeconds))
}

View File

@ -93,7 +93,7 @@ extension VideoPlayer {
.padding2()
.padding2(.horizontal)
}
.onChange(of: currentOverlayType) { newValue in
.onChange(of: currentOverlayType) { _, newValue in
guard newValue == .chapters else { return }
if let currentChapter = viewModel.chapter(from: currentProgressHandler.seconds) {
scrollViewProxy?.scrollTo(currentChapter.hashValue, anchor: .center)

View File

@ -102,7 +102,7 @@ extension VideoPlayer.Overlay {
.foregroundColor(.white)
}
}
.onChange(of: isPresentingOverlay) { newValue in
.onChange(of: isPresentingOverlay) { _, newValue in
guard newValue else { return }
}
}

View File

@ -50,14 +50,14 @@ extension VideoPlayer {
.animation(.linear(duration: 0.1), value: currentOverlayType)
.environment(\.currentOverlayType, $currentOverlayType)
.environmentObject(overlayTimer)
.onChange(of: currentOverlayType) { newValue in
.onChange(of: currentOverlayType) { _, newValue in
if [.smallMenu, .chapters].contains(newValue) {
overlayTimer.pause()
} else if isPresentingOverlay {
overlayTimer.start(5)
}
}
.onChange(of: overlayTimer.isActive) { isActive in
.onChange(of: overlayTimer.isActive) { _, isActive in
guard !isActive else { return }
withAnimation(.linear(duration: 0.3)) {

View File

@ -160,7 +160,7 @@ extension VideoPlayer {
endPoint: .bottom
)
}
.onChange(of: focusedSection) { newValue in
.onChange(of: focusedSection) { _, newValue in
guard let newValue else { return }
lastFocusedSection = newValue
}

View File

@ -74,7 +74,7 @@ struct VideoPlayer: View {
.environment(\.isPresentingOverlay, $isPresentingOverlay)
.environment(\.isScrubbing, $isScrubbing)
}
.onChange(of: videoPlayerManager.currentProgressHandler.scrubbedProgress) { newValue in
.onChange(of: videoPlayerManager.currentProgressHandler.scrubbedProgress) { _, newValue in
guard !newValue.isNaN && !newValue.isInfinite else {
return
}
@ -102,7 +102,7 @@ struct VideoPlayer: View {
}
}
.ignoresSafeArea()
.onChange(of: isScrubbing) { newValue in
.onChange(of: isScrubbing) { _, newValue in
guard !newValue else { return }
videoPlayerManager.proxy.setTime(.seconds(currentProgressHandler.scrubbedSeconds))
}

View File

@ -820,7 +820,6 @@
E1DABAFC2A270EE7008AC34A /* MediaSourcesCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1DABAFB2A270EE7008AC34A /* MediaSourcesCard.swift */; };
E1DABAFE2A27B982008AC34A /* RatingsCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1DABAFD2A27B982008AC34A /* RatingsCard.swift */; };
E1DC9814296DC06200982F06 /* PulseLogHandler in Frameworks */ = {isa = PBXBuildFile; productRef = E1DC9813296DC06200982F06 /* PulseLogHandler */; };
E1DC9819296DD1CD00982F06 /* CinematicBackgroundView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1DC9818296DD1CD00982F06 /* CinematicBackgroundView.swift */; };
E1DC981A296DD1CD00982F06 /* CinematicBackgroundView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1DC9818296DD1CD00982F06 /* CinematicBackgroundView.swift */; };
E1DC983D296DEB9B00982F06 /* UnwatchedIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1DC983C296DEB9B00982F06 /* UnwatchedIndicator.swift */; };
E1DC983E296DEB9B00982F06 /* UnwatchedIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1DC983C296DEB9B00982F06 /* UnwatchedIndicator.swift */; };
@ -4400,7 +4399,6 @@
E10231482BCF8A6D009D71FC /* ChannelLibraryViewModel.swift in Sources */,
E107BB9327880A8F00354E07 /* CollectionItemViewModel.swift in Sources */,
E129428828F0831F00796AC6 /* SplitTimestamp.swift in Sources */,
E1DC9819296DD1CD00982F06 /* CinematicBackgroundView.swift in Sources */,
C46DD8E72A8FA77F0046A504 /* LiveBottomBarView.swift in Sources */,
E11CEB8D28999B4A003E74C7 /* Font.swift in Sources */,
E139CC1F28EC83E400688DE2 /* Int.swift in Sources */,