Apply latest SwiftFormat

This commit is contained in:
Max Desiatov 2020-11-09 12:27:17 +00:00
parent bff7c1bf27
commit f24a09f006
No known key found for this signature in database
GPG Key ID: FE08EBF9CF58CBA2
67 changed files with 353 additions and 353 deletions

View File

@ -77,7 +77,7 @@ let package = Package(
name: "JavaScriptKit", name: "JavaScriptKit",
package: "JavaScriptKit", package: "JavaScriptKit",
condition: .when(platforms: [.wasi]) condition: .when(platforms: [.wasi])
) ),
] ]
), ),
.target( .target(
@ -92,7 +92,7 @@ let package = Package(
name: "JavaScriptKit", name: "JavaScriptKit",
package: "JavaScriptKit", package: "JavaScriptKit",
condition: .when(platforms: [.wasi]) condition: .when(platforms: [.wasi])
) ),
] ]
), ),
.target( .target(

View File

@ -42,8 +42,8 @@ public protocol App: _TitledApp {
init() init()
} }
extension App { public extension App {
public static func main() { static func main() {
let app = Self() let app = Self()
_launch(app, EnvironmentValues()) _launch(app, EnvironmentValues())
} }

View File

@ -53,8 +53,8 @@ import CombineShim
extension AppStorage: ObservedProperty {} extension AppStorage: ObservedProperty {}
extension AppStorage { public extension AppStorage {
public init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil) init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil)
where Value == Bool where Value == Bool
{ {
defaultValue = wrappedValue defaultValue = wrappedValue
@ -64,7 +64,7 @@ extension AppStorage {
read = { $0.read(key: $1) } read = { $0.read(key: $1) }
} }
public init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil) init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil)
where Value == Int where Value == Int
{ {
defaultValue = wrappedValue defaultValue = wrappedValue
@ -74,7 +74,7 @@ extension AppStorage {
read = { $0.read(key: $1) } read = { $0.read(key: $1) }
} }
public init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil) init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil)
where Value == Double where Value == Double
{ {
defaultValue = wrappedValue defaultValue = wrappedValue
@ -84,7 +84,7 @@ extension AppStorage {
read = { $0.read(key: $1) } read = { $0.read(key: $1) }
} }
public init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil) init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil)
where Value == String where Value == String
{ {
defaultValue = wrappedValue defaultValue = wrappedValue
@ -94,7 +94,7 @@ extension AppStorage {
read = { $0.read(key: $1) } read = { $0.read(key: $1) }
} }
public init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil) init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil)
where Value: RawRepresentable, Value.RawValue == Int where Value: RawRepresentable, Value.RawValue == Int
{ {
defaultValue = wrappedValue defaultValue = wrappedValue
@ -109,7 +109,7 @@ extension AppStorage {
} }
} }
public init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil) init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil)
where Value: RawRepresentable, Value.RawValue == String where Value: RawRepresentable, Value.RawValue == String
{ {
defaultValue = wrappedValue defaultValue = wrappedValue
@ -125,8 +125,8 @@ extension AppStorage {
} }
} }
extension AppStorage where Value: ExpressibleByNilLiteral { public extension AppStorage where Value: ExpressibleByNilLiteral {
public init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil) init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil)
where Value == Bool? where Value == Bool?
{ {
defaultValue = wrappedValue defaultValue = wrappedValue
@ -136,7 +136,7 @@ extension AppStorage where Value: ExpressibleByNilLiteral {
read = { $0.read(key: $1) } read = { $0.read(key: $1) }
} }
public init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil) init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil)
where Value == Int? where Value == Int?
{ {
defaultValue = wrappedValue defaultValue = wrappedValue
@ -146,7 +146,7 @@ extension AppStorage where Value: ExpressibleByNilLiteral {
read = { $0.read(key: $1) } read = { $0.read(key: $1) }
} }
public init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil) init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil)
where Value == Double? where Value == Double?
{ {
defaultValue = wrappedValue defaultValue = wrappedValue
@ -156,7 +156,7 @@ extension AppStorage where Value: ExpressibleByNilLiteral {
read = { $0.read(key: $1) } read = { $0.read(key: $1) }
} }
public init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil) init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil)
where Value == String? where Value == String?
{ {
defaultValue = wrappedValue defaultValue = wrappedValue
@ -172,8 +172,8 @@ struct DefaultAppStorageEnvironmentKey: EnvironmentKey {
static let defaultValue: _StorageProvider? = nil static let defaultValue: _StorageProvider? = nil
} }
extension EnvironmentValues { public extension EnvironmentValues {
public var _defaultAppStorage: _StorageProvider? { var _defaultAppStorage: _StorageProvider? {
get { get {
self[DefaultAppStorageEnvironmentKey.self] self[DefaultAppStorageEnvironmentKey.self]
} }
@ -183,8 +183,8 @@ extension EnvironmentValues {
} }
} }
extension View { public extension View {
public func defaultAppStorage(_ store: _StorageProvider) -> some View { func defaultAppStorage(_ store: _StorageProvider) -> some View {
environment(\._defaultAppStorage, store) environment(\._defaultAppStorage, store)
} }
} }

View File

@ -16,7 +16,7 @@
// //
@_functionBuilder @_functionBuilder
public struct SceneBuilder { public enum SceneBuilder {
public static func buildBlock<Content: Scene>(_ content: Content) -> some Scene { public static func buildBlock<Content: Scene>(_ content: Content) -> some Scene {
content content
} }
@ -25,24 +25,24 @@ public struct SceneBuilder {
// swiftlint:disable large_tuple // swiftlint:disable large_tuple
// swiftlint:disable function_parameter_count // swiftlint:disable function_parameter_count
extension SceneBuilder { public extension SceneBuilder {
public static func buildBlock<C0, C1>(_ c0: C0, _ c1: C1) -> some Scene where C0: Scene, static func buildBlock<C0, C1>(_ c0: C0, _ c1: C1) -> some Scene where C0: Scene,
C1: Scene C1: Scene
{ {
_TupleScene((c0, c1), children: [_AnyScene(c0), _AnyScene(c1)]) _TupleScene((c0, c1), children: [_AnyScene(c0), _AnyScene(c1)])
} }
} }
extension SceneBuilder { public extension SceneBuilder {
public static func buildBlock<C0, C1, C2>(_ c0: C0, _ c1: C1, _ c2: C2) -> some Scene static func buildBlock<C0, C1, C2>(_ c0: C0, _ c1: C1, _ c2: C2) -> some Scene
where C0: Scene, C1: Scene, C2: Scene where C0: Scene, C1: Scene, C2: Scene
{ {
_TupleScene((c0, c1, c2), children: [_AnyScene(c0), _AnyScene(c1), _AnyScene(c2)]) _TupleScene((c0, c1, c2), children: [_AnyScene(c0), _AnyScene(c1), _AnyScene(c2)])
} }
} }
extension SceneBuilder { public extension SceneBuilder {
public static func buildBlock<C0, C1, C2, C3>( static func buildBlock<C0, C1, C2, C3>(
_ c0: C0, _ c0: C0,
_ c1: C1, _ c1: C1,
_ c2: C2, _ c2: C2,
@ -55,8 +55,8 @@ extension SceneBuilder {
} }
} }
extension SceneBuilder { public extension SceneBuilder {
public static func buildBlock<C0, C1, C2, C3, C4>( static func buildBlock<C0, C1, C2, C3, C4>(
_ c0: C0, _ c0: C0,
_ c1: C1, _ c1: C1,
_ c2: C2, _ c2: C2,
@ -70,8 +70,8 @@ extension SceneBuilder {
} }
} }
extension SceneBuilder { public extension SceneBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5>( static func buildBlock<C0, C1, C2, C3, C4, C5>(
_ c0: C0, _ c0: C0,
_ c1: C1, _ c1: C1,
_ c2: C2, _ c2: C2,
@ -95,8 +95,8 @@ extension SceneBuilder {
} }
} }
extension SceneBuilder { public extension SceneBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6>( static func buildBlock<C0, C1, C2, C3, C4, C5, C6>(
_ c0: C0, _ c0: C0,
_ c1: C1, _ c1: C1,
_ c2: C2, _ c2: C2,
@ -122,8 +122,8 @@ extension SceneBuilder {
} }
} }
extension SceneBuilder { public extension SceneBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7>( static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7>(
_ c0: C0, _ c0: C0,
_ c1: C1, _ c1: C1,
_ c2: C2, _ c2: C2,
@ -151,8 +151,8 @@ extension SceneBuilder {
} }
} }
extension SceneBuilder { public extension SceneBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8>( static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8>(
_ c0: C0, _ c0: C0,
_ c1: C1, _ c1: C1,
_ c2: C2, _ c2: C2,
@ -182,8 +182,8 @@ extension SceneBuilder {
} }
} }
extension SceneBuilder { public extension SceneBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9>( static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9>(
_ c0: C0, _ c0: C0,
_ c1: C1, _ c1: C1,
_ c2: C2, _ c2: C2,

View File

@ -25,8 +25,8 @@ struct ScenePhaseKey: EnvironmentKey {
static let defaultValue: ScenePhase = .active static let defaultValue: ScenePhase = .active
} }
extension EnvironmentValues { public extension EnvironmentValues {
public var scenePhase: ScenePhase { var scenePhase: ScenePhase {
get { get {
self[ScenePhaseKey.self] self[ScenePhaseKey.self]
} }

View File

@ -53,36 +53,36 @@ public enum _DefaultSceneStorageProvider {
extension SceneStorage: ObservedProperty {} extension SceneStorage: ObservedProperty {}
extension SceneStorage { public extension SceneStorage {
public init(wrappedValue: Value, _ key: String) where Value == Bool { init(wrappedValue: Value, _ key: String) where Value == Bool {
defaultValue = wrappedValue defaultValue = wrappedValue
self.key = key self.key = key
store = { $0.store(key: $1, value: $2) } store = { $0.store(key: $1, value: $2) }
read = { $0.read(key: $1) } read = { $0.read(key: $1) }
} }
public init(wrappedValue: Value, _ key: String) where Value == Int { init(wrappedValue: Value, _ key: String) where Value == Int {
defaultValue = wrappedValue defaultValue = wrappedValue
self.key = key self.key = key
store = { $0.store(key: $1, value: $2) } store = { $0.store(key: $1, value: $2) }
read = { $0.read(key: $1) } read = { $0.read(key: $1) }
} }
public init(wrappedValue: Value, _ key: String) where Value == Double { init(wrappedValue: Value, _ key: String) where Value == Double {
defaultValue = wrappedValue defaultValue = wrappedValue
self.key = key self.key = key
store = { $0.store(key: $1, value: $2) } store = { $0.store(key: $1, value: $2) }
read = { $0.read(key: $1) } read = { $0.read(key: $1) }
} }
public init(wrappedValue: Value, _ key: String) where Value == String { init(wrappedValue: Value, _ key: String) where Value == String {
defaultValue = wrappedValue defaultValue = wrappedValue
self.key = key self.key = key
store = { $0.store(key: $1, value: $2) } store = { $0.store(key: $1, value: $2) }
read = { $0.read(key: $1) } read = { $0.read(key: $1) }
} }
public init(wrappedValue: Value, _ key: String) where Value: RawRepresentable, init(wrappedValue: Value, _ key: String) where Value: RawRepresentable,
Value.RawValue == Int Value.RawValue == Int
{ {
defaultValue = wrappedValue defaultValue = wrappedValue
@ -96,7 +96,7 @@ extension SceneStorage {
} }
} }
public init(wrappedValue: Value, _ key: String) init(wrappedValue: Value, _ key: String)
where Value: RawRepresentable, Value.RawValue == String where Value: RawRepresentable, Value.RawValue == String
{ {
defaultValue = wrappedValue defaultValue = wrappedValue

View File

@ -36,8 +36,8 @@ public extension Scene {
} }
} }
extension _SceneModifier where Body == Never { public extension _SceneModifier where Body == Never {
public func body(content: SceneContent) -> Body { func body(content: SceneContent) -> Body {
fatalError(""" fatalError("""
\(self) is a primitive `_SceneModifier`, you're not supposed to run `body(content:)` \(self) is a primitive `_SceneModifier`, you're not supposed to run `body(content:)`
""") """)

View File

@ -21,6 +21,6 @@ public protocol DynamicProperty {
mutating func update() mutating func update()
} }
extension DynamicProperty { public extension DynamicProperty {
public mutating func update() {} mutating func update() {}
} }

View File

@ -39,8 +39,8 @@ public struct _EnvironmentKeyWritingModifier<Value>: ViewModifier, EnvironmentMo
} }
} }
extension View { public extension View {
public func environment<V>( func environment<V>(
_ keyPath: WritableKeyPath<EnvironmentValues, V>, _ keyPath: WritableKeyPath<EnvironmentValues, V>,
_ value: V _ value: V
) -> some View { ) -> some View {

View File

@ -71,8 +71,8 @@ extension ObservableObject {
} }
} }
extension View { public extension View {
public func environmentObject<B>(_ bindable: B) -> some View where B: ObservableObject { func environmentObject<B>(_ bindable: B) -> some View where B: ObservableObject {
environment(B.environmentStore, bindable) environment(B.environmentStore, bindable)
} }
} }

View File

@ -49,8 +49,8 @@ struct IsEnabledKey: EnvironmentKey {
static let defaultValue = true static let defaultValue = true
} }
extension EnvironmentValues { public extension EnvironmentValues {
public var isEnabled: Bool { var isEnabled: Bool {
get { get {
self[IsEnabledKey.self] self[IsEnabledKey.self]
} }
@ -72,8 +72,8 @@ struct _EnvironmentValuesWritingModifier: ViewModifier, EnvironmentModifier {
} }
} }
extension View { public extension View {
public func environmentValues(_ values: EnvironmentValues) -> some View { func environmentValues(_ values: EnvironmentValues) -> some View {
modifier(_EnvironmentValuesWritingModifier(environmentValues: values)) modifier(_EnvironmentValuesWritingModifier(environmentValues: values))
} }
} }

View File

@ -32,12 +32,12 @@ extension ModifiedContent: AppearanceActionType
var disappear: (() -> ())? { modifier.disappear } var disappear: (() -> ())? { modifier.disappear }
} }
extension View { public extension View {
public func onAppear(perform action: (() -> ())? = nil) -> some View { func onAppear(perform action: (() -> ())? = nil) -> some View {
modifier(_AppearanceActionModifier(appear: action)) modifier(_AppearanceActionModifier(appear: action))
} }
public func onDisappear(perform action: (() -> ())? = nil) -> some View { func onDisappear(perform action: (() -> ())? = nil) -> some View {
modifier(_AppearanceActionModifier(disappear: action)) modifier(_AppearanceActionModifier(disappear: action))
} }
} }

View File

@ -29,19 +29,19 @@ public struct _ClipEffect<ClipShape>: ViewModifier where ClipShape: Shape {
} }
} }
extension View { public extension View {
public func clipShape<S>(_ shape: S, style: FillStyle = FillStyle()) -> some View where S: Shape { func clipShape<S>(_ shape: S, style: FillStyle = FillStyle()) -> some View where S: Shape {
modifier(_ClipEffect(shape: shape, style: style)) modifier(_ClipEffect(shape: shape, style: style))
} }
public func clipped(antialiased: Bool = false) -> some View { func clipped(antialiased: Bool = false) -> some View {
clipShape( clipShape(
Rectangle(), Rectangle(),
style: FillStyle(antialiased: antialiased) style: FillStyle(antialiased: antialiased)
) )
} }
public func cornerRadius(_ radius: CGFloat, antialiased: Bool = true) -> some View { func cornerRadius(_ radius: CGFloat, antialiased: Bool = true) -> some View {
clipShape( clipShape(
RoundedRectangle(cornerRadius: radius), RoundedRectangle(cornerRadius: radius),
style: FillStyle(antialiased: antialiased) style: FillStyle(antialiased: antialiased)

View File

@ -33,8 +33,8 @@ public struct _RotationEffect: GeometryEffect {
} }
} }
extension View { public extension View {
public func rotationEffect(_ angle: Angle, anchor: UnitPoint = .center) -> some View { func rotationEffect(_ angle: Angle, anchor: UnitPoint = .center) -> some View {
modifier(_RotationEffect(angle: angle, anchor: anchor)) modifier(_RotationEffect(angle: angle, anchor: anchor))
} }
} }

View File

@ -54,8 +54,8 @@ public struct _FlexFrameLayout: ViewModifier {
} }
} }
extension View { public extension View {
public func frame( func frame(
minWidth: CGFloat? = nil, minWidth: CGFloat? = nil,
idealWidth: CGFloat? = nil, idealWidth: CGFloat? = nil,
maxWidth: CGFloat? = nil, maxWidth: CGFloat? = nil,

View File

@ -28,8 +28,8 @@ public struct _FrameLayout: ViewModifier {
} }
} }
extension View { public extension View {
public func frame( func frame(
width: CGFloat? = nil, width: CGFloat? = nil,
height: CGFloat? = nil, height: CGFloat? = nil,
alignment: Alignment = .center alignment: Alignment = .center

View File

@ -13,12 +13,12 @@
// limitations under the License. // limitations under the License.
// FIXME: these should have standalone implementations // FIXME: these should have standalone implementations
extension View { public extension View {
public func _onMount(perform action: (() -> ())? = nil) -> some View { func _onMount(perform action: (() -> ())? = nil) -> some View {
modifier(_AppearanceActionModifier(appear: action)) modifier(_AppearanceActionModifier(appear: action))
} }
public func _onUnmount(perform action: (() -> ())? = nil) -> some View { func _onUnmount(perform action: (() -> ())? = nil) -> some View {
modifier(_AppearanceActionModifier(disappear: action)) modifier(_AppearanceActionModifier(disappear: action))
} }
} }

View File

@ -47,8 +47,8 @@ extension ModifiedContent: ViewModifier where Content: ViewModifier, Modifier: V
} }
} }
extension ViewModifier { public extension ViewModifier {
public func concat<T>(_ modifier: T) -> ModifiedContent<Self, T> where T: ViewModifier { func concat<T>(_ modifier: T) -> ModifiedContent<Self, T> where T: ViewModifier {
.init(content: self, modifier: modifier) .init(content: self, modifier: modifier)
} }
} }

View File

@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
extension View { public extension View {
// FIXME: Implement // FIXME: Implement
public func navigationBarTitle<S>(_ title: S) -> some View where S: StringProtocol { func navigationBarTitle<S>(_ title: S) -> some View where S: StringProtocol {
self self
} }
// FIXME: Implement // FIXME: Implement
public func navigationTitle<S>(_ title: S) -> some View where S: StringProtocol { func navigationTitle<S>(_ title: S) -> some View where S: StringProtocol {
self self
} }
} }

View File

@ -26,17 +26,17 @@ public struct _PaddingLayout: ViewModifier {
} }
} }
extension View { public extension View {
public func padding(_ insets: EdgeInsets) -> some View { func padding(_ insets: EdgeInsets) -> some View {
modifier(_PaddingLayout(insets: insets)) modifier(_PaddingLayout(insets: insets))
} }
public func padding(_ edges: Edge.Set = .all, _ length: CGFloat? = nil) -> some View { func padding(_ edges: Edge.Set = .all, _ length: CGFloat? = nil) -> some View {
let insets = length.map { EdgeInsets(_all: $0) } let insets = length.map { EdgeInsets(_all: $0) }
return modifier(_PaddingLayout(edges: edges, insets: insets)) return modifier(_PaddingLayout(edges: edges, insets: insets))
} }
public func padding(_ length: CGFloat) -> some View { func padding(_ length: CGFloat) -> some View {
padding(.all, length) padding(.all, length)
} }
} }

View File

@ -24,12 +24,12 @@ public struct RedactionReasons: OptionSet {
public static let placeholder: Self = .init(rawValue: 1 << 0) public static let placeholder: Self = .init(rawValue: 1 << 0)
} }
extension View { public extension View {
public func redacted(reason: RedactionReasons) -> some View { func redacted(reason: RedactionReasons) -> some View {
environment(\.redactionReasons, reason) environment(\.redactionReasons, reason)
} }
public func unredacted() -> some View { func unredacted() -> some View {
environment(\.redactionReasons, []) environment(\.redactionReasons, [])
} }
} }
@ -38,8 +38,8 @@ private struct RedactionReasonsKey: EnvironmentKey {
static let defaultValue: RedactionReasons = [] static let defaultValue: RedactionReasons = []
} }
extension EnvironmentValues { public extension EnvironmentValues {
public var redactionReasons: RedactionReasons { var redactionReasons: RedactionReasons {
get { get {
self[RedactionReasonsKey.self] self[RedactionReasonsKey.self]
} }

View File

@ -45,8 +45,8 @@ extension _BackgroundModifier: Equatable where Background: Equatable {
} }
} }
extension View { public extension View {
public func background<Background>( func background<Background>(
_ background: Background, _ background: Background,
alignment: Alignment = .center alignment: Alignment = .center
) -> some View where Background: View { ) -> some View where Background: View {
@ -84,14 +84,14 @@ extension _OverlayModifier: Equatable where Overlay: Equatable {
} }
} }
extension View { public extension View {
public func overlay<Overlay>(_ overlay: Overlay, alignment: Alignment = .center) -> some View func overlay<Overlay>(_ overlay: Overlay, alignment: Alignment = .center) -> some View
where Overlay: View where Overlay: View
{ {
modifier(_OverlayModifier(overlay: overlay, alignment: alignment)) modifier(_OverlayModifier(overlay: overlay, alignment: alignment))
} }
public func border<S>(_ content: S, width: CGFloat = 1) -> some View where S: ShapeStyle { func border<S>(_ content: S, width: CGFloat = 1) -> some View where S: ShapeStyle {
overlay(Rectangle().strokeBorder(content, lineWidth: width)) overlay(Rectangle().strokeBorder(content, lineWidth: width))
} }
} }

View File

@ -33,8 +33,8 @@ public extension View {
} }
} }
extension ViewModifier where Body == Never { public extension ViewModifier where Body == Never {
public func body(content: Content) -> Body { func body(content: Content) -> Body {
fatalError("\(self) is a primitive `ViewModifier`, you're not supposed to run `body(content:)`") fatalError("\(self) is a primitive `ViewModifier`, you're not supposed to run `body(content:)`")
} }
} }

View File

@ -144,7 +144,7 @@ extension TypeInfo {
// swiftlint:disable force_try // swiftlint:disable force_try
// Extract the view from the AnyView for modification, apply Environment changes: // Extract the view from the AnyView for modification, apply Environment changes:
if genericTypes.contains(where: { $0 is EnvironmentModifier.Type }), if genericTypes.contains(where: { $0 is EnvironmentModifier.Type }),
let modifier = try! property(named: "modifier").get(from: element) as? EnvironmentModifier let modifier = try! property(named: "modifier").get(from: element) as? EnvironmentModifier
{ {
modifier.modifyEnvironment(&modifiedEnv) modifier.modifyEnvironment(&modifiedEnv)
} }

View File

@ -91,7 +91,7 @@ extension _AnyScene {
) -> MountedScene<R> { ) -> MountedScene<R> {
var title: String? var title: String?
if let titledSelf = scene as? TitledScene, if let titledSelf = scene as? TitledScene,
let text = titledSelf.title let text = titledSelf.title
{ {
title = _TextProxy(text).rawText title = _TextProxy(text).rawText
} }

View File

@ -168,28 +168,28 @@ public enum RoundedCornerStyle: Hashable, Equatable {
case continuous case continuous
} }
extension Path { public extension Path {
public mutating func move(to p: CGPoint) { mutating func move(to p: CGPoint) {
elements.append(.move(to: p)) elements.append(.move(to: p))
} }
public mutating func addLine(to p: CGPoint) { mutating func addLine(to p: CGPoint) {
elements.append(.line(to: p)) elements.append(.line(to: p))
} }
public mutating func addQuadCurve(to p: CGPoint, control cp: CGPoint) { mutating func addQuadCurve(to p: CGPoint, control cp: CGPoint) {
elements.append(.quadCurve(to: p, control: cp)) elements.append(.quadCurve(to: p, control: cp))
} }
public mutating func addCurve(to p: CGPoint, control1 cp1: CGPoint, control2 cp2: CGPoint) { mutating func addCurve(to p: CGPoint, control1 cp1: CGPoint, control2 cp2: CGPoint) {
elements.append(.curve(to: p, control1: cp1, control2: cp2)) elements.append(.curve(to: p, control1: cp1, control2: cp2))
} }
public mutating func closeSubpath() { mutating func closeSubpath() {
elements.append(.closeSubpath) elements.append(.closeSubpath)
} }
public mutating func addRect(_ rect: CGRect, transform: CGAffineTransform = .identity) { mutating func addRect(_ rect: CGRect, transform: CGAffineTransform = .identity) {
move(to: rect.origin) move(to: rect.origin)
addLine(to: CGPoint(x: rect.size.width, y: 0).offset(by: rect.origin)) addLine(to: CGPoint(x: rect.size.width, y: 0).offset(by: rect.origin))
addLine(to: CGPoint(x: rect.size.width, y: rect.size.height).offset(by: rect.origin)) addLine(to: CGPoint(x: rect.size.width, y: rect.size.height).offset(by: rect.origin))
@ -197,7 +197,7 @@ extension Path {
closeSubpath() closeSubpath()
} }
public mutating func addRoundedRect( mutating func addRoundedRect(
in rect: CGRect, in rect: CGRect,
cornerSize: CGSize, cornerSize: CGSize,
style: RoundedCornerStyle = .circular, style: RoundedCornerStyle = .circular,
@ -238,7 +238,7 @@ extension Path {
closeSubpath() closeSubpath()
} }
public mutating func addEllipse(in rect: CGRect, transform: CGAffineTransform = .identity) { mutating func addEllipse(in rect: CGRect, transform: CGAffineTransform = .identity) {
subpaths.append(.init( subpaths.append(.init(
path: .init(ellipseIn: .init( path: .init(ellipseIn: .init(
origin: rect.origin.offset(by: .init(x: rect.size.width / 2, y: rect.size.height / 2)), origin: rect.origin.offset(by: .init(x: rect.size.width / 2, y: rect.size.height / 2)),
@ -248,15 +248,15 @@ extension Path {
)) ))
} }
public mutating func addRects(_ rects: [CGRect], transform: CGAffineTransform = .identity) { mutating func addRects(_ rects: [CGRect], transform: CGAffineTransform = .identity) {
rects.forEach { addRect($0) } rects.forEach { addRect($0) }
} }
public mutating func addLines(_ lines: [CGPoint]) { mutating func addLines(_ lines: [CGPoint]) {
lines.forEach { addLine(to: $0) } lines.forEach { addLine(to: $0) }
} }
public mutating func addRelativeArc( mutating func addRelativeArc(
center: CGPoint, center: CGPoint,
radius: CGFloat, radius: CGFloat,
startAngle: Angle, startAngle: Angle,
@ -275,7 +275,7 @@ extension Path {
// There's a great article on bezier curves here: // There's a great article on bezier curves here:
// https://pomax.github.io/bezierinfo // https://pomax.github.io/bezierinfo
// FIXME: Handle negative delta // FIXME: Handle negative delta
public mutating func addArc( mutating func addArc(
center: CGPoint, center: CGPoint,
radius: CGFloat, radius: CGFloat,
startAngle: Angle, startAngle: Angle,
@ -337,18 +337,18 @@ extension Path {
} }
// FIXME: How does this arc method work? // FIXME: How does this arc method work?
public mutating func addArc( mutating func addArc(
tangent1End p1: CGPoint, tangent1End p1: CGPoint,
tangent2End p2: CGPoint, tangent2End p2: CGPoint,
radius: CGFloat, radius: CGFloat,
transform: CGAffineTransform = .identity transform: CGAffineTransform = .identity
) {} ) {}
public mutating func addPath(_ path: Path, transform: CGAffineTransform = .identity) { mutating func addPath(_ path: Path, transform: CGAffineTransform = .identity) {
subpaths.append(.init(path: path, transform: transform)) subpaths.append(.init(path: path, transform: transform))
} }
public var currentPoint: CGPoint? { var currentPoint: CGPoint? {
switch elements.last { switch elements.last {
case let .move(to: point): return point case let .move(to: point): return point
case let .line(to: point): return point case let .line(to: point): return point
@ -358,13 +358,13 @@ extension Path {
} }
} }
public func applying(_ transform: CGAffineTransform) -> Path { func applying(_ transform: CGAffineTransform) -> Path {
var path = self var path = self
path.transform = transform path.transform = transform
return path return path
} }
public func offsetBy(dx: CGFloat, dy: CGFloat) -> Path { func offsetBy(dx: CGFloat, dy: CGFloat) -> Path {
applying(transform.translatedBy(x: dx, y: dy)) applying(transform.translatedBy(x: dx, y: dy))
} }
} }

View File

@ -15,8 +15,8 @@
// Created by Carson Katri on 7/21/20. // Created by Carson Katri on 7/21/20.
// //
extension Path { public extension Path {
public enum _Sizing { enum _Sizing {
case fixed case fixed
case flexible case flexible
} }

View File

@ -21,8 +21,8 @@ public protocol Shape: View {
public protocol ShapeStyle {} public protocol ShapeStyle {}
extension ShapeStyle where Self: View, Self.Body == _ShapeView<Rectangle, Self> { public extension ShapeStyle where Self: View, Self.Body == _ShapeView<Rectangle, Self> {
public var body: some View { var body: some View {
_ShapeView(shape: Rectangle(), style: self) _ShapeView(shape: Rectangle(), style: self)
} }
} }
@ -64,26 +64,26 @@ public struct _ShapeView<Content, Style>: View where Content: Shape, Style: Shap
} }
} }
extension Shape { public extension Shape {
public func trim(from startFraction: CGFloat = 0, to endFraction: CGFloat = 1) -> some Shape { func trim(from startFraction: CGFloat = 0, to endFraction: CGFloat = 1) -> some Shape {
_TrimmedShape(shape: self, startFraction: startFraction, endFraction: endFraction) _TrimmedShape(shape: self, startFraction: startFraction, endFraction: endFraction)
} }
} }
extension Shape { public extension Shape {
public func offset(_ offset: CGSize) -> OffsetShape<Self> { func offset(_ offset: CGSize) -> OffsetShape<Self> {
OffsetShape(shape: self, offset: offset) OffsetShape(shape: self, offset: offset)
} }
public func offset(_ offset: CGPoint) -> OffsetShape<Self> { func offset(_ offset: CGPoint) -> OffsetShape<Self> {
OffsetShape(shape: self, offset: CGSize(width: offset.x, height: offset.y)) OffsetShape(shape: self, offset: CGSize(width: offset.x, height: offset.y))
} }
public func offset(x: CGFloat = 0, y: CGFloat = 0) -> OffsetShape<Self> { func offset(x: CGFloat = 0, y: CGFloat = 0) -> OffsetShape<Self> {
OffsetShape(shape: self, offset: .init(width: x, height: y)) OffsetShape(shape: self, offset: .init(width: x, height: y))
} }
public func scale( func scale(
x: CGFloat = 1, x: CGFloat = 1,
y: CGFloat = 1, y: CGFloat = 1,
anchor: UnitPoint = .center anchor: UnitPoint = .center
@ -95,62 +95,62 @@ extension Shape {
) )
} }
public func scale(_ scale: CGFloat, anchor: UnitPoint = .center) -> ScaledShape<Self> { func scale(_ scale: CGFloat, anchor: UnitPoint = .center) -> ScaledShape<Self> {
self.scale(x: scale, y: scale, anchor: anchor) self.scale(x: scale, y: scale, anchor: anchor)
} }
public func rotation(_ angle: Angle, anchor: UnitPoint = .center) -> RotatedShape<Self> { func rotation(_ angle: Angle, anchor: UnitPoint = .center) -> RotatedShape<Self> {
RotatedShape(shape: self, angle: angle, anchor: anchor) RotatedShape(shape: self, angle: angle, anchor: anchor)
} }
public func transform(_ transform: CGAffineTransform) -> TransformedShape<Self> { func transform(_ transform: CGAffineTransform) -> TransformedShape<Self> {
TransformedShape(shape: self, transform: transform) TransformedShape(shape: self, transform: transform)
} }
} }
extension Shape { public extension Shape {
public func size(_ size: CGSize) -> some Shape { func size(_ size: CGSize) -> some Shape {
_SizedShape(shape: self, size: size) _SizedShape(shape: self, size: size)
} }
public func size(width: CGFloat, height: CGFloat) -> some Shape { func size(width: CGFloat, height: CGFloat) -> some Shape {
size(.init(width: width, height: height)) size(.init(width: width, height: height))
} }
} }
extension Shape { public extension Shape {
public func stroke(style: StrokeStyle) -> some Shape { func stroke(style: StrokeStyle) -> some Shape {
_StrokedShape(shape: self, style: style) _StrokedShape(shape: self, style: style)
} }
public func stroke(lineWidth: CGFloat = 1) -> some Shape { func stroke(lineWidth: CGFloat = 1) -> some Shape {
stroke(style: StrokeStyle(lineWidth: lineWidth)) stroke(style: StrokeStyle(lineWidth: lineWidth))
} }
} }
extension Shape { public extension Shape {
public func fill<S>( func fill<S>(
_ content: S, _ content: S,
style: FillStyle = FillStyle() style: FillStyle = FillStyle()
) -> some View where S: ShapeStyle { ) -> some View where S: ShapeStyle {
_ShapeView(shape: self, style: content, fillStyle: style) _ShapeView(shape: self, style: content, fillStyle: style)
} }
public func fill(style: FillStyle = FillStyle()) -> some View { func fill(style: FillStyle = FillStyle()) -> some View {
_ShapeView(shape: self, style: ForegroundStyle(), fillStyle: style) _ShapeView(shape: self, style: ForegroundStyle(), fillStyle: style)
} }
public func stroke<S>(_ content: S, style: StrokeStyle) -> some View where S: ShapeStyle { func stroke<S>(_ content: S, style: StrokeStyle) -> some View where S: ShapeStyle {
stroke(style: style).fill(content) stroke(style: style).fill(content)
} }
public func stroke<S>(_ content: S, lineWidth: CGFloat = 1) -> some View where S: ShapeStyle { func stroke<S>(_ content: S, lineWidth: CGFloat = 1) -> some View where S: ShapeStyle {
stroke(content, style: StrokeStyle(lineWidth: lineWidth)) stroke(content, style: StrokeStyle(lineWidth: lineWidth))
} }
} }
extension Shape { public extension Shape {
public var body: some View { var body: some View {
_ShapeView(shape: self, style: ForegroundStyle()) _ShapeView(shape: self, style: ForegroundStyle())
} }
} }

View File

@ -15,8 +15,8 @@
// Created by Carson Katri on 6/29/20. // Created by Carson Katri on 6/29/20.
// //
extension InsettableShape { public extension InsettableShape {
public func strokeBorder<S>( func strokeBorder<S>(
_ content: S, _ content: S,
style: StrokeStyle, style: StrokeStyle,
antialiased: Bool = true antialiased: Bool = true
@ -27,14 +27,14 @@ extension InsettableShape {
} }
@inlinable @inlinable
public func strokeBorder(style: StrokeStyle, antialiased: Bool = true) -> some View { func strokeBorder(style: StrokeStyle, antialiased: Bool = true) -> some View {
inset(by: style.lineWidth / 2) inset(by: style.lineWidth / 2)
.stroke(style: style) .stroke(style: style)
.fill(style: FillStyle(antialiased: antialiased)) .fill(style: FillStyle(antialiased: antialiased))
} }
@inlinable @inlinable
public func strokeBorder<S>( func strokeBorder<S>(
_ content: S, _ content: S,
lineWidth: CGFloat = 1, lineWidth: CGFloat = 1,
antialiased: Bool = true antialiased: Bool = true
@ -47,7 +47,7 @@ extension InsettableShape {
} }
@inlinable @inlinable
public func strokeBorder(lineWidth: CGFloat = 1, antialiased: Bool = true) -> some View { func strokeBorder(lineWidth: CGFloat = 1, antialiased: Bool = true) -> some View {
strokeBorder( strokeBorder(
style: StrokeStyle(lineWidth: lineWidth), style: StrokeStyle(lineWidth: lineWidth),
antialiased: antialiased antialiased: antialiased

View File

@ -51,7 +51,7 @@ protocol WritableValueStorage: ValueStorage {
extension State: WritableValueStorage {} extension State: WritableValueStorage {}
extension State where Value: ExpressibleByNilLiteral { public extension State where Value: ExpressibleByNilLiteral {
@inlinable @inlinable
public init() { self.init(wrappedValue: nil) } init() { self.init(wrappedValue: nil) }
} }

View File

@ -30,10 +30,10 @@ public struct _TargetRef<V: View, T>: View, TargetRefType {
public var body: V { view } public var body: V { view }
} }
extension View { public extension View {
/** Allows capturing target instance of aclosest descendant host view. The resulting instance /** Allows capturing target instance of aclosest descendant host view. The resulting instance
is written to a given `binding`. */ is written to a given `binding`. */
public func _targetRef<T: Target>(_ binding: Binding<T?>) -> _TargetRef<Self, T> { func _targetRef<T: Target>(_ binding: Binding<T?>) -> _TargetRef<Self, T> {
.init(binding: binding, view: self) .init(binding: binding, view: self)
} }
} }

View File

@ -97,8 +97,8 @@ extension EnvironmentValues {
} }
} }
extension View { public extension View {
public func buttonStyle<S>(_ style: S) -> some View where S: ButtonStyle { func buttonStyle<S>(_ style: S) -> some View where S: ButtonStyle {
environment(\.buttonStyle, _AnyButtonStyle(style)) environment(\.buttonStyle, _AnyButtonStyle(style))
} }
} }

View File

@ -92,8 +92,8 @@ extension EnvironmentValues {
} }
} }
extension View { public extension View {
public func listStyle<S>(_ style: S) -> some View where S: ListStyle { func listStyle<S>(_ style: S) -> some View where S: ListStyle {
environment(\.listStyle, style) environment(\.listStyle, style)
} }
} }

View File

@ -67,8 +67,8 @@ extension EnvironmentValues {
} }
} }
extension View { public extension View {
public func _navigationLinkStyle<S: _NavigationLinkStyle>(_ style: S) -> some View { func _navigationLinkStyle<S: _NavigationLinkStyle>(_ style: S) -> some View {
environment(\._navigationLinkStyle, _AnyNavigationLinkStyle(style)) environment(\._navigationLinkStyle, _AnyNavigationLinkStyle(style))
} }
} }

View File

@ -39,8 +39,8 @@ extension EnvironmentValues {
} }
} }
extension View { public extension View {
public func pickerStyle(_ style: PickerStyle) -> some View { func pickerStyle(_ style: PickerStyle) -> some View {
environment(\.pickerStyle, style) environment(\.pickerStyle, style)
} }
} }

View File

@ -48,8 +48,8 @@ extension EnvironmentValues {
} }
} }
extension View { public extension View {
public func textFieldStyle(_ style: TextFieldStyle) -> some View { func textFieldStyle(_ style: TextFieldStyle) -> some View {
environment(\.textFieldStyle, style) environment(\.textFieldStyle, style)
} }
} }

View File

@ -69,8 +69,8 @@ extension EnvironmentValues {
} }
} }
extension View { public extension View {
public func toggleStyle<S>(_ style: S) -> some View where S: ToggleStyle { func toggleStyle<S>(_ style: S) -> some View where S: ToggleStyle {
environment(\.toggleStyle, _AnyToggleStyle(style)) environment(\.toggleStyle, _AnyToggleStyle(style))
} }
} }

View File

@ -244,38 +244,38 @@ public struct _ColorProxy {
} }
} }
extension Color { public extension Color {
public enum RGBColorSpace { enum RGBColorSpace {
case sRGB case sRGB
case sRGBLinear case sRGBLinear
case displayP3 case displayP3
} }
} }
extension Color { public extension Color {
private init(systemColor: _SystemColorBox.SystemColor) { private init(systemColor: _SystemColorBox.SystemColor) {
self.init(_SystemColorBox(systemColor)) self.init(_SystemColorBox(systemColor))
} }
public static let clear: Self = .init(systemColor: .clear) static let clear: Self = .init(systemColor: .clear)
public static let black: Self = .init(systemColor: .black) static let black: Self = .init(systemColor: .black)
public static let white: Self = .init(systemColor: .white) static let white: Self = .init(systemColor: .white)
public static let gray: Self = .init(systemColor: .gray) static let gray: Self = .init(systemColor: .gray)
public static let red: Self = .init(systemColor: .red) static let red: Self = .init(systemColor: .red)
public static let green: Self = .init(systemColor: .green) static let green: Self = .init(systemColor: .green)
public static let blue: Self = .init(systemColor: .blue) static let blue: Self = .init(systemColor: .blue)
public static let orange: Self = .init(systemColor: .orange) static let orange: Self = .init(systemColor: .orange)
public static let yellow: Self = .init(systemColor: .yellow) static let yellow: Self = .init(systemColor: .yellow)
public static let pink: Self = .init(systemColor: .pink) static let pink: Self = .init(systemColor: .pink)
public static let purple: Self = .init(systemColor: .purple) static let purple: Self = .init(systemColor: .purple)
public static let primary: Self = .init(systemColor: .primary) static let primary: Self = .init(systemColor: .primary)
public static let secondary: Self = .init(systemColor: .secondary) static let secondary: Self = .init(systemColor: .secondary)
public static let accentColor: Self = .init(_EnvironmentDependentColorBox { static let accentColor: Self = .init(_EnvironmentDependentColorBox {
($0.accentColor ?? Self.blue) ($0.accentColor ?? Self.blue)
}) })
public init(_ color: UIColor) { init(_ color: UIColor) {
self = color.color self = color.color
} }
} }
@ -293,8 +293,8 @@ extension Color: ExpressibleByIntegerLiteral {
} }
} }
extension Color { public extension Color {
public init?(hex: String) { init?(hex: String) {
let cArray = Array(hex.count > 6 ? String(hex.dropFirst()) : hex) let cArray = Array(hex.count > 6 ? String(hex.dropFirst()) : hex)
guard cArray.count == 6 else { return nil } guard cArray.count == 6 else { return nil }
@ -338,8 +338,8 @@ public extension EnvironmentValues {
} }
} }
extension View { public extension View {
public func accentColor(_ accentColor: Color?) -> some View { func accentColor(_ accentColor: Color?) -> some View {
environment(\.accentColor, accentColor) environment(\.accentColor, accentColor)
} }
} }
@ -359,8 +359,8 @@ public extension EnvironmentValues {
} }
} }
extension View { public extension View {
public func foregroundColor(_ color: Color?) -> some View { func foregroundColor(_ color: Color?) -> some View {
environment(\.foregroundColor, color) environment(\.foregroundColor, color)
} }
} }

View File

@ -219,8 +219,8 @@ public struct Font: Hashable {
} }
} }
extension Font { public extension Font {
public struct Weight: Hashable { struct Weight: Hashable {
public let value: Int public let value: Int
public static let ultraLight: Self = .init(value: 100) public static let ultraLight: Self = .init(value: 100)
@ -235,8 +235,8 @@ extension Font {
} }
} }
extension Font { public extension Font {
public enum Leading { enum Leading {
case standard case standard
case tight case tight
case loose case loose
@ -247,9 +247,9 @@ public enum _FontNames: String, CaseIterable {
case system case system
} }
extension Font { public extension Font {
public static func system(size: CGFloat, weight: Weight = .regular, static func system(size: CGFloat, weight: Weight = .regular,
design: Design = .default) -> Self design: Design = .default) -> Self
{ {
.init( .init(
_ConcreteFontBox( _ConcreteFontBox(
@ -268,7 +268,7 @@ extension Font {
) )
} }
public enum Design: Hashable { enum Design: Hashable {
case `default` case `default`
case serif case serif
case rounded case rounded
@ -276,26 +276,26 @@ extension Font {
} }
} }
extension Font { public extension Font {
public static let largeTitle: Self = .init(_SystemFontBox(.largeTitle)) static let largeTitle: Self = .init(_SystemFontBox(.largeTitle))
public static let title: Self = .init(_SystemFontBox(.title)) static let title: Self = .init(_SystemFontBox(.title))
public static let title2: Self = .init(_SystemFontBox(.title2)) static let title2: Self = .init(_SystemFontBox(.title2))
public static let title3: Self = .init(_SystemFontBox(.title3)) static let title3: Self = .init(_SystemFontBox(.title3))
public static let headline: Font = .init(_SystemFontBox(.headline)) static let headline: Font = .init(_SystemFontBox(.headline))
public static let subheadline: Self = .init(_SystemFontBox(.subheadline)) static let subheadline: Self = .init(_SystemFontBox(.subheadline))
public static let body: Self = .init(_SystemFontBox(.body)) static let body: Self = .init(_SystemFontBox(.body))
public static let callout: Self = .init(_SystemFontBox(.callout)) static let callout: Self = .init(_SystemFontBox(.callout))
public static let footnote: Self = .init(_SystemFontBox(.footnote)) static let footnote: Self = .init(_SystemFontBox(.footnote))
public static let caption: Self = .init(_SystemFontBox(.caption)) static let caption: Self = .init(_SystemFontBox(.caption))
public static let caption2: Self = .init(_SystemFontBox(.caption2)) static let caption2: Self = .init(_SystemFontBox(.caption2))
public static func system(_ style: TextStyle, design: Design = .default) -> Self { static func system(_ style: TextStyle, design: Design = .default) -> Self {
.init(_ModifiedFontBox(previously: style.font.provider) { .init(_ModifiedFontBox(previously: style.font.provider) {
$0._design = design $0._design = design
}) })
} }
public enum TextStyle: Hashable, CaseIterable { enum TextStyle: Hashable, CaseIterable {
case largeTitle case largeTitle
case title case title
case title2 case title2

View File

@ -63,8 +63,8 @@ public struct _Button<Label>: View where Label: View {
} }
} }
extension Button where Label == Text { public extension Button where Label == Text {
public init<S>(_ title: S, action: @escaping () -> ()) where S: StringProtocol { init<S>(_ title: S, action: @escaping () -> ()) where S: StringProtocol {
self.init(action: action) { self.init(action: action) {
Text(title) Text(title)
} }

View File

@ -30,8 +30,8 @@ public struct Link<Label>: View where Label: View {
} }
} }
extension Link where Label == Text { public extension Link where Label == Text {
public init<S: StringProtocol>(_ titleKey: S, destination: URL) { init<S: StringProtocol>(_ titleKey: S, destination: URL) {
self.init(destination: destination) { Text(titleKey) } self.init(destination: destination) { Text(titleKey) }
} }
} }

View File

@ -45,7 +45,7 @@ public struct DisclosureGroup<Label, Content>: View where Label: View, Content:
} }
} }
extension DisclosureGroup where Label == Text { public extension DisclosureGroup where Label == Text {
// FIXME: Implement LocalizedStringKey // FIXME: Implement LocalizedStringKey
// public init(_ titleKey: LocalizedStringKey, // public init(_ titleKey: LocalizedStringKey,
// @ViewBuilder content: @escaping () -> Content) // @ViewBuilder content: @escaping () -> Content)
@ -54,14 +54,14 @@ extension DisclosureGroup where Label == Text {
// @SwiftUI.ViewBuilder content: @escaping () -> Content) // @SwiftUI.ViewBuilder content: @escaping () -> Content)
@_disfavoredOverload @_disfavoredOverload
public init<S>(_ label: S, @ViewBuilder content: @escaping () -> Content) init<S>(_ label: S, @ViewBuilder content: @escaping () -> Content)
where S: StringProtocol where S: StringProtocol
{ {
self.init(content: content, label: { Text(label) }) self.init(content: content, label: { Text(label) })
} }
@_disfavoredOverload @_disfavoredOverload
public init<S>( init<S>(
_ label: S, _ label: S,
isExpanded: Binding<Bool>, isExpanded: Binding<Bool>,
@ViewBuilder content: @escaping () -> Content @ViewBuilder content: @escaping () -> Content

View File

@ -90,8 +90,8 @@ struct _IDKey: EnvironmentKey {
static let defaultValue: AnyHashable? = nil static let defaultValue: AnyHashable? = nil
} }
extension EnvironmentValues { public extension EnvironmentValues {
public var _id: AnyHashable? { var _id: AnyHashable? {
get { get {
self[_IDKey.self] self[_IDKey.self]
} }
@ -121,8 +121,8 @@ struct IDView<Content, ID>: View, _AnyIDView where Content: View, ID: Hashable {
} }
} }
extension View { public extension View {
public func id<ID>(_ id: ID) -> some View where ID: Hashable { func id<ID>(_ id: ID) -> some View where ID: Hashable {
IDView(self, id: id) IDView(self, id: id)
} }
} }

View File

@ -96,7 +96,7 @@ public struct List<SelectionValue, Content>: View
} }
} }
public struct _ListRow { public enum _ListRow {
static func buildItems<RowView>( static func buildItems<RowView>(
_ children: [AnyView], _ children: [AnyView],
@ViewBuilder rowView: @escaping (AnyView, Bool) -> RowView @ViewBuilder rowView: @escaping (AnyView, Bool) -> RowView
@ -133,9 +133,9 @@ public struct _ListProxy<SelectionValue, Content>
public var selection: List<SelectionValue, Content>._Selection { subject.selection } public var selection: List<SelectionValue, Content>._Selection { subject.selection }
} }
extension List { public extension List {
// - MARK: Collection initializers // - MARK: Collection initializers
public init<Data, RowContent>( init<Data, RowContent>(
_ data: Data, _ data: Data,
selection: Binding<Set<SelectionValue>>?, selection: Binding<Set<SelectionValue>>?,
@ViewBuilder rowContent: @escaping (Data.Element) -> RowContent @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent
@ -147,11 +147,11 @@ extension List {
self.init(selection: selection) { ForEach(data) { row in HStack { rowContent(row) } } } self.init(selection: selection) { ForEach(data) { row in HStack { rowContent(row) } } }
} }
public init<Data, ID, RowContent>(_ data: Data, init<Data, ID, RowContent>(_ data: Data,
id: KeyPath<Data.Element, ID>, id: KeyPath<Data.Element, ID>,
selection: Binding<Set<SelectionValue>>?, selection: Binding<Set<SelectionValue>>?,
@ViewBuilder rowContent: @escaping (Data.Element) -> RowContent) @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent)
where Content == ForEach<Data, ID, HStack<RowContent>>, where Content == ForEach<Data, ID, HStack<RowContent>>,
Data: RandomAccessCollection, Data: RandomAccessCollection,
ID: Hashable, RowContent: View ID: Hashable, RowContent: View
@ -159,7 +159,7 @@ extension List {
self.init(selection: selection) { ForEach(data, id: id) { row in HStack { rowContent(row) } } } self.init(selection: selection) { ForEach(data, id: id) { row in HStack { rowContent(row) } } }
} }
public init<Data, ID, RowContent>( init<Data, ID, RowContent>(
_ data: Data, _ data: Data,
id: KeyPath<Data.Element, ID>, id: KeyPath<Data.Element, ID>,
selection: Binding<SelectionValue?>?, selection: Binding<SelectionValue?>?,
@ -175,9 +175,9 @@ extension List {
} }
} }
public init<Data, RowContent>(_ data: Data, init<Data, RowContent>(_ data: Data,
selection: Binding<SelectionValue?>?, selection: Binding<SelectionValue?>?,
@ViewBuilder rowContent: @escaping (Data.Element) -> RowContent) @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent)
where Content == ForEach<Data, Data.Element.ID, HStack<RowContent>>, where Content == ForEach<Data, Data.Element.ID, HStack<RowContent>>,
Data: RandomAccessCollection, RowContent: View, Data.Element: Identifiable Data: RandomAccessCollection, RowContent: View, Data.Element: Identifiable
{ {
@ -191,7 +191,7 @@ extension List {
} }
// - MARK: Range initializers // - MARK: Range initializers
public init<RowContent>( init<RowContent>(
_ data: Range<Int>, _ data: Range<Int>,
selection: Binding<Set<SelectionValue>>?, selection: Binding<Set<SelectionValue>>?,
@ViewBuilder rowContent: @escaping (Int) -> RowContent @ViewBuilder rowContent: @escaping (Int) -> RowContent
@ -205,7 +205,7 @@ extension List {
} }
} }
public init<RowContent>( init<RowContent>(
_ data: Range<Int>, _ data: Range<Int>,
selection: Binding<SelectionValue?>?, selection: Binding<SelectionValue?>?,
@ViewBuilder rowContent: @escaping (Int) -> RowContent @ViewBuilder rowContent: @escaping (Int) -> RowContent
@ -221,7 +221,7 @@ extension List {
// - MARK: OutlineGroup initializers // - MARK: OutlineGroup initializers
public init<Data, RowContent>( init<Data, RowContent>(
_ data: Data, _ data: Data,
children: KeyPath<Data.Element, Data?>, children: KeyPath<Data.Element, Data?>,
selection: Binding<Set<SelectionValue>>?, selection: Binding<Set<SelectionValue>>?,
@ -242,7 +242,7 @@ extension List {
} }
} }
public init<Data, ID, RowContent>( init<Data, ID, RowContent>(
_ data: Data, _ data: Data,
id: KeyPath<Data.Element, ID>, id: KeyPath<Data.Element, ID>,
children: KeyPath<Data.Element, Data?>, children: KeyPath<Data.Element, Data?>,
@ -264,7 +264,7 @@ extension List {
} }
} }
public init<Data, RowContent>( init<Data, RowContent>(
_ data: Data, _ data: Data,
children: KeyPath<Data.Element, Data?>, children: KeyPath<Data.Element, Data?>,
selection: Binding<SelectionValue?>?, selection: Binding<SelectionValue?>?,
@ -285,7 +285,7 @@ extension List {
} }
} }
public init<Data, ID, RowContent>( init<Data, ID, RowContent>(
_ data: Data, _ data: Data,
id: KeyPath<Data.Element, ID>, id: KeyPath<Data.Element, ID>,
children: KeyPath<Data.Element, Data?>, children: KeyPath<Data.Element, Data?>,
@ -308,13 +308,13 @@ extension List {
} }
} }
extension List where SelectionValue == Never { public extension List where SelectionValue == Never {
public init(@ViewBuilder content: () -> Content) { init(@ViewBuilder content: () -> Content) {
selection = .one(nil) selection = .one(nil)
self.content = content() self.content = content()
} }
public init<Data, RowContent>( init<Data, RowContent>(
_ data: Data, _ data: Data,
@ViewBuilder rowContent: @escaping (Data.Element) -> RowContent @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent
) )
@ -327,7 +327,7 @@ extension List where SelectionValue == Never {
} }
} }
public init<Data, RowContent>( init<Data, RowContent>(
_ data: Data, _ data: Data,
children: KeyPath<Data.Element, Data?>, children: KeyPath<Data.Element, Data?>,
@ViewBuilder rowContent: @escaping (Data.Element) -> RowContent @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent
@ -347,7 +347,7 @@ extension List where SelectionValue == Never {
} }
} }
public init<Data, ID, RowContent>( init<Data, ID, RowContent>(
_ data: Data, _ data: Data,
id: KeyPath<Data.Element, ID>, id: KeyPath<Data.Element, ID>,
children: KeyPath<Data.Element, Data?>, children: KeyPath<Data.Element, Data?>,
@ -368,7 +368,7 @@ extension List where SelectionValue == Never {
} }
} }
public init<Data, ID, RowContent>( init<Data, ID, RowContent>(
_ data: Data, _ data: Data,
id: KeyPath<Data.Element, ID>, id: KeyPath<Data.Element, ID>,
@ViewBuilder rowContent: @escaping (Data.Element) -> RowContent @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent
@ -382,7 +382,7 @@ extension List where SelectionValue == Never {
} }
} }
public init<RowContent>( init<RowContent>(
_ data: Range<Int>, _ data: Range<Int>,
@ViewBuilder rowContent: @escaping (Int) -> RowContent @ViewBuilder rowContent: @escaping (Int) -> RowContent
) )

View File

@ -29,13 +29,13 @@ public struct OutlineGroup<Data, ID, Parent, Leaf, Subgroup>
let content: (Data.Element) -> Leaf let content: (Data.Element) -> Leaf
} }
extension OutlineGroup where ID == Data.Element.ID, public extension OutlineGroup where ID == Data.Element.ID,
Parent: View, Parent: View,
Parent == Leaf, Parent == Leaf,
Subgroup == DisclosureGroup<Parent, OutlineSubgroupChildren>, Subgroup == DisclosureGroup<Parent, OutlineSubgroupChildren>,
Data.Element: Identifiable Data.Element: Identifiable
{ {
public init<DataElement>( init<DataElement>(
_ root: DataElement, _ root: DataElement,
children: KeyPath<DataElement, Data?>, children: KeyPath<DataElement, Data?>,
@ViewBuilder content: @escaping (DataElement) -> Leaf @ViewBuilder content: @escaping (DataElement) -> Leaf
@ -43,7 +43,7 @@ extension OutlineGroup where ID == Data.Element.ID,
self.init(root, id: \.id, children: children, content: content) self.init(root, id: \.id, children: children, content: content)
} }
public init<DataElement>( init<DataElement>(
_ data: Data, _ data: Data,
children: KeyPath<DataElement, Data?>, children: KeyPath<DataElement, Data?>,
@ViewBuilder content: @escaping (DataElement) -> Leaf @ViewBuilder content: @escaping (DataElement) -> Leaf
@ -52,11 +52,11 @@ extension OutlineGroup where ID == Data.Element.ID,
} }
} }
extension OutlineGroup where Parent: View, public extension OutlineGroup where Parent: View,
Parent == Leaf, Parent == Leaf,
Subgroup == DisclosureGroup<Parent, OutlineSubgroupChildren> Subgroup == DisclosureGroup<Parent, OutlineSubgroupChildren>
{ {
public init<DataElement>( init<DataElement>(
_ root: DataElement, _ root: DataElement,
id: KeyPath<DataElement, ID>, id: KeyPath<DataElement, ID>,
children: KeyPath<DataElement, Data?>, children: KeyPath<DataElement, Data?>,
@ -70,7 +70,7 @@ extension OutlineGroup where Parent: View,
self.content = content self.content = content
} }
public init<DataElement>( init<DataElement>(
_ data: Data, _ data: Data,
id: KeyPath<DataElement, ID>, id: KeyPath<DataElement, ID>,
children: KeyPath<DataElement, Data?>, children: KeyPath<DataElement, Data?>,

View File

@ -88,20 +88,20 @@ extension Section: View, SectionView where Parent: View, Content: View, Footer:
} }
} }
extension Section where Parent == EmptyView, Content: View, Footer: View { public extension Section where Parent == EmptyView, Content: View, Footer: View {
public init(footer: Footer, @ViewBuilder content: () -> Content) { init(footer: Footer, @ViewBuilder content: () -> Content) {
self.init(header: EmptyView(), footer: footer, content: content) self.init(header: EmptyView(), footer: footer, content: content)
} }
} }
extension Section where Parent: View, Content: View, Footer == EmptyView { public extension Section where Parent: View, Content: View, Footer == EmptyView {
public init(header: Parent, @ViewBuilder content: () -> Content) { init(header: Parent, @ViewBuilder content: () -> Content) {
self.init(header: header, footer: EmptyView(), content: content) self.init(header: header, footer: EmptyView(), content: content)
} }
} }
extension Section where Parent == EmptyView, Content: View, Footer == EmptyView { public extension Section where Parent == EmptyView, Content: View, Footer == EmptyView {
public init(@ViewBuilder content: () -> Content) { init(@ViewBuilder content: () -> Content) {
self.init(header: EmptyView(), footer: EmptyView(), content: content) self.init(header: EmptyView(), footer: EmptyView(), content: content)
} }
} }

View File

@ -50,10 +50,10 @@ public struct NavigationLink<Label, Destination>: View where Label: View, Destin
} }
} }
extension NavigationLink where Label == Text { public extension NavigationLink where Label == Text {
/// Creates an instance that presents `destination`, with a `Text` label /// Creates an instance that presents `destination`, with a `Text` label
/// generated from a title string. /// generated from a title string.
public init<S>(_ title: S, destination: Destination) where S: StringProtocol { init<S>(_ title: S, destination: Destination) where S: StringProtocol {
self.init(destination: destination) { Text(title) } self.init(destination: destination) { Text(title) }
} }

View File

@ -67,7 +67,7 @@ public struct Picker<Label: View, SelectionValue: Hashable, Content: View>: View
// update the binding. // update the binding.
ForEach(0..<children.count) { index in ForEach(0..<children.count) { index in
if let forEach = mapAnyView(children[index], transform: { (v: ForEachProtocol) in v }), if let forEach = mapAnyView(children[index], transform: { (v: ForEachProtocol) in v }),
forEach.elementType == SelectionValue.self forEach.elementType == SelectionValue.self
{ {
let nestedChildren = forEach.children let nestedChildren = forEach.children
@ -82,9 +82,9 @@ public struct Picker<Label: View, SelectionValue: Hashable, Content: View>: View
} }
} }
extension Picker where Label == Text { public extension Picker where Label == Text {
@_disfavoredOverload @_disfavoredOverload
public init<S: StringProtocol>( init<S: StringProtocol>(
_ title: S, _ title: S,
selection: Binding<SelectionValue>, selection: Binding<SelectionValue>,
@ViewBuilder content: () -> Content @ViewBuilder content: () -> Content

View File

@ -42,8 +42,8 @@ public struct Slider<Label, ValueLabel>: View where Label: View, ValueLabel: Vie
} }
} }
extension Slider where Label == EmptyView, ValueLabel == EmptyView { public extension Slider where Label == EmptyView, ValueLabel == EmptyView {
public init<V>( init<V>(
value: Binding<V>, value: Binding<V>,
in bounds: ClosedRange<V> = 0...1, in bounds: ClosedRange<V> = 0...1,
onEditingChanged: @escaping (Bool) -> () = { _ in } onEditingChanged: @escaping (Bool) -> () = { _ in }
@ -57,7 +57,7 @@ extension Slider where Label == EmptyView, ValueLabel == EmptyView {
self.onEditingChanged = onEditingChanged self.onEditingChanged = onEditingChanged
} }
public init<V>( init<V>(
value: Binding<V>, value: Binding<V>,
in bounds: ClosedRange<V>, in bounds: ClosedRange<V>,
step: V.Stride = 1, step: V.Stride = 1,
@ -73,8 +73,8 @@ extension Slider where Label == EmptyView, ValueLabel == EmptyView {
} }
} }
extension Slider where ValueLabel == EmptyView { public extension Slider where ValueLabel == EmptyView {
public init<V>( init<V>(
value: Binding<V>, value: Binding<V>,
in bounds: ClosedRange<V> = 0...1, in bounds: ClosedRange<V> = 0...1,
onEditingChanged: @escaping (Bool) -> () = { _ in }, onEditingChanged: @escaping (Bool) -> () = { _ in },
@ -89,7 +89,7 @@ extension Slider where ValueLabel == EmptyView {
self.onEditingChanged = onEditingChanged self.onEditingChanged = onEditingChanged
} }
public init<V>( init<V>(
value: Binding<V>, value: Binding<V>,
in bounds: ClosedRange<V>, in bounds: ClosedRange<V>,
step: V.Stride = 1, step: V.Stride = 1,
@ -106,8 +106,8 @@ extension Slider where ValueLabel == EmptyView {
} }
} }
extension Slider { public extension Slider {
public init<V>( init<V>(
value: Binding<V>, value: Binding<V>,
in bounds: ClosedRange<V> = 0...1, in bounds: ClosedRange<V> = 0...1,
onEditingChanged: @escaping (Bool) -> () = { _ in }, onEditingChanged: @escaping (Bool) -> () = { _ in },
@ -124,7 +124,7 @@ extension Slider {
self.onEditingChanged = onEditingChanged self.onEditingChanged = onEditingChanged
} }
public init<V>( init<V>(
value: Binding<V>, value: Binding<V>,
in bounds: ClosedRange<V>, in bounds: ClosedRange<V>,
step: V.Stride = 1, step: V.Stride = 1,

View File

@ -32,16 +32,16 @@ public struct Toggle<Label>: View where Label: View {
} }
} }
extension Toggle where Label == Text { public extension Toggle where Label == Text {
public init<S>(_ title: S, isOn: Binding<Bool>) where S: StringProtocol { init<S>(_ title: S, isOn: Binding<Bool>) where S: StringProtocol {
self.init(isOn: isOn) { self.init(isOn: isOn) {
Text(title) Text(title)
} }
} }
} }
extension Toggle where Label == AnyView { public extension Toggle where Label == AnyView {
public init(_ configuration: ToggleStyleConfiguration) { init(_ configuration: ToggleStyleConfiguration) {
label = configuration.label label = configuration.label
_isOn = configuration.$isOn _isOn = configuration.$isOn
} }

View File

@ -45,8 +45,8 @@ public struct SecureField<Label>: View where Label: View {
} }
} }
extension SecureField where Label == Text { public extension SecureField where Label == Text {
public init<S>( init<S>(
_ title: S, text: Binding<String>, _ title: S, text: Binding<String>,
onCommit: @escaping () -> () = {} onCommit: @escaping () -> () = {}
) where S: StringProtocol { ) where S: StringProtocol {

View File

@ -77,8 +77,8 @@ public struct Text: View {
} }
} }
extension Text._Storage { public extension Text._Storage {
public var rawText: String { var rawText: String {
switch self { switch self {
case let .segmentedText(segments): case let .segmentedText(segments):
return segments return segments
@ -149,8 +149,8 @@ public extension Text {
} }
} }
extension Text { public extension Text {
public static func _concatenating(lhs: Self, rhs: Self) -> Self { static func _concatenating(lhs: Self, rhs: Self) -> Self {
.init(storage: .segmentedText([ .init(storage: .segmentedText([
(lhs.storage, lhs.modifiers), (lhs.storage, lhs.modifiers),
(rhs.storage, rhs.modifiers), (rhs.storage, rhs.modifiers),

View File

@ -46,8 +46,8 @@ public struct TextField<Label>: View where Label: View {
} }
} }
extension TextField where Label == Text { public extension TextField where Label == Text {
public init<S>( init<S>(
_ title: S, _ title: S,
text: Binding<String>, text: Binding<String>,
onEditingChanged: @escaping (Bool) -> () = { _ in }, onEditingChanged: @escaping (Bool) -> () = { _ in },

View File

@ -21,8 +21,8 @@ public protocol View {
@ViewBuilder var body: Self.Body { get } @ViewBuilder var body: Self.Body { get }
} }
extension Never { public extension Never {
public var body: Never { var body: Never {
neverBody("Never") neverBody("Never")
} }
} }

View File

@ -62,7 +62,7 @@ extension Optional: View where Wrapped: View {
} }
} }
@_functionBuilder public struct ViewBuilder { @_functionBuilder public enum ViewBuilder {
public static func buildBlock() -> EmptyView { EmptyView() } public static func buildBlock() -> EmptyView { EmptyView() }
public static func buildBlock<Content>( public static func buildBlock<Content>(
@ -91,16 +91,16 @@ extension Optional: View where Wrapped: View {
// swiftlint:disable large_tuple // swiftlint:disable large_tuple
// swiftlint:disable function_parameter_count // swiftlint:disable function_parameter_count
extension ViewBuilder { public extension ViewBuilder {
public static func buildBlock<C0, C1>(_ c0: C0, _ c1: C1) -> TupleView<(C0, C1)> static func buildBlock<C0, C1>(_ c0: C0, _ c1: C1) -> TupleView<(C0, C1)>
where C0: View, C1: View where C0: View, C1: View
{ {
TupleView(c0, c1) TupleView(c0, c1)
} }
} }
extension ViewBuilder { public extension ViewBuilder {
public static func buildBlock<C0, C1, C2>( static func buildBlock<C0, C1, C2>(
_ c0: C0, _ c0: C0,
_ c1: C1, _ c1: C1,
_ c2: C2 _ c2: C2
@ -109,8 +109,8 @@ extension ViewBuilder {
} }
} }
extension ViewBuilder { public extension ViewBuilder {
public static func buildBlock<C0, C1, C2, C3>( static func buildBlock<C0, C1, C2, C3>(
_ c0: C0, _ c0: C0,
_ c1: C1, _ c1: C1,
_ c2: C2, _ c2: C2,
@ -120,8 +120,8 @@ extension ViewBuilder {
} }
} }
extension ViewBuilder { public extension ViewBuilder {
public static func buildBlock<C0, C1, C2, C3, C4>( static func buildBlock<C0, C1, C2, C3, C4>(
_ c0: C0, _ c0: C0,
_ c1: C1, _ c1: C1,
_ c2: C2, _ c2: C2,
@ -132,8 +132,8 @@ extension ViewBuilder {
} }
} }
extension ViewBuilder { public extension ViewBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5>( static func buildBlock<C0, C1, C2, C3, C4, C5>(
_ c0: C0, _ c0: C0,
_ c1: C1, _ c1: C1,
_ c2: C2, _ c2: C2,
@ -147,8 +147,8 @@ extension ViewBuilder {
} }
} }
extension ViewBuilder { public extension ViewBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6>( static func buildBlock<C0, C1, C2, C3, C4, C5, C6>(
_ c0: C0, _ c0: C0,
_ c1: C1, _ c1: C1,
_ c2: C2, _ c2: C2,
@ -163,8 +163,8 @@ extension ViewBuilder {
} }
} }
extension ViewBuilder { public extension ViewBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7>( static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7>(
_ c0: C0, _ c0: C0,
_ c1: C1, _ c1: C1,
_ c2: C2, _ c2: C2,
@ -180,8 +180,8 @@ extension ViewBuilder {
} }
} }
extension ViewBuilder { public extension ViewBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8>( static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8>(
_ c0: C0, _ c0: C0,
_ c1: C1, _ c1: C1,
_ c2: C2, _ c2: C2,
@ -198,8 +198,8 @@ extension ViewBuilder {
} }
} }
extension ViewBuilder { public extension ViewBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9>( static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9>(
_ c0: C0, _ c0: C0,
_ c1: C1, _ c1: C1,
_ c2: C2, _ c2: C2,

View File

@ -20,8 +20,8 @@ import JavaScriptKit
import TokamakCore import TokamakCore
import TokamakStaticHTML import TokamakStaticHTML
extension App { public extension App {
public static func _launch(_ app: Self, _ rootEnvironment: EnvironmentValues) { static func _launch(_ app: Self, _ rootEnvironment: EnvironmentValues) {
_launch(app, rootEnvironment, TokamakDOM.body) _launch(app, rootEnvironment, TokamakDOM.body)
} }
@ -32,7 +32,7 @@ extension App {
/// The body is styled with `margin: 0;` to match the `SwiftUI` layout /// The body is styled with `margin: 0;` to match the `SwiftUI` layout
/// system as closely as possible /// system as closely as possible
/// ///
public static func _launch( static func _launch(
_ app: Self, _ app: Self,
_ rootEnvironment: EnvironmentValues, _ rootEnvironment: EnvironmentValues,
_ body: JSObject _ body: JSObject
@ -54,18 +54,18 @@ extension App {
ColorSchemeObserver.observe(div) ColorSchemeObserver.observe(div)
} }
public static func _setTitle(_ title: String) { static func _setTitle(_ title: String) {
let titleTag = document.createElement!("title").object! let titleTag = document.createElement!("title").object!
titleTag.id = "_tokamak-app-title" titleTag.id = "_tokamak-app-title"
titleTag.innerHTML = .string(title) titleTag.innerHTML = .string(title)
_ = head.appendChild!(titleTag) _ = head.appendChild!(titleTag)
} }
public var _phasePublisher: AnyPublisher<ScenePhase, Never> { var _phasePublisher: AnyPublisher<ScenePhase, Never> {
ScenePhaseObserver.publisher.eraseToAnyPublisher() ScenePhaseObserver.publisher.eraseToAnyPublisher()
} }
public var _colorSchemePublisher: AnyPublisher<ColorScheme, Never> { var _colorSchemePublisher: AnyPublisher<ColorScheme, Never> {
ColorSchemeObserver.publisher.eraseToAnyPublisher() ColorSchemeObserver.publisher.eraseToAnyPublisher()
} }
} }

View File

@ -131,8 +131,8 @@ public typealias ViewBuilder = TokamakCore.ViewBuilder
// FIXME: I would put this inside TokamakCore, but for // FIXME: I would put this inside TokamakCore, but for
// some reason it doesn't get exported with the typealias // some reason it doesn't get exported with the typealias
extension Text { public extension Text {
public static func + (lhs: Self, rhs: Self) -> Self { static func + (lhs: Self, rhs: Self) -> Self {
_concatenating(lhs: lhs, rhs: rhs) _concatenating(lhs: lhs, rhs: rhs)
} }
} }

View File

@ -15,11 +15,11 @@
import JavaScriptKit import JavaScriptKit
import TokamakCore import TokamakCore
extension View { public extension View {
/** Allows capturing DOM references of host views. The resulting reference is written /** Allows capturing DOM references of host views. The resulting reference is written
to a given `binding`. to a given `binding`.
*/ */
public func _domRef(_ binding: Binding<JSObject?>) -> some View { func _domRef(_ binding: Binding<JSObject?>) -> some View {
// Convert `Binding<JSObject?>` to `Binding<DOMNode?>` first. // Convert `Binding<JSObject?>` to `Binding<DOMNode?>` first.
let targetBinding = Binding( let targetBinding = Binding(
get: { binding.wrappedValue.map(DOMNode.init) }, get: { binding.wrappedValue.map(DOMNode.init) },

View File

@ -29,50 +29,50 @@ protocol WebStorage {
var publisher: ObservableObjectPublisher { get } var publisher: ObservableObjectPublisher { get }
} }
extension WebStorage { public extension WebStorage {
func setItem<Value>(key: String, value: Value?) { internal func setItem<Value>(key: String, value: Value?) {
publisher.send() publisher.send()
if let value = value { if let value = value {
_ = storage.setItem!(key, String(describing: value)) _ = storage.setItem!(key, String(describing: value))
} }
} }
func getItem<Value>(key: String, _ initialize: (String) -> Value?) -> Value? { internal func getItem<Value>(key: String, _ initialize: (String) -> Value?) -> Value? {
guard let value = storage.getItem!(key).string else { guard let value = storage.getItem!(key).string else {
return nil return nil
} }
return initialize(value) return initialize(value)
} }
public func store(key: String, value: Bool?) { func store(key: String, value: Bool?) {
setItem(key: key, value: value) setItem(key: key, value: value)
} }
public func store(key: String, value: Int?) { func store(key: String, value: Int?) {
setItem(key: key, value: value) setItem(key: key, value: value)
} }
public func store(key: String, value: Double?) { func store(key: String, value: Double?) {
setItem(key: key, value: value) setItem(key: key, value: value)
} }
public func store(key: String, value: String?) { func store(key: String, value: String?) {
setItem(key: key, value: value) setItem(key: key, value: value)
} }
public func read(key: String) -> Bool? { func read(key: String) -> Bool? {
getItem(key: key, Bool.init) getItem(key: key, Bool.init)
} }
public func read(key: String) -> Int? { func read(key: String) -> Int? {
getItem(key: key, Int.init) getItem(key: key, Int.init)
} }
public func read(key: String) -> Double? { func read(key: String) -> Double? {
getItem(key: key, Double.init) getItem(key: key, Double.init)
} }
public func read(key: String) -> String? { func read(key: String) -> String? {
getItem(key: key, String.init) getItem(key: key, String.init)
} }
} }

View File

@ -40,8 +40,8 @@ public struct DynamicHTML<Content>: View, AnyDynamicHTML {
} }
} }
extension DynamicHTML where Content: StringProtocol { public extension DynamicHTML where Content: StringProtocol {
public init( init(
_ tag: String, _ tag: String,
_ attributes: [HTMLAttribute: String] = [:], _ attributes: [HTMLAttribute: String] = [:],
listeners: [String: Listener] = [:], listeners: [String: Listener] = [:],
@ -74,8 +74,8 @@ extension DynamicHTML: ParentView where Content: View {
} }
} }
extension DynamicHTML where Content == EmptyView { public extension DynamicHTML where Content == EmptyView {
public init( init(
_ tag: String, _ tag: String,
_ attributes: [HTMLAttribute: String] = [:], _ attributes: [HTMLAttribute: String] = [:],
listeners: [String: Listener] = [:] listeners: [String: Listener] = [:]

View File

@ -20,8 +20,8 @@ import TokamakShim
public struct ColorDemo: View { public struct ColorDemo: View {
var color: Color { var color: Color {
guard let v0d = Double(v0), guard let v0d = Double(v0),
let v1d = Double(v1), let v1d = Double(v1),
let v2d = Double(v2) let v2d = Double(v2)
else { else {
return .white return .white
} }

View File

@ -18,20 +18,20 @@
import CombineShim import CombineShim
import TokamakCore import TokamakCore
extension App { public extension App {
public static func _launch(_ app: Self, _ rootEnvironment: EnvironmentValues) { static func _launch(_ app: Self, _ rootEnvironment: EnvironmentValues) {
fatalError("TokamakStaticHTML does not support default `App._launch`") fatalError("TokamakStaticHTML does not support default `App._launch`")
} }
public static func _setTitle(_ title: String) { static func _setTitle(_ title: String) {
StaticHTMLRenderer.title = title StaticHTMLRenderer.title = title
} }
public var _phasePublisher: AnyPublisher<ScenePhase, Never> { var _phasePublisher: AnyPublisher<ScenePhase, Never> {
CurrentValueSubject<ScenePhase, Never>(.active).eraseToAnyPublisher() CurrentValueSubject<ScenePhase, Never>(.active).eraseToAnyPublisher()
} }
public var _colorSchemePublisher: AnyPublisher<ColorScheme, Never> { var _colorSchemePublisher: AnyPublisher<ColorScheme, Never> {
CurrentValueSubject<ColorScheme, Never>(.light).eraseToAnyPublisher() CurrentValueSubject<ColorScheme, Never>(.light).eraseToAnyPublisher()
} }
} }

View File

@ -92,8 +92,8 @@ public typealias ViewBuilder = TokamakCore.ViewBuilder
// FIXME: I would put this inside TokamakCore, but for // FIXME: I would put this inside TokamakCore, but for
// some reason it doesn't get exported with the typealias // some reason it doesn't get exported with the typealias
extension Text { public extension Text {
public static func + (lhs: Self, rhs: Self) -> Self { static func + (lhs: Self, rhs: Self) -> Self {
_concatenating(lhs: lhs, rhs: rhs) _concatenating(lhs: lhs, rhs: rhs)
} }
} }

View File

@ -34,7 +34,7 @@ extension ModifiedContent: ViewDeferredToRenderer where Content: View {
public var deferredBody: AnyView { public var deferredBody: AnyView {
if let domModifier = modifier as? DOMViewModifier { if let domModifier = modifier as? DOMViewModifier {
if let adjacentModifier = content as? AnyModifiedContent, if let adjacentModifier = content as? AnyModifiedContent,
!(adjacentModifier.anyModifier.isOrderDependent || domModifier.isOrderDependent) !(adjacentModifier.anyModifier.isOrderDependent || domModifier.isOrderDependent)
{ {
// Flatten non-order-dependent modifiers // Flatten non-order-dependent modifiers
var attr = domModifier.attributes var attr = domModifier.attributes

View File

@ -20,8 +20,8 @@ public protocol DOMViewModifier {
var isOrderDependent: Bool { get } var isOrderDependent: Bool { get }
} }
extension DOMViewModifier { public extension DOMViewModifier {
public var isOrderDependent: Bool { false } var isOrderDependent: Bool { false }
} }
extension ModifiedContent: DOMViewModifier extension ModifiedContent: DOMViewModifier

View File

@ -50,8 +50,8 @@ public protocol AnyHTML {
var attributes: [HTMLAttribute: String] { get } var attributes: [HTMLAttribute: String] { get }
} }
extension AnyHTML { public extension AnyHTML {
public var outerHTML: String { var outerHTML: String {
""" """
<\(tag)\(attributes.isEmpty ? "" : " ")\ <\(tag)\(attributes.isEmpty ? "" : " ")\
\(attributes.map { #"\#($0)="\#($1)""# }.joined(separator: " "))>\ \(attributes.map { #"\#($0)="\#($1)""# }.joined(separator: " "))>\
@ -73,8 +73,8 @@ public struct HTML<Content>: View, AnyHTML {
} }
} }
extension HTML where Content: StringProtocol { public extension HTML where Content: StringProtocol {
public init( init(
_ tag: String, _ tag: String,
_ attributes: [HTMLAttribute: String] = [:], _ attributes: [HTMLAttribute: String] = [:],
content: Content content: Content
@ -103,8 +103,8 @@ extension HTML: ParentView where Content: View {
} }
} }
extension HTML where Content == EmptyView { public extension HTML where Content == EmptyView {
public init( init(
_ tag: String, _ tag: String,
_ attributes: [HTMLAttribute: String] = [:] _ attributes: [HTMLAttribute: String] = [:]
) { ) {
@ -116,8 +116,8 @@ public protocol StylesConvertible {
var styles: [String: String] { get } var styles: [String: String] { get }
} }
extension Dictionary { public extension Dictionary {
public var inlineStyles: String { var inlineStyles: String {
map { "\($0.0): \($0.1);" } map { "\($0.0): \($0.1);" }
.joined(separator: " ") .joined(separator: " ")
} }

View File

@ -24,8 +24,8 @@ public protocol SpacerContainer {
var fillCrossAxis: Bool { get } var fillCrossAxis: Bool { get }
} }
extension SpacerContainer where Self: ParentView { public extension SpacerContainer where Self: ParentView {
public var hasSpacer: Bool { var hasSpacer: Bool {
children children
.compactMap { .compactMap {
mapAnyView($0) { (v: Spacer) in mapAnyView($0) { (v: Spacer) in
@ -45,7 +45,7 @@ extension SpacerContainer where Self: ParentView {
// Does a child SpacerContainer along the opposite axis have a spacer? // Does a child SpacerContainer along the opposite axis have a spacer?
// (e.g., an HStack with a child VStack which contains a spacer) // (e.g., an HStack with a child VStack which contains a spacer)
// If so, we need to fill the cross-axis so the child can show the correct layout. // If so, we need to fill the cross-axis so the child can show the correct layout.
public var fillCrossAxis: Bool { var fillCrossAxis: Bool {
children children
.compactMap { .compactMap {
mapAnyView($0) { (v: SpacerContainer) in v } mapAnyView($0) { (v: SpacerContainer) in v }