|
| 1 | +import Foundation |
| 2 | +import SwiftUI |
| 3 | + |
| 4 | +struct TranscriptDropdownButton: View { |
| 5 | + let transcriptText: String |
| 6 | + |
| 7 | + @State private var isCollapsed: Bool = true |
| 8 | + |
| 9 | + init(transcriptText: String) { |
| 10 | + self.transcriptText = transcriptText |
| 11 | + } |
| 12 | + |
| 13 | + var body: some View { |
| 14 | + HStack(alignment: .top, spacing: 12) { |
| 15 | + Image(systemName: isCollapsed ? "chevron.down" : "chevron.up") |
| 16 | + .font(.system(size: 16, weight: .bold)) |
| 17 | + |
| 18 | + |
| 19 | + VStack(alignment: .leading) { |
| 20 | + Text("Transcript") |
| 21 | + .font(UIConstants.Typography.cardTitle) |
| 22 | + .foregroundColor(UIConstants.Colors.textPrimary) |
| 23 | + |
| 24 | + VStack { |
| 25 | + |
| 26 | + if !isCollapsed { |
| 27 | + Text(transcriptText) |
| 28 | + } |
| 29 | + } |
| 30 | + } |
| 31 | + |
| 32 | + Spacer() |
| 33 | + |
| 34 | + } |
| 35 | + .frame(alignment: .topLeading) |
| 36 | + .padding(.horizontal, UIConstants.Spacing.cardPadding + 4) |
| 37 | + .padding(.vertical, UIConstants.Spacing.cardPadding) |
| 38 | + .background( |
| 39 | + RoundedRectangle(cornerRadius: 20) |
| 40 | + .fill(UIConstants.Colors.cardSecondaryBackground) |
| 41 | + .overlay( |
| 42 | + RoundedRectangle(cornerRadius: 20) |
| 43 | + .stroke( |
| 44 | + UIConstants.Gradients.standardBorder, |
| 45 | + lineWidth: 1 |
| 46 | + ) |
| 47 | + ) |
| 48 | + ) |
| 49 | + .onTapGesture { |
| 50 | + withAnimation(.easeInOut(duration: 0.25)) { |
| 51 | + isCollapsed.toggle() |
| 52 | + } |
| 53 | + } |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +#Preview { |
| 58 | + GeometryReader { geometry in |
| 59 | + VStack(spacing: 16) { |
| 60 | + TranscriptDropdownButton( |
| 61 | + transcriptText: "Lorem ipsum dolor sit amet" |
| 62 | + ) |
| 63 | + } |
| 64 | + .padding(20) |
| 65 | + } |
| 66 | + .frame(width: 500, height: 300) |
| 67 | + .background(UIConstants.Gradients.backgroundGradient) |
| 68 | +} |
0 commit comments