commit 5c131e62d7be8d4f3f8358c3042343fe1acef1f1
parent 29ab48287fa4a68ae9b5e2f17c3bbeae78075cfc
Author: ericholguin <eric.holguinsanchez@gmail.com>
Date: Thu, 13 Apr 2023 20:54:08 -0600
Add QR Code in profiles
Changelog-Added: Add QR Code in profiles
Closes: #918
Diffstat:
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/damus/Views/Profile/ProfileView.swift b/damus/Views/Profile/ProfileView.swift
@@ -119,6 +119,7 @@ struct ProfileView: View {
@State var showing_select_wallet: Bool = false
@State var is_zoomed: Bool = false
@State var show_share_sheet: Bool = false
+ @State var show_qr_code: Bool = false
@State var action_sheet_presented: Bool = false
@State var filter_state : FilterState = .posts
@State var yOffset: CGFloat = 0
@@ -213,6 +214,10 @@ struct ProfileView: View {
Button(NSLocalizedString("Share", comment: "Button to share the link to a profile.")) {
show_share_sheet = true
}
+
+ Button(NSLocalizedString("QR Code", comment: "Button to view profile's qr code.")) {
+ show_qr_code = true
+ }
// Only allow reporting if logged in with private key and the currently viewed profile is not the logged in profile.
if profile.pubkey != damus_state.pubkey && damus_state.is_privkey_user {
@@ -465,6 +470,9 @@ struct ProfileView: View {
}
}
}
+ .fullScreenCover(isPresented: $show_qr_code) {
+ QRCodeView(damus_state: damus_state, pubkey: profile.pubkey)
+ }
}
}
diff --git a/damus/Views/QRCodeView.swift b/damus/Views/QRCodeView.swift
@@ -10,12 +10,13 @@ import CoreImage.CIFilterBuiltins
struct QRCodeView: View {
let damus_state: DamusState
+ @State var pubkey: String = ""
@Environment(\.dismiss) var dismiss
@Environment(\.presentationMode) var presentationMode
var maybe_key: String? {
- guard let key = bech32_pubkey(damus_state.pubkey) else {
+ guard let key = bech32_pubkey(pubkey) else {
return nil
}
@@ -39,10 +40,11 @@ struct QRCodeView: View {
}
VStack(alignment: .center) {
- let profile = damus_state.profiles.lookup(id: damus_state.pubkey)
- if (damus_state.profiles.lookup(id: damus_state.pubkey)?.picture) != nil {
- ProfilePicView(pubkey: damus_state.pubkey, size: 90.0, highlight: .custom(DamusColors.white, 4.0), profiles: damus_state.profiles)
+ let profile = damus_state.profiles.lookup(id: pubkey)
+
+ if (damus_state.profiles.lookup(id: pubkey)?.picture) != nil {
+ ProfilePicView(pubkey: pubkey, size: 90.0, highlight: .custom(DamusColors.white, 4.0), profiles: damus_state.profiles)
.padding(.top, 50)
} else {
Image(systemName: "person.fill")
@@ -92,6 +94,11 @@ struct QRCodeView: View {
}
}
+ .onAppear() {
+ if pubkey.isEmpty {
+ pubkey = damus_state.pubkey
+ }
+ }
.modifier(SwipeToDismissModifier(minDistance: nil, onDismiss: {
presentationMode.wrappedValue.dismiss()
}))