-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
237 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentView | ||
x:Class="NuSocial.Controls.ProfileImage" | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Name="root"> | ||
<Grid> | ||
<Image IsAnimationPlaying="{Binding IsAnimationPlaying, Source={x:Reference root}}" Source="{Binding Aspect, Source={x:Reference root}}" /> | ||
</Grid> | ||
</ContentView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
using BindableProps; | ||
|
||
namespace NuSocial.Controls; | ||
|
||
public partial class ProfileImage : ContentView | ||
{ | ||
[BindableProp] | ||
private Aspect _aspect = Aspect.Fill; | ||
|
||
[BindableProp(PropertyChangedDelegate = nameof(UpdateSize))] | ||
private double _borderSize; | ||
|
||
[BindableProp(PropertyChangedDelegate = nameof(UpdateIsCircularImage))] | ||
private double _cornerRadius; | ||
|
||
[BindableProp(PropertyChangedDelegate = nameof(UpdateIsCircularImage))] | ||
private bool _isCircular = false; | ||
|
||
private double _lastCornerRadius; | ||
|
||
[BindableProp(PropertyChangedDelegate = nameof(UpdateSize))] | ||
private double _size = 50.0; | ||
|
||
[BindableProp(PropertyChangedDelegate = nameof(UpdateSource))] | ||
private string _source = string.Empty; | ||
|
||
[BindableProp] | ||
private bool _isAnimationPlaying = false; | ||
|
||
public ProfileImage() | ||
{ | ||
InitializeComponent(); | ||
|
||
//UpdateBadgeType(); | ||
|
||
UpdateSize(this); | ||
|
||
//UpdateStatusIndicatorPosition(); | ||
} | ||
|
||
private static void UpdateBorder(BindableObject bindable) | ||
{ | ||
if (bindable is ProfileImage control) | ||
{ | ||
if (control.Size > 0) | ||
{ | ||
if (control.BorderSize == 0) | ||
{ | ||
//borderBoxView.IsVisible = false; | ||
} | ||
else | ||
{ | ||
var cornerRadius = control.CornerRadius + control.BorderSize; | ||
var heightRequest = control.Size + (control.BorderSize * 2); | ||
var widthRequest = control.Size + (control.BorderSize * 2); | ||
|
||
//borderBoxView.IsVisible = true; | ||
|
||
//if (UXDivers.Grial.Effects.GetCornerRadius(borderBoxView) != cornerRadius || borderBoxView.HeightRequest != heightRequest || borderBoxView.WidthRequest != widthRequest) | ||
//{ | ||
// borderBoxView.HeightRequest = heightRequest; | ||
// borderBoxView.WidthRequest = widthRequest; | ||
// UXDivers.Grial.Effects.SetCornerRadius(borderBoxView, cornerRadius); | ||
//} | ||
} | ||
} | ||
} | ||
} | ||
|
||
private static void UpdateSource(BindableObject bindable, object? oldValue = null, object? newValue = null) | ||
{ | ||
if (bindable is ProfileImage control) | ||
{ | ||
if (newValue is string newStr && !string.IsNullOrEmpty(newStr)) | ||
{ | ||
if (newStr.EndsWith(".gif", StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
control.IsAnimationPlaying = true; | ||
} | ||
else | ||
{ | ||
control.IsAnimationPlaying = false; | ||
} | ||
} | ||
} | ||
} | ||
|
||
private static void UpdateCornerRadius(BindableObject bindable, object? oldValue = null, object? newValue = null) | ||
{ | ||
if (bindable is ProfileImage control) | ||
{ | ||
if (control.IsCircular && control.CornerRadius != control.Size / 2) | ||
{ | ||
control.CornerRadius = control.Size / 2; | ||
} | ||
|
||
UpdateBorder(bindable); | ||
} | ||
} | ||
|
||
private static void UpdateIsCircularImage(BindableObject bindable, object? oldValue = null, object? newValue = null) | ||
{ | ||
if (bindable is ProfileImage control) | ||
{ | ||
if (control.IsCircular) | ||
{ | ||
control._lastCornerRadius = control.CornerRadius; | ||
control.CornerRadius = control.Size / 2; | ||
} | ||
else | ||
{ | ||
control.CornerRadius = control._lastCornerRadius; | ||
control._lastCornerRadius = 0; | ||
} | ||
} | ||
} | ||
|
||
private static void UpdateSize(BindableObject bindable, object? oldValue = null, object? newValue = null) | ||
{ | ||
if (bindable is ProfileImage control) | ||
{ | ||
control.HeightRequest = control.Size + (control.BorderSize * 2); | ||
control.WidthRequest = control.Size + (control.BorderSize * 2); | ||
|
||
UpdateCornerRadius(bindable); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters