1using CommunityToolkit.Mvvm.ComponentModel;
24 if (this.QrCodeWidth == 0 || this.QrCodeHeight == 0)
30 if (this.QrResolutionScale == 0)
33 byte[] Bin = Services.UI.QR.QrCode.GeneratePng(Uri, this.QrCodeWidth * this.QrResolutionScale, this.QrCodeHeight * this.QrResolutionScale);
34 this.QrCode = ImageSource.FromStream(() =>
new MemoryStream(Bin));
38 this.HasQrCode =
true;
47 this.QrCodeBin =
null;
48 this.QrCodeContentType =
null;
49 this.QrCodeUri =
null;
50 this.HasQrCode =
false;
59 private ImageSource? qrCode;
65 private bool hasQrCode;
71 private string? qrCodeUri;
77 private int qrCodeWidth;
83 private int qrCodeHeight;
91 private int qrResolutionScale;
97 private byte[]? qrCodeBin;
103 private string? qrCodeContentType;
109 #region ILinkableView
124 public virtual string?
Link => this.QrCodeUri;
129 public abstract Task<string>
Title {
get; }
139 public virtual byte[]?
Media => this.QrCodeBin;
const string Png
The PNG MIME type.
const int DefaultImageHeight
The default height to use when generating QR Code images.
const int DefaultImageWidth
The default width to use when generating QR Code images.
const int DefaultResolutionScale
The default scale factor to apply to the QR Code image resolution.
A set of never changing property constants and helpful values.
A view model that holds the XMPP state.
virtual bool HasMedia
If linkable view has media associated with link.
virtual ? string Link
Link to the current view
QrXmppViewModel()
Creates an instance of a XmppViewModel.
virtual bool IsLinkable
If the current view is linkable.
virtual ? string MediaContentType
Content-Type of associated media.
abstract Task< string > Title
Title of the current view
void RemoveQrCode()
Removes the QR-code
void GenerateQrCode(string Uri)
Generates a QR-code
virtual ? byte[] Media
Encoded media, if available.
virtual bool EncodeAppLinks
If App links should be encoded with the link.
A view model that holds the XMPP state.
Interface for linkable views.