@@ -1,7 +1,7 @@
import Foundation

struct WikipediaURL {
static func search(querying query: String) -> URL? {
public enum WikipediaURL {
public static func search(querying query: String) -> URL? {
guard let encodedQuery = query.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)
else { return nil }

@@ -1,6 +1,6 @@
import Combine
import Foundation

protocol APIService {
public protocol APIService {
func request<T: Decodable>(with builder: RequestBuilder) -> AnyPublisher<T, APIError>
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,9 @@
public struct Dimension {
public let name: String
public let value: String?

public init(name: String, value: String?) {
self.name = name
self.value = value
}
}
@@ -0,0 +1,5 @@
import Foundation

extension URL {
public static var example: Self { Self(string: "https://example.com")! }
}
@@ -1,14 +1,19 @@
import SwiftUI

struct AttributeRow: View {
let name: String
let value: String?
public struct AttributeRow: View {
private let name: String
private let value: String?

var body: some View {
public init(name: String, value: String?) {
self.name = name
self.value = value
}

public var body: some View {
if let value = value {
VStack(alignment: .leading) {
Text(name)
.foregroundColor(.mutedText)
.foregroundColor(Colors.secondaryText)
.font(.caption)
Text(value)
}
@@ -0,0 +1,5 @@
import SwiftUI

public struct Colors {
public static var secondaryText: Color = .gray
}
@@ -1,9 +1,14 @@
import SwiftUI
import Toolbox

struct DimensionGroup: View {
let dimensions: [Dimension]
public struct DimensionGroup: View {
private let dimensions: [Toolbox.Dimension]

var body: some View {
public init(dimensions: [Toolbox.Dimension]) {
self.dimensions = dimensions
}

public var body: some View {
VStack(alignment: .leading, spacing: 16) {
ForEach(dimensions, id: \.name) { dimension in
if let value = dimension.value {
@@ -17,9 +22,9 @@ struct DimensionGroup: View {
struct DimensionGroup_Previews: PreviewProvider {
static var previews: some View {
DimensionGroup(dimensions: [
Dimension(name: "Height", value: "205 ft"),
Dimension(name: "Missing value", value: nil),
Dimension(name: "Spread", value: "80 ft"),
Toolbox.Dimension(name: "Height", value: "205 ft"),
Toolbox.Dimension(name: "Missing value", value: nil),
Toolbox.Dimension(name: "Spread", value: "80 ft"),
])
.autosizedPreview()
}
@@ -18,7 +18,7 @@ struct DimensionView: View {
Text(name)
.font(.caption)
.bold()
.foregroundColor(.mutedText)
.foregroundColor(Colors.secondaryText)
Text(value)
.font(.title2)
.bold()
@@ -0,0 +1,40 @@
import SwiftUI
import Toolbox

public struct DimensionsView: View {
private let height: String?
private let spread: String?
private let diameter: String?
private let circumference: String?

public init(height: String?, spread: String?, diameter: String?, circumference: String?) {
self.height = height
self.spread = spread
self.diameter = diameter
self.circumference = circumference
}

public var body: some View {
HStack(spacing: 16) {
DimensionGroup(dimensions: [
Toolbox.Dimension(name: "Height", value: height),
Toolbox.Dimension(name: "Spread", value: spread)
])

Spacer()

DimensionGroup(dimensions: [
Toolbox.Dimension(name: "Diameter", value: diameter),
Toolbox.Dimension(name: "Circumference", value: circumference)
])
}
.padding(.trailing)
}
}

struct DimensionsView_Previews: PreviewProvider {
static var previews: some View {
DimensionsView(height: "85 ft", spread: "107 ft", diameter: "48 in", circumference: "12.8 in")
.autosizedPreview()
}
}
@@ -1,7 +1,8 @@
import MapKit
import Toolbox

public extension MapView {
class Coordinator: NSObject, MKMapViewDelegate {
extension MapView {
public class Coordinator: NSObject, MKMapViewDelegate {
var parent: MapView

init(_ parent: MapView) {
@@ -1,5 +1,6 @@
import MapKit
import SwiftUI
import Toolbox

let AnnotationViewIdentifier = "Annotation View"

@@ -1,13 +1,19 @@
import SwiftUI
import Toolbox

struct NameView: View {
let url: URL?
let title: String
let subtitle: String

public struct NameView: View {
private let url: URL?
private let title: String
private let subtitle: String
@State private var showingSafari = false

var body: some View {
public init(url: URL?, title: String, subtitle: String) {
self.url = url
self.title = title
self.subtitle = subtitle
}

public var body: some View {
if let url = url {
SafariButton(url: url) {
content
@@ -23,7 +29,7 @@ struct NameView: View {
.font(.title)
Text(subtitle)
.font(.title3)
.foregroundColor(.mutedText)
.foregroundColor(Colors.secondaryText)
}
}
}
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,16 @@
import SafariServices
import SwiftUI

public struct SafariView: UIViewControllerRepresentable {
private let url: URL

public init(url: URL) {
self.url = url
}

public func makeUIViewController(context: UIViewControllerRepresentableContext<SafariView>) -> SFSafariViewController {
return SFSafariViewController(url: url)
}

public func updateUIViewController(_ uiViewController: SFSafariViewController, context: UIViewControllerRepresentableContext<SafariView>) {}
}
@@ -1,7 +1,7 @@
import SwiftUI

extension View {
func autosizedPreview() -> some View {
public func autosizedPreview() -> some View {
previewLayout(PreviewLayout.sizeThatFits)
.padding()
}

Large diffs are not rendered by default.