Skip to content

Commit

Permalink
Run swift-format
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrandonw authored and actions-user committed Jul 13, 2020
1 parent 80f44fb commit 8cc8492
Show file tree
Hide file tree
Showing 13 changed files with 1,045 additions and 1,041 deletions.
4 changes: 2 additions & 2 deletions Examples/CaseStudies/tvOSCaseStudies/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
Expand All @@ -17,7 +17,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
environment: .init()
)
)

let window = UIWindow(frame: UIScreen.main.bounds)
window.rootViewController = UIHostingController(rootView: contentView)
self.window = window
Expand Down
73 changes: 37 additions & 36 deletions Examples/CaseStudies/tvOSCaseStudies/FocusView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ struct FocusEnvironment {
var randomElement: () -> Int = { (1..<11).randomElement()! }
}

let focusReducer = Reducer<FocusState, FocusAction, FocusEnvironment> { state, action, environment in
let focusReducer = Reducer<FocusState, FocusAction, FocusEnvironment> {
state, action, environment in
switch action {
case .randomButtonClicked:
state.currentFocus = environment.randomElement()
Expand All @@ -31,51 +32,51 @@ let focusReducer = Reducer<FocusState, FocusAction, FocusEnvironment> { state, a
}

#if swift(>=5.3)
@available(tvOS 14.0, *)
struct FocusView: View {
let store: Store<FocusState, FocusAction>
@available(tvOS 14.0, *)
struct FocusView: View {
let store: Store<FocusState, FocusAction>

@Environment(\.resetFocus) var resetFocus
@Namespace private var namespace
@Environment(\.resetFocus) var resetFocus
@Namespace private var namespace

var body: some View {
WithViewStore(self.store) { viewStore in
VStack(spacing: 100) {
Text(readMe)
.font(.headline)
.multilineTextAlignment(.leading)
.padding()
var body: some View {
WithViewStore(self.store) { viewStore in
VStack(spacing: 100) {
Text(readMe)
.font(.headline)
.multilineTextAlignment(.leading)
.padding()

HStack(spacing: 40) {
ForEach(1..<11) { index in
Button(numbers[index]) {}
.prefersDefaultFocus(viewStore.currentFocus == index, in: self.namespace)
HStack(spacing: 40) {
ForEach(1..<11) { index in
Button(numbers[index]) {}
.prefersDefaultFocus(viewStore.currentFocus == index, in: self.namespace)
}
}
}

Button("Focus Random") { viewStore.send(.randomButtonClicked) }
}
.onChange(of: viewStore.currentFocus) { _ in
// Update the view's focus when the state tells us the focus changed.
self.resetFocus(in: self.namespace)
Button("Focus Random") { viewStore.send(.randomButtonClicked) }
}
.onChange(of: viewStore.currentFocus) { _ in
// Update the view's focus when the state tells us the focus changed.
self.resetFocus(in: self.namespace)
}
.focusScope(self.namespace)
}
.focusScope(self.namespace)
}
}
}

@available(tvOS 14.0, *)
struct FocusView_Previews: PreviewProvider {
static var previews: some View {
FocusView(
store: .init(
initialState: .init(),
reducer: focusReducer,
environment: .init()
@available(tvOS 14.0, *)
struct FocusView_Previews: PreviewProvider {
static var previews: some View {
FocusView(
store: .init(
initialState: .init(),
reducer: focusReducer,
environment: .init()
)
)
)
}
}
}
#endif

private let numbers = [
Expand All @@ -89,5 +90,5 @@ private let numbers = [
"Seven",
"Eight",
"Nine",
"Ten"
"Ten",
]
24 changes: 12 additions & 12 deletions Examples/CaseStudies/tvOSCaseStudies/RootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import SwiftUI

struct RootView: View {
let store: Store<RootState, RootAction>

var body: some View {
NavigationView {
Form {
Expand All @@ -13,21 +13,21 @@ struct RootView: View {
}
}
}

var focusView: AnyView? {
if #available(tvOS 14.0, *) {
#if swift(>=5.3)
return AnyView(
NavigationLink(
destination: FocusView(
store: self.store.scope(state: { $0.focus }, action: RootAction.focus)
),
label: {
Text("Focus")
})
)
return AnyView(
NavigationLink(
destination: FocusView(
store: self.store.scope(state: { $0.focus }, action: RootAction.focus)
),
label: {
Text("Focus")
})
)
#else
return nil
return nil
#endif
} else {
return nil
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import XCTest

@testable import tvOSCaseStudies

class tvOSCaseStudiesTests: XCTestCase {
Expand Down
4 changes: 2 additions & 2 deletions Sources/ComposableCoreMotion/Internal/Exports.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if canImport(CoreMotion)
@_exported import ComposableArchitecture
@_exported import CoreMotion
@_exported import ComposableArchitecture
@_exported import CoreMotion
#endif
34 changes: 17 additions & 17 deletions Sources/ComposableCoreMotion/Models/AccelerometerData.swift
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#if canImport(CoreMotion)
import CoreMotion
import CoreMotion

/// A data sample from the device's three accelerometers.
///
/// See the documentation for `CMAccelerometerData` for more info.
public struct AccelerometerData: Equatable {
public var acceleration: CMAcceleration
/// A data sample from the device's three accelerometers.
///
/// See the documentation for `CMAccelerometerData` for more info.
public struct AccelerometerData: Equatable {
public var acceleration: CMAcceleration

public init(_ accelerometerData: CMAccelerometerData) {
self.acceleration = accelerometerData.acceleration
}
public init(_ accelerometerData: CMAccelerometerData) {
self.acceleration = accelerometerData.acceleration
}

public init(acceleration: CMAcceleration) {
self.acceleration = acceleration
}
public init(acceleration: CMAcceleration) {
self.acceleration = acceleration
}

public static func == (lhs: Self, rhs: Self) -> Bool {
lhs.acceleration.x == rhs.acceleration.x
&& lhs.acceleration.y == rhs.acceleration.y
&& lhs.acceleration.z == rhs.acceleration.z
public static func == (lhs: Self, rhs: Self) -> Bool {
lhs.acceleration.x == rhs.acceleration.x
&& lhs.acceleration.y == rhs.acceleration.y
&& lhs.acceleration.z == rhs.acceleration.z
}
}
}
#endif
Loading

0 comments on commit 8cc8492

Please sign in to comment.