Organize all the re-exports into a single file (#193)

* Organize all the re-exports into a single file

Hypothetically, Core.swift could be copy-pasted unmodified into any renderer

* Update ZStack.swift
This commit is contained in:
Jed Fox 2020-07-19 10:46:19 -04:00 committed by GitHub
parent b495a2447d
commit 743d9a0de8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 114 additions and 161 deletions

View File

@ -0,0 +1,110 @@
// Copyright 2020 Tokamak contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Created by Jed Fox on 7/18/20.
//
import TokamakCore
// MARK: Environment & State
public typealias Environment = TokamakCore.Environment
public typealias EnvironmentObject = TokamakCore.EnvironmentObject
public typealias ObservableObject = TokamakCore.ObservableObject
public typealias ObservedObject = TokamakCore.ObservedObject
public typealias Published = TokamakCore.Published
public typealias State = TokamakCore.State
// MARK: Modifiers & Styles
public typealias ViewModifier = TokamakCore.ViewModifier
public typealias ModifiedContent = TokamakCore.ModifiedContent
public typealias DefaultTextFieldStyle = TokamakCore.DefaultTextFieldStyle
public typealias PlainTextFieldStyle = TokamakCore.PlainTextFieldStyle
public typealias RoundedBorderTextFieldStyle = TokamakCore.RoundedBorderTextFieldStyle
public typealias SquareBorderTextFieldStyle = TokamakCore.SquareBorderTextFieldStyle
public typealias DefaultListStyle = TokamakCore.DefaultListStyle
public typealias PlainListStyle = TokamakCore.PlainListStyle
public typealias InsetListStyle = TokamakCore.InsetListStyle
public typealias GroupedListStyle = TokamakCore.GroupedListStyle
public typealias InsetGroupedListStyle = TokamakCore.InsetGroupedListStyle
public typealias DefaultPickerStyle = TokamakCore.DefaultPickerStyle
public typealias PopUpButtonPickerStyle = TokamakCore.PopUpButtonPickerStyle
public typealias RadioGroupPickerStyle = TokamakCore.RadioGroupPickerStyle
public typealias SegmentedPickerStyle = TokamakCore.SegmentedPickerStyle
public typealias WheelPickerStyle = TokamakCore.WheelPickerStyle
// MARK: Shapes
public typealias Shape = TokamakCore.Shape
public typealias Capsule = TokamakCore.Capsule
public typealias Circle = TokamakCore.Circle
public typealias Ellipse = TokamakCore.Ellipse
public typealias Path = TokamakCore.Path
public typealias Rectangle = TokamakCore.Rectangle
public typealias RoundedRectangle = TokamakCore.RoundedRectangle
// MARK: Primitive values
public typealias Color = TokamakCore.Color
public typealias Font = TokamakCore.Font
public typealias CGAffineTransform = TokamakCore.CGAffineTransform
public typealias CGPoint = TokamakCore.CGPoint
public typealias CGRect = TokamakCore.CGRect
public typealias CGSize = TokamakCore.CGSize
// MARK: Views
public typealias Button = TokamakCore.Button
public typealias DisclosureGroup = TokamakCore.DisclosureGroup
public typealias Divider = TokamakCore.Divider
public typealias ForEach = TokamakCore.ForEach
public typealias GridItem = TokamakCore.GridItem
public typealias Group = TokamakCore.Group
public typealias HStack = TokamakCore.HStack
public typealias LazyHGrid = TokamakCore.LazyHGrid
public typealias LazyVGrid = TokamakCore.LazyVGrid
public typealias List = TokamakCore.List
public typealias OutlineGroup = TokamakCore.OutlineGroup
public typealias Picker = TokamakCore.Picker
public typealias ScrollView = TokamakCore.ScrollView
public typealias Section = TokamakCore.Section
public typealias SecureField = TokamakCore.SecureField
public typealias Spacer = TokamakCore.Spacer
public typealias Text = TokamakCore.Text
public typealias TextField = TokamakCore.TextField
public typealias VStack = TokamakCore.VStack
public typealias ZStack = TokamakCore.ZStack
// MARK: Special Views
public typealias View = TokamakCore.View
public typealias AnyView = TokamakCore.AnyView
public typealias EmptyView = TokamakCore.EmptyView
// MARK: Misc
// FIXME: I would put this inside TokamakCore, but for
// some reason it doesn't get exported with the typealias
extension Text {
public static func + (lhs: Self, rhs: Self) -> Self {
_concatenating(lhs: lhs, rhs: rhs)
}
}

View File

@ -1,21 +0,0 @@
// Copyright 2020 Tokamak contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Created by Carson Katri on 6/30/20.
//
import TokamakCore
public typealias Environment = TokamakCore.Environment
public typealias EnvironmentObject = TokamakCore.EnvironmentObject

View File

@ -14,9 +14,6 @@
import TokamakCore
public typealias ViewModifier = TokamakCore.ViewModifier
public typealias ModifiedContent = TokamakCore.ModifiedContent
public protocol DOMViewModifier {
var attributes: [String: String] { get }
/// Can the modifier be flattened?

View File

@ -17,8 +17,6 @@
import TokamakCore
public typealias Path = TokamakCore.Path
extension Path: ViewDeferredToRenderer {
// TODO: Support transformations
func svgFrom(storage: Storage,

View File

@ -17,8 +17,6 @@
import TokamakCore
public typealias Shape = TokamakCore.Shape
// Border modifier
extension _OverlayModifier: DOMViewModifier
where Overlay == _ShapeView<_StrokedShape<TokamakCore.Rectangle._Inset>, Color> {

View File

@ -43,9 +43,3 @@ extension _ShapeView: ViewDeferredToRenderer {
}
}
}
public typealias Rectangle = TokamakCore.Rectangle
public typealias RoundedRectangle = TokamakCore.RoundedRectangle
public typealias Ellipse = TokamakCore.Ellipse
public typealias Circle = TokamakCore.Circle
public typealias Capsule = TokamakCore.Capsule

View File

@ -1,29 +0,0 @@
// Copyright 2020 Tokamak contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Created by Jed Fox on 06/30/2020.
//
import TokamakCore
public typealias DefaultTextFieldStyle = TokamakCore.DefaultTextFieldStyle
public typealias PlainTextFieldStyle = TokamakCore.PlainTextFieldStyle
public typealias RoundedBorderTextFieldStyle = TokamakCore.RoundedBorderTextFieldStyle
public typealias SquareBorderTextFieldStyle = TokamakCore.SquareBorderTextFieldStyle
public typealias DefaultListStyle = TokamakCore.DefaultListStyle
public typealias PlainListStyle = TokamakCore.PlainListStyle
public typealias InsetListStyle = TokamakCore.InsetListStyle
public typealias GroupedListStyle = TokamakCore.GroupedListStyle
public typealias InsetGroupedListStyle = TokamakCore.InsetGroupedListStyle

View File

@ -14,22 +14,12 @@
import TokamakCore
public typealias Font = TokamakCore.Font
public typealias Color = TokamakCore.Color
extension Color: CustomStringConvertible {
public var description: String {
"rgb(\(red * 255), \(green * 255), \(blue * 255), \(opacity * 255))"
}
}
public typealias CGRect = TokamakCore.CGRect
public typealias CGPoint = TokamakCore.CGPoint
public typealias CGSize = TokamakCore.CGSize
public typealias CGAffineTransform = TokamakCore.CGAffineTransform
public typealias GridItem = TokamakCore.GridItem
extension GridItem: CustomStringConvertible {
public var description: String {
switch size {

View File

@ -17,8 +17,6 @@
import TokamakCore
public typealias Button = TokamakCore.Button
extension Button: ViewDeferredToRenderer where Label == Text {
public var deferredBody: AnyView {
AnyView(HTML("button", listeners: ["click": { _ in _ButtonProxy(self).action() }]) {

View File

@ -17,9 +17,6 @@
import TokamakCore
public typealias DisclosureGroup = TokamakCore.DisclosureGroup
public typealias OutlineGroup = TokamakCore.OutlineGroup
extension DisclosureGroup: ViewDeferredToRenderer {
var chevron: some View {
HTML("div",

View File

@ -14,8 +14,6 @@
import TokamakCore
public typealias Divider = TokamakCore.Divider
extension Divider: AnyHTML {
var innerHTML: String? { nil }
var tag: String { "hr" }

View File

@ -1,17 +0,0 @@
// Copyright 2020 Tokamak contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import TokamakCore
public typealias ForEach = TokamakCore.ForEach

View File

@ -1,17 +0,0 @@
// Copyright 2020 Tokamak contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import TokamakCore
public typealias Group = TokamakCore.Group

View File

@ -14,8 +14,6 @@
import TokamakCore
public typealias HStack = TokamakCore.HStack
extension VerticalAlignment {
var cssValue: String {
switch self {

View File

@ -20,14 +20,6 @@ import TokamakCore
public typealias Listener = (JSObjectRef) -> ()
public typealias View = TokamakCore.View
public typealias AnyView = TokamakCore.AnyView
public typealias EmptyView = TokamakCore.EmptyView
public typealias State = TokamakCore.State
public typealias ObservableObject = TokamakCore.ObservableObject
public typealias Published = TokamakCore.Published
public typealias ObservedObject = TokamakCore.ObservedObject
protocol AnyHTML {
var innerHTML: String? { get }
var tag: String { get }

View File

@ -17,8 +17,6 @@
import TokamakCore
public typealias LazyHGrid = TokamakCore.LazyHGrid
extension LazyHGrid: SpacerContainer {
var axis: SpacerContainerAxis { .horizontal }
var hasSpacer: Bool { false }

View File

@ -17,8 +17,6 @@
import TokamakCore
public typealias LazyVGrid = TokamakCore.LazyVGrid
extension LazyVGrid: SpacerContainer {
var axis: SpacerContainerAxis { .vertical }
var hasSpacer: Bool { false }

View File

@ -14,9 +14,6 @@
import TokamakCore
public typealias List = TokamakCore.List
public typealias Section = TokamakCore.Section
extension PlainListStyle: ListStyleDeferredToRenderer {
public func sectionHeader<Header>(_ header: Header) -> AnyView where Header: View {
AnyView(header

View File

@ -15,13 +15,6 @@
import JavaScriptKit
import TokamakCore
public typealias Picker = TokamakCore.Picker
public typealias PopUpButtonPickerStyle = TokamakCore.PopUpButtonPickerStyle
public typealias RadioGroupPickerStyle = TokamakCore.RadioGroupPickerStyle
public typealias SegmentedPickerStyle = TokamakCore.SegmentedPickerStyle
public typealias WheelPickerStyle = TokamakCore.WheelPickerStyle
public typealias DefaultPickerStyle = TokamakCore.DefaultPickerStyle
extension _PickerContainer: ViewDeferredToRenderer {
public var deferredBody: AnyView {
AnyView(HTML("label") {

View File

@ -17,8 +17,6 @@
import TokamakCore
public typealias ScrollView = TokamakCore.ScrollView
extension ScrollView: ViewDeferredToRenderer, SpacerContainer {
var axis: SpacerContainerAxis {
if axes.contains(.horizontal) {

View File

@ -17,8 +17,6 @@
import TokamakCore
public typealias SecureField = TokamakCore.SecureField
extension SecureField: ViewDeferredToRenderer where Label == Text {
public var deferredBody: AnyView {
let proxy = _SecureFieldProxy(self)

View File

@ -14,8 +14,6 @@
import TokamakCore
public typealias Spacer = TokamakCore.Spacer
enum SpacerContainerAxis {
case horizontal, vertical
}

View File

@ -15,16 +15,6 @@
import JavaScriptKit
import TokamakCore
public typealias Text = TokamakCore.Text
// FIXME: I would put this inside TokamakCore, but for
// some reason it doesn't get exported with the typealias
extension Text {
public static func + (lhs: Self, rhs: Self) -> Self {
_concatenating(lhs: lhs, rhs: rhs)
}
}
extension Font.Design: CustomStringConvertible {
/// Some default font stacks for the various designs
public var description: String {

View File

@ -17,8 +17,6 @@
import TokamakCore
public typealias TextField = TokamakCore.TextField
func css(for style: TextFieldStyle) -> String {
if style is PlainTextFieldStyle {
return """

View File

@ -14,8 +14,6 @@
import TokamakCore
public typealias VStack = TokamakCore.VStack
extension HorizontalAlignment {
var cssValue: String {
switch self {

View File

@ -14,8 +14,6 @@
import TokamakCore
public typealias ZStack = TokamakCore.ZStack
struct _ZStack_ContentGridItem: ViewModifier, DOMViewModifier {
let attributes = ["style": "grid-area: a;"]
@ -35,7 +33,10 @@ extension ZStack: ViewDeferredToRenderer {
align-items: \(alignment.vertical.cssValue)
""",
]) {
TupleView(children, children: children.map { AnyView($0.modifier(_ZStack_ContentGridItem())) })
TupleView(
children,
children: children.map { AnyView($0.modifier(_ZStack_ContentGridItem())) }
)
})
}
}