Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Update toast pill UI to show at bottom (#2006)

Leendert de Borstd5b0e70ab926
diff --git a/apps/mobile-app/ios/VaultUI/Selection/Components/CredentialCardView.swift b/apps/mobile-app/ios/VaultUI/Selection/Components/CredentialCardView.swift
index 380ab7bc5..4dd26e8c9 100644
--- a/apps/mobile-app/ios/VaultUI/Selection/Components/CredentialCardView.swift
+++ b/apps/mobile-app/ios/VaultUI/Selection/Components/CredentialCardView.swift
@@ -8,13 +8,17 @@ private let locBundle = Bundle.vaultUI
public struct AutofillCredentialCard: View {
let credential: AutofillCredential
let action: () -> Void
+ let onCopy: (String) -> Void
@Environment(\.colorScheme) private var colorScheme
- @State private var showCopyToast = false
- @State private var copyToastMessage = ""
- public init(credential: AutofillCredential, action: @escaping () -> Void) {
+ public init(
+ credential: AutofillCredential,
+ action: @escaping () -> Void,
+ onCopy: @escaping (String) -> Void = { _ in }
+ ) {
self.credential = credential
self.action = action
+ self.onCopy = onCopy
}
private var colors: ColorConstants.Colors.Type {
@@ -77,8 +81,7 @@ public struct AutofillCredentialCard: View {
if let username = credential.username, !username.isEmpty {
Button(action: {
UIPasteboard.general.string = username
- copyToastMessage = String(localized: "username_copied", bundle: locBundle)
- showCopyToast = true
+ onCopy(String(localized: "username_copied", bundle: locBundle))
}, label: {
Label(String(localized: "copy_username", bundle: locBundle), systemImage: "person")
})
@@ -87,8 +90,7 @@ public struct AutofillCredentialCard: View {
if let password = credential.password, !password.isEmpty {
Button(action: {
UIPasteboard.general.string = password
- copyToastMessage = String(localized: "password_copied", bundle: locBundle)
- showCopyToast = true
+ onCopy(String(localized: "password_copied", bundle: locBundle))
}, label: {
Label(String(localized: "copy_password", bundle: locBundle), systemImage: "key")
})
@@ -97,8 +99,7 @@ public struct AutofillCredentialCard: View {
if let email = credential.email, !email.isEmpty {
Button(action: {
UIPasteboard.general.string = email
- copyToastMessage = String(localized: "email_copied", bundle: locBundle)
- showCopyToast = true
+ onCopy(String(localized: "email_copied", bundle: locBundle))
}, label: {
Label(String(localized: "copy_email", bundle: locBundle), systemImage: "envelope")
})
@@ -110,8 +111,7 @@ public struct AutofillCredentialCard: View {
!code.isEmpty {
Button(action: {
UIPasteboard.general.string = code
- copyToastMessage = String(localized: "totp_code_copied", bundle: locBundle)
- showCopyToast = true
+ onCopy(String(localized: "totp_code_copied", bundle: locBundle))
}, label: {
Label(String(localized: "copy_totp_code", bundle: locBundle), systemImage: "number")
})
@@ -140,29 +140,37 @@ public struct AutofillCredentialCard: View {
Label(String(localized: "edit", bundle: locBundle), systemImage: "pencil")
})
})
+ }
+}
+
+/// Toast pill used for copy confirmations.
+public struct CopyToastView: View {
+ public let message: String
+
+ public init(message: String) {
+ self.message = message
+ }
+
+ public var body: some View {
+ HStack(spacing: 10) {
+ Image(systemName: "checkmark.circle.fill")
+ .font(.system(size: 18, weight: .semibold))
+ .foregroundStyle(.green)
+ Text(message)
+ .font(.subheadline.weight(.medium))
+ .foregroundStyle(.primary)
+ }
+ .padding(.horizontal, 16)
+ .padding(.vertical, 10)
+ .background(
+ Capsule()
+ .fill(.regularMaterial)
+ )
.overlay(
- Group {
- if showCopyToast {
- VStack {
- Spacer()
- Text(copyToastMessage)
- .padding()
- .background(Color.black.opacity(0.7))
- .foregroundColor(colorScheme == .dark ? ColorConstants.Dark.text : ColorConstants.Light.text)
- .cornerRadius(8)
- .padding(.bottom, 20)
- }
- .transition(.opacity)
- .onAppear {
- DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
- withAnimation {
- showCopyToast = false
- }
- }
- }
- }
- }
+ Capsule()
+ .strokeBorder(Color.primary.opacity(0.08), lineWidth: 0.5)
)
+ .shadow(color: Color.black.opacity(0.18), radius: 12, x: 0, y: 4)
}
}
diff --git a/apps/mobile-app/ios/VaultUI/Selection/CredentialProviderView.swift b/apps/mobile-app/ios/VaultUI/Selection/CredentialProviderView.swift
index 523b02da6..684bf9f15 100644
--- a/apps/mobile-app/ios/VaultUI/Selection/CredentialProviderView.swift
+++ b/apps/mobile-app/ios/VaultUI/Selection/CredentialProviderView.swift
@@ -11,6 +11,7 @@ public struct CredentialProviderView: View {
@Environment(\.dismiss) private var dismiss
@Environment(\.colorScheme) private var colorScheme
+ @State private var toastMessage: String?
public init(viewModel: CredentialProviderViewModel) {
self._viewModel = ObservedObject(wrappedValue: viewModel)
@@ -90,7 +91,8 @@ public struct CredentialProviderView: View {
username: username,
password: password
)
- }
+ },
+ onCopy: presentToast
)
}
}
@@ -160,6 +162,19 @@ public struct CredentialProviderView: View {
}
}
}
+ .overlay(alignment: .bottom) {
+ if let message = toastMessage {
+ CopyToastView(message: message)
+ .padding(.bottom, 24)
+ .transition(.move(edge: .bottom).combined(with: .opacity))
+ }
+ }
+ .animation(.spring(response: 0.4, dampingFraction: 0.85), value: toastMessage)
+ .task(id: toastMessage) {
+ guard toastMessage != nil else { return }
+ try? await Task.sleep(nanoseconds: 2_000_000_000)
+ toastMessage = nil
+ }
.task {
try? await Task.sleep(nanoseconds: 100_000_000)
await viewModel.loadCredentials()
@@ -170,6 +185,12 @@ public struct CredentialProviderView: View {
}
}
+ /// Show the global copy-confirmation toast. Each call resets the
+ /// auto-dismiss timer via `.task(id: toastMessage)` on the body.
+ private func presentToast(_ message: String) {
+ toastMessage = message
+ }
+
/// Two-way binding that maps the optional pendingLinkSelection to a Bool
/// for SwiftUI's `alert(_:isPresented:presenting:)` modifier. Setting the
/// bound value to `false` clears the pending selection on the view-model.
@@ -218,6 +239,7 @@ private struct AutofillCredentialCardWithSelection: View {
let credential: AutofillCredential
let isChoosingTextToInsert: Bool
let onSelect: (String, String) -> Void
+ let onCopy: (String) -> Void
@State private var showSelectionSheet = false
@State private var totpCode: String?
@@ -250,7 +272,7 @@ private struct AutofillCredentialCardWithSelection: View {
// Fill both username and password immediately for normal autofill
onSelect(identifier, credential.password ?? "")
}
- })
+ }, onCopy: onCopy)
.confirmationDialog(
String(localized: "select_text_to_insert", bundle: locBundle),
isPresented: $showSelectionSheet,