Skip to content

Commit 9a5a71c

Browse files
committed
[trello.com/c/bfhjk1NL] Fix: toolbar for macOS
1 parent 91ee008 commit 9a5a71c

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

Adamant/Modules/PartnerQR/PartnerQRView.swift

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@ struct PartnerQRView: View {
1212
@ObservedObject var viewModel: PartnerQRViewModel
1313

1414
var body: some View {
15-
Form {
16-
infoSection()
17-
toggleSection()
18-
buttonSection()
19-
}
20-
.navigationBarTitleDisplayMode(.inline)
21-
.toolbar {
22-
ToolbarItem(placement: .principal) {
23-
toolbar()
15+
GeometryReader { geometry in
16+
Form {
17+
infoSection()
18+
toggleSection()
19+
buttonSection()
20+
}
21+
.navigationBarTitleDisplayMode(.inline)
22+
.toolbar {
23+
ToolbarItem(placement: .principal) {
24+
toolbar(maxWidth: geometry.size.width)
25+
}
2426
}
2527
}
2628
}
2729
}
2830

2931
private extension PartnerQRView {
30-
func toolbar() -> some View {
31-
Button(action: {
32-
viewModel.renameContact()
33-
}) {
32+
func toolbar(maxWidth: CGFloat) -> some View {
33+
Button(action: viewModel.renameContact) {
3434
HStack {
3535
if let uiImage = viewModel.partnerImage {
3636
Image(uiImage: uiImage)
@@ -42,9 +42,8 @@ private extension PartnerQRView {
4242
.minimumScaleFactor(0.7)
4343
.lineLimit(1)
4444
}
45-
.frame(maxWidth: UIScreen.main.bounds.width - 150)
45+
.frame(maxWidth: maxWidth - toolbarSpace, alignment: .center)
4646
}
47-
.frame(maxWidth: UIScreen.main.bounds.width - 150)
4847
}
4948

5049
func infoSection() -> some View {
@@ -106,3 +105,5 @@ private extension PartnerQRView {
106105
}
107106
}
108107
}
108+
109+
private let toolbarSpace: CGFloat = 150

0 commit comments

Comments
 (0)