diff --git a/Tiny/Core/Components/Theme/Models/BackgroundTheme.swift b/Tiny/Core/Components/Theme/Models/BackgroundTheme.swift index 9445c06..14be2e9 100644 --- a/Tiny/Core/Components/Theme/Models/BackgroundTheme.swift +++ b/Tiny/Core/Components/Theme/Models/BackgroundTheme.swift @@ -29,4 +29,17 @@ enum BackgroundTheme: String, CaseIterable, Identifiable { return "bgBlack" } } + + var color: Color { + switch self { + case .purple: + return Color(hex: "32173F") ?? Color.black + case .pink: + return Color(hex: "3F1738") ?? Color.black + case .blue: + return Color(hex: "19173F") ?? Color.black + case .black: + return Color.black + } + } } diff --git a/Tiny/Features/Room/Views/RoomCodeDisplayView.swift b/Tiny/Features/Room/Views/RoomCodeDisplayView.swift index d4bf99b..09c4b9b 100644 --- a/Tiny/Features/Room/Views/RoomCodeDisplayView.swift +++ b/Tiny/Features/Room/Views/RoomCodeDisplayView.swift @@ -6,18 +6,36 @@ // import SwiftUI +import UIKit struct RoomCodeDisplayView: View { @EnvironmentObject var authService: AuthenticationService + @EnvironmentObject var themeManager: ThemeManager @Environment(\.dismiss) var dismiss @State private var showCopiedMessage = false - + var body: some View { ZStack { - Color(.systemBackground) - .ignoresSafeArea() - - VStack(spacing: 30) { + Color(hex: "030411").ignoresSafeArea() + + // Bottom circular glow + Circle() + .fill( + RadialGradient( + gradient: Gradient(colors: [ + themeManager.selectedBackground.color.opacity(1), + themeManager.selectedBackground.color.opacity(0) + ]), + center: .center, + startRadius: 0, + endRadius: 600 + ) + ) + .frame(width: 200, height: 200) + .blur(radius: 60) + .offset(y: 120) // Near bottom + + VStack(spacing: 10) { // Header HStack { Spacer() @@ -31,65 +49,68 @@ struct RoomCodeDisplayView: View { } .padding(.horizontal) .padding(.top, 10) - + Spacer() - + // Icon - Image(systemName: "person.2.circle.fill") - .font(.system(size: 80)) - .foregroundColor(.pink) - + Image("yellowHeart") + .resizable() + .scaledToFit() + .frame(width: 30) + // Title - VStack(spacing: 10) { + VStack(spacing: 5) { Text(authService.currentUser?.role == .mother ? "Your Room Code" : "Room Code") .font(.title2) .fontWeight(.bold) - - Text(authService.currentUser?.role == .mother ? - "Share this code with your partner" : - "You're connected to this room") - .font(.subheadline) - .foregroundColor(.secondary) - .multilineTextAlignment(.center) - .padding(.horizontal, 40) + + Text(authService.currentUser?.role == .mother ? + "Share this code with your partner" : + "You're connected to this room") + .font(.subheadline) + .foregroundColor(.secondary) + .multilineTextAlignment(.center) + .padding(.horizontal, 40) } - + // Room Code Display if let roomCode = authService.currentUser?.roomCode { - VStack(spacing: 15) { - Text(roomCode) - .font(.system(size: 48, weight: .bold, design: .rounded)) - .tracking(8) - .foregroundColor(.primary) - .padding(.vertical, 20) - .padding(.horizontal, 40) - .background( - RoundedRectangle(cornerRadius: 16) - .fill(Color(.systemGray6)) - ) - - // Copy Button + ZStack { Button(action: copyRoomCode) { - HStack(spacing: 8) { - Image(systemName: showCopiedMessage ? "checkmark" : "doc.on.doc") - .font(.system(size: 16)) - Text(showCopiedMessage ? "Copied!" : "Copy Code") - .fontWeight(.medium) + HStack { + Text(roomCode) + .font(.system(size: 18, weight: .heavy, design: .rounded)) + .tracking(3) + .foregroundColor(.white) + Image(systemName: "doc.on.doc") + .foregroundColor(.white) } - .foregroundColor(showCopiedMessage ? .green : .blue) - .padding(.horizontal, 24) - .padding(.vertical, 12) + .padding(.vertical, 20) + .padding(.horizontal, 40) .background( - RoundedRectangle(cornerRadius: 10) - .fill(showCopiedMessage ? Color.green.opacity(0.1) : Color.blue.opacity(0.1)) + // Frosted capsule background + Capsule() + .fill(.ultraThinMaterial) // frosted glass effect + .opacity(0.8) ) } + + if showCopiedMessage { + Text("Copied!") + .font(.caption) + .fontWeight(.bold) + .foregroundColor(.white) + .padding(.vertical, 8) + .padding(.horizontal, 12) + .background(Capsule().fill(Color.black.opacity(0.6))) + .offset(y: 50) // Position below the button + .transition(.opacity) + } } } else { VStack(spacing: 15) { if authService.currentUser?.role == .mother { - ProgressView() - .padding() + ProgressView().padding() Text("Creating room...") .font(.subheadline) .foregroundColor(.secondary) @@ -97,7 +118,6 @@ struct RoomCodeDisplayView: View { Text("No room code") .font(.subheadline) .foregroundColor(.secondary) - Text("Ask your partner for their room code") .font(.caption) .foregroundColor(.secondary) @@ -106,26 +126,17 @@ struct RoomCodeDisplayView: View { } } } - - Spacer() Spacer() } } } - + private func copyRoomCode() { if let roomCode = authService.currentUser?.roomCode { UIPasteboard.general.string = roomCode - - withAnimation { - showCopiedMessage = true - } - - // Reset after 2 seconds + withAnimation { showCopiedMessage = true } DispatchQueue.main.asyncAfter(deadline: .now() + 2) { - withAnimation { - showCopiedMessage = false - } + withAnimation { showCopiedMessage = false } } } } @@ -134,4 +145,26 @@ struct RoomCodeDisplayView: View { #Preview { RoomCodeDisplayView() .environmentObject(AuthenticationService()) + .environmentObject(ThemeManager()) +} + +#Preview { + // Create a mock AuthenticationService with a sample user + let authService = AuthenticationService() + authService.currentUser = User( + id: "1", + email: "mother@example.com", + name: "Jane Doe", + role: .mother, + pregnancyWeeks: 20, + roomCode: "ABCD12", // Sample room code + createdAt: Date() + ) + + let themeManager = ThemeManager() + + return RoomCodeDisplayView() + .environmentObject(authService) + .environmentObject(themeManager) + .preferredColorScheme(.dark) // Optional: show dark mode preview } diff --git a/Tiny/Resources/Localizable.xcstrings b/Tiny/Resources/Localizable.xcstrings index 03eec97..8f5024d 100644 --- a/Tiny/Resources/Localizable.xcstrings +++ b/Tiny/Resources/Localizable.xcstrings @@ -202,11 +202,7 @@ }, "Copied!" : { - "comment" : "A confirmation message displayed when the room code is successfully copied to the clipboard.", - "isCommentAutoGenerated" : true - }, - "Copy Code" : { - "comment" : "A button label that says \"Copy Code\".", + "comment" : "A message displayed when the user successfully copies the room code.", "isCommentAutoGenerated" : true }, "Creating room..." : {