55 lines
1.3 KiB
Swift
55 lines
1.3 KiB
Swift
//
|
|
// UIComponents.swift
|
|
// TeachMate
|
|
//
|
|
// Created by Hongli on 2025/3/18.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
// Shared UI components for forms across the app
|
|
public struct FormSection<Content: View>: View {
|
|
public let title: String
|
|
public let content: Content
|
|
@Environment(\.colorScheme) private var colorScheme
|
|
|
|
public init(title: String, @ViewBuilder content: () -> Content) {
|
|
self.title = title
|
|
self.content = content()
|
|
}
|
|
|
|
public var body: some View {
|
|
VStack(alignment: .leading, spacing: 12) {
|
|
Text(title)
|
|
.font(.headline)
|
|
.foregroundStyle(.primary)
|
|
|
|
content
|
|
.padding()
|
|
.frame(maxWidth: .infinity)
|
|
.background(colorScheme == .dark ? Color.black : Color.white)
|
|
.cornerRadius(12)
|
|
}
|
|
.frame(maxWidth: .infinity)
|
|
}
|
|
}
|
|
|
|
public struct SummaryRow: View {
|
|
public let label: String
|
|
public let value: String
|
|
|
|
public var body: some View {
|
|
HStack(alignment: .top) {
|
|
Text(label)
|
|
.foregroundStyle(.secondary)
|
|
.frame(width: 80, alignment: .leading)
|
|
|
|
Text(value)
|
|
.foregroundStyle(.primary)
|
|
.fontWeight(.medium)
|
|
|
|
Spacer()
|
|
}
|
|
}
|
|
}
|