Skip to content

Commit 1a0f830

Browse files
authored
Fix CMM-657: edit card menu shown in the wrong places (#24774)
1 parent 8765593 commit 1a0f830

2 files changed

Lines changed: 45 additions & 37 deletions

File tree

Modules/Sources/JetpackStats/Views/EditCardMenuContent.swift

Lines changed: 44 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,56 @@ struct EditCardMenuContent: View {
44
let cardViewModel: TrafficCardViewModel
55

66
var body: some View {
7-
Section {
8-
Menu {
9-
ControlGroup {
10-
Button {
11-
cardViewModel.configurationDelegate?.moveCard(cardViewModel, direction: .up)
12-
} label: {
13-
Label(Strings.Buttons.moveUp, systemImage: "arrow.up")
14-
}
7+
if cardViewModel.configurationDelegate != nil {
8+
Section {
9+
contents
10+
}
11+
}
12+
}
1513

16-
Button {
17-
cardViewModel.configurationDelegate?.moveCard(cardViewModel, direction: .top)
18-
} label: {
19-
Label(Strings.Buttons.moveToTop, systemImage: "arrow.up.to.line")
20-
}
14+
@ViewBuilder
15+
private var contents: some View {
16+
Menu {
17+
ControlGroup {
18+
Button {
19+
cardViewModel.configurationDelegate?.moveCard(cardViewModel, direction: .up)
20+
} label: {
21+
Label(Strings.Buttons.moveUp, systemImage: "arrow.up")
2122
}
2223

23-
ControlGroup {
24-
Button {
25-
cardViewModel.configurationDelegate?.moveCard(cardViewModel, direction: .down)
26-
} label: {
27-
Label(Strings.Buttons.moveDown, systemImage: "arrow.down")
28-
}
29-
30-
Button {
31-
cardViewModel.configurationDelegate?.moveCard(cardViewModel, direction: .bottom)
32-
} label: {
33-
Label(Strings.Buttons.moveToBottom, systemImage: "arrow.down.to.line")
34-
}
24+
Button {
25+
cardViewModel.configurationDelegate?.moveCard(cardViewModel, direction: .top)
26+
} label: {
27+
Label(Strings.Buttons.moveToTop, systemImage: "arrow.up.to.line")
3528
}
36-
} label: {
37-
Label(Strings.Buttons.moveCard, systemImage: "arrow.up.arrow.down")
38-
}
39-
Button {
40-
cardViewModel.isEditing = true
41-
} label: {
42-
Label(Strings.Buttons.customize, systemImage: "widget.small")
4329
}
44-
Button(role: .destructive) {
45-
cardViewModel.configurationDelegate?.deleteCard(cardViewModel)
46-
} label: {
47-
Label(Strings.Buttons.deleteWidget, systemImage: "trash")
48-
.tint(Color.red)
30+
31+
ControlGroup {
32+
Button {
33+
cardViewModel.configurationDelegate?.moveCard(cardViewModel, direction: .down)
34+
} label: {
35+
Label(Strings.Buttons.moveDown, systemImage: "arrow.down")
36+
}
37+
38+
Button {
39+
cardViewModel.configurationDelegate?.moveCard(cardViewModel, direction: .bottom)
40+
} label: {
41+
Label(Strings.Buttons.moveToBottom, systemImage: "arrow.down.to.line")
42+
}
4943
}
44+
} label: {
45+
Label(Strings.Buttons.moveCard, systemImage: "arrow.up.arrow.down")
46+
}
47+
Button {
48+
cardViewModel.isEditing = true
49+
} label: {
50+
Label(Strings.Buttons.customize, systemImage: "widget.small")
51+
}
52+
Button(role: .destructive) {
53+
cardViewModel.configurationDelegate?.deleteCard(cardViewModel)
54+
} label: {
55+
Label(Strings.Buttons.deleteWidget, systemImage: "trash")
56+
.tint(Color.red)
5057
}
5158
}
5259
}

RELEASE-NOTES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
-----
33
* [*] New Stats: Add support for "weeks" granularity [#24767]
44
* [*] New Stats: Fix dark mode support in custom range picker [#24770]
5+
* [*] New Stats: Fix edit card menu shown in the wrong places [#24774]
56
* [*] Fix Split View mode on iPad on some scenarios in portrait mode [#24705]
67

78
26.1

0 commit comments

Comments
 (0)