Add QR Code in profiles
Changelog-Added: Add QR Code in profiles Closes: #918
This commit is contained in:
committed by
William Casarin
parent
29ab48287f
commit
5c131e62d7
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user