91 lines
3.3 KiB
Swift
91 lines
3.3 KiB
Swift
import SwiftUI
|
|
import Bedrock
|
|
import SwiftData
|
|
|
|
struct CardsHomeView: View {
|
|
@Environment(AppState.self) private var appState
|
|
@State private var showingCreateCard = false
|
|
|
|
var body: some View {
|
|
NavigationStack {
|
|
ScrollView {
|
|
VStack(spacing: Design.Spacing.xLarge) {
|
|
HeroBannerView()
|
|
SectionTitleView(
|
|
title: String.localized("Create your digital business card"),
|
|
subtitle: String.localized("Design and share polished cards for every context.")
|
|
)
|
|
CardCarouselView()
|
|
|
|
HStack(spacing: Design.Spacing.medium) {
|
|
if appState.cardStore.cards.isEmpty {
|
|
PrimaryActionButton(
|
|
title: String.localized("Create Card"),
|
|
systemImage: "plus"
|
|
) {
|
|
showingCreateCard = true
|
|
}
|
|
} else {
|
|
PrimaryActionButton(
|
|
title: String.localized("Send my card"),
|
|
systemImage: "paperplane.fill"
|
|
) {
|
|
appState.selectedTab = .share
|
|
}
|
|
|
|
Button(String.localized("New Card"), systemImage: "plus") {
|
|
showingCreateCard = true
|
|
}
|
|
.buttonStyle(.bordered)
|
|
.tint(Color.Accent.ink)
|
|
.controlSize(.large)
|
|
.accessibilityHint(String.localized("Create a new business card"))
|
|
}
|
|
}
|
|
|
|
WidgetsCalloutView()
|
|
}
|
|
.padding(.horizontal, Design.Spacing.large)
|
|
.padding(.vertical, Design.Spacing.xLarge)
|
|
}
|
|
.background(
|
|
LinearGradient(
|
|
colors: [Color.AppBackground.base, Color.AppBackground.accent],
|
|
startPoint: .top,
|
|
endPoint: .bottom
|
|
)
|
|
)
|
|
.navigationTitle(String.localized("My Cards"))
|
|
.sheet(isPresented: $showingCreateCard) {
|
|
CardEditorView(card: nil) { newCard in
|
|
appState.cardStore.addCard(newCard)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private struct SectionTitleView: View {
|
|
let title: String
|
|
let subtitle: String
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading, spacing: Design.Spacing.small) {
|
|
Text(title)
|
|
.font(.title3)
|
|
.bold()
|
|
.foregroundStyle(Color.Text.primary)
|
|
Text(subtitle)
|
|
.font(.subheadline)
|
|
.foregroundStyle(Color.Text.secondary)
|
|
}
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
let container = try! ModelContainer(for: BusinessCard.self, Contact.self)
|
|
return CardsHomeView()
|
|
.environment(AppState(modelContext: container.mainContext))
|
|
}
|