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 showing_select_wallet: Bool = false
|
||||||
@State var is_zoomed: Bool = false
|
@State var is_zoomed: Bool = false
|
||||||
@State var show_share_sheet: 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 action_sheet_presented: Bool = false
|
||||||
@State var filter_state : FilterState = .posts
|
@State var filter_state : FilterState = .posts
|
||||||
@State var yOffset: CGFloat = 0
|
@State var yOffset: CGFloat = 0
|
||||||
@@ -214,6 +215,10 @@ struct ProfileView: View {
|
|||||||
show_share_sheet = true
|
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.
|
// 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 {
|
if profile.pubkey != damus_state.pubkey && damus_state.is_privkey_user {
|
||||||
Button(NSLocalizedString("Report", comment: "Button to report a profile."), role: .destructive) {
|
Button(NSLocalizedString("Report", comment: "Button to report a profile."), role: .destructive) {
|
||||||
@@ -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 {
|
struct QRCodeView: View {
|
||||||
let damus_state: DamusState
|
let damus_state: DamusState
|
||||||
|
@State var pubkey: String = ""
|
||||||
|
|
||||||
@Environment(\.dismiss) var dismiss
|
@Environment(\.dismiss) var dismiss
|
||||||
@Environment(\.presentationMode) var presentationMode
|
@Environment(\.presentationMode) var presentationMode
|
||||||
|
|
||||||
var maybe_key: String? {
|
var maybe_key: String? {
|
||||||
guard let key = bech32_pubkey(damus_state.pubkey) else {
|
guard let key = bech32_pubkey(pubkey) else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,10 +40,11 @@ struct QRCodeView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
VStack(alignment: .center) {
|
VStack(alignment: .center) {
|
||||||
let profile = damus_state.profiles.lookup(id: damus_state.pubkey)
|
|
||||||
|
|
||||||
if (damus_state.profiles.lookup(id: damus_state.pubkey)?.picture) != nil {
|
let profile = damus_state.profiles.lookup(id: pubkey)
|
||||||
ProfilePicView(pubkey: damus_state.pubkey, size: 90.0, highlight: .custom(DamusColors.white, 4.0), profiles: damus_state.profiles)
|
|
||||||
|
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)
|
.padding(.top, 50)
|
||||||
} else {
|
} else {
|
||||||
Image(systemName: "person.fill")
|
Image(systemName: "person.fill")
|
||||||
@@ -92,6 +94,11 @@ struct QRCodeView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
.onAppear() {
|
||||||
|
if pubkey.isEmpty {
|
||||||
|
pubkey = damus_state.pubkey
|
||||||
|
}
|
||||||
|
}
|
||||||
.modifier(SwipeToDismissModifier(minDistance: nil, onDismiss: {
|
.modifier(SwipeToDismissModifier(minDistance: nil, onDismiss: {
|
||||||
presentationMode.wrappedValue.dismiss()
|
presentationMode.wrappedValue.dismiss()
|
||||||
}))
|
}))
|
||||||
|
|||||||
Reference in New Issue
Block a user