Skip to content

Commit

Permalink
Run swift-format
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencelis authored and github-actions[bot] committed Aug 2, 2024
1 parent 181925d commit f6aee43
Show file tree
Hide file tree
Showing 25 changed files with 374 additions and 178 deletions.
10 changes: 4 additions & 6 deletions Examples/CaseStudies/Internal/CaseStudy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,9 @@ struct UIKitCaseStudyButton<C: UIKitCaseStudy>: View {
}
.sheet(isPresented: $isPresented) {
UIViewControllerRepresenting {
(
(caseStudy as? UINavigationController)
?? UINavigationController(rootViewController: caseStudy)
)
.setUp(caseStudy: caseStudy)
((caseStudy as? UINavigationController)
?? UINavigationController(rootViewController: caseStudy))
.setUp(caseStudy: caseStudy)
}
.modifier(CaseStudyModifier(caseStudy: caseStudy))
}
Expand All @@ -110,7 +108,7 @@ extension UINavigationController {
rootView: Form {
Text(template: caseStudy.readMe)
}
.presentationDetents([.medium])
.presentationDetents([.medium])
),
animated: true
)
Expand Down
2 changes: 1 addition & 1 deletion Examples/CaseStudies/SwiftUI/EnumNavigation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct EnumNavigation: SwiftUICaseStudy {
"""

@State var destination: Destination?

var body: some View {
Section {
Button("Alert is presented: \(destination.is(\.alert) ? "" : "")") {
Expand Down
10 changes: 6 additions & 4 deletions Examples/CaseStudies/UIKit/AnimationsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ class AnimationsViewController: UIViewController, UIKitCaseStudy {
let scaleStack = UIStackView(arrangedSubviews: [scaleLabel, isScaledSwitch])
scaleStack.spacing = 12
scaleStack.axis = .horizontal
let colorsButton = UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
guard let self else { return }
Task { await self.model.cycleColors() }
})
let colorsButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
guard let self else { return }
Task { await self.model.cycleColors() }
})
colorsButton.setTitle("Cycle colors", for: .normal)
let stack = UIStackView(arrangedSubviews: [
scaleStack,
Expand Down
26 changes: 16 additions & 10 deletions Examples/CaseStudies/UIKit/BasicsNavigationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,26 @@ class BasicsNavigationViewController: UIViewController, UIKitCaseStudy {
super.viewDidLoad()
view.backgroundColor = .systemBackground

let showAlertButton = UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
self?.model.alert = "Hello!"
})
let showSheetButton = UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
self?.model.sheet = .random(in: 1...1_000)
})
let showAlertButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
self?.model.alert = "Hello!"
})
let showSheetButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
self?.model.sheet = .random(in: 1...1_000)
})
let showSheetFromBooleanButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
self?.model.isSheetPresented = true
})
let drillDownButton = UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
self?.model.drillDown = .random(in: 1...1_000)
})
})
let drillDownButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
self?.model.drillDown = .random(in: 1...1_000)
})

let stack = UIStackView(arrangedSubviews: [
showAlertButton,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,26 @@ class ConciseEnumNavigationViewController: UIViewController, UIKitCaseStudy {
super.viewDidLoad()
view.backgroundColor = .systemBackground

let showAlertButton = UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
self?.model.destination = .alert("Hello!")
})
let showSheetButton = UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
self?.model.destination = .sheet(.random(in: 1...1_000))
})
let showAlertButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
self?.model.destination = .alert("Hello!")
})
let showSheetButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
self?.model.destination = .sheet(.random(in: 1...1_000))
})
let showSheetFromBooleanButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
self?.model.destination = .sheetWithoutPayload
})
let drillDownButton = UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
self?.model.destination = .drillDown(.random(in: 1...1_000))
})
let drillDownButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
self?.model.destination = .drillDown(.random(in: 1...1_000))
})

let stack = UIStackView(arrangedSubviews: [
showAlertButton,
Expand Down Expand Up @@ -128,4 +134,3 @@ class ConciseEnumNavigationViewController: UIViewController, UIKitCaseStudy {
rootViewController: BasicsNavigationViewController()
)
}

24 changes: 14 additions & 10 deletions Examples/CaseStudies/UIKit/EnumControlsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ class EnumControlsViewController: UIViewController, UIKitCaseStudy {
quantityStepper.maximumValue = .infinity
let quantityStack = UIStackView(arrangedSubviews: [
quantityLabel,
quantityStepper
quantityStepper,
])
let outOfStockButton = UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
self?.status = .outOfStock(isOnBackOrder: false)
})
let outOfStockButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
self?.status = .outOfStock(isOnBackOrder: false)
})
outOfStockButton.setTitle("Out of stock", for: .normal)
let inStockStack = UIStackView(arrangedSubviews: [
quantityStack,
outOfStockButton
outOfStockButton,
])
inStockStack.axis = .vertical

Expand All @@ -49,15 +51,17 @@ class EnumControlsViewController: UIViewController, UIKitCaseStudy {
let isOnBackOrderSwitch = UISwitch()
let isOnBackOrderStack = UIStackView(arrangedSubviews: [
isOnBackOrderLabel,
isOnBackOrderSwitch
isOnBackOrderSwitch,
])
let backInStockButton = UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
self?.status = .inStock(quantity: 100)
})
let backInStockButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
self?.status = .inStock(quantity: 100)
})
backInStockButton.setTitle("Back in stock!", for: .normal)
let outOfStockStack = UIStackView(arrangedSubviews: [
isOnBackOrderStack,
backInStockButton
backInStockButton,
])
outOfStockStack.axis = .vertical

Expand Down
110 changes: 68 additions & 42 deletions Examples/CaseStudies/UIKit/ErasedNavigationStackController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,20 @@ private class RootViewController: UIViewController {
NumberFeatureViewController(number: number)
}

let numberButton = UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
self?.traitCollection.push(value: Int.random(in: 1...1_000))
})
let numberButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
self?.traitCollection.push(value: Int.random(in: 1...1_000))
})
numberButton.setTitle("Push number feature", for: .normal)

let deepLinkButton = UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
self?.traitCollection.push(value: Int.random(in: 1...1_000))
self?.traitCollection.push(value: "Hello!")
self?.traitCollection.push(value: Bool.random())
})
let deepLinkButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
self?.traitCollection.push(value: Int.random(in: 1...1_000))
self?.traitCollection.push(value: "Hello!")
self?.traitCollection.push(value: Bool.random())
})
deepLinkButton.setTitle("Push features: number → string → bool", for: .normal)

let stack = UIStackView(arrangedSubviews: [
Expand Down Expand Up @@ -89,19 +93,25 @@ private class NumberFeatureViewController: UIViewController {
StringFeatureViewController(string: string)
}

let numberButton = UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
self?.traitCollection.push(value: Int.random(in: 1...1_000))
})
let numberButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
self?.traitCollection.push(value: Int.random(in: 1...1_000))
})
numberButton.setTitle("Push number feature", for: .normal)

let stringButton = UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
self?.traitCollection.push(value: "Hello!")
})
let stringButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
self?.traitCollection.push(value: "Hello!")
})
stringButton.setTitle("Push string feature", for: .normal)

let dismissButton = UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
self?.traitCollection.dismiss()
})
let dismissButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
self?.traitCollection.dismiss()
})
dismissButton.setTitle("Dismiss", for: .normal)

let stack = UIStackView(arrangedSubviews: [
Expand All @@ -123,7 +133,7 @@ private class NumberFeatureViewController: UIViewController {

private class StringFeatureViewController: UIViewController {
let string: String
init(string: String ) {
init(string: String) {
self.string = string
super.init(nibName: nil, bundle: nil)
title = "Feature '\(string)'"
Expand All @@ -139,24 +149,32 @@ private class StringFeatureViewController: UIViewController {
BoolFeatureViewController(bool: bool)
}

let numberButton = UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
self?.traitCollection.push(value: Int.random(in: 1...1_000))
})
let numberButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
self?.traitCollection.push(value: Int.random(in: 1...1_000))
})
numberButton.setTitle("Push number feature", for: .normal)

let stringButton = UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
self?.traitCollection.push(value: "Hello!")
})
let stringButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
self?.traitCollection.push(value: "Hello!")
})
stringButton.setTitle("Push string feature", for: .normal)

let boolButton = UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
self?.traitCollection.push(value: "\(Bool.random())")
})
let boolButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
self?.traitCollection.push(value: "\(Bool.random())")
})
boolButton.setTitle("Push boolean feature", for: .normal)

let dismissButton = UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
self?.traitCollection.dismiss()
})
let dismissButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
self?.traitCollection.dismiss()
})
dismissButton.setTitle("Dismiss", for: .normal)

let stack = UIStackView(arrangedSubviews: [
Expand Down Expand Up @@ -191,24 +209,32 @@ private class BoolFeatureViewController: UIViewController {
super.viewDidLoad()
view.backgroundColor = .systemBackground

let numberButton = UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
self?.traitCollection.push(value: Int.random(in: 1...1_000))
})
let numberButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
self?.traitCollection.push(value: Int.random(in: 1...1_000))
})
numberButton.setTitle("Push number feature", for: .normal)

let stringButton = UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
self?.traitCollection.push(value: "Hello!")
})
let stringButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
self?.traitCollection.push(value: "Hello!")
})
stringButton.setTitle("Push string feature", for: .normal)

let boolButton = UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
self?.traitCollection.push(value: "\(Bool.random())")
})
let boolButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
self?.traitCollection.push(value: "\(Bool.random())")
})
boolButton.setTitle("Push boolean feature", for: .normal)

let dismissButton = UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
self?.traitCollection.dismiss()
})
let dismissButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
self?.traitCollection.dismiss()
})
dismissButton.setTitle("Dismiss", for: .normal)

let stack = UIStackView(arrangedSubviews: [
Expand Down
46 changes: 28 additions & 18 deletions Examples/CaseStudies/UIKit/FocusViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,38 @@ class FocusViewController: UIViewController, UIKitCaseStudy {

let currentFocusLabel = UILabel()

let focusBioButton = UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
self?.model.focus = .bio
})
let focusBioButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
self?.model.focus = .bio
})
focusBioButton.setTitle("Focus bio", for: .normal)
let focusEmailButton = UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
self?.model.focus = .email
})
let focusEmailButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
self?.model.focus = .email
})
focusEmailButton.setTitle("Focus email", for: .normal)
let focusPasswordButton = UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
self?.model.focus = .password
})
let focusPasswordButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
self?.model.focus = .password
})
focusPasswordButton.setTitle("Focus password", for: .normal)
let focusUsernameButton = UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
self?.model.focus = .username
})
let focusUsernameButton = UIButton(
type: .system,
primaryAction: UIAction { [weak self] _ in
self?.model.focus = .username
})
focusUsernameButton.setTitle("Focus username", for: .normal)
let resignFirstResponder = UIButton(type: .system, primaryAction: UIAction { _ in
bioTextField.resignFirstResponder()
emailTextField.resignFirstResponder()
passwordTextField.resignFirstResponder()
usernameTextField.resignFirstResponder()
})
let resignFirstResponder = UIButton(
type: .system,
primaryAction: UIAction { _ in
bioTextField.resignFirstResponder()
emailTextField.resignFirstResponder()
passwordTextField.resignFirstResponder()
usernameTextField.resignFirstResponder()
})
resignFirstResponder.setTitle("Resign first responder", for: .normal)

let stack = UIStackView(arrangedSubviews: [
Expand Down
Loading

0 comments on commit f6aee43

Please sign in to comment.