From faa224df3333354e3d80c68800b9979d274c8805 Mon Sep 17 00:00:00 2001 From: Bosco Ho Date: Tue, 10 Oct 2023 23:59:02 -0700 Subject: [PATCH] Updated account transition (#685) Commit: 78351b1e4c594f1c1f63004cc178b2591db7b21d [78351b1e] --- Mlem.xcodeproj/project.pbxproj | 8 ++--- .../Onboarding/AccountTransitionView.swift | 34 +++++++++++++++++++ Mlem/Window.swift | 23 +++---------- 3 files changed, 43 insertions(+), 22 deletions(-) create mode 100644 Mlem/Views/Onboarding/AccountTransitionView.swift diff --git a/Mlem.xcodeproj/project.pbxproj b/Mlem.xcodeproj/project.pbxproj index aa39af684..e8ba508eb 100644 --- a/Mlem.xcodeproj/project.pbxproj +++ b/Mlem.xcodeproj/project.pbxproj @@ -70,7 +70,6 @@ 503BA26F2A2C94540052516C /* URL+Identifiable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 503BA26E2A2C94540052516C /* URL+Identifiable.swift */; }; 504106CD2A744D7F000AAEF8 /* CommentRepository+Dependency.swift in Sources */ = {isa = PBXBuildFile; fileRef = 504106CC2A744D7F000AAEF8 /* CommentRepository+Dependency.swift */; }; 504ECBAA2AB27C73006C0B96 /* LandingPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 504ECBA92AB27C73006C0B96 /* LandingPage.swift */; }; - 504ECBAC2AB27CB1006C0B96 /* OnboardingRoutes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 504ECBAB2AB27CB1006C0B96 /* OnboardingRoutes.swift */; }; 504ECBAE2AB45B2A006C0B96 /* LemmyURL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 504ECBAD2AB45B2A006C0B96 /* LemmyURL.swift */; }; 504ECBB12AB4B101006C0B96 /* LemmyURLTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 504ECBB02AB4B101006C0B96 /* LemmyURLTests.swift */; }; 505240E32A86916500EA4558 /* FavoriteCommunitiesTracker+Dependency.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505240E22A86916500EA4558 /* FavoriteCommunitiesTracker+Dependency.swift */; }; @@ -328,6 +327,7 @@ CD18DC6F2A5209C3002C56BC /* MarkPrivateMessageAsReadRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD18DC6E2A5209C3002C56BC /* MarkPrivateMessageAsReadRequest.swift */; }; CD18DC732A522A7C002C56BC /* CreatePrivateMessageRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD18DC722A522A7C002C56BC /* CreatePrivateMessageRequest.swift */; }; CD2053102AC878B50000AA38 /* UpdatedTimestampView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD20530F2AC878B50000AA38 /* UpdatedTimestampView.swift */; }; + CD2053122ACB72190000AA38 /* AccountTransitionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD2053112ACB72190000AA38 /* AccountTransitionView.swift */; }; CD2053142ACBAF150000AA38 /* AvatarType.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD2053132ACBAF150000AA38 /* AvatarType.swift */; }; CD2053172ACBBB5A0000AA38 /* DefaultAvatarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD2053162ACBBB5A0000AA38 /* DefaultAvatarView.swift */; }; CD2BD6782A79F55800ECFF89 /* ImageSize.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD2BD6772A79F55800ECFF89 /* ImageSize.swift */; }; @@ -551,7 +551,6 @@ 503BA26E2A2C94540052516C /* URL+Identifiable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URL+Identifiable.swift"; sourceTree = ""; }; 504106CC2A744D7F000AAEF8 /* CommentRepository+Dependency.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CommentRepository+Dependency.swift"; sourceTree = ""; }; 504ECBA92AB27C73006C0B96 /* LandingPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LandingPage.swift; sourceTree = ""; }; - 504ECBAB2AB27CB1006C0B96 /* OnboardingRoutes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingRoutes.swift; sourceTree = ""; }; 504ECBAD2AB45B2A006C0B96 /* LemmyURL.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LemmyURL.swift; sourceTree = ""; }; 504ECBB02AB4B101006C0B96 /* LemmyURLTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LemmyURLTests.swift; sourceTree = ""; }; 505240E22A86916500EA4558 /* FavoriteCommunitiesTracker+Dependency.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FavoriteCommunitiesTracker+Dependency.swift"; sourceTree = ""; }; @@ -807,6 +806,7 @@ CD18DC6E2A5209C3002C56BC /* MarkPrivateMessageAsReadRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarkPrivateMessageAsReadRequest.swift; sourceTree = ""; }; CD18DC722A522A7C002C56BC /* CreatePrivateMessageRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreatePrivateMessageRequest.swift; sourceTree = ""; }; CD20530F2AC878B50000AA38 /* UpdatedTimestampView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdatedTimestampView.swift; sourceTree = ""; }; + CD2053112ACB72190000AA38 /* AccountTransitionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountTransitionView.swift; sourceTree = ""; }; CD2053132ACBAF150000AA38 /* AvatarType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AvatarType.swift; sourceTree = ""; }; CD2053162ACBBB5A0000AA38 /* DefaultAvatarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultAvatarView.swift; sourceTree = ""; }; CD2BD6772A79F55800ECFF89 /* ImageSize.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageSize.swift; sourceTree = ""; }; @@ -1168,6 +1168,7 @@ children = ( 504ECBA92AB27C73006C0B96 /* LandingPage.swift */, CDE3BA862A8C25B000B972E2 /* OnboardingView.swift */, + CD2053112ACB72190000AA38 /* AccountTransitionView.swift */, ); path = Onboarding; sourceTree = ""; @@ -2378,7 +2379,6 @@ children = ( E49E01F32ABD99D300E42BB3 /* Routable.swift */, E40E018B2AABF85500410B2C /* AppRoutes.swift */, - 504ECBAB2AB27CB1006C0B96 /* OnboardingRoutes.swift */, ); path = Routes; sourceTree = ""; @@ -2627,6 +2627,7 @@ 63D24EDE2A169F2A005CCA81 /* Markdown View.swift in Sources */, E453A1D02A81C2140004BB8A /* QuickLookPreviewController.swift in Sources */, B104A6E02A59C19400B3E725 /* OperationQueue - Easy init.swift in Sources */, + CD2053122ACB72190000AA38 /* AccountTransitionView.swift in Sources */, 03B7AAF32ABEF85300068B23 /* UserModel.swift in Sources */, CDC1C9432A7AC24600072E3D /* ReadCheck.swift in Sources */, 63F0C7A22A0519BA00A18C5D /* PostSortType.swift in Sources */, @@ -2895,7 +2896,6 @@ 637218432A3A2AAD008C4816 /* APIClient.swift in Sources */, CD82A2572A716D7C00111034 /* PersonRepository+Dependency.swift in Sources */, 63DF71F12A02999C002AC14E /* App Constants.swift in Sources */, - 504ECBAC2AB27CB1006C0B96 /* OnboardingRoutes.swift in Sources */, CD82A2532A716B8100111034 /* PersonRepository.swift in Sources */, CD69F55F2A40121D0028D4F7 /* Ellipsis Menu.swift in Sources */, 638535712A1779BC00815781 /* GeneralSettingsView.swift in Sources */, diff --git a/Mlem/Views/Onboarding/AccountTransitionView.swift b/Mlem/Views/Onboarding/AccountTransitionView.swift new file mode 100644 index 000000000..a7e706e0a --- /dev/null +++ b/Mlem/Views/Onboarding/AccountTransitionView.swift @@ -0,0 +1,34 @@ +// +// AccountTransitionView.swift +// Mlem +// +// Created by Eric Andrews on 2023-10-02. +// + +import Foundation +import SwiftUI + +struct TransitionView: View { + let accountName: String? + @State var accountNameOpacity: CGFloat = .zero + + var body: some View { + VStack(spacing: 24) { + if let accountName { + Text("Welcome") + .onAppear { + withAnimation(.easeIn(duration: 0.5)) { + accountNameOpacity = 1.0 + } + } + Text(accountName) + .opacity(accountNameOpacity) + } else { + Text("Goodbye!") + } + } + .font(.largeTitle) + .bold() + .frame(maxWidth: .infinity, maxHeight: .infinity) + } +} diff --git a/Mlem/Window.swift b/Mlem/Window.swift index 3c67437f4..6dc4988e1 100644 --- a/Mlem/Window.swift +++ b/Mlem/Window.swift @@ -75,7 +75,7 @@ struct Window: View { private func setFlow(_ flow: AppFlow) { transition(flow) - DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { + DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { self.flow = flow } } @@ -83,30 +83,17 @@ struct Window: View { /// This method changes the current application flow and places a _transition_ view across the active window while /// - Parameter newFlow: The `AppFlow` that the application should transition into private func transition(_ newFlow: AppFlow) { - struct TransitionView: View { - let text: String - - var body: some View { - VStack(spacing: 24) { - ProgressView() - .controlSize(.large) - Text(text) - } - .frame(maxWidth: .infinity, maxHeight: .infinity) - } - } - - let transitionText: String + let transitionAccountName: String? switch newFlow { case .onboarding: - transitionText = "See you soon 👋" + transitionAccountName = nil case let .account(account): - transitionText = "Welcome \(account.nickname) 🚀" + transitionAccountName = account.nickname } Task { @MainActor in - let transition = TransitionView(text: transitionText) + let transition = TransitionView(accountName: transitionAccountName) guard let transitionView = UIHostingController(rootView: transition).view, let window = UIApplication.shared.firstKeyWindow else { return