Skip to content

Commit 8cfc8c6

Browse files
committed
Formatting
Signed-off-by: Peter Friese <[email protected]>
1 parent a600525 commit 8cfc8c6

28 files changed

+2032
-3263
lines changed

Examples/FriendlyFlix/app/FriendlyFlix/FriendlyFlix/App/FriendlyFlixApp.swift

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// FriendlyFlixMocksApp.swift
2+
// FriendlyFlixApp.swift
33
// FriendlyFlixMocks
44
//
55
// Created by Peter Friese on 28.09.24.
@@ -16,22 +16,25 @@
1616
// See the License for the specific language governing permissions and
1717
// limitations under the License.
1818

19-
import SwiftUI
2019
import Firebase
2120
import FirebaseAuth
2221
import FirebaseDataConnect
2322
import FriendlyFlixSDK
23+
import SwiftUI
2424

2525
@main
2626
struct FriendlyFlixApp: App {
2727
private func loadRocketSimConnect() {
28-
#if DEBUG
29-
guard (Bundle(path: "/Applications/RocketSim.app/Contents/Frameworks/RocketSimConnectLinker.nocache.framework")?.load() == true) else {
30-
print("Failed to load linker framework")
31-
return
32-
}
33-
print("RocketSim Connect successfully linked")
34-
#endif
28+
#if DEBUG
29+
guard Bundle(
30+
path: "/Applications/RocketSim.app/Contents/Frameworks/RocketSimConnectLinker.nocache.framework"
31+
)?
32+
.load() == true else {
33+
print("Failed to load linker framework")
34+
return
35+
}
36+
print("RocketSim Connect successfully linked")
37+
#endif
3538
}
3639

3740
var authenticationService: AuthenticationService?
@@ -42,7 +45,9 @@ struct FriendlyFlixApp: App {
4245

4346
authenticationService = AuthenticationService()
4447
authenticationService?.onSignUp { user in
45-
print("User signed in \(user.displayName ?? "(no fullname)") with email \(user.email ?? "(no email)")")
48+
print(
49+
"User signed in \(user.displayName ?? "(no fullname)") with email \(user.email ?? "(no email)")"
50+
)
4651
let userName = String(user.email?.split(separator: "@").first ?? "(unknown)")
4752
Task {
4853
try await DataConnect.friendlyFlixConnector.upsertUserMutation.execute(username: userName)

Examples/FriendlyFlix/app/FriendlyFlix/FriendlyFlix/Features/Authentication/AccountScreen.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ struct AccountScreen: View {
3434
do {
3535
try authenticationService.signOut()
3636
dismiss()
37-
}
38-
catch {
39-
}
37+
} catch {}
4038
}
4139
}
4240

@@ -67,7 +65,7 @@ extension AccountScreen {
6765
.navigationBarTitleDisplayMode(.inline)
6866
.toolbar {
6967
ToolbarItem {
70-
Button(action: {dismiss()}) {
68+
Button(action: { dismiss() }) {
7169
Text("Done")
7270
}
7371
}

Examples/FriendlyFlix/app/FriendlyFlix/FriendlyFlix/Features/Authentication/AuthenticationScreen.swift

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
// See the License for the specific language governing permissions and
1717
// limitations under the License.
1818

19-
import SwiftUI
2019
import AuthenticationServices
20+
import SwiftUI
2121

2222
private enum FocusableField: Hashable {
2323
case email
@@ -44,11 +44,10 @@ struct AuthenticationScreen: View {
4444
@State private var errorMessage = ""
4545
@State private var displayName = ""
4646

47-
private var isValid: Bool {
47+
private var isValid: Bool {
4848
return if flow == .login {
4949
!email.isEmpty && !password.isEmpty
50-
}
51-
else {
50+
} else {
5251
!email.isEmpty && !password.isEmpty && password == confirmPassword
5352
}
5453
}
@@ -78,8 +77,7 @@ struct AuthenticationScreen: View {
7877
try await authenticationService.signUpWithEmailPassword(email: email, password: password)
7978
errorMessage = ""
8079
dismiss()
81-
}
82-
catch {
80+
} catch {
8381
print(error.localizedDescription)
8482
errorMessage = error.localizedDescription
8583
}
@@ -147,14 +145,13 @@ extension AuthenticationScreen {
147145

148146
Button(action: {
149147
if flow == .login { signInWithEmailPassword() }
150-
else { signUpWithEmailPassword()}
151-
} ) {
148+
else { signUpWithEmailPassword() }
149+
}) {
152150
if authenticationService.authenticationState != .authenticating {
153151
Text(flow == .login ? "Log in with password" : "Sign up")
154152
.padding(.vertical, 8)
155153
.frame(maxWidth: .infinity)
156-
}
157-
else {
154+
} else {
158155
ProgressView()
159156
.progressViewStyle(CircularProgressViewStyle(tint: .white))
160157
.padding(.vertical, 8)

Examples/FriendlyFlix/app/FriendlyFlix/FriendlyFlix/Features/Authentication/AuthenticationService.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
import FirebaseAuth
1516
import Foundation
1617
import Observation
17-
import FirebaseAuth
1818

1919
enum AuthenticationState {
2020
case unauthenticated
@@ -28,7 +28,7 @@ class AuthenticationService {
2828
var presentingAccountDialog = false
2929

3030
var authenticationState: AuthenticationState = .unauthenticated
31-
var user: User? = nil
31+
var user: User?
3232

3333
private var authenticationListener: AuthStateDidChangeListenerHandle?
3434

@@ -37,8 +37,7 @@ class AuthenticationService {
3737
if let user {
3838
self.authenticationState = .authenticated
3939
self.user = user
40-
}
41-
else {
40+
} else {
4241
self.authenticationState = .unauthenticated
4342
}
4443
}
@@ -60,7 +59,7 @@ class AuthenticationService {
6059
if let onSignUp, let user = Auth.auth().currentUser {
6160
onSignUp(user)
6261
}
63-
62+
6463
authenticationState = .authenticated
6564
}
6665

Examples/FriendlyFlix/app/FriendlyFlix/FriendlyFlix/Features/Authentication/AuthenticationToolbarButton.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ struct AuthenticationToolbarButton: View {
2424
private func onButtonTapped() {
2525
if authenticationService.authenticationState == .unauthenticated {
2626
authenticationService.presentingAuthenticationDialog.toggle()
27-
}
28-
else {
27+
} else {
2928
authenticationService.presentingAccountDialog.toggle()
3029
}
3130
}
@@ -34,7 +33,8 @@ struct AuthenticationToolbarButton: View {
3433
extension AuthenticationToolbarButton {
3534
var body: some View {
3635
Button(action: onButtonTapped) {
37-
Image(systemName: authenticationService.authenticationState == .unauthenticated ? "person.circle" : "person.circle.fill")
36+
Image(systemName: authenticationService
37+
.authenticationState == .unauthenticated ? "person.circle" : "person.circle.fill")
3838
}
3939
}
4040
}

Examples/FriendlyFlix/app/FriendlyFlix/FriendlyFlix/Features/Details/MovieCardView.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@
1616
// See the License for the specific language governing permissions and
1717
// limitations under the License.
1818

19-
20-
import SwiftUI
21-
import NukeUI
2219
import FirebaseDataConnect
2320
import FriendlyFlixSDK
21+
import NukeUI
22+
import SwiftUI
2423

2524
struct MovieCardView: View {
2625
@Environment(\.dismiss) private var dismiss
@@ -38,7 +37,10 @@ struct MovieCardView: View {
3837

3938
// MARK: - Favourite handling
4039

41-
private let isFavouriteRef: QueryRefObservation<GetIfFavoritedMovieQuery.Data, GetIfFavoritedMovieQuery.Variables>
40+
private let isFavouriteRef: QueryRefObservation<
41+
GetIfFavoritedMovieQuery.Data,
42+
GetIfFavoritedMovieQuery.Variables
43+
>
4244
private var isFavourite: Bool {
4345
isFavouriteRef.data?.favorite_movie?.movieId != nil
4446
}
@@ -48,8 +50,7 @@ struct MovieCardView: View {
4850
if isFavourite {
4951
let _ = try await connector.deleteFavoritedMovieMutation.execute(movieId: movie.id)
5052
let _ = try await isFavouriteRef.execute()
51-
}
52-
else {
53+
} else {
5354
let _ = try await connector.addFavoritedMovieMutation.execute(movieId: movie.id)
5455
let _ = try await isFavouriteRef.execute()
5556
}
@@ -134,14 +135,13 @@ extension MovieCardView {
134135
.task {
135136
do {
136137
let _ = try await isFavouriteRef.execute()
137-
}
138-
catch {
138+
} catch {
139139
print(error)
140140
}
141141
}
142142
}
143143
}
144144

145-
#Preview {
146-
MovieCardView(showDetails: true, movie: Movie.mock)
147-
}
145+
#Preview {
146+
MovieCardView(showDetails: true, movie: Movie.mock)
147+
}

Examples/FriendlyFlix/app/FriendlyFlix/FriendlyFlix/Features/Details/MovieDetailsView.swift

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
import FirebaseDataConnect
1616
import FriendlyFlixSDK
17-
import SwiftUI
1817
import NukeUI
18+
import SwiftUI
1919

2020
struct MovieDetailsView: View {
2121
private var movie: Movie
@@ -31,30 +31,29 @@ struct MovieDetailsView: View {
3131
releaseYear: movieDetails.releaseYear,
3232
rating: movieDetails.rating ?? 0,
3333
imageUrl: movieDetails.imageUrl,
34-
mainActors: movieDetails.mainActors.map({ mainActor in
34+
mainActors: movieDetails.mainActors.map { mainActor in
3535
MovieActor(id: mainActor.id,
3636
name: mainActor.name,
3737
imageUrl: mainActor.imageUrl)
38-
}),
39-
supportingActors: movieDetails.supportingActors.map({ supportingActor in
38+
},
39+
supportingActors: movieDetails.supportingActors.map { supportingActor in
4040
MovieActor(id: supportingActor.id,
4141
name: supportingActor.name,
4242
imageUrl: supportingActor.imageUrl)
43-
}),
44-
reviews: movieDetails.reviews.map({ review in
43+
},
44+
reviews: movieDetails.reviews.map { review in
4545
Review(id: review.id,
4646
reviewText: review.reviewText ?? "",
4747
rating: review.rating ?? 0,
4848
userName: review.user.username)
49-
})
49+
}
5050
)
5151
}
5252
}
5353

5454
public init(movie: Movie) {
5555
self.movie = movie
5656
}
57-
5857
}
5958

6059
extension MovieDetailsView {
@@ -106,7 +105,7 @@ extension MovieDetailsView {
106105
rating: Double(review.rating),
107106
reviewerName: review.userName,
108107
review: review.reviewText)
109-
.frame(width: 350)
108+
.frame(width: 350)
110109
}
111110
}
112111
.scrollTargetLayout()

Examples/FriendlyFlix/app/FriendlyFlix/FriendlyFlix/Features/Home/DetailsSection.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ struct DetailsSection<Title, Details>: View where Title: View, Details: View {
4848
}
4949

5050
extension DetailsSection where Title == Text {
51-
init (_ title: Text, content: @escaping () -> Details) {
51+
init(_ title: Text, content: @escaping () -> Details) {
5252
self.title = { title }
5353
self.content = { content() }
5454
}
5555

56-
init (_ title: any StringProtocol, content: @escaping () -> Details) {
56+
init(_ title: any StringProtocol, content: @escaping () -> Details) {
5757
self.title = { Text(title) }
5858
self.content = { content() }
5959
}

Examples/FriendlyFlix/app/FriendlyFlix/FriendlyFlix/Features/Home/HomeScreen.swift

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
// See the License for the specific language governing permissions and
1717
// limitations under the License.
1818

19-
import SwiftUI
2019
import FirebaseDataConnect
2120
import FriendlyFlixSDK
21+
import SwiftUI
2222

2323
struct HomeScreen: View {
2424
@Namespace private var namespace
@@ -42,23 +42,26 @@ struct HomeScreen: View {
4242

4343
private var heroMovies: [Movie] {
4444
connector.listMoviesQuery
45-
.ref({ optionalVars in
45+
.ref { optionalVars in
4646
optionalVars.limit = 3
4747
optionalVars.orderByReleaseYear = .DESC
48-
})
48+
}
4949
.data?.movies.map(Movie.init) ?? []
5050
}
5151

5252
private var topMovies: [Movie] {
5353
connector.listMoviesQuery
54-
.ref({ optionalVars in
54+
.ref { optionalVars in
5555
optionalVars.limit = 5
5656
optionalVars.orderByRating = .DESC
57-
})
57+
}
5858
.data?.movies.map(Movie.init) ?? []
5959
}
6060

61-
let watchListRef: QueryRefObservation<GetUserFavoriteMoviesQuery.Data, GetUserFavoriteMoviesQuery.Variables>
61+
let watchListRef: QueryRefObservation<
62+
GetUserFavoriteMoviesQuery.Data,
63+
GetUserFavoriteMoviesQuery.Variables
64+
>
6265
private var watchList: [Movie] {
6366
watchListRef.data?.user?.favoriteMovies.map(Movie.init) ?? []
6467
}
@@ -75,8 +78,12 @@ extension HomeScreen {
7578
TabView {
7679
ForEach(heroMovies) { movie in
7780
NavigationLink(value: movie) {
78-
MovieTeaserView(title: movie.title, subtitle: movie.description, imageUrl: movie.imageUrl)
79-
.matchedTransitionSource(id: movie.id, in: namespace)
81+
MovieTeaserView(
82+
title: movie.title,
83+
subtitle: movie.description,
84+
imageUrl: movie.imageUrl
85+
)
86+
.matchedTransitionSource(id: movie.id, in: namespace)
8087
}
8188
.buttonStyle(.noHighlight)
8289
}

Examples/FriendlyFlix/app/FriendlyFlix/FriendlyFlix/Features/Library/LibraryScreen.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// ProfileScreen.swift
2+
// LibraryScreen.swift
33
// FriendlyFlixMocks
44
//
55
// Created by Peter Friese on 28.09.24.
@@ -16,9 +16,9 @@
1616
// See the License for the specific language governing permissions and
1717
// limitations under the License.
1818

19-
import SwiftUI
2019
import FirebaseDataConnect
2120
import FriendlyFlixSDK
21+
import SwiftUI
2222

2323
struct LibraryScreen: View {
2424
@Namespace var namespace
@@ -34,7 +34,10 @@ struct LibraryScreen: View {
3434
watchListRef = connector.getUserFavoriteMoviesQuery.ref()
3535
}
3636

37-
private let watchListRef: QueryRefObservation<GetUserFavoriteMoviesQuery.Data, GetUserFavoriteMoviesQuery.Variables>
37+
private let watchListRef: QueryRefObservation<
38+
GetUserFavoriteMoviesQuery.Data,
39+
GetUserFavoriteMoviesQuery.Variables
40+
>
3841
private var watchList: [Movie] {
3942
watchListRef.data?.user?.favoriteMovies.map(Movie.init) ?? []
4043
}

0 commit comments

Comments
 (0)