Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Tiny/Core/Components/Theme/Models/BackgroundTheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
151 changes: 92 additions & 59 deletions Tiny/Features/Room/Views/RoomCodeDisplayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -31,73 +49,75 @@ 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)
} else {
Text("No room code")
.font(.subheadline)
.foregroundColor(.secondary)

Text("Ask your partner for their room code")
.font(.caption)
.foregroundColor(.secondary)
Expand All @@ -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 }
}
}
}
Expand All @@ -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
}
6 changes: 1 addition & 5 deletions Tiny/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -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..." : {
Expand Down