From 5e073f2c7214be9fb9b2743925575df4272c7026 Mon Sep 17 00:00:00 2001 From: Destu Cikal Date: Mon, 1 Dec 2025 04:31:35 +0700 Subject: [PATCH 1/3] fix: room code background --- .../Theme/Models/BackgroundTheme.swift | 13 ++++++++++ .../Room/Views/RoomCodeDisplayView.swift | 25 +++++++++++++++---- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/Tiny/Core/Components/Theme/Models/BackgroundTheme.swift b/Tiny/Core/Components/Theme/Models/BackgroundTheme.swift index 9445c06..c507af7 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..3e1549a 100644 --- a/Tiny/Features/Room/Views/RoomCodeDisplayView.swift +++ b/Tiny/Features/Room/Views/RoomCodeDisplayView.swift @@ -6,17 +6,30 @@ // import SwiftUI +import UIKit // Added import for UIScreen struct RoomCodeDisplayView: View { @EnvironmentObject var authService: AuthenticationService + @EnvironmentObject var themeManager: ThemeManager // Add ThemeManager @Environment(\.dismiss) var dismiss @State private var showCopiedMessage = false var body: some View { ZStack { - Color(.systemBackground) + // Dynamic background based on theme + themeManager.selectedBackground.color .ignoresSafeArea() + // Middle-bottom gradient circle + RadialGradient( + gradient: Gradient(colors: [themeManager.selectedBackground.color.opacity(0.8), themeManager.selectedBackground.color]), + center: .bottom, + startRadius: 0, + endRadius: UIScreen.main.bounds.width * 0.3 + ) + .offset(y: UIScreen.main.bounds.height / 3) // Adjust position to be middle-bottom + .ignoresSafeArea() + VStack(spacing: 30) { // Header HStack { @@ -35,10 +48,11 @@ struct RoomCodeDisplayView: View { Spacer() // Icon - Image(systemName: "person.2.circle.fill") - .font(.system(size: 80)) - .foregroundColor(.pink) - + Image("yellowHeart") + .resizable() + .scaledToFit() + .frame(width: 20) + // Title VStack(spacing: 10) { Text(authService.currentUser?.role == .mother ? "Your Room Code" : "Room Code") @@ -134,4 +148,5 @@ struct RoomCodeDisplayView: View { #Preview { RoomCodeDisplayView() .environmentObject(AuthenticationService()) + .environmentObject(ThemeManager()) // Add ThemeManager to the preview } From 947d2fe3803a9aad97da7c23beeb6b6965d9f196 Mon Sep 17 00:00:00 2001 From: Destu Cikal Date: Mon, 1 Dec 2025 05:33:57 +0700 Subject: [PATCH 2/3] fix: add background in room code display --- .../Theme/Models/BackgroundTheme.swift | 2 +- .../Room/Views/RoomCodeDisplayView.swift | 152 +++++++++--------- Tiny/Resources/Localizable.xcstrings | 8 - 3 files changed, 79 insertions(+), 83 deletions(-) diff --git a/Tiny/Core/Components/Theme/Models/BackgroundTheme.swift b/Tiny/Core/Components/Theme/Models/BackgroundTheme.swift index c507af7..14be2e9 100644 --- a/Tiny/Core/Components/Theme/Models/BackgroundTheme.swift +++ b/Tiny/Core/Components/Theme/Models/BackgroundTheme.swift @@ -33,7 +33,7 @@ enum BackgroundTheme: String, CaseIterable, Identifiable { var color: Color { switch self { case .purple: - return Color(hex: "32173F") ?? Color.black + return Color(hex: "32173F") ?? Color.black case .pink: return Color(hex: "3F1738") ?? Color.black case .blue: diff --git a/Tiny/Features/Room/Views/RoomCodeDisplayView.swift b/Tiny/Features/Room/Views/RoomCodeDisplayView.swift index 3e1549a..ee733f7 100644 --- a/Tiny/Features/Room/Views/RoomCodeDisplayView.swift +++ b/Tiny/Features/Room/Views/RoomCodeDisplayView.swift @@ -6,31 +6,36 @@ // import SwiftUI -import UIKit // Added import for UIScreen +import UIKit struct RoomCodeDisplayView: View { @EnvironmentObject var authService: AuthenticationService - @EnvironmentObject var themeManager: ThemeManager // Add ThemeManager + @EnvironmentObject var themeManager: ThemeManager @Environment(\.dismiss) var dismiss @State private var showCopiedMessage = false - + var body: some View { ZStack { - // Dynamic background based on theme - themeManager.selectedBackground.color - .ignoresSafeArea() - - // Middle-bottom gradient circle - RadialGradient( - gradient: Gradient(colors: [themeManager.selectedBackground.color.opacity(0.8), themeManager.selectedBackground.color]), - center: .bottom, - startRadius: 0, - endRadius: UIScreen.main.bounds.width * 0.3 - ) - .offset(y: UIScreen.main.bounds.height / 3) // Adjust position to be middle-bottom - .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() @@ -44,66 +49,54 @@ struct RoomCodeDisplayView: View { } .padding(.horizontal) .padding(.top, 10) - + Spacer() - + // Icon Image("yellowHeart") .resizable() .scaledToFit() - .frame(width: 20) + .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 - Button(action: copyRoomCode) { - HStack(spacing: 8) { - Image(systemName: showCopiedMessage ? "checkmark" : "doc.on.doc") - .font(.system(size: 16)) - Text(showCopiedMessage ? "Copied!" : "Copy Code") - .fontWeight(.medium) - } - .foregroundColor(showCopiedMessage ? .green : .blue) - .padding(.horizontal, 24) - .padding(.vertical, 12) - .background( - RoundedRectangle(cornerRadius: 10) - .fill(showCopiedMessage ? Color.green.opacity(0.1) : Color.blue.opacity(0.1)) - ) + Button(action: copyRoomCode) { + HStack { + Text(roomCode) + .font(.system(size: 18, weight: .heavy, design: .rounded)) + .tracking(3) + .foregroundColor(.white) + Image(systemName: "doc.on.doc") + .foregroundColor(.white) } + .padding(.vertical, 20) + .padding(.horizontal, 40) + .background( + // Frosted capsule background + Capsule() + .fill(.ultraThinMaterial) // frosted glass effect + .opacity(0.8) + ) } } else { VStack(spacing: 15) { if authService.currentUser?.role == .mother { - ProgressView() - .padding() + ProgressView().padding() Text("Creating room...") .font(.subheadline) .foregroundColor(.secondary) @@ -111,7 +104,6 @@ struct RoomCodeDisplayView: View { Text("No room code") .font(.subheadline) .foregroundColor(.secondary) - Text("Ask your partner for their room code") .font(.caption) .foregroundColor(.secondary) @@ -120,26 +112,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 } } } } @@ -148,5 +131,26 @@ struct RoomCodeDisplayView: View { #Preview { RoomCodeDisplayView() .environmentObject(AuthenticationService()) - .environmentObject(ThemeManager()) // Add ThemeManager to the preview + .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..5ecc526 100644 --- a/Tiny/Resources/Localizable.xcstrings +++ b/Tiny/Resources/Localizable.xcstrings @@ -200,14 +200,6 @@ }, "Control your screen with a simple gesture:" : { - }, - "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\".", - "isCommentAutoGenerated" : true }, "Creating room..." : { "comment" : "A message displayed while a room is being created.", From a830f2ebe6abb138e1b5f6e474bf4f4739dd36ed Mon Sep 17 00:00:00 2001 From: Destu Cikal Date: Mon, 1 Dec 2025 05:40:24 +0700 Subject: [PATCH 3/3] fix: show copied status --- .../Room/Views/RoomCodeDisplayView.swift | 44 ++++++++++++------- Tiny/Resources/Localizable.xcstrings | 4 ++ 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/Tiny/Features/Room/Views/RoomCodeDisplayView.swift b/Tiny/Features/Room/Views/RoomCodeDisplayView.swift index ee733f7..09c4b9b 100644 --- a/Tiny/Features/Room/Views/RoomCodeDisplayView.swift +++ b/Tiny/Features/Room/Views/RoomCodeDisplayView.swift @@ -75,23 +75,37 @@ struct RoomCodeDisplayView: View { // Room Code Display if let roomCode = authService.currentUser?.roomCode { - Button(action: copyRoomCode) { - HStack { - Text(roomCode) - .font(.system(size: 18, weight: .heavy, design: .rounded)) - .tracking(3) - .foregroundColor(.white) - Image(systemName: "doc.on.doc") + ZStack { + Button(action: copyRoomCode) { + HStack { + Text(roomCode) + .font(.system(size: 18, weight: .heavy, design: .rounded)) + .tracking(3) + .foregroundColor(.white) + Image(systemName: "doc.on.doc") + .foregroundColor(.white) + } + .padding(.vertical, 20) + .padding(.horizontal, 40) + .background( + // 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) } - .padding(.vertical, 20) - .padding(.horizontal, 40) - .background( - // Frosted capsule background - Capsule() - .fill(.ultraThinMaterial) // frosted glass effect - .opacity(0.8) - ) } } else { VStack(spacing: 15) { diff --git a/Tiny/Resources/Localizable.xcstrings b/Tiny/Resources/Localizable.xcstrings index 5ecc526..8f5024d 100644 --- a/Tiny/Resources/Localizable.xcstrings +++ b/Tiny/Resources/Localizable.xcstrings @@ -200,6 +200,10 @@ }, "Control your screen with a simple gesture:" : { + }, + "Copied!" : { + "comment" : "A message displayed when the user successfully copies the room code.", + "isCommentAutoGenerated" : true }, "Creating room..." : { "comment" : "A message displayed while a room is being created.",