Skip to content

Commit

Permalink
chore: formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
watt committed Dec 2, 2024
1 parent 6b7d087 commit cda870e
Show file tree
Hide file tree
Showing 40 changed files with 299 additions and 299 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public struct TextAttributeContainer {
public subscript<Key>(key: Key.Type) -> Key.Value? where Key: AttributedTextKey {
get {
if let value = storage[key.name] as? Key.Value {
return value
value
} else {
return nil
nil
}
}
set {
Expand Down
8 changes: 4 additions & 4 deletions BlueprintUI/Sources/BlueprintView/BlueprintView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@ public final class BlueprintView: UIView {

func constraint() -> SizeConstraint {
if bounds.width == 0 {
return .unconstrained
.unconstrained
} else {
return .init(width: bounds.width)
.init(width: bounds.width)
}
}

Expand Down Expand Up @@ -517,9 +517,9 @@ public final class BlueprintView: UIView {
self.automaticallyInheritsEnvironmentFromContainingBlueprintViews,
let inherited = self.inheritedBlueprintEnvironment
{
return inherited
inherited
} else {
return .empty
.empty
}
}()

Expand Down
12 changes: 6 additions & 6 deletions BlueprintUI/Sources/BlueprintView/ElementPreview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ public struct ElementPreview: View {
// MARK: View

public var body: some View {
ForEach(self.previewTypes, id: \.identifier) { previewType in
ForEach(previewTypes, id: \.identifier) { previewType in
previewType.previewView(
with: self.name,
for: self.provider()
with: name,
for: provider()
)
}
}
Expand Down Expand Up @@ -180,9 +180,9 @@ extension ElementPreview {

public var identifier: AnyHashable {
switch self {
case .device(let device): return device.rawValue
case .fixed(let width, let height): return "(\(width), \(height))"
case .thatFits(let padding): return "thatFits (\(padding)"
case .device(let device): device.rawValue
case .fixed(let width, let height): "(\(width), \(height))"
case .thatFits(let padding): "thatFits (\(padding)"
}
}

Expand Down
2 changes: 1 addition & 1 deletion BlueprintUI/Sources/Environment/AdaptedEnvironment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public struct AdaptedEnvironment: Element {
ElementContent(
child: wrapped,
environment: { env in
for adapter in self.adapters.reversed() {
for adapter in adapters.reversed() {
adapter(&env)
}
}
Expand Down
6 changes: 3 additions & 3 deletions BlueprintUI/Sources/Environment/Environment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ extension UIView {
/// If no views in the superview hierarchy are managed by Blueprint, this property returns nil.
var inheritedBlueprintEnvironment: Environment? {
if let environment = nativeViewNodeBlueprintEnvironment {
return environment
environment
} else if let superview = superview {
return superview.inheritedBlueprintEnvironment
superview.inheritedBlueprintEnvironment
} else {
return nil
nil
}
}

Expand Down
2 changes: 1 addition & 1 deletion BlueprintUI/Sources/Environment/EnvironmentReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public struct EnvironmentReader: Element {

public var content: ElementContent {
ElementContent { _, environment in
self.elementRepresentation(environment)
elementRepresentation(environment)
}
}

Expand Down
2 changes: 1 addition & 1 deletion BlueprintUI/Sources/Focus/FocusState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ extension FocusState {
},
onBlur: { [weak self] in
if let self = self, self.value == value {
self.value = self.defaultValue
self.value = defaultValue
}
}
)
Expand Down
4 changes: 2 additions & 2 deletions BlueprintUI/Sources/Internal/ElementIdentifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ struct ElementIdentifier: Hashable, CustomStringConvertible {

var description: String {
if let key = key {
return "\(elementType).\(key).\(count)"
"\(elementType).\(key).\(count)"
} else {
return "\(elementType).\(count)"
"\(elementType).\(count)"
}
}

Expand Down
4 changes: 2 additions & 2 deletions BlueprintUI/Sources/Internal/LayoutResultNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ extension Element {
func layout(frame: CGRect, environment: Environment, layoutMode: LayoutMode) -> LayoutResultNode {
switch layoutMode {
case .legacy:
return legacyLayout(
legacyLayout(
layoutAttributes: LayoutAttributes(frame: frame),
environment: environment
)

case .caffeinated(let options):
return caffeinatedLayout(
caffeinatedLayout(
frame: frame,
environment: environment,
node: LayoutTreeNode(
Expand Down
4 changes: 2 additions & 2 deletions BlueprintUI/Sources/Layout/Column.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public struct Column: StackElement {
var stackAlignment: StackLayout.Alignment {
switch self {
case .fill:
return .fill
.fill
case let .align(to: alignment):
return .align(to: alignment.id)
.align(to: alignment.id)
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions BlueprintUI/Sources/Layout/Conditionals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ extension Element {
then: (Self) -> Element
) -> Element {
if isTrue {
return then(self)
then(self)
} else {
return self
self
}
}

Expand All @@ -43,9 +43,9 @@ extension Element {
else: (Self) -> Element
) -> Element {
if isTrue {
return then(self)
then(self)
} else {
return `else`(self)
`else`(self)
}
}

Expand All @@ -66,9 +66,9 @@ extension Element {
then: (Value, Self) -> Element
) -> Element {
if let value = value {
return then(value, self)
then(value, self)
} else {
return self
self
}
}

Expand All @@ -92,9 +92,9 @@ extension Element {
else: (Self) -> Element
) -> Element {
if let value = value {
return then(value, self)
then(value, self)
} else {
return `else`(self)
`else`(self)
}
}

Expand Down
26 changes: 13 additions & 13 deletions BlueprintUI/Sources/Layout/ConstrainedSize.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,34 +71,34 @@ extension ConstrainedSize {
fileprivate func applied(to value: CGFloat) -> CGFloat {
switch self {
case .unconstrained:
return value
value
case let .atMost(max):
return min(max, value)
min(max, value)
case let .atLeast(min):
return max(min, value)
max(min, value)
case let .within(range):
return value.clamped(to: range)
value.clamped(to: range)
case let .absolute(absoluteValue):
return absoluteValue
absoluteValue
}
}

func applied(to constraint: SizeConstraint.Axis) -> SizeConstraint.Axis {
switch constraint {
case .atMost(let maxValue):
return .atMost(applied(to: maxValue))
.atMost(applied(to: maxValue))
case .unconstrained:
switch self {
case .unconstrained:
return .unconstrained
.unconstrained
case let .atMost(max):
return .atMost(max)
.atMost(max)
case .atLeast:
return .unconstrained
.unconstrained
case let .within(range):
return .atMost(range.upperBound)
.atMost(range.upperBound)
case let .absolute(absoluteValue):
return .atMost(absoluteValue)
.atMost(absoluteValue)
}
}
}
Expand Down Expand Up @@ -143,8 +143,8 @@ extension Element {
public func constrained(to sizeConstraint: SizeConstraint) -> ConstrainedSize {
func toConstrainedSize(_ axis: SizeConstraint.Axis) -> ConstrainedSize.Constraint {
switch axis {
case .atMost(let value): return .atMost(value)
case .unconstrained: return .unconstrained
case .atMost(let value): .atMost(value)
case .unconstrained: .unconstrained
}
}

Expand Down
24 changes: 12 additions & 12 deletions BlueprintUI/Sources/Layout/Decorate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public struct Decorate: ProxyElement {
let contentFrame = CGRect(
origin: .zero,
size: context.phase.onMeasure {
self.wrapped.content.measure(
wrapped.content.measure(
in: context.size,
environment: environment
)
Expand All @@ -72,22 +72,22 @@ public struct Decorate: ProxyElement {
}
)

let decorationFrame = self.position.frame(
let decorationFrame = position.frame(
with: contentFrame.size,
decoration: self.decoration,
decoration: decoration,
environment: environment
)

layout.sizing = .fixed(contentFrame.size)

switch self.layering {
switch layering {
case .above:
layout.add(with: contentFrame, child: self.wrapped)
layout.add(with: decorationFrame, child: self.decoration)
layout.add(with: contentFrame, child: wrapped)
layout.add(with: decorationFrame, child: decoration)

case .below:
layout.add(with: decorationFrame, child: self.decoration)
layout.add(with: contentFrame, child: self.wrapped)
layout.add(with: decorationFrame, child: decoration)
layout.add(with: contentFrame, child: wrapped)
}
}
}
Expand Down Expand Up @@ -116,10 +116,10 @@ extension Decorate {

var alignment: Alignment {
switch self {
case .topLeft: return .topLeading
case .topRight: return .topTrailing
case .bottomLeft: return .bottomLeading
case .bottomRight: return .bottomTrailing
case .topLeft: .topLeading
case .topRight: .topTrailing
case .bottomLeft: .bottomLeading
case .bottomRight: .bottomTrailing
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion BlueprintUI/Sources/Layout/GeometryReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public struct GeometryReader: Element {

public var content: ElementContent {
ElementContent { constraint, environment -> Element in
self.elementRepresentation(GeometryProxy(environment: environment, constraint: constraint))
elementRepresentation(GeometryProxy(environment: environment, constraint: constraint))
}
}

Expand Down
8 changes: 4 additions & 4 deletions BlueprintUI/Sources/Layout/GridRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,13 @@ extension GridRow {
private func _yVector(rowHeight: CGFloat) -> (CGFloat) -> (origin: CGFloat, height: CGFloat) {
switch verticalAlignment {
case .fill:
return { _ in (0, rowHeight) }
{ _ in (0, rowHeight) }
case .align(let id) where id == .top:
return { height in (0, height) }
{ height in (0, height) }
case .align(let id) where id == .center:
return { height in ((rowHeight - height) / 2.0, height) }
{ height in ((rowHeight - height) / 2.0, height) }
case .align(let id) where id == .bottom:
return { height in (rowHeight - height, height) }
{ height in (rowHeight - height, height) }
case .align:
fatalError("GridRow supports fill, top, center, and bottom alignment.")
}
Expand Down
2 changes: 1 addition & 1 deletion BlueprintUI/Sources/Layout/Layout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public protocol LegacyLayout {
extension LegacyLayout where Traits == () {

public static var defaultTraits: () {
return ()
()
}

}
Expand Down
14 changes: 7 additions & 7 deletions BlueprintUI/Sources/Layout/LayoutMode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public enum LayoutMode: Equatable {
public var name: String {
switch self {
case .legacy:
return "Legacy"
"Legacy"
case .caffeinated:
return "Caffeinated"
"Caffeinated"
}
}
}
Expand All @@ -47,17 +47,17 @@ extension LayoutMode: CustomStringConvertible {
public var description: String {
switch self {
case .legacy:
return "Legacy"
"Legacy"
case .caffeinated(let options):
switch (options.hintRangeBoundaries, options.searchUnconstrainedKeys) {
case (true, true):
return "Caffeinated (hint+search)"
"Caffeinated (hint+search)"
case (true, false):
return "Caffeinated (hint)"
"Caffeinated (hint)"
case (false, true):
return "Caffeinated (search)"
"Caffeinated (search)"
case (false, false):
return "Caffeinated"
"Caffeinated"
}
}
}
Expand Down
Loading

0 comments on commit cda870e

Please sign in to comment.