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",
package: "JavaScriptKit",
condition: .when(platforms: [.wasi])
)
),
]
),
.target(
@ -92,7 +92,7 @@ let package = Package(
name: "JavaScriptKit",
package: "JavaScriptKit",
condition: .when(platforms: [.wasi])
)
),
]
),
.target(

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -36,8 +36,8 @@ public extension Scene {
}
}
extension _SceneModifier where Body == Never {
public func body(content: SceneContent) -> Body {
public extension _SceneModifier where Body == Never {
func body(content: SceneContent) -> Body {
fatalError("""
\(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()
}
extension DynamicProperty {
public mutating func update() {}
public extension DynamicProperty {
mutating func update() {}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -26,17 +26,17 @@ public struct _PaddingLayout: ViewModifier {
}
}
extension View {
public func padding(_ insets: EdgeInsets) -> some View {
public extension View {
func padding(_ insets: EdgeInsets) -> some View {
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) }
return modifier(_PaddingLayout(edges: edges, insets: insets))
}
public func padding(_ length: CGFloat) -> some View {
func padding(_ length: CGFloat) -> some View {
padding(.all, length)
}
}

View File

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

View File

@ -45,8 +45,8 @@ extension _BackgroundModifier: Equatable where Background: Equatable {
}
}
extension View {
public func background<Background>(
public extension View {
func background<Background>(
_ background: Background,
alignment: Alignment = .center
) -> some View where Background: View {
@ -84,14 +84,14 @@ extension _OverlayModifier: Equatable where Overlay: Equatable {
}
}
extension View {
public func overlay<Overlay>(_ overlay: Overlay, alignment: Alignment = .center) -> some View
public extension View {
func overlay<Overlay>(_ overlay: Overlay, alignment: Alignment = .center) -> some View
where Overlay: View
{
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))
}
}

View File

@ -33,8 +33,8 @@ public extension View {
}
}
extension ViewModifier where Body == Never {
public func body(content: Content) -> Body {
public extension ViewModifier where Body == Never {
func body(content: Content) -> Body {
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
// Extract the view from the AnyView for modification, apply Environment changes:
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)
}

View File

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

View File

@ -168,28 +168,28 @@ public enum RoundedCornerStyle: Hashable, Equatable {
case continuous
}
extension Path {
public mutating func move(to p: CGPoint) {
public extension Path {
mutating func move(to p: CGPoint) {
elements.append(.move(to: p))
}
public mutating func addLine(to p: CGPoint) {
mutating func addLine(to p: CGPoint) {
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))
}
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))
}
public mutating func closeSubpath() {
mutating func 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)
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))
@ -197,7 +197,7 @@ extension Path {
closeSubpath()
}
public mutating func addRoundedRect(
mutating func addRoundedRect(
in rect: CGRect,
cornerSize: CGSize,
style: RoundedCornerStyle = .circular,
@ -238,7 +238,7 @@ extension Path {
closeSubpath()
}
public mutating func addEllipse(in rect: CGRect, transform: CGAffineTransform = .identity) {
mutating func addEllipse(in rect: CGRect, transform: CGAffineTransform = .identity) {
subpaths.append(.init(
path: .init(ellipseIn: .init(
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) }
}
public mutating func addLines(_ lines: [CGPoint]) {
mutating func addLines(_ lines: [CGPoint]) {
lines.forEach { addLine(to: $0) }
}
public mutating func addRelativeArc(
mutating func addRelativeArc(
center: CGPoint,
radius: CGFloat,
startAngle: Angle,
@ -275,7 +275,7 @@ extension Path {
// There's a great article on bezier curves here:
// https://pomax.github.io/bezierinfo
// FIXME: Handle negative delta
public mutating func addArc(
mutating func addArc(
center: CGPoint,
radius: CGFloat,
startAngle: Angle,
@ -337,18 +337,18 @@ extension Path {
}
// FIXME: How does this arc method work?
public mutating func addArc(
mutating func addArc(
tangent1End p1: CGPoint,
tangent2End p2: CGPoint,
radius: CGFloat,
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))
}
public var currentPoint: CGPoint? {
var currentPoint: CGPoint? {
switch elements.last {
case let .move(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
path.transform = transform
return path
}
public func offsetBy(dx: CGFloat, dy: CGFloat) -> Path {
func offsetBy(dx: CGFloat, dy: CGFloat) -> Path {
applying(transform.translatedBy(x: dx, y: dy))
}
}

View File

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

View File

@ -21,8 +21,8 @@ public protocol Shape: View {
public protocol ShapeStyle {}
extension ShapeStyle where Self: View, Self.Body == _ShapeView<Rectangle, Self> {
public var body: some View {
public extension ShapeStyle where Self: View, Self.Body == _ShapeView<Rectangle, Self> {
var body: some View {
_ShapeView(shape: Rectangle(), style: self)
}
}
@ -64,26 +64,26 @@ public struct _ShapeView<Content, Style>: View where Content: Shape, Style: Shap
}
}
extension Shape {
public func trim(from startFraction: CGFloat = 0, to endFraction: CGFloat = 1) -> some Shape {
public extension Shape {
func trim(from startFraction: CGFloat = 0, to endFraction: CGFloat = 1) -> some Shape {
_TrimmedShape(shape: self, startFraction: startFraction, endFraction: endFraction)
}
}
extension Shape {
public func offset(_ offset: CGSize) -> OffsetShape<Self> {
public extension Shape {
func offset(_ offset: CGSize) -> OffsetShape<Self> {
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))
}
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))
}
public func scale(
func scale(
x: CGFloat = 1,
y: CGFloat = 1,
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)
}
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)
}
public func transform(_ transform: CGAffineTransform) -> TransformedShape<Self> {
func transform(_ transform: CGAffineTransform) -> TransformedShape<Self> {
TransformedShape(shape: self, transform: transform)
}
}
extension Shape {
public func size(_ size: CGSize) -> some Shape {
public extension Shape {
func size(_ size: CGSize) -> some Shape {
_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))
}
}
extension Shape {
public func stroke(style: StrokeStyle) -> some Shape {
public extension Shape {
func stroke(style: StrokeStyle) -> some Shape {
_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))
}
}
extension Shape {
public func fill<S>(
public extension Shape {
func fill<S>(
_ content: S,
style: FillStyle = FillStyle()
) -> some View where S: ShapeStyle {
_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)
}
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)
}
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))
}
}
extension Shape {
public var body: some View {
public extension Shape {
var body: some View {
_ShapeView(shape: self, style: ForegroundStyle())
}
}

View File

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

View File

@ -51,7 +51,7 @@ protocol WritableValueStorage: ValueStorage {
extension State: WritableValueStorage {}
extension State where Value: ExpressibleByNilLiteral {
public extension State where Value: ExpressibleByNilLiteral {
@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 }
}
extension View {
public extension View {
/** Allows capturing target instance of aclosest descendant host view. The resulting instance
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)
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -30,8 +30,8 @@ public struct Link<Label>: View where Label: View {
}
}
extension Link where Label == Text {
public init<S: StringProtocol>(_ titleKey: S, destination: URL) {
public extension Link where Label == Text {
init<S: StringProtocol>(_ titleKey: S, destination: URL) {
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
// public init(_ titleKey: LocalizedStringKey,
// @ViewBuilder content: @escaping () -> Content)
@ -54,14 +54,14 @@ extension DisclosureGroup where Label == Text {
// @SwiftUI.ViewBuilder content: @escaping () -> Content)
@_disfavoredOverload
public init<S>(_ label: S, @ViewBuilder content: @escaping () -> Content)
init<S>(_ label: S, @ViewBuilder content: @escaping () -> Content)
where S: StringProtocol
{
self.init(content: content, label: { Text(label) })
}
@_disfavoredOverload
public init<S>(
init<S>(
_ label: S,
isExpanded: Binding<Bool>,
@ViewBuilder content: @escaping () -> Content

View File

@ -90,8 +90,8 @@ struct _IDKey: EnvironmentKey {
static let defaultValue: AnyHashable? = nil
}
extension EnvironmentValues {
public var _id: AnyHashable? {
public extension EnvironmentValues {
var _id: AnyHashable? {
get {
self[_IDKey.self]
}
@ -121,8 +121,8 @@ struct IDView<Content, ID>: View, _AnyIDView where Content: View, ID: Hashable {
}
}
extension View {
public func id<ID>(_ id: ID) -> some View where ID: Hashable {
public extension View {
func id<ID>(_ id: ID) -> some View where ID: Hashable {
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>(
_ children: [AnyView],
@ViewBuilder rowView: @escaping (AnyView, Bool) -> RowView
@ -133,9 +133,9 @@ public struct _ListProxy<SelectionValue, Content>
public var selection: List<SelectionValue, Content>._Selection { subject.selection }
}
extension List {
public extension List {
// - MARK: Collection initializers
public init<Data, RowContent>(
init<Data, RowContent>(
_ data: Data,
selection: Binding<Set<SelectionValue>>?,
@ViewBuilder rowContent: @escaping (Data.Element) -> RowContent
@ -147,11 +147,11 @@ extension List {
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>,
selection: Binding<Set<SelectionValue>>?,
@ViewBuilder rowContent: @escaping (Data.Element) -> RowContent)
id: KeyPath<Data.Element, ID>,
selection: Binding<Set<SelectionValue>>?,
@ViewBuilder rowContent: @escaping (Data.Element) -> RowContent)
where Content == ForEach<Data, ID, HStack<RowContent>>,
Data: RandomAccessCollection,
ID: Hashable, RowContent: View
@ -159,7 +159,7 @@ extension List {
self.init(selection: selection) { ForEach(data, id: id) { row in HStack { rowContent(row) } } }
}
public init<Data, ID, RowContent>(
init<Data, ID, RowContent>(
_ data: Data,
id: KeyPath<Data.Element, ID>,
selection: Binding<SelectionValue?>?,
@ -175,9 +175,9 @@ extension List {
}
}
public init<Data, RowContent>(_ data: Data,
selection: Binding<SelectionValue?>?,
@ViewBuilder rowContent: @escaping (Data.Element) -> RowContent)
init<Data, RowContent>(_ data: Data,
selection: Binding<SelectionValue?>?,
@ViewBuilder rowContent: @escaping (Data.Element) -> RowContent)
where Content == ForEach<Data, Data.Element.ID, HStack<RowContent>>,
Data: RandomAccessCollection, RowContent: View, Data.Element: Identifiable
{
@ -191,7 +191,7 @@ extension List {
}
// - MARK: Range initializers
public init<RowContent>(
init<RowContent>(
_ data: Range<Int>,
selection: Binding<Set<SelectionValue>>?,
@ViewBuilder rowContent: @escaping (Int) -> RowContent
@ -205,7 +205,7 @@ extension List {
}
}
public init<RowContent>(
init<RowContent>(
_ data: Range<Int>,
selection: Binding<SelectionValue?>?,
@ViewBuilder rowContent: @escaping (Int) -> RowContent
@ -221,7 +221,7 @@ extension List {
// - MARK: OutlineGroup initializers
public init<Data, RowContent>(
init<Data, RowContent>(
_ data: Data,
children: KeyPath<Data.Element, Data?>,
selection: Binding<Set<SelectionValue>>?,
@ -242,7 +242,7 @@ extension List {
}
}
public init<Data, ID, RowContent>(
init<Data, ID, RowContent>(
_ data: Data,
id: KeyPath<Data.Element, ID>,
children: KeyPath<Data.Element, Data?>,
@ -264,7 +264,7 @@ extension List {
}
}
public init<Data, RowContent>(
init<Data, RowContent>(
_ data: Data,
children: KeyPath<Data.Element, Data?>,
selection: Binding<SelectionValue?>?,
@ -285,7 +285,7 @@ extension List {
}
}
public init<Data, ID, RowContent>(
init<Data, ID, RowContent>(
_ data: Data,
id: KeyPath<Data.Element, ID>,
children: KeyPath<Data.Element, Data?>,
@ -308,13 +308,13 @@ extension List {
}
}
extension List where SelectionValue == Never {
public init(@ViewBuilder content: () -> Content) {
public extension List where SelectionValue == Never {
init(@ViewBuilder content: () -> Content) {
selection = .one(nil)
self.content = content()
}
public init<Data, RowContent>(
init<Data, RowContent>(
_ data: Data,
@ViewBuilder rowContent: @escaping (Data.Element) -> RowContent
)
@ -327,7 +327,7 @@ extension List where SelectionValue == Never {
}
}
public init<Data, RowContent>(
init<Data, RowContent>(
_ data: Data,
children: KeyPath<Data.Element, Data?>,
@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,
id: KeyPath<Data.Element, ID>,
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,
id: KeyPath<Data.Element, ID>,
@ViewBuilder rowContent: @escaping (Data.Element) -> RowContent
@ -382,7 +382,7 @@ extension List where SelectionValue == Never {
}
}
public init<RowContent>(
init<RowContent>(
_ data: Range<Int>,
@ViewBuilder rowContent: @escaping (Int) -> RowContent
)

View File

@ -29,13 +29,13 @@ public struct OutlineGroup<Data, ID, Parent, Leaf, Subgroup>
let content: (Data.Element) -> Leaf
}
extension OutlineGroup where ID == Data.Element.ID,
public extension OutlineGroup where ID == Data.Element.ID,
Parent: View,
Parent == Leaf,
Subgroup == DisclosureGroup<Parent, OutlineSubgroupChildren>,
Data.Element: Identifiable
{
public init<DataElement>(
init<DataElement>(
_ root: DataElement,
children: KeyPath<DataElement, Data?>,
@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)
}
public init<DataElement>(
init<DataElement>(
_ data: Data,
children: KeyPath<DataElement, Data?>,
@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,
Subgroup == DisclosureGroup<Parent, OutlineSubgroupChildren>
{
public init<DataElement>(
init<DataElement>(
_ root: DataElement,
id: KeyPath<DataElement, ID>,
children: KeyPath<DataElement, Data?>,
@ -70,7 +70,7 @@ extension OutlineGroup where Parent: View,
self.content = content
}
public init<DataElement>(
init<DataElement>(
_ data: Data,
id: KeyPath<DataElement, ID>,
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 init(footer: Footer, @ViewBuilder content: () -> Content) {
public extension Section where Parent == EmptyView, Content: View, Footer: View {
init(footer: Footer, @ViewBuilder content: () -> Content) {
self.init(header: EmptyView(), footer: footer, content: content)
}
}
extension Section where Parent: View, Content: View, Footer == EmptyView {
public init(header: Parent, @ViewBuilder content: () -> Content) {
public extension Section where Parent: View, Content: View, Footer == EmptyView {
init(header: Parent, @ViewBuilder content: () -> Content) {
self.init(header: header, footer: EmptyView(), content: content)
}
}
extension Section where Parent == EmptyView, Content: View, Footer == EmptyView {
public init(@ViewBuilder content: () -> Content) {
public extension Section where Parent == EmptyView, Content: View, Footer == EmptyView {
init(@ViewBuilder 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
/// 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) }
}

View File

@ -67,7 +67,7 @@ public struct Picker<Label: View, SelectionValue: Hashable, Content: View>: View
// update the binding.
ForEach(0..<children.count) { index in
if let forEach = mapAnyView(children[index], transform: { (v: ForEachProtocol) in v }),
forEach.elementType == SelectionValue.self
forEach.elementType == SelectionValue.self
{
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
public init<S: StringProtocol>(
init<S: StringProtocol>(
_ title: S,
selection: Binding<SelectionValue>,
@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 init<V>(
public extension Slider where Label == EmptyView, ValueLabel == EmptyView {
init<V>(
value: Binding<V>,
in bounds: ClosedRange<V> = 0...1,
onEditingChanged: @escaping (Bool) -> () = { _ in }
@ -57,7 +57,7 @@ extension Slider where Label == EmptyView, ValueLabel == EmptyView {
self.onEditingChanged = onEditingChanged
}
public init<V>(
init<V>(
value: Binding<V>,
in bounds: ClosedRange<V>,
step: V.Stride = 1,
@ -73,8 +73,8 @@ extension Slider where Label == EmptyView, ValueLabel == EmptyView {
}
}
extension Slider where ValueLabel == EmptyView {
public init<V>(
public extension Slider where ValueLabel == EmptyView {
init<V>(
value: Binding<V>,
in bounds: ClosedRange<V> = 0...1,
onEditingChanged: @escaping (Bool) -> () = { _ in },
@ -89,7 +89,7 @@ extension Slider where ValueLabel == EmptyView {
self.onEditingChanged = onEditingChanged
}
public init<V>(
init<V>(
value: Binding<V>,
in bounds: ClosedRange<V>,
step: V.Stride = 1,
@ -106,8 +106,8 @@ extension Slider where ValueLabel == EmptyView {
}
}
extension Slider {
public init<V>(
public extension Slider {
init<V>(
value: Binding<V>,
in bounds: ClosedRange<V> = 0...1,
onEditingChanged: @escaping (Bool) -> () = { _ in },
@ -124,7 +124,7 @@ extension Slider {
self.onEditingChanged = onEditingChanged
}
public init<V>(
init<V>(
value: Binding<V>,
in bounds: ClosedRange<V>,
step: V.Stride = 1,

View File

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

View File

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

View File

@ -77,8 +77,8 @@ public struct Text: View {
}
}
extension Text._Storage {
public var rawText: String {
public extension Text._Storage {
var rawText: String {
switch self {
case let .segmentedText(segments):
return segments
@ -149,8 +149,8 @@ public extension Text {
}
}
extension Text {
public static func _concatenating(lhs: Self, rhs: Self) -> Self {
public extension Text {
static func _concatenating(lhs: Self, rhs: Self) -> Self {
.init(storage: .segmentedText([
(lhs.storage, lhs.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 init<S>(
public extension TextField where Label == Text {
init<S>(
_ title: S,
text: Binding<String>,
onEditingChanged: @escaping (Bool) -> () = { _ in },

View File

@ -21,8 +21,8 @@ public protocol View {
@ViewBuilder var body: Self.Body { get }
}
extension Never {
public var body: Never {
public extension Never {
var body: 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<Content>(
@ -91,16 +91,16 @@ extension Optional: View where Wrapped: View {
// swiftlint:disable large_tuple
// swiftlint:disable function_parameter_count
extension ViewBuilder {
public static func buildBlock<C0, C1>(_ c0: C0, _ c1: C1) -> TupleView<(C0, C1)>
public extension ViewBuilder {
static func buildBlock<C0, C1>(_ c0: C0, _ c1: C1) -> TupleView<(C0, C1)>
where C0: View, C1: View
{
TupleView(c0, c1)
}
}
extension ViewBuilder {
public static func buildBlock<C0, C1, C2>(
public extension ViewBuilder {
static func buildBlock<C0, C1, C2>(
_ c0: C0,
_ c1: C1,
_ c2: C2
@ -109,8 +109,8 @@ extension ViewBuilder {
}
}
extension ViewBuilder {
public static func buildBlock<C0, C1, C2, C3>(
public extension ViewBuilder {
static func buildBlock<C0, C1, C2, C3>(
_ c0: C0,
_ c1: C1,
_ c2: C2,
@ -120,8 +120,8 @@ extension ViewBuilder {
}
}
extension ViewBuilder {
public static func buildBlock<C0, C1, C2, C3, C4>(
public extension ViewBuilder {
static func buildBlock<C0, C1, C2, C3, C4>(
_ c0: C0,
_ c1: C1,
_ c2: C2,
@ -132,8 +132,8 @@ extension ViewBuilder {
}
}
extension ViewBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5>(
public extension ViewBuilder {
static func buildBlock<C0, C1, C2, C3, C4, C5>(
_ c0: C0,
_ c1: C1,
_ c2: C2,
@ -147,8 +147,8 @@ extension ViewBuilder {
}
}
extension ViewBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6>(
public extension ViewBuilder {
static func buildBlock<C0, C1, C2, C3, C4, C5, C6>(
_ c0: C0,
_ c1: C1,
_ c2: C2,
@ -163,8 +163,8 @@ extension ViewBuilder {
}
}
extension ViewBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7>(
public extension ViewBuilder {
static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7>(
_ c0: C0,
_ c1: C1,
_ c2: C2,
@ -180,8 +180,8 @@ extension ViewBuilder {
}
}
extension ViewBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8>(
public extension ViewBuilder {
static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8>(
_ c0: C0,
_ c1: C1,
_ c2: C2,
@ -198,8 +198,8 @@ extension ViewBuilder {
}
}
extension ViewBuilder {
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9>(
public extension ViewBuilder {
static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9>(
_ c0: C0,
_ c1: C1,
_ c2: C2,

View File

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

View File

@ -131,8 +131,8 @@ public typealias ViewBuilder = TokamakCore.ViewBuilder
// 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 {
public extension Text {
static func + (lhs: Self, rhs: Self) -> Self {
_concatenating(lhs: lhs, rhs: rhs)
}
}

View File

@ -15,11 +15,11 @@
import JavaScriptKit
import TokamakCore
extension View {
public extension View {
/** Allows capturing DOM references of host views. The resulting reference is written
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.
let targetBinding = Binding(
get: { binding.wrappedValue.map(DOMNode.init) },

View File

@ -29,50 +29,50 @@ protocol WebStorage {
var publisher: ObservableObjectPublisher { get }
}
extension WebStorage {
func setItem<Value>(key: String, value: Value?) {
public extension WebStorage {
internal func setItem<Value>(key: String, value: Value?) {
publisher.send()
if let value = 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 {
return nil
}
return initialize(value)
}
public func store(key: String, value: Bool?) {
func store(key: String, value: Bool?) {
setItem(key: key, value: value)
}
public func store(key: String, value: Int?) {
func store(key: String, value: Int?) {
setItem(key: key, value: value)
}
public func store(key: String, value: Double?) {
func store(key: String, value: Double?) {
setItem(key: key, value: value)
}
public func store(key: String, value: String?) {
func store(key: String, value: String?) {
setItem(key: key, value: value)
}
public func read(key: String) -> Bool? {
func read(key: String) -> Bool? {
getItem(key: key, Bool.init)
}
public func read(key: String) -> Int? {
func read(key: String) -> Int? {
getItem(key: key, Int.init)
}
public func read(key: String) -> Double? {
func read(key: String) -> Double? {
getItem(key: key, Double.init)
}
public func read(key: String) -> String? {
func read(key: String) -> String? {
getItem(key: key, String.init)
}
}

View File

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

View File

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

View File

@ -18,20 +18,20 @@
import CombineShim
import TokamakCore
extension App {
public static func _launch(_ app: Self, _ rootEnvironment: EnvironmentValues) {
public extension App {
static func _launch(_ app: Self, _ rootEnvironment: EnvironmentValues) {
fatalError("TokamakStaticHTML does not support default `App._launch`")
}
public static func _setTitle(_ title: String) {
static func _setTitle(_ title: String) {
StaticHTMLRenderer.title = title
}
public var _phasePublisher: AnyPublisher<ScenePhase, Never> {
var _phasePublisher: AnyPublisher<ScenePhase, Never> {
CurrentValueSubject<ScenePhase, Never>(.active).eraseToAnyPublisher()
}
public var _colorSchemePublisher: AnyPublisher<ColorScheme, Never> {
var _colorSchemePublisher: AnyPublisher<ColorScheme, Never> {
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
// some reason it doesn't get exported with the typealias
extension Text {
public static func + (lhs: Self, rhs: Self) -> Self {
public extension Text {
static func + (lhs: Self, rhs: Self) -> Self {
_concatenating(lhs: lhs, rhs: rhs)
}
}

View File

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

View File

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

View File

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

View File

@ -24,8 +24,8 @@ public protocol SpacerContainer {
var fillCrossAxis: Bool { get }
}
extension SpacerContainer where Self: ParentView {
public var hasSpacer: Bool {
public extension SpacerContainer where Self: ParentView {
var hasSpacer: Bool {
children
.compactMap {
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?
// (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.
public var fillCrossAxis: Bool {
var fillCrossAxis: Bool {
children
.compactMap {
mapAnyView($0) { (v: SpacerContainer) in v }