Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add '_spi(TokamakCore)' to ideally internal public members. #386

Merged
merged 11 commits into from
Mar 8, 2021
1 change: 1 addition & 0 deletions Sources/TokamakCore/App/Scenes/WindowGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public struct WindowGroup<Content>: Scene, TitledScene where Content: View {
self.content = content()
}

@_spi(TokamakCore)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you apply SwiftFormat as swiftformat . in the project directory to get rid of trailing whitespaces? You can also install a pre-commit hook as described here, which will apply formatting fixes automatically for you before you commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I had forgotten that.

public var body: Never {
neverScene("WindowGroup")
}
Expand Down
1 change: 1 addition & 0 deletions Sources/TokamakCore/App/Scenes/_SceneModifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public struct _SceneModifier_Content<Modifier>: Scene where Modifier: _SceneModi
public let modifier: Modifier
public let scene: _AnyScene

@_spi(TokamakCore)
public var body: Never {
neverScene("_SceneModifier_Content")
}
Expand Down
6 changes: 6 additions & 0 deletions Sources/TokamakCore/App/_AnyApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,32 @@ public struct _AnyApp: App {
bodyType = A.Body.self
}

@_spi(TokamakCore)
public var body: Never {
neverScene("_AnyApp")
}

@_spi(TokamakCore)
public init() {
fatalError("`_AnyApp` cannot be initialized without an underlying `App` type.")
}

@_spi(TokamakCore)
public static func _launch(_ app: Self, _ rootEnvironment: EnvironmentValues) {
fatalError("`_AnyApp` cannot be launched. Access underlying `app` value.")
}

@_spi(TokamakCore)
public static func _setTitle(_ title: String) {
fatalError("`title` cannot be set for `AnyApp`. Access underlying `app` value.")
}

@_spi(TokamakCore)
public var _phasePublisher: AnyPublisher<ScenePhase, Never> {
fatalError("`_AnyApp` cannot monitor scenePhase. Access underlying `app` value.")
}

@_spi(TokamakCore)
public var _colorSchemePublisher: AnyPublisher<ColorScheme, Never> {
fatalError("`_AnyApp` cannot monitor colorScheme. Access underlying `app` value.")
}
Expand Down
1 change: 1 addition & 0 deletions Sources/TokamakCore/App/_AnyScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public struct _AnyScene: Scene {
}
}

@_spi(TokamakCore)
public var body: Never {
neverScene("_AnyScene")
}
Expand Down
1 change: 1 addition & 0 deletions Sources/TokamakCore/Shapes/Shape.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public struct _ShapeView<Content, Style>: View where Content: Shape, Style: Shap
self.fillStyle = fillStyle
}

@_spi(TokamakCore)
public var body: Never {
neverBody("_ShapeView")
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/TokamakCore/Styles/ButtonStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
public struct ButtonStyleConfiguration {
public struct Label: View {
let content: AnyView

@_spi(TokamakCore)
public var body: Never {
neverBody("ButtonStyleConfiguration.Label")
}
Expand Down
1 change: 1 addition & 0 deletions Sources/TokamakCore/Tokens/Color.swift
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ public struct Color: Hashable, Equatable {
}

/// Create a `Color` dependent on the current `ColorScheme`.
@_spi(TokamakCore)
public static func _withScheme(_ resolver: @escaping (ColorScheme) -> Self) -> Self {
.init(_EnvironmentDependentColorBox {
resolver($0.colorScheme)
Expand Down
2 changes: 2 additions & 0 deletions Sources/TokamakCore/Views/AnyView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public struct AnyView: View {
}
}

@_spi(TokamakCore)
public var body: Never {
neverBody("AnyView")
}
Expand All @@ -80,6 +81,7 @@ public func mapAnyView<T, V>(_ anyView: AnyView, transform: (V) -> T) -> T? {
}

extension AnyView: ParentView {
@_spi(TokamakCore)
public var children: [AnyView] {
(view as? ParentView)?.children ?? []
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/TokamakCore/Views/Buttons/Button.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public struct _Button<Label>: View where Label: View {
self.action = action
}

@_spi(TokamakCore)
public var body: Never {
neverBody("_Button")
}
Expand All @@ -72,6 +73,7 @@ public extension Button where Label == Text {
}

extension Button: ParentView {
@_spi(TokamakCore)
public var children: [AnyView] {
(implementation.label as? GroupView)?.children ?? [AnyView(implementation.label)]
}
Expand Down
1 change: 1 addition & 0 deletions Sources/TokamakCore/Views/Buttons/Link.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public struct Link<Label>: View where Label: View {
(self.destination, self.label) = (destination, label())
}

@_spi(TokamakCore)
public var body: Never {
neverBody("Link")
}
Expand Down
1 change: 1 addition & 0 deletions Sources/TokamakCore/Views/Containers/DisclosureGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public struct DisclosureGroup<Label, Content>: View where Label: View, Content:
self.content = content
}

@_spi(TokamakCore)
public var body: Never {
neverBody("DisclosureGroup")
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/TokamakCore/Views/Containers/ForEach.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public struct ForEach<Data, ID, Content>: View where Data: RandomAccessCollectio
self.content = content
}

@_spi(TokamakCore)
public var body: Never {
neverBody("ForEach")
}
Expand Down Expand Up @@ -79,6 +80,7 @@ public extension ForEach where Data == Range<Int>, ID == Int {
}

extension ForEach: ParentView {
@_spi(TokamakCore)
public var children: [AnyView] {
data.map { AnyView(IDView(content($0), id: $0[keyPath: id])) }
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/TokamakCore/Views/Containers/Group.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ public struct Group<Content> {
}

extension Group: View where Content: View {
@_spi(TokamakCore)
public var body: Never {
neverBody("Group")
}
}

extension Group: ParentView where Content: View {
@_spi(TokamakCore)
public var children: [AnyView] { (content as? ParentView)?.children ?? [AnyView(content)] }
}

Expand Down
1 change: 1 addition & 0 deletions Sources/TokamakCore/Views/Containers/TupleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
///
/// Mainly for use with `@ViewBuilder`.
public struct TupleView<T>: View {
@_spi(TokamakCore)
public var body: Never {
neverBody("TupleView")
}
Expand Down
1 change: 1 addition & 0 deletions Sources/TokamakCore/Views/Image.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public struct Image: View {
self.bundle = bundle
}

@_spi(TokamakCore)
public var body: Never {
neverBody("Image")
}
Expand Down
1 change: 1 addition & 0 deletions Sources/TokamakCore/Views/Layout/GeometryReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public struct GeometryReader<Content>: View where Content: View {
self.content = content
}

@_spi(TokamakCore)
public var body: Never {
neverBody("GeometryReader")
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/TokamakCore/Views/Layout/HStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ public struct HStack<Content>: View where Content: View {
self.content = content()
}

@_spi(TokamakCore)
public var body: Never {
neverBody("HStack")
}
}

extension HStack: ParentView {
@_spi(TokamakCore)
public var children: [AnyView] {
(content as? GroupView)?.children ?? [AnyView(content)]
}
Expand Down
1 change: 1 addition & 0 deletions Sources/TokamakCore/Views/Layout/LazyHGrid.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public struct LazyHGrid<Content>: View where Content: View {
self.content = content()
}

@_spi(TokamakCore)
public var body: Never {
neverBody("LazyVGrid")
}
Expand Down
1 change: 1 addition & 0 deletions Sources/TokamakCore/Views/Layout/LazyVGrid.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public struct LazyVGrid<Content>: View where Content: View {
self.content = content()
}

@_spi(TokamakCore)
public var body: Never {
neverBody("LazyVGrid")
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/TokamakCore/Views/Layout/ScrollView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ public struct ScrollView<Content>: View where Content: View {
self.content = content()
}

@_spi(TokamakCore)
public var body: Never {
neverBody("ScrollView")
}
}

extension ScrollView: ParentView {
@_spi(TokamakCore)
public var children: [AnyView] {
(content as? GroupView)?.children ?? [AnyView(content)]
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/TokamakCore/Views/Layout/VStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ public struct VStack<Content>: View where Content: View {
self.content = content()
}

@_spi(TokamakCore)
public var body: Never {
neverBody("VStack")
}
}

extension VStack: ParentView {
@_spi(TokamakCore)
public var children: [AnyView] {
(content as? GroupView)?.children ?? [AnyView(content)]
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/TokamakCore/Views/Layout/ZStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ public struct ZStack<Content>: View where Content: View {
self.content = content()
}

@_spi(TokamakCore)
public var body: Never {
neverBody("ZStack")
}
}

extension ZStack: ParentView {
@_spi(TokamakCore)
public var children: [AnyView] {
(content as? GroupView)?.children ?? [AnyView(content)]
}
Expand Down
1 change: 1 addition & 0 deletions Sources/TokamakCore/Views/Navigation/NavigationLink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public struct NavigationLink<Label, Destination>: View where Label: View, Destin
// @ViewBuilder label: () -> Label
// ) where V : Hashable

@_spi(TokamakCore)
public var body: Never {
neverBody("NavigationLink")
}
Expand Down
1 change: 1 addition & 0 deletions Sources/TokamakCore/Views/Navigation/NavigationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public struct NavigationView<Content>: View where Content: View {
self.content = content()
}

@_spi(TokamakCore)
public var body: Never {
neverBody("NavigationView")
}
Expand Down
5 changes: 5 additions & 0 deletions Sources/TokamakCore/Views/Selectors/Picker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public struct _PickerContainer<Label: View, SelectionValue: Hashable, Content: V
self.content = content()
}

@_spi(TokamakCore)
public var body: Never {
neverBody("_PickerLabel")
}
Expand All @@ -47,6 +48,7 @@ public struct _PickerElement: View {
public let content: AnyView
@Environment(\.pickerStyle) public var style

@_spi(TokamakCore)
public var body: Never {
neverBody("_PickerElement")
}
Expand Down Expand Up @@ -105,12 +107,15 @@ public extension Picker where Label == Text {
}

extension Picker: ParentView {
@_spi(TokamakCore)
public var children: [AnyView] {
(content as? GroupView)?.children ?? [AnyView(content)]
}
}

@_spi(TokamakCore)
extension Picker: _PickerContainerProtocol {
@_spi(TokamakCore)
public var elements: [_AnyIDView] {
(content as? ForEachProtocol)?.children
.compactMap {
Expand Down
2 changes: 2 additions & 0 deletions Sources/TokamakCore/Views/Selectors/Slider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public struct Slider<Label, ValueLabel>: View where Label: View, ValueLabel: Vie
let step: _SliderStep
let onEditingChanged: (Bool) -> ()

@_spi(TokamakCore)
public var body: Never {
neverBody("Slider")
}
Expand Down Expand Up @@ -144,6 +145,7 @@ public extension Slider {
}

extension Slider: ParentView {
@_spi(TokamakCore)
public var children: [AnyView] {
((label as? GroupView)?.children ?? [AnyView(label)])
+ ((minValueLabel as? GroupView)?.children ?? [AnyView(minValueLabel)])
Expand Down
1 change: 1 addition & 0 deletions Sources/TokamakCore/Views/Selectors/Toggle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public extension Toggle where Label == AnyView {
}

extension Toggle: ParentView {
@_spi(TokamakCore)
public var children: [AnyView] {
(label as? GroupView)?.children ?? [AnyView(label)]
}
Expand Down
3 changes: 3 additions & 0 deletions Sources/TokamakCore/Views/Spacers/Divider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
/// A horizontal line for separating content.
public struct Divider: View {
@Environment(\.self) public var environment

public init() {}

@_spi(TokamakCore)
public var body: Never {
neverBody("Divider")
}
Expand Down
1 change: 1 addition & 0 deletions Sources/TokamakCore/Views/Spacers/Spacer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public struct Spacer: View {
self.minLength = minLength
}

@_spi(TokamakCore)
public var body: Never {
neverBody("Spacer")
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/TokamakCore/Views/Text/SecureField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public struct SecureField<Label>: View where Label: View {
let textBinding: Binding<String>
let onCommit: () -> ()

@_spi(TokamakCore)
public var body: Never {
neverBody("SecureField")
}
Expand All @@ -57,6 +58,7 @@ public extension SecureField where Label == Text {
}

extension SecureField: ParentView {
@_spi(TokamakCore)
public var children: [AnyView] {
(label as? GroupView)?.children ?? [AnyView(label)]
}
Expand Down
1 change: 1 addition & 0 deletions Sources/TokamakCore/Views/Text/Text.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public struct Text: View {
self.init(storage: .verbatim(String(content)))
}

@_spi(TokamakCore)
public var body: Never {
neverBody("Text")
}
Expand Down
1 change: 1 addition & 0 deletions Sources/TokamakCore/Views/Text/TextEditor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public struct TextEditor: View {
textBinding = text
}

@_spi(TokamakCore)
public var body: Never {
neverBody("TextEditor")
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/TokamakCore/Views/Text/TextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public struct TextField<Label>: View where Label: View {
let onCommit: () -> ()
@Environment(\.textFieldStyle) var style

@_spi(TokamakCore)
public var body: Never {
neverBody("TextField")
}
Expand Down Expand Up @@ -68,6 +69,7 @@ public extension TextField where Label == Text {
}

extension TextField: ParentView {
@_spi(TokamakCore)
public var children: [AnyView] {
(label as? GroupView)?.children ?? [AnyView(label)]
}
Expand Down
Loading