SaveKeyView: add spacers to make Text frames invariant upon Copy-tap
Closes: #192
This commit is contained in:
committed by
William Casarin
parent
d0e9e6c03a
commit
3d5a098423
@@ -147,20 +147,24 @@ struct SaveKeyView: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
HStack {
|
HStack {
|
||||||
Button(action: copy_text) {
|
Spacer()
|
||||||
Label("", systemImage: is_copied ? "checkmark.circle.fill" : "doc.on.doc")
|
VStack {
|
||||||
.foregroundColor(is_copied ? .green : .white)
|
spacerBlock(width: 0, height: 0)
|
||||||
.background {
|
Button(action: copy_text) {
|
||||||
if is_copied {
|
Label("", systemImage: is_copied ? "checkmark.circle.fill" : "doc.on.doc")
|
||||||
Circle()
|
.foregroundColor(is_copied ? .green : .white)
|
||||||
.foregroundColor(.white)
|
.background {
|
||||||
.frame(width: 25, height: 25, alignment: .center)
|
if is_copied {
|
||||||
.padding(.leading, -8)
|
Circle()
|
||||||
.padding(.top, 1)
|
.foregroundColor(.white)
|
||||||
} else {
|
.frame(width: 25, height: 25, alignment: .center)
|
||||||
EmptyView()
|
.padding(.leading, -8)
|
||||||
|
.padding(.top, 1)
|
||||||
|
} else {
|
||||||
|
EmptyView()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Text(text)
|
Text(text)
|
||||||
@@ -174,8 +178,15 @@ struct SaveKeyView: View {
|
|||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
copy_text()
|
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 {
|
struct SaveKeysView_Previews: PreviewProvider {
|
||||||
|
|||||||
Reference in New Issue
Block a user