Skip to content

Commit

Permalink
Update for tvOS
Browse files Browse the repository at this point in the history
  • Loading branch information
kean committed Apr 16, 2023
1 parent e9453f3 commit 6655c9d
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 49 deletions.
4 changes: 2 additions & 2 deletions Sources/PulseUI/Extensions/SwiftUI+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ enum SwipeActionEdge {
case leading
case trailing

#if os(iOS) || os(tvOS) || os(macOS)
#if os(iOS) || os(macOS)
@available(iOS 15, tvOS 15, *)
var native: HorizontalEdge {
switch self {
Expand All @@ -103,7 +103,7 @@ extension Backport {

@ViewBuilder
func swipeActions<T: View>(edge: SwipeActionEdge = .trailing, allowsFullSwipe: Bool = true, @ViewBuilder closure: () -> T) -> some View {
#if os(iOS) || os(tvOS) || os(macOS)
#if os(iOS) || os(macOS)
if #available(iOS 15, tvOS 15, *) {
content.swipeActions(edge: edge.native, allowsFullSwipe: allowsFullSwipe, content: closure)
} else {
Expand Down
2 changes: 1 addition & 1 deletion Sources/PulseUI/Features/Console/ConsoleView-tvos.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private struct ConsoleMenuView: View {

var body: some View {
Section {
Toggle(isOn: $viewModel.isOnlyErrors) {
Toggle(isOn: $viewModel.options.isOnlyErrors) {
Label("Errors Only", systemImage: "exclamationmark.octagon")
}
Toggle(isOn: consoleViewModel.bindingForNetworkMode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,15 @@
import SwiftUI
import Pulse

#if os(iOS) || os(macOS) || os(tvOS)
#if os(iOS) || os(macOS)

struct ConsoleSearchTimePeriodCell: View {
@Binding var selection: ConsoleSearchCriteria.Dates
#if os(tvOS)
@State private var quickFilter: ConsoleDatesQuickFilter = .session
#endif

var body: some View {
#if os(iOS) || os(macOS)
DateRangePicker(title: "Start", date: $selection.startDate)
DateRangePicker(title: "End", date: $selection.endDate)
quickFilters
#endif

#if os(tvOS)
Picker("Date Range", selection: $quickFilter) {
ForEach(ConsoleDatesQuickFilter.allCases, id: \.self) {
Text($0.title).tag($0)
}
}
.onChange(of: quickFilter) {
if let filter = $0.makeDateFilter() {
selection = filter
}
}
#endif
}

@ViewBuilder
Expand All @@ -50,24 +32,4 @@ struct ConsoleSearchTimePeriodCell: View {
}
}

#if os(tvOS)
private enum ConsoleDatesQuickFilter: String, Hashable, CaseIterable {
case session
case recent
case today
case all

var title: String { rawValue.capitalized }

func makeDateFilter() -> ConsoleSearchCriteria.Dates? {
switch self {
case .session: return .session
case .recent: return .recent
case .today: return .today
case .all: return nil
}
}
}
#endif

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ extension ConsoleSearchCriteria {
static var recent: Dates {
Dates(startDate: Date().addingTimeInterval(-1200))
}

static var session: Dates {
Dates(startDate: LoggerStore.Session.current.startDate)
}
}

struct LogLevels: ConsoleFilterProtocol {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ import SwiftUI
import Pulse
import CoreData

#warning("temp")

struct ConsoleSessionsPickerView: View {
@Binding var selection: Set<UUID>
@State private var isShowingPicker = false

@Environment(\.store) private var store: LoggerStore

#if os(watchOS)
#if os(watchOS) || os(tvOS)
@FetchRequest(sortDescriptors: [NSSortDescriptor(keyPath: \LoggerSessionEntity.createdAt, ascending: false)])
private var sessions: FetchedResults<LoggerSessionEntity>
#endif
Expand Down

0 comments on commit 6655c9d

Please sign in to comment.