SyncAuthPromptModal.swift 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import SwiftUI
  2. /// Modal sheet prompting unauthenticated users to register or log in before synchronizing recordings.
  3. struct SyncAuthPromptModal: View {
  4. @Environment(\.dismiss) private var dismiss
  5. var onLoginClick: () -> Void
  6. var body: some View {
  7. ZStack {
  8. Color.spaceBlack.ignoresSafeArea()
  9. VStack(spacing: 24) {
  10. // Header Icon
  11. ZStack {
  12. Circle()
  13. .fill(Color.primary.opacity(0.06))
  14. .frame(width: 72, height: 72)
  15. Image(systemName: "icloud.and.arrow.up")
  16. .font(.system(size: 32, weight: .light))
  17. .foregroundStyle(Color.primary)
  18. }
  19. .padding(.top, 16)
  20. // Title & Subtitle
  21. VStack(spacing: 8) {
  22. Text("同步录音需要登录")
  23. .font(.system(size: 18, weight: .bold))
  24. .foregroundStyle(Color.primary)
  25. Text("请先注册或登录星痕现场记录账号\n数据才能安全同步至云端备份。")
  26. .font(.system(size: 13))
  27. .foregroundStyle(Color.secondary)
  28. .multilineTextAlignment(.center)
  29. .lineSpacing(4)
  30. }
  31. .padding(.horizontal, 20)
  32. // Value propositions
  33. VStack(alignment: .leading, spacing: 12) {
  34. featureRow(icon: "lock.shield", text: "端到端云端加密备份")
  35. featureRow(icon: "laptopcomputer.and.iphone", text: "多设备实时同步记录")
  36. featureRow(icon: "mic.fill", text: "专属录音设备绑定与管理")
  37. }
  38. .padding(16)
  39. .background(Color.cardBackground.opacity(0.5))
  40. .businessBorder(cornerRadius: 10)
  41. .padding(.horizontal, 16)
  42. Spacer()
  43. // Action Buttons
  44. VStack(spacing: 12) {
  45. Button {
  46. dismiss()
  47. onLoginClick()
  48. } label: {
  49. Text("立即注册 / 登录")
  50. .font(.system(size: 15, weight: .semibold))
  51. .foregroundStyle(Color.spaceBlack)
  52. .frame(maxWidth: .infinity)
  53. .padding(.vertical, 14)
  54. .background(Color.primary)
  55. .cornerRadius(8)
  56. }
  57. Button {
  58. dismiss()
  59. } label: {
  60. Text("暂不同步")
  61. .font(.system(size: 14, weight: .regular))
  62. .foregroundStyle(Color.secondary)
  63. .padding(.vertical, 8)
  64. }
  65. }
  66. .padding(.horizontal, 16)
  67. .padding(.bottom, 24)
  68. }
  69. }
  70. }
  71. private func featureRow(icon: String, text: String) -> some View {
  72. HStack(spacing: 12) {
  73. Image(systemName: icon)
  74. .font(.system(size: 14, weight: .regular))
  75. .foregroundStyle(Color.primary)
  76. .frame(width: 20)
  77. Text(text)
  78. .font(.system(size: 13, weight: .regular))
  79. .foregroundStyle(Color.primary.opacity(0.85))
  80. }
  81. }
  82. }
  83. #Preview {
  84. SyncAuthPromptModal(onLoginClick: {})
  85. }