diff --git a/database/DatabaseExampleSwiftUI/DatabaseExample/DatabaseExample.xcodeproj/project.pbxproj b/database/DatabaseExampleSwiftUI/DatabaseExample/DatabaseExample.xcodeproj/project.pbxproj index 906555780..a45f017c1 100644 --- a/database/DatabaseExampleSwiftUI/DatabaseExample/DatabaseExample.xcodeproj/project.pbxproj +++ b/database/DatabaseExampleSwiftUI/DatabaseExample/DatabaseExample.xcodeproj/project.pbxproj @@ -21,6 +21,26 @@ C796F29C26CCE3DA0076C5F5 /* ScreenDimensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C796F29B26CCE3DA0076C5F5 /* ScreenDimensions.swift */; }; C796F29D26CCE3DA0076C5F5 /* ScreenDimensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C796F29B26CCE3DA0076C5F5 /* ScreenDimensions.swift */; }; C796F29E26CCE9DE0076C5F5 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B9029EF026A10B1500C92F12 /* GoogleService-Info.plist */; }; + C796F2AD26D2281A0076C5F5 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C796F2AC26D2281A0076C5F5 /* Preview Assets.xcassets */; }; + C796F2B226D228380076C5F5 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B9029EF026A10B1500C92F12 /* GoogleService-Info.plist */; }; + C796F2B326D2283B0076C5F5 /* Comment.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7C6B5B2268DAC1800546A57 /* Comment.swift */; }; + C796F2B426D2283E0076C5F5 /* UserViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7F60CF5268EBEDE002F68AB /* UserViewModel.swift */; }; + C796F2B526D228410076C5F5 /* PostViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C79D1AC226A4114600B6A169 /* PostViewModel.swift */; }; + C796F2B626D228490076C5F5 /* PostsType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C730A31E26B0998A00A29E81 /* PostsType.swift */; }; + C796F2B726D228490076C5F5 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7F60CFB268EE316002F68AB /* ContentView.swift */; }; + C796F2B826D228490076C5F5 /* PostDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C799B60D269E1CEF00A43C40 /* PostDetailView.swift */; }; + C796F2B926D228490076C5F5 /* NewPostsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C70B63FE2696B29400851A91 /* NewPostsView.swift */; }; + C796F2BA26D228490076C5F5 /* PostCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C799B610269E1E3B00A43C40 /* PostCell.swift */; }; + C796F2BB26D228490076C5F5 /* SignUpView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7F60CF1268E352F002F68AB /* SignUpView.swift */; }; + C796F2BC26D228490076C5F5 /* PostListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C77ABFAA26B8992600BDE919 /* PostListViewModel.swift */; }; + C796F2BD26D228490076C5F5 /* LoginView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7C6B575268C8C9A00546A57 /* LoginView.swift */; }; + C796F2BE26D228490076C5F5 /* PostsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C79D1AEC26A8D9A300B6A169 /* PostsView.swift */; }; + C796F2BF26D228490076C5F5 /* Database+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C77ABFAD26B8A7FF00BDE919 /* Database+Extensions.swift */; }; + C796F2C026D228490076C5F5 /* DatabaseExampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7C6B574268C8C9A00546A57 /* DatabaseExampleApp.swift */; }; + C796F2C126D228490076C5F5 /* ScreenDimensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C796F29B26CCE3DA0076C5F5 /* ScreenDimensions.swift */; }; + C796F2C326D228F30076C5F5 /* FirebaseAuth in Frameworks */ = {isa = PBXBuildFile; productRef = C796F2C226D228F30076C5F5 /* FirebaseAuth */; }; + C796F2C526D228F30076C5F5 /* FirebaseDatabase in Frameworks */ = {isa = PBXBuildFile; productRef = C796F2C426D228F30076C5F5 /* FirebaseDatabase */; }; + C796F2C626D390010076C5F5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C7C6B576268C8C9C00546A57 /* Assets.xcassets */; }; C799B60E269E1CEF00A43C40 /* PostDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C799B60D269E1CEF00A43C40 /* PostDetailView.swift */; }; C799B60F269E1CEF00A43C40 /* PostDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C799B60D269E1CEF00A43C40 /* PostDetailView.swift */; }; C799B611269E1E3B00A43C40 /* PostCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C799B610269E1E3B00A43C40 /* PostCell.swift */; }; @@ -55,6 +75,9 @@ C77ABFAA26B8992600BDE919 /* PostListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostListViewModel.swift; sourceTree = ""; }; C77ABFAD26B8A7FF00BDE919 /* Database+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Database+Extensions.swift"; sourceTree = ""; }; C796F29B26CCE3DA0076C5F5 /* ScreenDimensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScreenDimensions.swift; sourceTree = ""; }; + C796F2A326D228180076C5F5 /* DatabaseExample (tvOS).app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "DatabaseExample (tvOS).app"; sourceTree = BUILT_PRODUCTS_DIR; }; + C796F2AC26D2281A0076C5F5 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; + C796F2AE26D2281A0076C5F5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; C799B60D269E1CEF00A43C40 /* PostDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostDetailView.swift; sourceTree = ""; }; C799B610269E1E3B00A43C40 /* PostCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostCell.swift; sourceTree = ""; }; C79D1AC226A4114600B6A169 /* PostViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostViewModel.swift; sourceTree = ""; }; @@ -74,6 +97,15 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + C796F2A026D228180076C5F5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + C796F2C526D228F30076C5F5 /* FirebaseDatabase in Frameworks */, + C796F2C326D228F30076C5F5 /* FirebaseAuth in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; C7C6B578268C8C9C00546A57 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -103,6 +135,23 @@ name = Frameworks; sourceTree = ""; }; + C796F2A426D228180076C5F5 /* tvOS */ = { + isa = PBXGroup; + children = ( + C796F2AE26D2281A0076C5F5 /* Info.plist */, + C796F2AB26D2281A0076C5F5 /* Preview Content */, + ); + path = tvOS; + sourceTree = ""; + }; + C796F2AB26D2281A0076C5F5 /* Preview Content */ = { + isa = PBXGroup; + children = ( + C796F2AC26D2281A0076C5F5 /* Preview Assets.xcassets */, + ); + path = "Preview Content"; + sourceTree = ""; + }; C7C6B56E268C8C9A00546A57 = { isa = PBXGroup; children = ( @@ -110,6 +159,7 @@ C7C6B573268C8C9A00546A57 /* Shared */, C7C6B57D268C8C9C00546A57 /* iOS */, C7C6B584268C8C9C00546A57 /* macOS */, + C796F2A426D228180076C5F5 /* tvOS */, C7C6B57C268C8C9C00546A57 /* Products */, C796F29626CCDCEF0076C5F5 /* Frameworks */, ); @@ -131,6 +181,7 @@ children = ( C7C6B57B268C8C9C00546A57 /* DatabaseExample.app */, C7C6B583268C8C9C00546A57 /* DatabaseExample.app */, + C796F2A326D228180076C5F5 /* DatabaseExample (tvOS).app */, ); name = Products; sourceTree = ""; @@ -183,6 +234,27 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ + C796F2A226D228180076C5F5 /* DatabaseExample (tvOS) */ = { + isa = PBXNativeTarget; + buildConfigurationList = C796F2B126D2281A0076C5F5 /* Build configuration list for PBXNativeTarget "DatabaseExample (tvOS)" */; + buildPhases = ( + C796F29F26D228180076C5F5 /* Sources */, + C796F2A026D228180076C5F5 /* Frameworks */, + C796F2A126D228180076C5F5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "DatabaseExample (tvOS)"; + packageProductDependencies = ( + C796F2C226D228F30076C5F5 /* FirebaseAuth */, + C796F2C426D228F30076C5F5 /* FirebaseDatabase */, + ); + productName = tvOSDatabaseExample; + productReference = C796F2A326D228180076C5F5 /* DatabaseExample (tvOS).app */; + productType = "com.apple.product-type.application"; + }; C7C6B57A268C8C9C00546A57 /* DatabaseExample (iOS) */ = { isa = PBXNativeTarget; buildConfigurationList = C7C6B58F268C8C9C00546A57 /* Build configuration list for PBXNativeTarget "DatabaseExample (iOS)" */; @@ -235,6 +307,9 @@ LastSwiftUpdateCheck = 1250; LastUpgradeCheck = 1250; TargetAttributes = { + C796F2A226D228180076C5F5 = { + CreatedOnToolsVersion = 12.5; + }; C7C6B57A268C8C9C00546A57 = { CreatedOnToolsVersion = 12.5; }; @@ -261,11 +336,22 @@ targets = ( C7C6B57A268C8C9C00546A57 /* DatabaseExample (iOS) */, C7C6B582268C8C9C00546A57 /* DatabaseExample (macOS) */, + C796F2A226D228180076C5F5 /* DatabaseExample (tvOS) */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + C796F2A126D228180076C5F5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C796F2AD26D2281A0076C5F5 /* Preview Assets.xcassets in Resources */, + C796F2C626D390010076C5F5 /* Assets.xcassets in Resources */, + C796F2B226D228380076C5F5 /* GoogleService-Info.plist in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; C7C6B579268C8C9C00546A57 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -287,6 +373,28 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + C796F29F26D228180076C5F5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C796F2B526D228410076C5F5 /* PostViewModel.swift in Sources */, + C796F2B726D228490076C5F5 /* ContentView.swift in Sources */, + C796F2BE26D228490076C5F5 /* PostsView.swift in Sources */, + C796F2BC26D228490076C5F5 /* PostListViewModel.swift in Sources */, + C796F2B626D228490076C5F5 /* PostsType.swift in Sources */, + C796F2C126D228490076C5F5 /* ScreenDimensions.swift in Sources */, + C796F2B826D228490076C5F5 /* PostDetailView.swift in Sources */, + C796F2B926D228490076C5F5 /* NewPostsView.swift in Sources */, + C796F2BF26D228490076C5F5 /* Database+Extensions.swift in Sources */, + C796F2B326D2283B0076C5F5 /* Comment.swift in Sources */, + C796F2C026D228490076C5F5 /* DatabaseExampleApp.swift in Sources */, + C796F2B426D2283E0076C5F5 /* UserViewModel.swift in Sources */, + C796F2BD26D228490076C5F5 /* LoginView.swift in Sources */, + C796F2BB26D228490076C5F5 /* SignUpView.swift in Sources */, + C796F2BA26D228490076C5F5 /* PostCell.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; C7C6B577268C8C9C00546A57 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -334,6 +442,51 @@ /* End PBXSourcesBuildPhase section */ /* Begin XCBuildConfiguration section */ + C796F2AF26D2281A0076C5F5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image"; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_ASSET_PATHS = "\"tvOS/Preview Content\""; + ENABLE_PREVIEWS = YES; + INFOPLIST_FILE = tvOS/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.google.firebase.quickstart.DatabaseExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = appletvos; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 3; + TVOS_DEPLOYMENT_TARGET = 14.5; + }; + name = Debug; + }; + C796F2B026D2281A0076C5F5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image"; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_ASSET_PATHS = "\"tvOS/Preview Content\""; + ENABLE_PREVIEWS = YES; + INFOPLIST_FILE = tvOS/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.google.firebase.quickstart.DatabaseExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = appletvos; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 3; + TVOS_DEPLOYMENT_TARGET = 14.5; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; C7C6B58D268C8C9C00546A57 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -535,6 +688,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + C796F2B126D2281A0076C5F5 /* Build configuration list for PBXNativeTarget "DatabaseExample (tvOS)" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C796F2AF26D2281A0076C5F5 /* Debug */, + C796F2B026D2281A0076C5F5 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; C7C6B572268C8C9A00546A57 /* Build configuration list for PBXProject "DatabaseExample" */ = { isa = XCConfigurationList; buildConfigurations = ( @@ -586,6 +748,16 @@ package = C7C6B595268C8D7800546A57 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */; productName = FirebaseDatabase; }; + C796F2C226D228F30076C5F5 /* FirebaseAuth */ = { + isa = XCSwiftPackageProductDependency; + package = C7C6B595268C8D7800546A57 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */; + productName = FirebaseAuth; + }; + C796F2C426D228F30076C5F5 /* FirebaseDatabase */ = { + isa = XCSwiftPackageProductDependency; + package = C7C6B595268C8D7800546A57 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */; + productName = FirebaseDatabase; + }; C7C6B596268C8D7800546A57 /* FirebaseDatabaseSwift-Beta */ = { isa = XCSwiftPackageProductDependency; package = C7C6B595268C8D7800546A57 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */; diff --git a/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Models/ScreenDimensions.swift b/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Models/ScreenDimensions.swift index cafa1c8e2..b31a014ba 100644 --- a/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Models/ScreenDimensions.swift +++ b/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Models/ScreenDimensions.swift @@ -17,7 +17,7 @@ import SwiftUI class ScreenDimensions { - #if os(iOS) + #if os(iOS) || os(tvOS) static var width: CGFloat = UIScreen.main.bounds.size.width static var height: CGFloat = UIScreen.main.bounds.size.height #elseif os(macOS) diff --git a/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/ContentView.swift b/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/ContentView.swift index 6428ba262..b56bd5bfc 100644 --- a/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/ContentView.swift +++ b/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/ContentView.swift @@ -21,7 +21,7 @@ struct ContentView: View { @AppStorage("isSignedIn") var isSignedIn = true // define variables for creating a new post for macOS - #if os(macOS) + #if os(macOS) || os(tvOS) @StateObject var postList = PostListViewModel() @State private var newPostsViewPresented = false #endif @@ -43,7 +43,8 @@ struct ContentView: View { } } .accentColor(Color(.systemTeal)) - #if os(iOS) + + #if os(iOS) || os(tvOS) tabView #elseif os(macOS) tabView diff --git a/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/LoginView.swift b/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/LoginView.swift index 1a5667e40..2e464e1b5 100644 --- a/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/LoginView.swift +++ b/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/LoginView.swift @@ -43,7 +43,7 @@ struct LoginView: View { emailTextField .keyboardType(.emailAddress) .autocapitalization(UITextAutocapitalizationType.none) - #elseif os(macOS) + #elseif os(macOS) || os(tvOS) emailTextField #endif } @@ -53,7 +53,7 @@ struct LoginView: View { emailInputField .background(RoundedRectangle(cornerRadius: 10).fill(Color(.systemGray5))) .frame(width: ScreenDimensions.width * 0.8) - #elseif os(macOS) + #elseif os(macOS) || os(tvOS) emailInputField #endif @@ -72,7 +72,7 @@ struct LoginView: View { passwordInputField .background(RoundedRectangle(cornerRadius: 10).fill(Color(.systemGray5))) .frame(width: ScreenDimensions.width * 0.8) - #elseif os(macOS) + #elseif os(macOS) || os(tvOS) passwordInputField #endif @@ -81,16 +81,22 @@ struct LoginView: View { .fixedSize() // Login button - Button(action: user.login) { + let loginButton = Button(action: user.login) { Text("Login".uppercased()) .foregroundColor(.white) .font(.title2) .bold() } - .buttonStyle(BorderlessButtonStyle()) .padding(0.025 * ScreenDimensions.height) .background(Capsule().fill(Color(.systemTeal))) + #if os(iOS) || os(macOS) + loginButton + .buttonStyle(BorderlessButtonStyle()) + #elseif os(tvOS) + loginButton + #endif + Spacer() .frame(idealHeight: 0.05 * ScreenDimensions.height) .fixedSize() @@ -98,16 +104,21 @@ struct LoginView: View { // Navigation text HStack { Text("Don't have an account?") - Button(action: { + let signUpButton = Button(action: { signUpViewPresented = true }) { Text("Sign up".uppercased()) .bold() } - .buttonStyle(BorderlessButtonStyle()) .sheet(isPresented: $signUpViewPresented) { SignUpView(user: user, isPresented: $signUpViewPresented) } + #if os(iOS) || os(macOS) + signUpButton + .buttonStyle(BorderlessButtonStyle()) + #elseif os(tvOS) + signUpButton + #endif } } .alert(isPresented: $user.alert, content: { diff --git a/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/NewPostsView.swift b/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/NewPostsView.swift index 7a4edfe96..3b661d8a2 100644 --- a/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/NewPostsView.swift +++ b/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/NewPostsView.swift @@ -24,6 +24,11 @@ struct NewPostsView: View { var body: some View { HStack { + Button(action: { + isPresented = false + }) { + Image(systemName: "chevron.left") + } Spacer() Button(action: { isPresented = false @@ -37,26 +42,39 @@ struct NewPostsView: View { } .padding(20) VStack { + // post title let postTitleInput = TextField("Add a title", text: $newPostTitle) .font(.largeTitle) - .textFieldStyle(RoundedBorderTextFieldStyle()) - let postBodyInput = TextEditor(text: $newPostBody) + .padding() - #if os(iOS) + #if os(iOS) || os(tvOS) postTitleInput .frame( width: ScreenDimensions.width * 0.88, height: ScreenDimensions.height * 0.08, alignment: .leading ) + #elseif os(macOS) + postTitleInput + .frame(minWidth: 400) + #endif + + // post body + #if os(iOS) || os(macOS) + let postBodyInput = TextEditor(text: $newPostBody) + .padding() + #elseif os(tvOS) + let postBodyInput = TextField("Say something...", text: $newPostBody) + .padding() + #endif + + #if os(iOS) || os(tvOS) postBodyInput .frame( width: ScreenDimensions.width * 0.88, alignment: .leading ) #elseif os(macOS) - postTitleInput - .frame(minWidth: 300) postBodyInput .frame(minWidth: 300, minHeight: 300) #endif diff --git a/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/PostCell.swift b/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/PostCell.swift index 1f33bc37a..d0b67604d 100644 --- a/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/PostCell.swift +++ b/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/PostCell.swift @@ -28,10 +28,15 @@ struct PostCell: View { Image(systemName: "person.fill") Text(post.author) Spacer() - Image(systemName: post.isStarred ? "star.fill" : "star") - .onTapGesture { - post.didTapStarButton() - } + let starButton = Image(systemName: post.isStarred ? "star.fill" : "star") + #if os(iOS) || os(macOS) + starButton + .onTapGesture { + post.didTapStarButton() + } + #elseif os(tvOS) + starButton + #endif Text("\(post.starCount)") } Text(post.title) diff --git a/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/PostDetailView.swift b/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/PostDetailView.swift index ba6ff3528..3753cb614 100644 --- a/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/PostDetailView.swift +++ b/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/PostDetailView.swift @@ -37,7 +37,6 @@ struct PostDetailView: View { Text(post.body) } .padding() - .background(RoundedRectangle(cornerRadius: 10).fill(Color(red: 229, green: 229, blue: 234))) // comments for the particular post List { ForEach(post.comments) { comment in @@ -56,8 +55,6 @@ struct PostDetailView: View { let commentInput = HStack { TextField("Comment", text: $comment) .padding() - .background(RoundedRectangle(cornerRadius: 10) - .fill(Color(red: 229, green: 229, blue: 234))) Button(action: { post.didTapSendButton(commentField: comment) comment = "" @@ -69,7 +66,7 @@ struct PostDetailView: View { } } - #if os(iOS) + #if os(iOS) || os(tvOS) commentInput .frame( width: ScreenDimensions.width * 0.85, @@ -102,7 +99,7 @@ struct PostDetailView: View { width: ScreenDimensions.width * 0.9, alignment: .center ) - #elseif os(macOS) + #elseif os(macOS) || os(tvOS) postDetailView .frame( width: 400, diff --git a/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/PostsView.swift b/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/PostsView.swift index a79accdd6..8fdfc38a6 100644 --- a/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/PostsView.swift +++ b/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/PostsView.swift @@ -22,7 +22,7 @@ struct PostsView: View { @StateObject var user = UserViewModel() // define variables for creating a new post for iOS - #if os(iOS) + #if os(iOS) || os(tvOS) @State private var newPostsViewPresented = false #endif @@ -43,7 +43,7 @@ struct PostsView: View { postList.onViewDisappear() } .navigationTitle(title) - #if os(iOS) + #if os(iOS) || os(tvOS) postListView .toolbar { ToolbarItemGroup(placement: .navigationBarLeading) { diff --git a/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/SignUpView.swift b/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/SignUpView.swift index 28e2d214b..10aabf4a8 100644 --- a/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/SignUpView.swift +++ b/database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/SignUpView.swift @@ -42,7 +42,7 @@ struct SignUpView: View { emailTextField .keyboardType(.emailAddress) .autocapitalization(UITextAutocapitalizationType.none) - #elseif os(macOS) + #elseif os(macOS) || os(tvOS) emailTextField #endif } @@ -52,7 +52,7 @@ struct SignUpView: View { emailInputField .background(RoundedRectangle(cornerRadius: 10).fill(Color(.systemGray5))) .frame(width: ScreenDimensions.width * 0.8) - #elseif os(macOS) + #elseif os(macOS) || os(tvOS) emailInputField #endif @@ -71,7 +71,7 @@ struct SignUpView: View { passwordInputField .background(RoundedRectangle(cornerRadius: 10).fill(Color(.systemGray5))) .frame(width: ScreenDimensions.width * 0.8) - #elseif os(macOS) + #elseif os(macOS) || os(tvOS) passwordInputField #endif @@ -80,16 +80,22 @@ struct SignUpView: View { .fixedSize() // Sign up button - Button(action: user.signUp) { + let signUpButton = Button(action: user.signUp) { Text("Sign up".uppercased()) .foregroundColor(.white) .font(.title2) .bold() } - .buttonStyle(BorderlessButtonStyle()) .padding(0.025 * ScreenDimensions.height) .background(Capsule().fill(Color(.systemTeal))) + #if os(iOS) || os(macOS) + signUpButton + .buttonStyle(BorderlessButtonStyle()) + #elseif os(tvOS) + signUpButton + #endif + Spacer() .frame(idealHeight: 0.05 * ScreenDimensions.height) .fixedSize() @@ -97,13 +103,19 @@ struct SignUpView: View { // Navigation text HStack { Text("Already have an account?") - Button(action: { + let loginButton = Button(action: { isPresented = false }) { Text("Login".uppercased()) .bold() } - .buttonStyle(BorderlessButtonStyle()) + + #if os(iOS) || os(macOS) + loginButton + .buttonStyle(BorderlessButtonStyle()) + #elseif os(tvOS) + loginButton + #endif } } .alert(isPresented: $user.alert, content: { diff --git a/database/DatabaseExampleSwiftUI/DatabaseExample/tvOS/Info.plist b/database/DatabaseExampleSwiftUI/DatabaseExample/tvOS/Info.plist new file mode 100644 index 000000000..16d307cc9 --- /dev/null +++ b/database/DatabaseExampleSwiftUI/DatabaseExample/tvOS/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchScreen + + UIRequiredDeviceCapabilities + + arm64 + + UIUserInterfaceStyle + Automatic + + diff --git a/database/DatabaseExampleSwiftUI/DatabaseExample/tvOS/Preview Content/Preview Assets.xcassets/Contents.json b/database/DatabaseExampleSwiftUI/DatabaseExample/tvOS/Preview Content/Preview Assets.xcassets/Contents.json new file mode 100644 index 000000000..73c00596a --- /dev/null +++ b/database/DatabaseExampleSwiftUI/DatabaseExample/tvOS/Preview Content/Preview Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +}