Navigation improvements

This commit is contained in:
Arkadiusz Fal 2022-05-29 22:12:59 +02:00
parent a2e23fe72c
commit 31c5ed1643
5 changed files with 13 additions and 6 deletions

View File

@ -78,7 +78,7 @@ final class NavigationModel: ObservableObject {
return
}
navigation.presentingPlaylist = false
player.presentingPlayer = false
navigation.presentingChannel = false
let recent = RecentItem(from: channel)
@ -116,7 +116,6 @@ final class NavigationModel: ObservableObject {
navigationStyle: NavigationStyle,
delay: Bool = false
) {
navigation.presentingChannel = false
navigation.presentingPlaylist = false
let recent = RecentItem(from: playlist)

View File

@ -22,4 +22,8 @@ final class Store<Data>: ResourceObserver, ObservableObject {
func replace(_ items: Data) {
all = items
}
func clear() {
all = nil
}
}

View File

@ -43,8 +43,8 @@ struct AppTabNavigation: View {
searchNavigationView
}
.id(accounts.current?.id ?? "")
.overlay(channelView)
.overlay(playlistView)
.overlay(channelView)
.environment(\.navigationStyle, .tab)
}

View File

@ -30,7 +30,7 @@ struct ChannelPlaylistView: View {
}
private var presentedPlaylist: ChannelPlaylist? {
recents.presentedPlaylist ?? playlist
playlist ?? recents.presentedPlaylist
}
private var resource: Resource? {
@ -54,6 +54,7 @@ struct ChannelPlaylistView: View {
#if os(iOS)
.onChange(of: navigation.presentingPlaylist) { newValue in
if newValue {
store.clear()
viewVerticalOffset = 0
resource?.load()
} else {
@ -61,6 +62,7 @@ struct ChannelPlaylistView: View {
}
}
.offset(y: viewVerticalOffset)
.opacity(viewVerticalOffset == Self.hiddenOffset ? 0 : 1)
.animation(.easeIn(duration: 0.2), value: viewVerticalOffset)
#endif
} else {

View File

@ -33,7 +33,7 @@ struct ChannelVideosView: View {
@Namespace private var focusNamespace
var presentedChannel: Channel? {
recents.presentedChannel ?? channel
channel ?? recents.presentedChannel
}
var videos: [ContentItem] {
@ -50,13 +50,15 @@ struct ChannelVideosView: View {
#if os(iOS)
.onChange(of: navigation.presentingChannel) { newValue in
if newValue {
resource?.load()
store.clear()
viewVerticalOffset = 0
resource?.load()
} else {
viewVerticalOffset = Self.hiddenOffset
}
}
.offset(y: viewVerticalOffset)
.opacity(viewVerticalOffset == Self.hiddenOffset ? 0 : 1)
.animation(.easeIn(duration: 0.2), value: viewVerticalOffset)
#endif
} else {