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 9, 2022
1 parent f132bd0 commit 699db8a
Show file tree
Hide file tree
Showing 23 changed files with 79 additions and 72 deletions.
2 changes: 1 addition & 1 deletion App/Previews/GameOverPreview/GameOverPreviewApp.swift
Expand Up @@ -16,7 +16,7 @@ struct GameOverPreviewApp: App {
WindowGroup {
GameOverView(
store: .solo
// store: .multiplayer
// store: .multiplayer
)
}
}
Expand Down
22 changes: 11 additions & 11 deletions App/Previews/LeaderboardsPreview/LeaderboardsPreviewApp.swift
Expand Up @@ -37,17 +37,17 @@ struct LeaderboardsPreviewApp: App {
score: 4_000 - index * 100
)
}
+ [
.init(
id: .init(rawValue: UUID()),
isSupporter: false,
isYourScore: true,
outOf: 2_000,
playerDisplayName: "Blob Sr.",
rank: 100,
score: 1_000
)
]
+ [
.init(
id: .init(rawValue: UUID()),
isSupporter: false,
isYourScore: true,
outOf: 2_000,
playerDisplayName: "Blob Sr.",
rank: 100,
score: 1_000
)
]
)
)
}
Expand Down
4 changes: 3 additions & 1 deletion App/Previews/SettingsPreview/SettingsPreviewApp.swift
Expand Up @@ -39,7 +39,9 @@ struct SettingsPreviewApp: App {
setUserInterfaceStyle: { userInterfaceStyle in
await MainActor.run {
guard
let scene = UIApplication.shared.connectedScenes.first(where: { $0 is UIWindowScene })
let scene = UIApplication.shared.connectedScenes.first(where: {
$0 is UIWindowScene
})
as? UIWindowScene
else { return }
scene.keyWindow?.overrideUserInterfaceStyle = userInterfaceStyle
Expand Down
2 changes: 1 addition & 1 deletion Sources/ApiClient/Client.swift
Expand Up @@ -8,7 +8,7 @@ public struct ApiClient {
public var authenticate:
@Sendable (ServerRoute.AuthenticateRequest) async throws -> CurrentPlayerEnvelope
public var baseUrl: @Sendable () -> URL
public var currentPlayer: @Sendable() -> CurrentPlayerEnvelope?
public var currentPlayer: @Sendable () -> CurrentPlayerEnvelope?
public var logout: @Sendable () async -> Void
public var refreshCurrentPlayer: @Sendable () async throws -> CurrentPlayerEnvelope
public var request: @Sendable (ServerRoute) async throws -> (Data, URLResponse)
Expand Down
7 changes: 3 additions & 4 deletions Sources/AppFeature/AppView.swift
Expand Up @@ -235,10 +235,9 @@ let appReducerCore = Reducer<AppState, AppAction, AppEnvironment> { state, actio
}

case let .appDelegate(.userNotifications(.didReceiveResponse(response, completionHandler))):
if
let data =
try? JSONSerialization
.data(withJSONObject: response.notification.request.content.userInfo),
if let data =
try? JSONSerialization
.data(withJSONObject: response.notification.request.content.userInfo),
let pushNotificationContent = try? JSONDecoder()
.decode(PushNotificationContent.self, from: data)
{
Expand Down
8 changes: 4 additions & 4 deletions Sources/AppFeature/StoreKitCore.swift
Expand Up @@ -28,8 +28,7 @@ extension Reducer where Action == AppAction, Environment == AppEnvironment {
let verifiableTransactions = transactions.filter { $0.transactionState.canBeVerified }
let otherTransactions = transactions.filter { !$0.transactionState.canBeVerified }

if
!verifiableTransactions.isEmpty,
if !verifiableTransactions.isEmpty,
let appStoreReceiptURL = environment.storeKit.appStoreReceiptURL(),
let receiptData = try? Data(contentsOf: appStoreReceiptURL, options: .alwaysMapped)
{
Expand Down Expand Up @@ -66,8 +65,9 @@ extension Reducer where Action == AppAction, Environment == AppEnvironment {
return .fireAndForget {
for transaction in envelope.transactions
where envelope.verifyEnvelope.verifiedProductIds
.contains(where: { $0 == transaction.payment.productIdentifier }) {
await environment.storeKit.finishTransaction(transaction)
.contains(where: { $0 == transaction.payment.productIdentifier })
{
await environment.storeKit.finishTransaction(transaction)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/AudioPlayerClient/Client.swift
Expand Up @@ -7,7 +7,7 @@ public struct AudioPlayerClient {
public var secondaryAudioShouldBeSilencedHint: @Sendable () async -> Bool
public var setGlobalVolumeForMusic: @Sendable (Float) async -> Void
public var setGlobalVolumeForSoundEffects: @Sendable (Float) async -> Void
public var setVolume: @Sendable (Sound, Float) async ->Void
public var setVolume: @Sendable (Sound, Float) async -> Void
public var stop: @Sendable (Sound) async -> Void

public struct Sound: Hashable {
Expand Down
2 changes: 1 addition & 1 deletion Sources/ComposableGameCenter/CrossPlatformSupport.swift
Expand Up @@ -6,7 +6,7 @@
public func present() {
guard
let scene = UIKit.UIApplication.shared.connectedScenes.first(where: { $0 is UIWindowScene })
as? UIWindowScene
as? UIWindowScene
else { return }
scene.keyWindow?.rootViewController?.present(self, animated: true)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/ComposableStoreKit/Live.swift
Expand Up @@ -42,7 +42,7 @@ extension StoreKitClient {
guard
let scene = await UIApplication.shared.connectedScenes
.first(where: { $0 is UIWindowScene })
as? UIWindowScene
as? UIWindowScene
else { return }
await SKStoreReviewController.requestReview(in: scene)
},
Expand Down
3 changes: 1 addition & 2 deletions Sources/ComposableUserNotifications/Interface.swift
Expand Up @@ -7,8 +7,7 @@ public struct UserNotificationClient {
public var delegate: @Sendable () -> AsyncStream<DelegateEvent>
public var getNotificationSettings: @Sendable () async -> Notification.Settings
public var removeDeliveredNotificationsWithIdentifiers: @Sendable ([String]) async -> Void
public var removePendingNotificationRequestsWithIdentifiers:
@Sendable ([String]) async -> Void
public var removePendingNotificationRequestsWithIdentifiers: @Sendable ([String]) async -> Void
public var requestAuthorization: @Sendable (UNAuthorizationOptions) async throws -> Bool

public enum DelegateEvent: Equatable {
Expand Down
2 changes: 1 addition & 1 deletion Sources/FileClient/Client.swift
Expand Up @@ -12,7 +12,7 @@ public struct FileClient {
try await JSONDecoder().decode(A.self, from: self.load(fileName))
}

public func save<A: Encodable>(_ data: A, to fileName: String) async throws -> Void {
public func save<A: Encodable>(_ data: A, to fileName: String) async throws {
try await self.save(fileName, JSONEncoder().encode(data))
}
}
2 changes: 1 addition & 1 deletion Sources/FileClient/Mocks.swift
Expand Up @@ -20,7 +20,7 @@ extension FileClient {

public mutating func override<A: Encodable>(load file: String, _ data: A) {
let fulfill = expectation(description: "FileClient.load(\(file))")
self.load = { @Sendable [self] in
self.load = { @Sendable[self] in
if $0 == file {
fulfill()
return try JSONEncoder().encode(data)
Expand Down
10 changes: 4 additions & 6 deletions Sources/GameCore/GameCore.swift
Expand Up @@ -1128,12 +1128,10 @@ extension Reducer where State == GameState, Action == GameAction, Environment ==
TaskResult {
if state.isGameOver {
let completedGame = CompletedGame(gameState: state)
if
let completedMatch = CompletedMatch(
completedGame: completedGame,
turnBasedContext: turnBasedContext
)
{
if let completedMatch = CompletedMatch(
completedGame: completedGame,
turnBasedContext: turnBasedContext
) {
try await environment.gameCenter.turnBasedMatch.endMatchInTurn(
.init(
for: turnBasedContext.match.matchId,
Expand Down
12 changes: 7 additions & 5 deletions Sources/GameCore/SoundsCore.swift
Expand Up @@ -89,13 +89,15 @@ extension Reducer where State == GameState, Action == GameAction, Environment ==
if cubeIsShaking {
state.cubeStartedShakingAt = state.cubeStartedShakingAt ?? environment.date()

return cubeWasShaking ? .none : .fireAndForget {
await environment.audioPlayer.play(.cubeShake)
for await _ in environment.mainQueue.timer(interval: .seconds(2)) {
return cubeWasShaking
? .none
: .fireAndForget {
await environment.audioPlayer.play(.cubeShake)
for await _ in environment.mainQueue.timer(interval: .seconds(2)) {
await environment.audioPlayer.play(.cubeShake)
}
}
}
.cancellable(id: CubeShakingID.self)
.cancellable(id: CubeShakingID.self)

} else {
state.cubeStartedShakingAt = nil
Expand Down
4 changes: 2 additions & 2 deletions Sources/LeaderboardFeature/Leaderboard.swift
Expand Up @@ -347,7 +347,7 @@ extension ApiClient {
}
)
}
?? .init()
?? .init()
}
}

Expand All @@ -374,7 +374,7 @@ extension ApiClient {
results: response.map(ResultEnvelope.Result.init)
)
}
?? .init()
?? .init()
}
}

Expand Down
5 changes: 3 additions & 2 deletions Sources/LowPowerModeClient/Mocks.swift
Expand Up @@ -8,7 +8,7 @@ extension LowPowerModeClient {
public static let `false` = Self(
start: { AsyncStream { $0.yield(false) } }
)

public static let `true` = Self(
start: { AsyncStream { $0.yield(true) } }
)
Expand All @@ -25,7 +25,8 @@ extension LowPowerModeClient {
Task {
await continuation.yield(isLowPowerModeEnabled.value)
for await _ in DispatchQueue.main.timer(interval: 2) {
let isLowPowerModeEnabled = await isLowPowerModeEnabled
let isLowPowerModeEnabled =
await isLowPowerModeEnabled
.withValue { isLowPowerModeEnabled -> Bool in
isLowPowerModeEnabled.toggle()
return isLowPowerModeEnabled
Expand Down
4 changes: 2 additions & 2 deletions Sources/ServerConfigClient/Live.swift
Expand Up @@ -8,8 +8,8 @@ extension ServerConfigClient {
Self(
config: {
(UserDefaults.standard.object(forKey: serverConfigKey) as? Data)
.flatMap { try? jsonDecoder.decode(ServerConfig.self, from: $0) }
?? ServerConfig()
.flatMap { try? jsonDecoder.decode(ServerConfig.self, from: $0) }
?? ServerConfig()
},
refresh: {
let config = try await fetch()
Expand Down
2 changes: 1 addition & 1 deletion Sources/SettingsFeature/FileClientEffects.swift
Expand Up @@ -6,7 +6,7 @@ extension FileClient {
try await self.load(UserSettings.self, from: userSettingsFileName)
}

public func save(userSettings: UserSettings) async throws -> Void {
public func save(userSettings: UserSettings) async throws {
try await self.save(userSettings, to: userSettingsFileName)
}
}
Expand Down
25 changes: 13 additions & 12 deletions Sources/SettingsFeature/Settings.swift
Expand Up @@ -551,18 +551,19 @@ public let settingsReducer = Reducer<SettingsState, SettingsAction, SettingsEnvi
}
}

async let productsResponse: Void = shouldFetchProducts
? send(
.productsResponse(
TaskResult {
try await environment.storeKit.fetchProducts([
environment.serverConfig.config().productIdentifiers.fullGame
])
}
),
animation: .default
)
: ()
async let productsResponse: Void =
shouldFetchProducts
? send(
.productsResponse(
TaskResult {
try await environment.storeKit.fetchProducts([
environment.serverConfig.config().productIdentifiers.fullGame
])
}
),
animation: .default
)
: ()

async let settingsResponse: Void = send(
.userNotificationSettingsResponse(
Expand Down
2 changes: 1 addition & 1 deletion Sources/TcaHelpers/OptionalPaths.swift
Expand Up @@ -205,7 +205,7 @@ extension Reducer {
"\(file)",
line,
"\(globalAction)",
"\(State.self)"
"\(State.self)",
]
)
#endif
Expand Down
12 changes: 7 additions & 5 deletions Sources/TrailerFeature/Trailer.swift
Expand Up @@ -109,7 +109,7 @@ public let trailerReducer = Reducer<TrailerState, TrailerAction, TrailerEnvironm
case .task:
return .run { send in
await environment.audioPlayer.load(AudioPlayerClient.Sound.allCases)

// Play trailer music
await environment.audioPlayer.play(.onboardingBgMusic)

Expand All @@ -134,7 +134,8 @@ public let trailerReducer = Reducer<TrailerState, TrailerAction, TrailerEnvironm
)

try await environment.mainQueue.sleep(
for: .seconds(.random(in: (0.3*moveNubToFaceDuration)...(0.7*moveNubToFaceDuration)))
for: .seconds(
.random(in: (0.3 * moveNubToFaceDuration)...(0.7 * moveNubToFaceDuration)))
)
// Press the nub on the first character
if characterIndex == 0 {
Expand All @@ -159,8 +160,9 @@ public let trailerReducer = Reducer<TrailerState, TrailerAction, TrailerEnvironm
try await environment.mainQueue.sleep(
for: .seconds(
.random(
in: moveNubToSubmitButtonDuration ...
(moveNubToSubmitButtonDuration + submitHestitationDuration)
in:
moveNubToSubmitButtonDuration...(moveNubToSubmitButtonDuration
+ submitHestitationDuration)
)
)
)
Expand All @@ -175,7 +177,7 @@ public let trailerReducer = Reducer<TrailerState, TrailerAction, TrailerEnvironm
try await environment.mainQueue.sleep(for: .seconds(0.2))
await send(.game(.submitButtonTapped(reaction: nil)))
try await environment.mainQueue.sleep(for: .seconds(0.3))
await send(.set(\.$nub.isPressed, false), animateWithDuration: 0.3 )
await send(.set(\.$nub.isPressed, false), animateWithDuration: 0.3)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/UIApplicationClient/Mocks.swift
Expand Up @@ -21,7 +21,7 @@ extension UIApplicationClient {
public static let noop = Self(
alternateIconName: { nil },
alternateIconNameAsync: { nil },
open: { _, _ in false},
open: { _, _ in false },
openSettingsURLString: { "settings://isowords/settings" },
setAlternateIconName: { _ in },
supportsAlternateIcons: { true },
Expand Down
15 changes: 9 additions & 6 deletions Sources/UpgradeInterstitialFeature/UpgradeInterstitialView.swift
Expand Up @@ -101,9 +101,10 @@ public let upgradeInterstitialReducer = Reducer<
}
}

guard event.isFullGamePurchased(
identifier: environment.serverConfig.config().productIdentifiers.fullGame
)
guard
event.isFullGamePurchased(
identifier: environment.serverConfig.config().productIdentifiers.fullGame
)
else { return .none }
return .task { .delegate(.fullGamePurchased) }

Expand All @@ -123,9 +124,11 @@ public let upgradeInterstitialReducer = Reducer<
let response = try await environment.storeKit.fetchProducts([
environment.serverConfig.config().productIdentifiers.fullGame
])
guard let product = response.products.first(where: { product in
product.productIdentifier == environment.serverConfig.config().productIdentifiers.fullGame
})
guard
let product = response.products.first(where: { product in
product.productIdentifier
== environment.serverConfig.config().productIdentifiers.fullGame
})
else { return }
await send(.fullGameProductResponse(product), animation: .default)
}
Expand Down

0 comments on commit 699db8a

Please sign in to comment.