1 files changed, 49 insertions, 0 deletions
diff --git a/MatrixUtils.Web/Shared/MxcAvatar.razor b/MatrixUtils.Web/Shared/MxcAvatar.razor
new file mode 100644
index 0000000..822894a
--- /dev/null
+++ b/MatrixUtils.Web/Shared/MxcAvatar.razor
@@ -0,0 +1,49 @@
+<MxcImage Homeserver="@Homeserver" Uri="@MxcUri" style="@StyleString"/>
+
+@code {
+ private string _style;
+
+ [Parameter]
+ public string? MxcUri {
+ get;
+ set {
+ if(field == value) return;
+ field = value;
+ // UriHasChanged(value);
+ StateHasChanged();
+ }
+ }
+
+ [Parameter]
+ public bool Circular { get; set; }
+
+ [Parameter]
+ public int Size { get; set; } = 48;
+
+ [Parameter]
+ public string SizeUnit { get; set; } = "px";
+
+ [Parameter]
+ public required AuthenticatedHomeserverGeneric Homeserver { get; set; }
+
+ private string StyleString => $"{(Circular ? "border-radius: 50%;" : "")} width: {Size}{SizeUnit}; height: {Size}{SizeUnit}; object-fit: cover;";
+
+ private static readonly string Prefix = "mxc://";
+ private static readonly int PrefixLength = Prefix.Length;
+
+ // private async Task UriHasChanged(string? value) {
+ // if (string.IsNullOrWhiteSpace(value) || !value.StartsWith(Prefix)) {
+ // Console.WriteLine($"[MxcAvatar] UriHasChanged: {value} does not start with {Prefix}!");
+ // return;
+ // }
+ //
+ // if (Homeserver is null) {
+ // Console.WriteLine($"[MxcAvatar] Homeserver is required for MxcAvatar! URI: {MxcUri}, Homeserver: {Homeserver?.ToString() ?? "null"}");
+ // return;
+ // }
+ //
+ // Console.WriteLine($"[MxcAvatar] Homeserver: {Homeserver}");
+ // StateHasChanged();
+ // }
+
+}
\ No newline at end of file
|