From 29f6252ae284cb4b7a2ba8ccafa615133d2e31ed Mon Sep 17 00:00:00 2001 From: William Brawner Date: Tue, 7 Dec 2021 19:32:27 -0700 Subject: [PATCH] Hide empty fields on transaction details page --- .../Transaction/TransactionDetailsView.swift | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Twigs/Transaction/TransactionDetailsView.swift b/Twigs/Transaction/TransactionDetailsView.swift index 1c7704d..abdf103 100644 --- a/Twigs/Transaction/TransactionDetailsView.swift +++ b/Twigs/Transaction/TransactionDetailsView.swift @@ -58,17 +58,20 @@ struct LabeledField: View { let value: String? let showDivider: Bool + @ViewBuilder var body: some View { - VStack { - HStack { - Text(self.label) - .foregroundColor(.secondary) - Spacer() - Text(verbatim: value ?? "") - .multilineTextAlignment(.trailing) - } - if showDivider { - Divider() + if let val = value, !val.isEmpty { + VStack { + HStack { + Text(self.label) + .foregroundColor(.secondary) + Spacer() + Text(verbatim: value ?? "") + .multilineTextAlignment(.trailing) + } + if showDivider { + Divider() + } } } }