diff --git a/Session.xcodeproj/project.pbxproj b/Session.xcodeproj/project.pbxproj index 399caa073..28fbc7b20 100644 --- a/Session.xcodeproj/project.pbxproj +++ b/Session.xcodeproj/project.pbxproj @@ -166,6 +166,7 @@ 7BDCFC0B2421EB7600641C39 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = B6F509951AA53F760068F56A /* Localizable.strings */; }; 7BDE2A982A8B122900AE4393 /* LandingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BDE2A972A8B122900AE4393 /* LandingView.swift */; }; 7BDE2A9A2A8C59CF00AE4393 /* AttributedText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BDE2A992A8C59CF00AE4393 /* AttributedText.swift */; }; + 7BF570D32A9C1F9300DB013E /* Toast.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BF570D22A9C1F9300DB013E /* Toast.swift */; }; 7BF8D1FB2A70AF57005F1D6E /* SwiftUI+Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BF8D1FA2A70AF57005F1D6E /* SwiftUI+Theme.swift */; }; 7BFA8AE32831D0D4001876F3 /* ContextMenuVC+EmojiReactsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BFA8AE22831D0D4001876F3 /* ContextMenuVC+EmojiReactsView.swift */; }; 7BFD1A8A2745C4F000FB91B9 /* Permissions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BFD1A892745C4F000FB91B9 /* Permissions.swift */; }; @@ -1289,6 +1290,7 @@ 7BDE2A972A8B122900AE4393 /* LandingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LandingView.swift; sourceTree = ""; }; 7BDE2A992A8C59CF00AE4393 /* AttributedText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttributedText.swift; sourceTree = ""; }; 7BE2701D2A64C11500CEB71A /* SessionCarouselView+SwiftUI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SessionCarouselView+SwiftUI.swift"; sourceTree = ""; }; + 7BF570D22A9C1F9300DB013E /* Toast.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toast.swift; sourceTree = ""; }; 7BF8D1FA2A70AF57005F1D6E /* SwiftUI+Theme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SwiftUI+Theme.swift"; sourceTree = ""; }; 7BFA8AE22831D0D4001876F3 /* ContextMenuVC+EmojiReactsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ContextMenuVC+EmojiReactsView.swift"; sourceTree = ""; }; 7BFD1A892745C4F000FB91B9 /* Permissions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Permissions.swift; sourceTree = ""; }; @@ -2962,6 +2964,7 @@ FD0B77AF29B69A65009169BA /* TopBannerController.swift */, 7BDE2A992A8C59CF00AE4393 /* AttributedText.swift */, 7B87EF432A8DA720002A0E8F /* SessionTextField.swift */, + 7BF570D22A9C1F9300DB013E /* Toast.swift */, ); path = Components; sourceTree = ""; @@ -5514,6 +5517,7 @@ C331FFB92558FA8D00070591 /* UIView+Constraints.swift in Sources */, 7BDE2A9A2A8C59CF00AE4393 /* AttributedText.swift in Sources */, 7B87EF442A8DA720002A0E8F /* SessionTextField.swift in Sources */, + 7BF570D32A9C1F9300DB013E /* Toast.swift in Sources */, FD0B77B029B69A65009169BA /* TopBannerController.swift in Sources */, FD37E9F628A5F106003AE748 /* Configuration.swift in Sources */, 7BF8D1FB2A70AF57005F1D6E /* SwiftUI+Theme.swift in Sources */, diff --git a/Session/Onboarding/LoadAccountView.swift b/Session/Onboarding/LoadAccountView.swift index 722cc2fef..a4e2e18ce 100644 --- a/Session/Onboarding/LoadAccountView.swift +++ b/Session/Onboarding/LoadAccountView.swift @@ -12,7 +12,7 @@ struct LoadAccountView: View { @State var tabIndex = 0 @State private var recoveryPassword: String = "" @State private var hexEncodedSeed: String = "" - @State private var errorString: String? = nil + @State private var errorString: String? = "Test Error" var body: some View { ZStack(alignment: .topLeading) { @@ -273,18 +273,9 @@ struct ScanQRCodeView: View { maxHeight: .infinity ) - if error?.isEmpty == false { - VStack { - Spacer() - - Text(error!) - .font(.system(size: Values.verySmallFontSize)) - .foregroundColor(themeColor: .textPrimary) - .multilineTextAlignment(.center) - .frame( - width: 320, - height: 44 - ) + if let error: String = error, !error.isEmpty { + withAnimation(.easeIn(duration: 0.5)) { + Toast(error) } } } else { diff --git a/SessionUIKit/Components/Toast.swift b/SessionUIKit/Components/Toast.swift new file mode 100644 index 000000000..f5b9cb433 --- /dev/null +++ b/SessionUIKit/Components/Toast.swift @@ -0,0 +1,54 @@ +// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved. + +import SwiftUI + +public struct Toast: View { + @State var dismiss: Bool = false + + let message: String + + static let width: CGFloat = 320 + static let height: CGFloat = 44 + + public init(_ message: String) { + self.message = message + } + + public var body: some View { + VStack { + Spacer() + + if !dismiss { + ZStack { + Capsule() + .foregroundColor(themeColor: .toast_background) + + Text(message) + .font(.system(size: Values.verySmallFontSize)) + .foregroundColor(themeColor: .textPrimary) + .multilineTextAlignment(.center) + .frame(maxWidth: .infinity) + .padding(.horizontal, Values.mediumSpacing) + } + .frame( + width: Self.width, + height: Self.height + ) + .padding(.bottom, Values.smallSpacing) + } + } + .onAppear { + Timer.scheduledTimerOnMainThread(withTimeInterval: 5) { _ in + withAnimation(.easeOut(duration: 0.5)) { + dismiss.toggle() + } + } + } + } +} + +struct Toast_Previews: PreviewProvider { + static var previews: some View { + Toast("This QR code does not contain a Recovery Password.") + } +} diff --git a/SessionUIKit/Style Guide/Themes/Theme+ClassicDark.swift b/SessionUIKit/Style Guide/Themes/Theme+ClassicDark.swift index 207fba3f3..50ca43052 100644 --- a/SessionUIKit/Style Guide/Themes/Theme+ClassicDark.swift +++ b/SessionUIKit/Style Guide/Themes/Theme+ClassicDark.swift @@ -83,6 +83,7 @@ internal enum Theme_ClassicDark: ThemeColors { .alert_text: .classicDark6, .alert_background: .classicDark1, .alert_buttonBackground: .classicDark1, + .toast_background: .classicDark2, // ConversationButton .conversationButton_background: .classicDark1, @@ -203,6 +204,7 @@ internal enum Theme_ClassicDark: ThemeColors { .alert_text: .classicDark6, .alert_background: .classicDark1, .alert_buttonBackground: .classicDark1, + .toast_background: .classicDark2, // ConversationButton .conversationButton_background: .classicDark1, diff --git a/SessionUIKit/Style Guide/Themes/Theme+ClassicLight.swift b/SessionUIKit/Style Guide/Themes/Theme+ClassicLight.swift index 4436227a7..80713a460 100644 --- a/SessionUIKit/Style Guide/Themes/Theme+ClassicLight.swift +++ b/SessionUIKit/Style Guide/Themes/Theme+ClassicLight.swift @@ -83,6 +83,7 @@ internal enum Theme_ClassicLight: ThemeColors { .alert_text: .classicLight0, .alert_background: .classicLight6, .alert_buttonBackground: .classicLight6, + .toast_background: .classicLight4, // ConversationButton .conversationButton_background: .classicLight6, @@ -203,6 +204,7 @@ internal enum Theme_ClassicLight: ThemeColors { .alert_text: .classicLight0, .alert_background: .classicLight6, .alert_buttonBackground: .classicLight6, + .toast_background: .classicLight4, // ConversationButton .conversationButton_background: .classicLight6, diff --git a/SessionUIKit/Style Guide/Themes/Theme+OceanDark.swift b/SessionUIKit/Style Guide/Themes/Theme+OceanDark.swift index 62e14e674..2de74e9fb 100644 --- a/SessionUIKit/Style Guide/Themes/Theme+OceanDark.swift +++ b/SessionUIKit/Style Guide/Themes/Theme+OceanDark.swift @@ -83,6 +83,7 @@ internal enum Theme_OceanDark: ThemeColors { .alert_text: .oceanDark7, .alert_background: .oceanDark3, .alert_buttonBackground: .oceanDark3, + .toast_background: .oceanDark4, // ConversationButton .conversationButton_background: .oceanDark3, @@ -203,6 +204,7 @@ internal enum Theme_OceanDark: ThemeColors { .alert_text: .oceanDark7, .alert_background: .oceanDark3, .alert_buttonBackground: .oceanDark3, + .toast_background: .oceanDark4, // ConversationButton .conversationButton_background: .oceanDark3, diff --git a/SessionUIKit/Style Guide/Themes/Theme+OceanLight.swift b/SessionUIKit/Style Guide/Themes/Theme+OceanLight.swift index 63125bdee..93fa004fc 100644 --- a/SessionUIKit/Style Guide/Themes/Theme+OceanLight.swift +++ b/SessionUIKit/Style Guide/Themes/Theme+OceanLight.swift @@ -83,6 +83,7 @@ internal enum Theme_OceanLight: ThemeColors { .alert_text: .oceanLight0, .alert_background: .oceanLight7, .alert_buttonBackground: .oceanLight7, + .toast_background: .oceanLight5, // ConversationButton .conversationButton_background: .oceanLight7, @@ -203,6 +204,7 @@ internal enum Theme_OceanLight: ThemeColors { .alert_text: .oceanLight0, .alert_background: .oceanLight7, .alert_buttonBackground: .oceanLight7, + .toast_background: .oceanLight5, // ConversationButton .conversationButton_background: .oceanLight7, diff --git a/SessionUIKit/Style Guide/Themes/Theme.swift b/SessionUIKit/Style Guide/Themes/Theme.swift index 72a38004b..eabf5ac9a 100644 --- a/SessionUIKit/Style Guide/Themes/Theme.swift +++ b/SessionUIKit/Style Guide/Themes/Theme.swift @@ -195,6 +195,7 @@ public indirect enum ThemeValue: Hashable { case alert_text case alert_background case alert_buttonBackground + case toast_background // ConversationButton case conversationButton_background