Skip to content

Commit

Permalink
Fix tvOS support
Browse files Browse the repository at this point in the history
  • Loading branch information
aromanov91 committed May 19, 2024
1 parent 34e83f9 commit dc6ac3e
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let package = Package(
platforms: [
.iOS(.v15),
.macOS(.v13),
.tvOS(.v15),
.tvOS(.v16),
.watchOS(.v9),
],
products: [
Expand Down
11 changes: 7 additions & 4 deletions Sources/OversizeComponents/MapView/MapPreviewView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ public struct MapPreviewView: View {
Map(coordinateRegion: .constant(region), interactionModes: .zoom, annotationItems: annotations) {
MapMarker(coordinate: $0.coordinate)
}

.onTapGesture {
if action == nil {
let placemark = MKPlacemark(coordinate: location, addressDictionary: nil)
let mapItem = MKMapItem(placemark: placemark)
mapItem.name = annotation
mapItem.openInMaps()
#if !os(tvOS)
let placemark = MKPlacemark(coordinate: location, addressDictionary: nil)
let mapItem = MKMapItem(placemark: placemark)
mapItem.name = annotation
mapItem.openInMaps()
#endif
} else {
action?()
}
Expand Down
72 changes: 37 additions & 35 deletions Sources/OversizeComponents/NoteEditor/NoteEditor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,47 @@
import OversizeUI
import SwiftUI

@available(iOS 16.0, *)
public struct NoteEditor: View {
@Environment(\.dismiss) private var dismiss
@Binding private var text: String
@FocusState var isFocus: Bool
private let title: String?
#if os(iOS) || os(macOS)
@available(iOS 16.0, *)
public struct NoteEditor: View {
@Environment(\.dismiss) private var dismiss
@Binding private var text: String
@FocusState var isFocus: Bool
private let title: String?

public init(_ title: String? = nil, text: Binding<String>) {
self.title = title
_text = text
}
public init(_ title: String? = nil, text: Binding<String>) {
self.title = title
_text = text
}

public var body: some View {
TextEditor(text: $text)
.focused($isFocus)
.padding(.leading, .xSmall)
.padding(.bottom, .xSmall)
.background(Color.backgroundPrimary)
.toolbar {
if let title {
ToolbarItem(placement: .principal) {
Text(title)
.font(.headline)
public var body: some View {
TextEditor(text: $text)
.focused($isFocus)
.padding(.leading, .xSmall)
.padding(.bottom, .xSmall)
.background(Color.backgroundPrimary)
.toolbar {
if let title {
ToolbarItem(placement: .principal) {
Text(title)
.font(.headline)
}
}
}

ToolbarItem(placement: .cancellationAction) {
Button {
dismiss()
} label: {
Image.Base.close.icon()
ToolbarItem(placement: .cancellationAction) {
Button {
dismiss()
} label: {
Image.Base.close.icon()
}
}
}
}
#if os(iOS)
.navigationBarTitleDisplayMode(.inline)
#endif
.onAppear {
isFocus = true
}
#if os(iOS)
.navigationBarTitleDisplayMode(.inline)
#endif
.onAppear {
isFocus = true
}
}
}
}
#endif
4 changes: 3 additions & 1 deletion Sources/OversizeComponents/WebView/WebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

import OversizeUI
import SwiftUI
import WebKit
#if canImport(WebKit)
import WebKit
#endif

public struct WebView: View {
@State var tabBarVisibility: Visibility = .hidden
Expand Down

0 comments on commit dc6ac3e

Please sign in to comment.