Skip to content

Commit 2daacd4

Browse files
committed
🔀 Merge branch 'peterfriese/samples/movietracker-new-ui/connect-dataconnect' into peterfriese/samples/movietracker-new-ui/main
Signed-off-by: Peter Friese <[email protected]>
2 parents 794ed5c + 4ed5d65 commit 2daacd4

34 files changed

+4273
-2122
lines changed

‎Examples/FriendlyFlix/app/FriendlyFlix/FriendlyFlix.xcodeproj/project.pbxproj‎

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
8854EC512CC6AC2700A09F27 /* FirebaseAuth in Frameworks */ = {isa = PBXBuildFile; productRef = 8854EC502CC6AC2700A09F27 /* FirebaseAuth */; };
10+
88896F392CCA5AD80089A19C /* NukeUI in Frameworks */ = {isa = PBXBuildFile; productRef = 88896F382CCA5AD80089A19C /* NukeUI */; };
11+
88BA433B2CC937E10063E309 /* FirebaseDataConnect in Frameworks */ = {isa = PBXBuildFile; productRef = 88BA433A2CC937E10063E309 /* FirebaseDataConnect */; };
12+
88BA43402CC938250063E309 /* FriendlyFlixSDK in Frameworks */ = {isa = PBXBuildFile; productRef = 88BA433F2CC938250063E309 /* FriendlyFlixSDK */; };
1113
/* End PBXBuildFile section */
1214

1315
/* Begin PBXFileReference section */
@@ -27,7 +29,9 @@
2729
isa = PBXFrameworksBuildPhase;
2830
buildActionMask = 2147483647;
2931
files = (
30-
8854EC512CC6AC2700A09F27 /* FirebaseAuth in Frameworks */,
32+
88896F392CCA5AD80089A19C /* NukeUI in Frameworks */,
33+
88BA433B2CC937E10063E309 /* FirebaseDataConnect in Frameworks */,
34+
88BA43402CC938250063E309 /* FriendlyFlixSDK in Frameworks */,
3135
);
3236
runOnlyForDeploymentPostprocessing = 0;
3337
};
@@ -70,7 +74,9 @@
7074
);
7175
name = FriendlyFlix;
7276
packageProductDependencies = (
73-
8854EC502CC6AC2700A09F27 /* FirebaseAuth */,
77+
88BA433A2CC937E10063E309 /* FirebaseDataConnect */,
78+
88BA433F2CC938250063E309 /* FriendlyFlixSDK */,
79+
88896F382CCA5AD80089A19C /* NukeUI */,
7480
);
7581
productName = FriendlyFlix;
7682
productReference = 88A9E6342CA834C600B3C4EF /* FriendlyFlix.app */;
@@ -101,7 +107,9 @@
101107
mainGroup = 88A9E62B2CA834C600B3C4EF;
102108
minimizedProjectReferenceProxies = 1;
103109
packageReferences = (
104-
8854EC4F2CC6AC2700A09F27 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */,
110+
88BA43392CC937E10063E309 /* XCRemoteSwiftPackageReference "data-connect-ios-sdk" */,
111+
88BA433E2CC938250063E309 /* XCLocalSwiftPackageReference "../FriendlyFlixSDK" */,
112+
88896F372CCA5AD80089A19C /* XCRemoteSwiftPackageReference "Nuke" */,
105113
);
106114
preferredProjectObjectVersion = 77;
107115
productRefGroup = 88A9E6352CA834C600B3C4EF /* Products */;
@@ -334,22 +342,46 @@
334342
};
335343
/* End XCConfigurationList section */
336344

345+
/* Begin XCLocalSwiftPackageReference section */
346+
88BA433E2CC938250063E309 /* XCLocalSwiftPackageReference "../FriendlyFlixSDK" */ = {
347+
isa = XCLocalSwiftPackageReference;
348+
relativePath = ../FriendlyFlixSDK;
349+
};
350+
/* End XCLocalSwiftPackageReference section */
351+
337352
/* Begin XCRemoteSwiftPackageReference section */
338-
8854EC4F2CC6AC2700A09F27 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */ = {
353+
88896F372CCA5AD80089A19C /* XCRemoteSwiftPackageReference "Nuke" */ = {
339354
isa = XCRemoteSwiftPackageReference;
340-
repositoryURL = "https://github.com/firebase/firebase-ios-sdk.git";
355+
repositoryURL = "https://github.com/kean/Nuke?tab=readme-ov-file";
341356
requirement = {
342357
kind = upToNextMajorVersion;
343-
minimumVersion = 11.0.0;
358+
minimumVersion = 12.8.0;
359+
};
360+
};
361+
88BA43392CC937E10063E309 /* XCRemoteSwiftPackageReference "data-connect-ios-sdk" */ = {
362+
isa = XCRemoteSwiftPackageReference;
363+
repositoryURL = "https://github.com/firebase/data-connect-ios-sdk";
364+
requirement = {
365+
branch = main;
366+
kind = branch;
344367
};
345368
};
346369
/* End XCRemoteSwiftPackageReference section */
347370

348371
/* Begin XCSwiftPackageProductDependency section */
349-
8854EC502CC6AC2700A09F27 /* FirebaseAuth */ = {
372+
88896F382CCA5AD80089A19C /* NukeUI */ = {
373+
isa = XCSwiftPackageProductDependency;
374+
package = 88896F372CCA5AD80089A19C /* XCRemoteSwiftPackageReference "Nuke" */;
375+
productName = NukeUI;
376+
};
377+
88BA433A2CC937E10063E309 /* FirebaseDataConnect */ = {
378+
isa = XCSwiftPackageProductDependency;
379+
package = 88BA43392CC937E10063E309 /* XCRemoteSwiftPackageReference "data-connect-ios-sdk" */;
380+
productName = FirebaseDataConnect;
381+
};
382+
88BA433F2CC938250063E309 /* FriendlyFlixSDK */ = {
350383
isa = XCSwiftPackageProductDependency;
351-
package = 8854EC4F2CC6AC2700A09F27 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
352-
productName = FirebaseAuth;
384+
productName = FriendlyFlixSDK;
353385
};
354386
/* End XCSwiftPackageProductDependency section */
355387
};

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
import SwiftUI
2020
import Firebase
21+
import FirebaseAuth
22+
import FirebaseDataConnect
23+
import FriendlyFlixSDK
2124

2225
@main
2326
struct FriendlyFlixApp: App {
@@ -31,15 +34,26 @@ struct FriendlyFlixApp: App {
3134
#endif
3235
}
3336

34-
init () {
37+
var authenticationService: AuthenticationService?
38+
39+
init() {
3540
loadRocketSimConnect()
3641
FirebaseApp.configure()
42+
43+
authenticationService = AuthenticationService()
44+
authenticationService?.onSignUp { user in
45+
print("User signed in \(user.displayName ?? "(no fullname)") with email \(user.email ?? "(no email)")")
46+
let userName = String(user.email?.split(separator: "@").first ?? "(unknown)")
47+
Task {
48+
try await DataConnect.friendlyFlixConnector.upsertUserMutation.execute(username: userName)
49+
}
50+
}
3751
}
3852

3953
var body: some Scene {
4054
WindowGroup {
4155
RootView()
42-
.environment(AuthenticationService())
56+
.environment(authenticationService)
4357
}
4458
}
4559
}

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,6 @@ extension AccountScreen {
5757
}
5858
}
5959

60-
Section {
61-
Button(role: .destructive, action: {}) {
62-
Text("Clear viewing history")
63-
}
64-
}
65-
6660
Section {
6761
Button(action: signOut) {
6862
Text("Sign out")
@@ -84,4 +78,5 @@ extension AccountScreen {
8478

8579
#Preview {
8680
AccountScreen()
81+
.environment(AuthenticationService())
8782
}

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

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,7 @@ struct AuthenticationScreen: View {
9090
extension AuthenticationScreen {
9191
var body: some View {
9292
VStack {
93-
// Image("login")
94-
// .resizable()
95-
// .aspectRatio(contentMode: .fit)
96-
// .frame(minHeight: 300, maxHeight: 400)
97-
// Text(viewModel.flow == .login ? "Log in" : "Sign up")
98-
Text("Welcome")
93+
Text("Welcome to FriendlyFlix")
9994
.font(.largeTitle)
10095
.fontWeight(.bold)
10196
.frame(maxWidth: .infinity, alignment: .leading)
@@ -170,29 +165,6 @@ extension AuthenticationScreen {
170165
.frame(maxWidth: .infinity)
171166
.buttonStyle(.borderedProminent)
172167

173-
HStack {
174-
VStack { Divider() }
175-
Text("or")
176-
VStack { Divider() }
177-
}
178-
179-
if flow == .login {
180-
SignInWithAppleButton(.signIn) { request in
181-
} onCompletion: { result in
182-
}
183-
.signInWithAppleButtonStyle(colorScheme == .light ? .black : .white)
184-
.frame(maxWidth: .infinity, minHeight: 50, maxHeight: 50)
185-
.cornerRadius(8)
186-
}
187-
else {
188-
SignInWithAppleButton(.signUp) { request in
189-
} onCompletion: { result in
190-
}
191-
.signInWithAppleButtonStyle(colorScheme == .light ? .black : .white)
192-
.frame(maxWidth: .infinity, minHeight: 50, maxHeight: 50)
193-
.cornerRadius(8)
194-
}
195-
196168
HStack {
197169
Text(flow == .login ? "Don't have an account yet?" : "Already have an account?")
198170
Button(action: {

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,23 @@ class AuthenticationService {
4444
}
4545
}
4646

47+
private var onSignUp: ((User) -> Void)?
48+
public func onSignUp(_ action: @escaping (User) -> Void) {
49+
onSignUp = action
50+
}
51+
4752
func signInWithEmailPassword(email: String, password: String) async throws {
4853
try await Auth.auth().signIn(withEmail: email, password: password)
4954
authenticationState = .authenticated
5055
}
5156

5257
func signUpWithEmailPassword(email: String, password: String) async throws {
5358
try await Auth.auth().createUser(withEmail: email, password: password)
59+
60+
if let onSignUp, let user = Auth.auth().currentUser {
61+
onSignUp(user)
62+
}
63+
5464
authenticationState = .authenticated
5565
}
5666

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,22 @@
1919
import SwiftUI
2020

2121
struct AuthenticationToolbarButton: View {
22-
@Environment(AuthenticationService.self) var viewModel
22+
@Environment(AuthenticationService.self) var authenticationService
2323

24-
var body: some View {
25-
Button(action: onButtonTapped) {
26-
Image(systemName: viewModel.authenticationState == .unauthenticated ? "person.circle" : "person.circle.fill")
24+
private func onButtonTapped() {
25+
if authenticationService.authenticationState == .unauthenticated {
26+
authenticationService.presentingAuthenticationDialog.toggle()
27+
}
28+
else {
29+
authenticationService.presentingAccountDialog.toggle()
2730
}
2831
}
32+
}
2933

30-
func onButtonTapped() {
31-
if viewModel.authenticationState == .unauthenticated {
32-
viewModel.presentingAuthenticationDialog.toggle()
33-
}
34-
else {
35-
viewModel.presentingAccountDialog.toggle()
34+
extension AuthenticationToolbarButton {
35+
var body: some View {
36+
Button(action: onButtonTapped) {
37+
Image(systemName: authenticationService.authenticationState == .unauthenticated ? "person.circle" : "person.circle.fill")
3638
}
3739
}
3840
}

‎Examples/FriendlyFlix/app/FriendlyFlix/FriendlyFlix/Features/Categories/CategoriesView.swift‎

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)