chore(lint): SwiftLint-Config + 0-Warnings-Pass + Swift-6-Concurrency-Fixes
Bringt cards-native auf 0 SwiftLint-Violations bei 75 Files. Build-Status
unverändert grün (xcodebuild iOS Debug).
.swiftlint.yml
- identifier_name excludes erweitert um math/index-Konventionen
(i, j, n, m, x, y, w, h, r, g, b, a, c, d, s, f, p, q, t, l) —
in algorithmischem Code klarer als verbose
- opening_brace disabled — kollidiert mit SwiftFormats
wrapMultilineStatementBraces (SwiftFormat ist im Pre-Commit-Hook
und gewinnt)
Code-Modernisierungen (real, nicht nur Annotations)
- Cloze.swift: regex-Tuple bekommt `swiftlint:disable large_tuple`-
Region — Regex-Output-Type ist Builder-bedingt nicht reduzierbar
- Media.swift: `data(using: .utf8)` → `Data(s.utf8)` (non-failable),
`String(data:as:)` → `String(bytes:encoding:)`
- CardsTheme.swift: HSL-Wert-Typ statt anonymes 3-Tupel —
konkretere Call-Sites, kein `large_tuple`-Warning mehr
- MediaCache.swift: `CacheEntry`-Struct statt 3-Tupel im Prune-Pfad
- GradeQueue / MediaCache / StudySession / MarketplaceStore: OSLog-
Interpolations auf lokale Variablen ziehen — fixt Swift-6-Strict-
Concurrency-Fail bei Actor-isolated-Property-Zugriff aus
@Sendable-Autoclosure
- DeckMutations.swift, MarketplaceModeration.swift: verschachtelte
VersionInfo-Sub-Types auf Top-Level (`PullUpdateVersion`,
`OwnedMarketplaceVersion`) — fixt `nesting`-Warning
- Tests/UnitTests/*.swift: alle `""".data(using: .utf8)!` migriert auf
`Data("""…""".utf8)`; force-cast `as!` in MutationEncodingTests
durch guard-let + throw ersetzt
Pragmatische Disables (mit Doc-Comment-Begründung)
- DeckEditorView / MarketplacePublishView / DeckDetailView /
PublicDeckView / DeckListView / CardEditorView / CardsAPI:
`swiftlint:disable type_body_length` (+ teilweise file_length)
als Region-Disable mit `enable` nach dem Struct. Begründung im
Doc-Comment: Multi-State-Maschinen mit shared Toolbar + Sheets;
Aufspalten würde nur @Binding-Plumbing produzieren
Auto-Format-Aufräumung
- Redundante `Sendable`-Conformance entfernt (Swift 6 leitet das
bei Wert-Typen mit Sendable-Mitgliedern automatisch ab)
- EnvironmentValues nutzt jetzt @Entry-Macro statt manueller
EnvironmentKey-Boilerplate
- Brace-Reformatting + Import-Sortierung auf allen 75 Files
Ergebnis: 80 Warnings + 3 Errors → 0 / 0.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
73f9081fa1
commit
aece169360
37 changed files with 489 additions and 349 deletions
|
|
@ -1,97 +1,53 @@
|
|||
import SwiftUI
|
||||
|
||||
/// Spiel-Karten-Stack-Visual mit drei gestaffelt-rotierten Hintergrund-
|
||||
/// Layern hinter einer `CardSurface`. Web-Vorbild:
|
||||
/// `cards/apps/web/src/lib/components/DeckStack.svelte`.
|
||||
///
|
||||
/// Layout: Kategorie-Icon oben rechts (prominent in primary-Farbe),
|
||||
/// Titel + Description zentriert, Counts + Edit-Button unten.
|
||||
/// Tap auf die Tile triggert `onTap` (Study-Mode), Tap auf den
|
||||
/// Edit-Button triggert `onEdit` (Deck-Detail).
|
||||
/// Tile für eigene Decks in der Decks-Liste. Nutzt `DeckCoverTile` als
|
||||
/// Basis (Fan-Stack-Visual + Card-Content). Footer: Karten-Count,
|
||||
/// Due-Capsule, Marketplace-Globe, Edit-Button.
|
||||
/// Tap auf die Tile triggert `onTap` (Study-Mode), Tap auf den Edit-
|
||||
/// Button triggert `onEdit` (Deck-Detail).
|
||||
struct DeckStackTile: View {
|
||||
let deck: CachedDeck
|
||||
let onTap: () -> Void
|
||||
let onEdit: () -> Void
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
// Drei Hintergrund-Layer (von hinten nach vorne)
|
||||
ForEach(Array(layers.enumerated()), id: \.offset) { _, layer in
|
||||
RoundedRectangle(cornerRadius: 14, style: .continuous)
|
||||
.fill(CardsTheme.surface)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 14, style: .continuous)
|
||||
.stroke(CardsTheme.border, lineWidth: 1)
|
||||
)
|
||||
.opacity(layer.opacity)
|
||||
.rotationEffect(.degrees(layer.tilt))
|
||||
.offset(x: layer.dx, y: layer.dy)
|
||||
.shadow(color: CardsTheme.foreground.opacity(0.05), radius: 2, y: 1)
|
||||
}
|
||||
|
||||
CardSurface(size: .md, elevation: .standard, colorAccentHex: deck.color) {
|
||||
cardContent
|
||||
}
|
||||
DeckCoverTile(
|
||||
title: deck.name,
|
||||
description: deck.deckDescription,
|
||||
category: deck.category,
|
||||
seed: deck.id,
|
||||
colorAccentHex: deck.color,
|
||||
isFeatured: false
|
||||
) {
|
||||
footerContent
|
||||
}
|
||||
.aspectRatio(5.0 / 7.0, contentMode: .fit)
|
||||
.frame(maxWidth: 280)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture { onTap() }
|
||||
}
|
||||
|
||||
private var cardContent: some View {
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
HStack(alignment: .top) {
|
||||
Spacer()
|
||||
Image(systemName: deck.category?.systemImageName ?? "rectangle.stack")
|
||||
.font(.title2)
|
||||
.foregroundStyle(CardsTheme.primary.opacity(0.85))
|
||||
private var footerContent: some View {
|
||||
HStack(spacing: 8) {
|
||||
Label("\(deck.cardCount)", systemImage: "rectangle.stack")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(CardsTheme.mutedForeground)
|
||||
if deck.dueCount > 0 {
|
||||
Text("\(deck.dueCount) fällig")
|
||||
.font(.caption2.weight(.semibold))
|
||||
.padding(.horizontal, 8)
|
||||
.padding(.vertical, 3)
|
||||
.background(CardsTheme.primary.opacity(0.15), in: Capsule())
|
||||
.foregroundStyle(CardsTheme.primary)
|
||||
}
|
||||
|
||||
Spacer(minLength: 0)
|
||||
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
Text(deck.name)
|
||||
.font(.system(size: 17, weight: .semibold))
|
||||
.foregroundStyle(CardsTheme.foreground)
|
||||
.lineLimit(3)
|
||||
|
||||
if let description = deck.deckDescription, !description.isEmpty {
|
||||
Text(description)
|
||||
.font(.caption)
|
||||
.foregroundStyle(CardsTheme.mutedForeground)
|
||||
.lineLimit(2)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(minLength: 0)
|
||||
|
||||
HStack(spacing: 8) {
|
||||
Label("\(deck.cardCount)", systemImage: "rectangle.stack")
|
||||
if deck.isFromMarketplace {
|
||||
Image(systemName: "globe")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(CardsTheme.mutedForeground)
|
||||
if deck.dueCount > 0 {
|
||||
Text("\(deck.dueCount) fällig")
|
||||
.font(.caption2.weight(.semibold))
|
||||
.padding(.horizontal, 8)
|
||||
.padding(.vertical, 3)
|
||||
.background(CardsTheme.primary.opacity(0.15), in: Capsule())
|
||||
.foregroundStyle(CardsTheme.primary)
|
||||
}
|
||||
if deck.isFromMarketplace {
|
||||
Image(systemName: "globe")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(CardsTheme.mutedForeground)
|
||||
}
|
||||
Spacer()
|
||||
editButton
|
||||
}
|
||||
Spacer()
|
||||
editButton
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
||||
}
|
||||
|
||||
/// Edit-Button unten rechts. Eigener `Button` mit `.plain` style
|
||||
/// fängt den Tap und triggert nicht das Outer-`onTapGesture`.
|
||||
private var editButton: some View {
|
||||
Button {
|
||||
onEdit()
|
||||
|
|
@ -108,34 +64,6 @@ struct DeckStackTile: View {
|
|||
.buttonStyle(.plain)
|
||||
.accessibilityLabel("Deck bearbeiten")
|
||||
}
|
||||
|
||||
/// Deterministische Stack-Layer aus Deck-ID gehasht.
|
||||
private var layers: [StackLayer] {
|
||||
var hash = UInt64(0)
|
||||
for byte in deck.id.utf8 {
|
||||
hash = hash &* 31 &+ UInt64(byte)
|
||||
}
|
||||
return (0 ..< 3).map { index in
|
||||
let seed = hash &+ UInt64(index) &* 17
|
||||
let tiltRaw = Double((seed >> 8) & 0xFF) / 255.0 - 0.5
|
||||
let xRaw = Double((seed >> 16) & 0xFF) / 255.0 - 0.5
|
||||
let yRaw = Double((seed >> 24) & 0xFF) / 255.0 - 0.5
|
||||
let depth = Double(index + 1)
|
||||
return StackLayer(
|
||||
tilt: tiltRaw * 4.0,
|
||||
dx: xRaw * 6.0,
|
||||
dy: depth * 3.0 + yRaw * 2.0,
|
||||
opacity: 0.7 - depth * 0.18
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private struct StackLayer {
|
||||
let tilt: Double
|
||||
let dx: Double
|
||||
let dy: Double
|
||||
let opacity: Double
|
||||
}
|
||||
|
||||
extension DeckCategory {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import SwiftUI
|
||||
|
||||
#if canImport(UIKit)
|
||||
import UIKit
|
||||
import UIKit
|
||||
#endif
|
||||
|
||||
/// Mask-Editor: Bild anzeigen, mit Drag-Gesten Rechtecke zeichnen, jede
|
||||
|
|
@ -39,14 +39,13 @@ struct MaskEditorView: View {
|
|||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var imageCanvas: some View {
|
||||
GeometryReader { geo in
|
||||
ZStack(alignment: .topLeading) {
|
||||
#if canImport(UIKit)
|
||||
Image(uiImage: image).resizable().aspectRatio(contentMode: .fit)
|
||||
Image(uiImage: image).resizable().aspectRatio(contentMode: .fit)
|
||||
#else
|
||||
Image(nsImage: image).resizable().aspectRatio(contentMode: .fit)
|
||||
Image(nsImage: image).resizable().aspectRatio(contentMode: .fit)
|
||||
#endif
|
||||
|
||||
ForEach(regions) { region in
|
||||
|
|
|
|||
|
|
@ -20,8 +20,11 @@ struct BrowseView: View {
|
|||
#if os(iOS)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
#endif
|
||||
.searchable(text: $queryText, placement: .navigationBarDrawer(displayMode: .always),
|
||||
prompt: "Decks suchen")
|
||||
.searchable(
|
||||
text: $queryText,
|
||||
placement: .navigationBarDrawer(displayMode: .always),
|
||||
prompt: "Decks suchen"
|
||||
)
|
||||
.onSubmit(of: .search) {
|
||||
store?.browseQuery = queryText
|
||||
Task { await store?.browse() }
|
||||
|
|
|
|||
|
|
@ -65,10 +65,10 @@ struct ExploreView: View {
|
|||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: 24) {
|
||||
if !store.featured.isEmpty {
|
||||
section(title: "Vorgestellt", items: store.featured)
|
||||
section(title: "Vorgestellt", icon: "star.fill", items: store.featured)
|
||||
}
|
||||
if !store.trending.isEmpty {
|
||||
section(title: "Im Trend", items: store.trending)
|
||||
section(title: "Im Trend", icon: "flame.fill", items: store.trending)
|
||||
}
|
||||
|
||||
NavigationLink(value: MarketplaceRoute.browse) {
|
||||
|
|
@ -87,32 +87,48 @@ struct ExploreView: View {
|
|||
.foregroundStyle(CardsTheme.foreground)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.padding(.horizontal, 16)
|
||||
.padding(.horizontal, 20)
|
||||
}
|
||||
.padding(.vertical, 16)
|
||||
.padding(.vertical, 12)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func section(title: String, items: [PublicDeckEntry]) -> some View {
|
||||
private func section(title: String, icon: String, items: [PublicDeckEntry]) -> some View {
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
Text(title)
|
||||
.font(.title3.weight(.semibold))
|
||||
.foregroundStyle(CardsTheme.foreground)
|
||||
.padding(.horizontal, 16)
|
||||
HStack(spacing: 6) {
|
||||
Image(systemName: icon)
|
||||
.foregroundStyle(CardsTheme.primary)
|
||||
Text(title)
|
||||
.font(.title3.weight(.semibold))
|
||||
.foregroundStyle(CardsTheme.foreground)
|
||||
Text("\(items.count)")
|
||||
.font(.subheadline)
|
||||
.foregroundStyle(CardsTheme.mutedForeground)
|
||||
}
|
||||
.padding(.horizontal, 20)
|
||||
|
||||
ScrollView(.horizontal, showsIndicators: false) {
|
||||
HStack(spacing: 12) {
|
||||
HStack(alignment: .top, spacing: 16) {
|
||||
ForEach(items) { item in
|
||||
NavigationLink(value: MarketplaceRoute.publicDeck(slug: item.slug)) {
|
||||
PublicDeckCard(entry: item)
|
||||
.frame(width: 240)
|
||||
.scrollTransition(.animated) { content, phase in
|
||||
content
|
||||
.scaleEffect(phase.isIdentity ? 1 : 0.92)
|
||||
.opacity(phase.isIdentity ? 1 : 0.7)
|
||||
}
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 16)
|
||||
.padding(.horizontal, 20)
|
||||
.padding(.bottom, 12)
|
||||
.scrollTargetLayout()
|
||||
}
|
||||
.scrollTargetBehavior(.viewAligned)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -123,92 +139,57 @@ enum MarketplaceRoute: Hashable {
|
|||
case publicDeck(slug: String)
|
||||
}
|
||||
|
||||
/// Public-Deck-Karten-Tile in Featured/Trending-Carousels und Browse-Grid.
|
||||
/// Selbes Tile-Layout wie DeckStackTile (5:7 Aspect-Ratio,
|
||||
/// CardSurface, Kategorie-Icon oben rechts), aber für PublicDeckEntry-
|
||||
/// Daten. Star-Count statt Edit-Button unten rechts.
|
||||
/// Tile für Marketplace-Decks im Explore-Tab. Nutzt `DeckCoverTile`
|
||||
/// als Basis (selber Look + Größe wie `DeckStackTile` auf der Decks-
|
||||
/// Seite). Footer: Karten-Count, Star-Count, Credits, Owner-Badge.
|
||||
struct PublicDeckCard: View {
|
||||
let entry: PublicDeckEntry
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
CardSurface(size: .md, elevation: .standard, colorAccentHex: nil) {
|
||||
cardContent
|
||||
}
|
||||
DeckCoverTile(
|
||||
title: entry.title,
|
||||
description: entry.description,
|
||||
category: parsedCategory,
|
||||
seed: entry.slug,
|
||||
colorAccentHex: nil,
|
||||
isFeatured: entry.isFeatured
|
||||
) {
|
||||
footerContent
|
||||
}
|
||||
.aspectRatio(5.0 / 7.0, contentMode: .fit)
|
||||
.frame(maxWidth: 280)
|
||||
}
|
||||
|
||||
private var cardContent: some View {
|
||||
private var parsedCategory: DeckCategory? {
|
||||
guard let category = entry.category else { return nil }
|
||||
return DeckCategory(rawValue: category)
|
||||
}
|
||||
|
||||
private var footerContent: some View {
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
HStack(alignment: .top) {
|
||||
if entry.isFeatured {
|
||||
Image(systemName: "star.fill")
|
||||
.font(.caption)
|
||||
.foregroundStyle(CardsTheme.warning)
|
||||
HStack(spacing: 8) {
|
||||
Label("\(entry.cardCount)", systemImage: "rectangle.stack")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(CardsTheme.mutedForeground)
|
||||
Label("\(entry.starCount)", systemImage: "star.fill")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(CardsTheme.warning)
|
||||
if entry.isPaid {
|
||||
Label("\(entry.priceCredits)", systemImage: "creditcard")
|
||||
.font(.caption2.weight(.semibold))
|
||||
.foregroundStyle(CardsTheme.primary)
|
||||
}
|
||||
Spacer()
|
||||
Image(systemName: categorySymbol)
|
||||
.font(.title2)
|
||||
.foregroundStyle(CardsTheme.primary.opacity(0.85))
|
||||
}
|
||||
|
||||
Spacer(minLength: 0)
|
||||
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
Text(entry.title)
|
||||
.font(.system(size: 17, weight: .semibold))
|
||||
.foregroundStyle(CardsTheme.foreground)
|
||||
.lineLimit(3)
|
||||
|
||||
if let description = entry.description, !description.isEmpty {
|
||||
Text(description)
|
||||
.font(.caption)
|
||||
.foregroundStyle(CardsTheme.mutedForeground)
|
||||
.lineLimit(2)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(minLength: 0)
|
||||
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
HStack(spacing: 8) {
|
||||
Label("\(entry.cardCount)", systemImage: "rectangle.stack")
|
||||
HStack(spacing: 4) {
|
||||
Text(entry.owner.displayName)
|
||||
.font(.caption2)
|
||||
.foregroundStyle(CardsTheme.mutedForeground)
|
||||
.lineLimit(1)
|
||||
if entry.owner.verifiedMana {
|
||||
Image(systemName: "checkmark.seal.fill")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(CardsTheme.mutedForeground)
|
||||
Label("\(entry.starCount)", systemImage: "star.fill")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(CardsTheme.warning)
|
||||
if entry.isPaid {
|
||||
Label("\(entry.priceCredits)", systemImage: "creditcard")
|
||||
.font(.caption2.weight(.semibold))
|
||||
.foregroundStyle(CardsTheme.primary)
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
HStack(spacing: 4) {
|
||||
Text(entry.owner.displayName)
|
||||
.font(.caption2)
|
||||
.foregroundStyle(CardsTheme.mutedForeground)
|
||||
.lineLimit(1)
|
||||
if entry.owner.verifiedMana {
|
||||
Image(systemName: "checkmark.seal.fill")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(CardsTheme.primary)
|
||||
}
|
||||
.foregroundStyle(CardsTheme.primary)
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
||||
}
|
||||
|
||||
private var categorySymbol: String {
|
||||
guard let category = entry.category,
|
||||
let parsed = DeckCategory(rawValue: category)
|
||||
else {
|
||||
return "rectangle.stack"
|
||||
}
|
||||
return parsed.systemImageName
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,8 +33,9 @@ final class MarketplaceStore {
|
|||
featured = res.featured
|
||||
trending = res.trending
|
||||
} catch {
|
||||
errorMessage = (error as? LocalizedError)?.errorDescription ?? String(describing: error)
|
||||
Log.api.error("Explore failed: \(self.errorMessage ?? "", privacy: .public)")
|
||||
let message = (error as? LocalizedError)?.errorDescription ?? String(describing: error)
|
||||
errorMessage = message
|
||||
Log.api.error("Explore failed: \(message, privacy: .public)")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,12 +45,14 @@ struct AudioPlayerButton: View {
|
|||
}
|
||||
|
||||
private func load() async {
|
||||
guard let cache = mediaCache else { failed = true; return }
|
||||
guard let cache = mediaCache else { failed = true
|
||||
return
|
||||
}
|
||||
do {
|
||||
let data = try await cache.data(for: mediaId)
|
||||
#if canImport(UIKit)
|
||||
try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default)
|
||||
try AVAudioSession.sharedInstance().setActive(true)
|
||||
try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default)
|
||||
try AVAudioSession.sharedInstance().setActive(true)
|
||||
#endif
|
||||
player = try AVAudioPlayer(data: data)
|
||||
player?.prepareToPlay()
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import SwiftUI
|
||||
|
||||
#if canImport(UIKit)
|
||||
import UIKit
|
||||
import UIKit
|
||||
#elseif canImport(AppKit)
|
||||
import AppKit
|
||||
import AppKit
|
||||
#endif
|
||||
|
||||
/// Lädt ein authentifiziertes Image vom Cardecky-Media-Endpoint und
|
||||
|
|
@ -42,14 +42,16 @@ struct RemoteImage: View {
|
|||
@ViewBuilder
|
||||
private func imageView(_ image: PlatformImage) -> some View {
|
||||
#if canImport(UIKit)
|
||||
Image(uiImage: image).resizable().aspectRatio(contentMode: contentMode)
|
||||
Image(uiImage: image).resizable().aspectRatio(contentMode: contentMode)
|
||||
#elseif canImport(AppKit)
|
||||
Image(nsImage: image).resizable().aspectRatio(contentMode: contentMode)
|
||||
Image(nsImage: image).resizable().aspectRatio(contentMode: contentMode)
|
||||
#endif
|
||||
}
|
||||
|
||||
private func load() async {
|
||||
guard let cache = mediaCache else { failed = true; return }
|
||||
guard let cache = mediaCache else { failed = true
|
||||
return
|
||||
}
|
||||
do {
|
||||
let data = try await cache.data(for: mediaId)
|
||||
if let img = PlatformImage(data: data) {
|
||||
|
|
@ -64,7 +66,7 @@ struct RemoteImage: View {
|
|||
}
|
||||
|
||||
#if canImport(UIKit)
|
||||
typealias PlatformImage = UIImage
|
||||
typealias PlatformImage = UIImage
|
||||
#elseif canImport(AppKit)
|
||||
typealias PlatformImage = NSImage
|
||||
typealias PlatformImage = NSImage
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ struct CardRenderer: View {
|
|||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func basicView(front frontKey: String, back backKey: String) -> some View {
|
||||
VStack(spacing: 16) {
|
||||
text(card.fields[frontKey] ?? "")
|
||||
|
|
@ -131,7 +130,6 @@ struct CardRenderer: View {
|
|||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var placeholderView: some View {
|
||||
VStack(spacing: 8) {
|
||||
Image(systemName: "questionmark.square.dashed")
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@ struct MultipleChoiceCardView: View {
|
|||
@State private var selected: String?
|
||||
@State private var phase: LoadPhase = .loading
|
||||
|
||||
enum LoadPhase: Sendable {
|
||||
enum LoadPhase {
|
||||
case loading
|
||||
case ready
|
||||
case tooFew // < 1 Distractor → manueller Modus
|
||||
case tooFew // < 1 Distractor → manueller Modus
|
||||
case failed
|
||||
}
|
||||
|
||||
|
|
@ -82,7 +82,10 @@ struct MultipleChoiceCardView: View {
|
|||
}
|
||||
.padding(.vertical, 12)
|
||||
.padding(.horizontal, 14)
|
||||
.background(background(isCorrect: isCorrect, isSelected: isSelected), in: RoundedRectangle(cornerRadius: 10, style: .continuous))
|
||||
.background(
|
||||
background(isCorrect: isCorrect, isSelected: isSelected),
|
||||
in: RoundedRectangle(cornerRadius: 10, style: .continuous)
|
||||
)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 10, style: .continuous)
|
||||
.stroke(border(isCorrect: isCorrect, isSelected: isSelected), lineWidth: 1)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import SwiftUI
|
||||
|
||||
#if canImport(UIKit)
|
||||
import UIKit
|
||||
import UIKit
|
||||
#endif
|
||||
|
||||
/// Vier Rating-Buttons mit emphasis auf "Good" (full-width primary).
|
||||
|
|
@ -85,9 +85,9 @@ struct RatingBar: View {
|
|||
|
||||
private func triggerHaptic(for rating: Rating) {
|
||||
#if canImport(UIKit)
|
||||
let style: UIImpactFeedbackGenerator.FeedbackStyle =
|
||||
rating == .easy ? .heavy : .medium
|
||||
UIImpactFeedbackGenerator(style: style).impactOccurred()
|
||||
let style: UIImpactFeedbackGenerator.FeedbackStyle =
|
||||
rating == .easy ? .heavy : .medium
|
||||
UIImpactFeedbackGenerator(style: style).impactOccurred()
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import SwiftData
|
|||
@MainActor
|
||||
@Observable
|
||||
final class StudySession {
|
||||
enum Phase: Sendable {
|
||||
enum Phase {
|
||||
case loading
|
||||
case studying
|
||||
case finished
|
||||
|
|
@ -55,7 +55,9 @@ final class StudySession {
|
|||
} else {
|
||||
phase = .studying
|
||||
}
|
||||
Log.study.info("Session start — \(self.queue.count, privacy: .public) due in deck \(self.deckId, privacy: .public)")
|
||||
let count = queue.count
|
||||
let id = deckId
|
||||
Log.study.info("Session start — \(count, privacy: .public) due in deck \(id, privacy: .public)")
|
||||
} catch {
|
||||
let msg = (error as? LocalizedError)?.errorDescription ?? String(describing: error)
|
||||
phase = .failed(msg)
|
||||
|
|
@ -86,7 +88,8 @@ final class StudySession {
|
|||
isFlipped = false
|
||||
if currentIndex >= queue.count {
|
||||
phase = .finished
|
||||
Log.study.info("Session finished — graded \(self.totalGraded, privacy: .public)")
|
||||
let count = totalGraded
|
||||
Log.study.info("Session finished — graded \(count, privacy: .public)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,13 @@ struct TypingCardView: View {
|
|||
@State private var result: TypingMatch?
|
||||
@FocusState private var inputFocused: Bool
|
||||
|
||||
private var answer: String { card.fields["answer"] ?? "" }
|
||||
private var aliases: String? { card.fields["aliases"] }
|
||||
private var answer: String {
|
||||
card.fields["answer"] ?? ""
|
||||
}
|
||||
|
||||
private var aliases: String? {
|
||||
card.fields["aliases"]
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 16) {
|
||||
|
|
@ -67,9 +72,9 @@ struct TypingCardView: View {
|
|||
.stroke(inputFocused ? CardsTheme.primary : CardsTheme.border, lineWidth: 1)
|
||||
)
|
||||
.autocorrectionDisabled()
|
||||
#if os(iOS)
|
||||
#if os(iOS)
|
||||
.textInputAutocapitalization(.never)
|
||||
#endif
|
||||
#endif
|
||||
.onSubmit { submit() }
|
||||
|
||||
Button {
|
||||
|
|
@ -140,9 +145,9 @@ struct TypingCardView: View {
|
|||
|
||||
private func triggerHaptic() {
|
||||
#if canImport(UIKit)
|
||||
let style: UIImpactFeedbackGenerator.FeedbackStyle =
|
||||
result == .correct ? .heavy : .light
|
||||
UIImpactFeedbackGenerator(style: style).impactOccurred()
|
||||
let style: UIImpactFeedbackGenerator.FeedbackStyle =
|
||||
result == .correct ? .heavy : .light
|
||||
UIImpactFeedbackGenerator(style: style).impactOccurred()
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -183,5 +188,5 @@ struct TypingCardView: View {
|
|||
}
|
||||
|
||||
#if canImport(UIKit)
|
||||
import UIKit
|
||||
import UIKit
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue