Skip to content

Commit af20820

Browse files
committed
refactor: restructure DeckCardRowView
1 parent e5a103d commit af20820

File tree

1 file changed

+47
-38
lines changed

1 file changed

+47
-38
lines changed

SWDestinyTrades/Classes/SwiftUI/Features/Decks/Components/DeckCardRowView.swift

Lines changed: 47 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -30,53 +30,62 @@ struct DeckCardRowView: View {
3030

3131
var body: some View {
3232
HStack {
33-
Image("ic_\(card.typeCode)")
34-
.resizable()
35-
.renderingMode(.template)
36-
.foregroundStyle(card.factionColor())
37-
.frame(width: 25, height: 25)
38-
.accessibilityHidden(true)
33+
cardInfoButton
34+
quantityControl
35+
}
36+
.padding(.vertical, 4)
37+
.swipeActions(edge: .trailing, allowsFullSwipe: true) {
38+
Button(L10n.delete, role: .destructive) {
39+
onRemove()
40+
}
41+
}
42+
}
3943

40-
Text("\(quantity)")
41-
.font(.body)
42-
.frame(minWidth: 30)
44+
private var cardInfoButton: some View {
45+
Button(action: onTap) {
46+
HStack {
47+
Image("ic_\(card.typeCode)")
48+
.resizable()
49+
.renderingMode(.template)
50+
.foregroundStyle(card.factionColor())
51+
.frame(width: 25, height: 25)
52+
.accessibilityHidden(true)
4353

44-
VStack(alignment: .leading, spacing: 2) {
45-
Text(card.name)
46-
.font(.headline)
47-
.lineLimit(1)
54+
Text("\(quantity)")
55+
.font(.body)
56+
.frame(minWidth: 30)
4857

49-
if !card.subtitle.isEmpty {
50-
Text(card.subtitle)
51-
.font(.caption)
52-
.foregroundStyle(.secondary)
58+
VStack(alignment: .leading, spacing: 2) {
59+
Text(card.name)
60+
.font(.headline)
5361
.lineLimit(1)
54-
}
55-
}
56-
57-
Spacer()
5862

59-
if card.typeCode == "character", card.isUnique {
60-
EliteToggleButton(isElite: $isElite) { newValue in
61-
onEliteToggle(newValue)
63+
if !card.subtitle.isEmpty {
64+
Text(card.subtitle)
65+
.font(.caption)
66+
.foregroundStyle(.secondary)
67+
.lineLimit(1)
68+
}
6269
}
63-
} else if !(card.typeCode == "character" && card.isUnique), card.typeCode != "battlefield" {
64-
Stepper("", value: $quantity, in: 1 ... card.deckLimit) { _ in
65-
onQuantityChange(quantity)
66-
}
67-
.labelsHidden()
70+
71+
Spacer()
6872
}
73+
.contentShape(Rectangle())
6974
}
70-
.padding(.vertical, 4)
71-
.contentShape(Rectangle())
72-
.onTapGesture {
73-
onTap()
74-
}
75-
.accessibilityAddTraits(.isButton)
76-
.swipeActions(edge: .trailing, allowsFullSwipe: true) {
77-
Button(L10n.delete, role: .destructive) {
78-
onRemove()
75+
.buttonStyle(.plain)
76+
}
77+
78+
@ViewBuilder
79+
private var quantityControl: some View {
80+
if card.typeCode == "character", card.isUnique {
81+
EliteToggleButton(isElite: $isElite) { newValue in
82+
onEliteToggle(newValue)
83+
}
84+
} else if !(card.typeCode == "character" && card.isUnique), card.typeCode != "battlefield" {
85+
Stepper("", value: $quantity, in: 1 ... card.deckLimit) { _ in
86+
onQuantityChange(quantity)
7987
}
88+
.labelsHidden()
8089
}
8190
}
8291
}

0 commit comments

Comments
 (0)