Add ability to hide "Recently Added" section at home screen (#1087)

This commit is contained in:
Dhocking 2024-06-12 10:35:01 -07:00 committed by GitHub
parent 1d284c800d
commit 5334c57c65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 26 additions and 4 deletions

View File

@ -112,6 +112,7 @@ extension Defaults.Keys {
static let showPosterLabels: Key<Bool> = UserKey("showPosterLabels", default: true)
static let nextUpPosterType: Key<PosterDisplayType> = UserKey("nextUpPosterType", default: .portrait)
static let recentlyAddedPosterType: Key<PosterDisplayType> = UserKey("recentlyAddedPosterType", default: .portrait)
static let showRecentlyAdded: Key<Bool> = UserKey("showRecentlyAdded", default: true)
static let latestInLibraryPosterType: Key<PosterDisplayType> = UserKey("latestInLibraryPosterType", default: .portrait)
static let shouldShowMissingSeasons: Key<Bool> = UserKey("shouldShowMissingSeasons", default: true)
static let shouldShowMissingEpisodes: Key<Bool> = UserKey("shouldShowMissingEpisodes", default: true)

View File

@ -19,6 +19,9 @@ struct HomeView: View {
@StateObject
private var viewModel = HomeViewModel()
@Default(.Customization.showRecentlyAdded)
private var showRecentlyAdded
@ViewBuilder
private var contentView: some View {
ScrollView {
@ -29,10 +32,13 @@ struct HomeView: View {
NextUpView(viewModel: viewModel.nextUpViewModel)
RecentlyAddedView(viewModel: viewModel.recentlyAddedViewModel)
if showRecentlyAdded {
RecentlyAddedView(viewModel: viewModel.recentlyAddedViewModel)
}
} else {
CinematicRecentlyAddedView(viewModel: viewModel.recentlyAddedViewModel)
if showRecentlyAdded {
CinematicRecentlyAddedView(viewModel: viewModel.recentlyAddedViewModel)
}
NextUpView(viewModel: viewModel.nextUpViewModel)
}

View File

@ -37,6 +37,8 @@ struct CustomizeViewsSettings: View {
private var libraryRandomImage
@Default(.Customization.Library.showFavorites)
private var showFavorites
@Default(.Customization.showRecentlyAdded)
private var showRecentlyAdded
@EnvironmentObject
private var router: SettingsCoordinator.Router
@ -92,6 +94,9 @@ struct CustomizeViewsSettings: View {
Toggle("Random Image", isOn: $libraryRandomImage)
Toggle("Show Favorites", isOn: $showFavorites)
Toggle("Show Recently Added", isOn: $showRecentlyAdded)
} header: {
L10n.library.text
}

View File

@ -18,6 +18,8 @@ struct HomeView: View {
@Default(.Customization.nextUpPosterType)
private var nextUpPosterType
@Default(.Customization.showRecentlyAdded)
private var showRecentlyAdded
@Default(.Customization.recentlyAddedPosterType)
private var recentlyAddedPosterType
@ -38,7 +40,9 @@ struct HomeView: View {
NextUpView(homeViewModel: viewModel)
RecentlyAddedView(viewModel: viewModel.recentlyAddedViewModel)
if showRecentlyAdded {
RecentlyAddedView(viewModel: viewModel.recentlyAddedViewModel)
}
ForEach(viewModel.libraries) { viewModel in
LatestInLibraryView(viewModel: viewModel)

View File

@ -38,6 +38,8 @@ struct CustomizeViewsSettings: View {
private var nextUpPosterType
@Default(.Customization.recentlyAddedPosterType)
private var recentlyAddedPosterType
@Default(.Customization.showRecentlyAdded)
private var showRecentlyAdded
@Default(.Customization.latestInLibraryPosterType)
private var latestInLibraryPosterType
@Default(.Customization.similarPosterType)
@ -160,6 +162,10 @@ struct CustomizeViewsSettings: View {
}
}
Section("Home") {
Toggle("Show recently added", isOn: $showRecentlyAdded)
}
Section {
Toggle("Remember layout", isOn: $rememberLibraryLayout)
} footer: {