68 lines
2.2 KiB
Swift
68 lines
2.2 KiB
Swift
import SwiftUI
|
|
|
|
/// Success state shown after the contact has been saved.
|
|
struct ClipSuccessView: View {
|
|
@State private var showCheckmark = false
|
|
|
|
var body: some View {
|
|
VStack(spacing: ClipDesign.Spacing.xLarge) {
|
|
// Animated checkmark
|
|
Image(systemName: "checkmark.circle.fill")
|
|
.resizable()
|
|
.scaledToFit()
|
|
.frame(width: ClipDesign.Size.avatarLarge, height: ClipDesign.Size.avatarLarge)
|
|
.foregroundStyle(Color.Clip.success)
|
|
.scaleEffect(showCheckmark ? 1 : 0.5)
|
|
.opacity(showCheckmark ? 1 : 0)
|
|
.animation(.spring(response: 0.5, dampingFraction: 0.6), value: showCheckmark)
|
|
|
|
VStack(spacing: ClipDesign.Spacing.small) {
|
|
Text("Contact Saved!")
|
|
.font(.title2)
|
|
.bold()
|
|
.foregroundStyle(Color.Clip.text)
|
|
|
|
Text("You can find this contact in your Contacts app.")
|
|
.font(.subheadline)
|
|
.foregroundStyle(Color.Clip.secondaryText)
|
|
.multilineTextAlignment(.center)
|
|
}
|
|
|
|
// Open Contacts button
|
|
Button {
|
|
openContacts()
|
|
} label: {
|
|
Text("Open Contacts")
|
|
.font(.headline)
|
|
.foregroundStyle(Color.Clip.background)
|
|
.frame(maxWidth: .infinity)
|
|
.frame(height: ClipDesign.Size.buttonHeight)
|
|
.background(Color.Clip.success)
|
|
.clipShape(.capsule)
|
|
}
|
|
.padding(.horizontal, ClipDesign.Spacing.xLarge)
|
|
.padding(.top, ClipDesign.Spacing.large)
|
|
}
|
|
.padding(ClipDesign.Spacing.xLarge)
|
|
.onAppear {
|
|
showCheckmark = true
|
|
}
|
|
.accessibilityElement(children: .combine)
|
|
.accessibilityLabel(Text("Contact saved successfully"))
|
|
}
|
|
|
|
private func openContacts() {
|
|
if let url = URL(string: "contacts://") {
|
|
UIApplication.shared.open(url)
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
ZStack {
|
|
Color.Clip.background
|
|
.ignoresSafeArea()
|
|
ClipSuccessView()
|
|
}
|
|
}
|