Skip to content

Commit

Permalink
Improved 'In Production' filter.
Browse files Browse the repository at this point in the history
Added company function to tvOS version.
  • Loading branch information
MadeiraAlexandre committed Aug 31, 2023
1 parent 568edcd commit 7a7b398
Show file tree
Hide file tree
Showing 22 changed files with 300 additions and 123 deletions.
1 change: 0 additions & 1 deletion AppleWatch/Views/Components/WatchlistSectionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ struct WatchlistSectionView: View {
} header: {
Text(NSLocalizedString(title, comment: ""))
}
.padding(.bottom)
} else {
Text("No results")
}
Expand Down
2 changes: 1 addition & 1 deletion AppleWatch/Views/Lists/UpNextListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct UpNextListView: View {
}
}
.navigationTitle("upNext")
.navigationBarTitleDisplayMode(.inline)
.navigationBarTitleDisplayMode(.large)
}
}

Expand Down
2 changes: 1 addition & 1 deletion AppleWatch/Views/Lists/UpcomingListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct UpcomingListView: View {
}
}
.navigationTitle("Upcoming")
.navigationBarTitleDisplayMode(.inline)
.navigationBarTitleDisplayMode(.large)
.navigationDestination(for: WatchlistItem.self) { item in
ItemContentView(id: item.itemId,
title: item.itemTitle,
Expand Down
2 changes: 1 addition & 1 deletion AppleWatch/Views/Navigation/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct SettingsView: View {
}
}
.navigationTitle("Settings")
.navigationBarTitleDisplayMode(.inline)
.navigationBarTitleDisplayMode(.large)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion AppleWatch/Views/Navigation/TrendingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct TrendingView: View {
}
.overlay { if !isLoaded { ProgressView().unredacted() } }
.navigationTitle("Trending")
.navigationBarTitleDisplayMode(.inline)
.navigationBarTitleDisplayMode(.large)
.navigationDestination(for: ItemContent.self) { item in
ItemContentView(id: item.id,
title: item.itemTitle,
Expand Down
5 changes: 4 additions & 1 deletion Shared/Extensions/WatchlistItem-Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@ extension WatchlistItem {
}
private var isUpcomingTvShow: Bool {
if itemMedia == .tvShow {
if itemSchedule == .soon && upcomingSeason && notify { return true }
if let firstAirDate, let date {
if firstAirDate <= Date() && date <= Date() { return false }
}
if itemSchedule == .soon && upcomingSeason && notify { return true }
if itemSchedule == .soon && upcomingSeason { return true }
if itemSchedule == .soon && nextSeasonNumber == 1 { return true }
if itemSchedule == .renewed && notify && date != nil && upcomingSeason { return true }
Expand Down
190 changes: 105 additions & 85 deletions Shared/View/Company/CompanyDetails.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,26 @@ struct CompanyDetails: View {
@StateObject private var settings = SettingsStore.shared
var body: some View {
VStack {
#if os(tvOS)
ScrollView {
HStack {
Text(company.name)
.font(.title)
.foregroundColor(.secondary)
Spacer()
}
posterStyle
}
#else
switch settings.sectionStyleType {
case .list: listStyle
case .poster: ScrollView { posterStyle }
case .card: ScrollView { cardStyle }
}
#endif
}
.overlay {
if !viewModel.isLoaded { ProgressView().unredacted() }
if !viewModel.isLoaded { ProgressView().unredacted() }
}
.toolbar {
#if os(iOS)
Expand All @@ -32,7 +44,9 @@ struct CompanyDetails: View {
#endif
}
.redacted(reason: viewModel.isLoaded ? [] : .placeholder)
#if !os(tvOS)
.navigationTitle(company.name)
#endif
#if os(iOS)
.navigationBarTitleDisplayMode(.large)
#endif
Expand Down Expand Up @@ -72,33 +86,33 @@ struct CompanyDetails: View {
Form {
Section {
List {
if !viewModel.items.isEmpty {
ForEach(viewModel.items) { item in
ItemContentRowView(item: item, showPopup: $showPopup, popupType: $popupType)
}
if viewModel.isLoaded && !viewModel.endPagination {
CenterHorizontalView {
ProgressView("Loading")
.padding(.horizontal)
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + 1.2) {
Task {
await viewModel.load(company.id)
}
}
}
}
}
} else {
if viewModel.isLoaded {
CenterHorizontalView {
Text("Try again later.")
.fontDesign(.monospaced)
.font(.headline)
.foregroundColor(.secondary)
}
}
}
if !viewModel.items.isEmpty {
ForEach(viewModel.items) { item in
ItemContentRowView(item: item, showPopup: $showPopup, popupType: $popupType)
}
if viewModel.isLoaded && !viewModel.endPagination {
CenterHorizontalView {
ProgressView("Loading")
.padding(.horizontal)
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + 1.2) {
Task {
await viewModel.load(company.id)
}
}
}
}
}
} else {
if viewModel.isLoaded {
CenterHorizontalView {
Text("Try again later.")
.fontDesign(.monospaced)
.font(.headline)
.foregroundColor(.secondary)
}
}
}
}
}
}
Expand All @@ -109,70 +123,70 @@ struct CompanyDetails: View {

private var cardStyle: some View {
LazyVGrid(columns: DrawingConstants.columns, spacing: 20) {
if !viewModel.items.isEmpty {
ForEach(viewModel.items) { item in
ItemContentCardView(item: item, showPopup: $showPopup, popupType: $popupType)
.buttonStyle(.plain)
}
if viewModel.isLoaded && !viewModel.endPagination {
CenterHorizontalView {
ProgressView()
.padding()
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + 1.2) {
Task {
await viewModel.load(company.id)
}
}
}
}
}
} else {
if viewModel.isLoaded {
CenterHorizontalView {
Text("Try again later.")
.fontDesign(.monospaced)
.font(.headline)
.foregroundColor(.secondary)
}
}
}
if !viewModel.items.isEmpty {
ForEach(viewModel.items) { item in
ItemContentCardView(item: item, showPopup: $showPopup, popupType: $popupType)
.buttonStyle(.plain)
}
if viewModel.isLoaded && !viewModel.endPagination {
CenterHorizontalView {
ProgressView()
.padding()
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + 1.2) {
Task {
await viewModel.load(company.id)
}
}
}
}
}
} else {
if viewModel.isLoaded {
CenterHorizontalView {
Text("Try again later.")
.fontDesign(.monospaced)
.font(.headline)
.foregroundColor(.secondary)
}
}
}
}
.padding()
}

@ViewBuilder
private var posterStyle: some View {
LazyVGrid(columns: settings.isCompactUI ? DrawingConstants.compactColumns : DrawingConstants.posterColumns,
spacing: settings.isCompactUI ? 10 : 20) {
if !viewModel.items.isEmpty {
ForEach(viewModel.items) { item in
ItemContentPosterView(item: item, showPopup: $showPopup, popupType: $popupType)
.buttonStyle(.plain)
}
if viewModel.isLoaded && !viewModel.endPagination {
CenterHorizontalView {
ProgressView()
.padding()
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + 1.2) {
Task {
await viewModel.load(company.id)
}
}
}
}
}
} else {
if viewModel.isLoaded {
CenterHorizontalView {
Text("Try again later.")
.fontDesign(.monospaced)
.font(.headline)
.foregroundColor(.secondary)
}
}
}
spacing: settings.isCompactUI ? 10 : DrawingConstants.posterSpacing) {
if !viewModel.items.isEmpty {
ForEach(viewModel.items) { item in
ItemContentPosterView(item: item, showPopup: $showPopup, popupType: $popupType)
.buttonStyle(.plain)
}
if viewModel.isLoaded && !viewModel.endPagination {
CenterHorizontalView {
ProgressView()
.padding()
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + 1.2) {
Task {
await viewModel.load(company.id)
}
}
}
}
}
} else {
if viewModel.isLoaded {
CenterHorizontalView {
Text("Try again later.")
.fontDesign(.monospaced)
.font(.headline)
.foregroundColor(.secondary)
}
}
}
}.padding(.all, settings.isCompactUI ? 10 : nil)
}
}
Expand All @@ -192,5 +206,11 @@ private struct DrawingConstants {
static let columns: [GridItem] = [GridItem(.adaptive(minimum: UIDevice.isIPad ? 240 : 160 ))]
#endif
static let compactColumns: [GridItem] = [GridItem(.adaptive(minimum: 80))]
#if os(tvOS)
static let posterColumns = [GridItem(.adaptive(minimum: 260))]
static let posterSpacing: CGFloat = 40
#else
static let posterColumns = [GridItem(.adaptive(minimum: 160))]
static let posterSpacing: CGFloat = 20
#endif
}
2 changes: 1 addition & 1 deletion Shared/View/ItemContent/EndpointDetails.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct EndpointDetails: View {
#endif
}
#if os(iOS)
.navigationBarTitleDisplayMode(.inline)
.navigationBarTitleDisplayMode(.large)
#endif
}

Expand Down
6 changes: 3 additions & 3 deletions Shared/View/ItemContent/ItemContentSectionDetails.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct ItemContentSectionDetails: View {
}
.actionPopup(isShowing: $showPopup, for: popupType)
#if os(iOS)
.navigationBarTitleDisplayMode(.inline)
.navigationBarTitleDisplayMode(.large)
.searchable(text: $query, placement: UIDevice.isIPhone ? .navigationBarDrawer(displayMode: .always) : .toolbar)
.autocorrectionDisabled()
.onChange(of: query) { _ in
Expand All @@ -63,10 +63,10 @@ struct ItemContentSectionDetails: View {
Text(item.title).tag(item)
}
} label: {
Label("sectionStyleTypePicker", systemImage: "circle.grid.2x2")
Label("Section Style", systemImage: "circle.grid.2x2")
}
} label: {
Label("sectionStyleTypePicker", systemImage: "circle.grid.2x2")
Label("Section Style", systemImage: "circle.grid.2x2")
.labelStyle(.iconOnly)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Shared/View/ItemContent/NotificationListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct NotificationListView: View {
#if os(macOS)
.formStyle(.grouped)
#elseif os(iOS)
.navigationBarTitleDisplayMode(.inline)
.navigationBarTitleDisplayMode(.large)
#endif
.toolbar {
#if os(iOS)
Expand Down
5 changes: 0 additions & 5 deletions Shared/View/ItemContent/Platform/ItemContentPadView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,10 @@ struct QuickInformationView: View {
content: item?.itemGenres)
if let companies = item?.itemCompanies, let company = item?.itemCompany {
if !companies.isEmpty {
#if !os(tvOS)
NavigationLink(value: companies) {
companiesLabel(company: company)
}
.buttonStyle(.plain)
#else
companiesLabel(company: company)
#endif
}
} else {
infoView(title: NSLocalizedString("Production Company",
Expand Down Expand Up @@ -335,7 +331,6 @@ struct QuickInformationView: View {
#endif
}
Text(company)
.lineLimit(1)
.font(.caption2)
.foregroundColor(.secondary)
}
Expand Down
7 changes: 6 additions & 1 deletion Shared/View/ItemContent/Platform/ItemContentPhoneView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ struct ItemContentPhoneView: View {
}

}
.navigationTitle(navigationTitle)
.toolbar {
ToolbarItem(placement: .principal) {
VStack { }
}
}
.navigationTitle(title)
.navigationBarTitleDisplayMode(.inline)
.onAppear {
if !navigationTitle.isEmpty {
Expand Down
1 change: 0 additions & 1 deletion Shared/View/ItemContent/Platform/ItemContentTVView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ struct ItemContentTVView: View {
displayAsCard: true)
CastListView(credits: viewModel.credits)
.padding(.bottom)
AttributionView()
}
.ignoresSafeArea(.all, edges: .horizontal)
}
Expand Down
Loading

0 comments on commit 7a7b398

Please sign in to comment.