From 3d5a098423802a9e9d4f934d71ac2398e4ed3e65 Mon Sep 17 00:00:00 2001 From: gladiusKatana Date: Thu, 29 Dec 2022 20:17:24 -0500 Subject: [PATCH] SaveKeyView: add spacers to make Text frames invariant upon Copy-tap Closes: #192 --- damus/Views/SaveKeysView.swift | 37 ++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/damus/Views/SaveKeysView.swift b/damus/Views/SaveKeysView.swift index 7f92f279..3946b04b 100644 --- a/damus/Views/SaveKeysView.swift +++ b/damus/Views/SaveKeysView.swift @@ -147,20 +147,24 @@ struct SaveKeyView: View { var body: some View { HStack { - Button(action: copy_text) { - Label("", systemImage: is_copied ? "checkmark.circle.fill" : "doc.on.doc") - .foregroundColor(is_copied ? .green : .white) - .background { - if is_copied { - Circle() - .foregroundColor(.white) - .frame(width: 25, height: 25, alignment: .center) - .padding(.leading, -8) - .padding(.top, 1) - } else { - EmptyView() + Spacer() + VStack { + spacerBlock(width: 0, height: 0) + Button(action: copy_text) { + Label("", systemImage: is_copied ? "checkmark.circle.fill" : "doc.on.doc") + .foregroundColor(is_copied ? .green : .white) + .background { + if is_copied { + Circle() + .foregroundColor(.white) + .frame(width: 25, height: 25, alignment: .center) + .padding(.leading, -8) + .padding(.top, 1) + } else { + EmptyView() + } } - } + } } Text(text) @@ -174,8 +178,15 @@ struct SaveKeyView: View { .onTapGesture { copy_text() } + + spacerBlock(width: 0, height: 0) /// set a 'width' > 0 here to vary key Text's aspect ratio } } + + @ViewBuilder private func spacerBlock(width: CGFloat, height: CGFloat) -> some View { + Color.orange.opacity(1) + .frame(width: width, height: height) + } } struct SaveKeysView_Previews: PreviewProvider {