Skip to content

Commit

Permalink
Fixed BaseRepositoryDataTemplate AvatarImage Bug
Browse files Browse the repository at this point in the history
AvatarImage was rendering as an oval on smaller screens
  • Loading branch information
brminnick committed Dec 28, 2021
1 parent 73d27f6 commit e6996f9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions GitTrends/Views/Base/CircleImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public CircleImage()
this.Bind(Frame.BorderColorProperty, nameof(BorderColor), source: this);

Content = new CachedImage()
.Bind(CachedImage.AspectProperty, nameof(Aspect), source: this)
.Bind(CachedImage.SourceProperty, nameof(ImageSource), source: this)
.Bind(CachedImage.ErrorPlaceholderProperty, nameof(ErrorPlaceholder), source: this)
.Bind(CachedImage.LoadingPlaceholderProperty, nameof(LoadingPlaceholder), source: this);
Expand Down
5 changes: 4 additions & 1 deletion GitTrends/Views/Base/CirclePancakeView.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Xamarin.CommunityToolkit.Markup;
using System;
using Xamarin.CommunityToolkit.Markup;
using Xamarin.Forms.PancakeView;

namespace GitTrends
Expand All @@ -7,6 +8,8 @@ public class CirclePancakeView : PancakeView
{
public CirclePancakeView()
{
HeightRequest = WidthRequest = Math.Min(HeightRequest, WidthRequest);

this.Bind<PancakeView, double, double>(CornerRadiusProperty, nameof(Width), convert: convertWidthToCornerRadius, source: this);

IsClippedToBounds = true;
Expand Down
7 changes: 4 additions & 3 deletions GitTrends/Views/Repository/BaseRepositoryDataTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ abstract class BaseRepositoryDataTemplate : DataTemplate
const int _statsColumnSize = 40;
const double _statisticsRowHeight = StatisticsLabel.StatisticsFontSize + 4;
const double _emojiColumnSize = _statisticsRowHeight;
readonly static double _circleImageHeight = IsSmallScreen ? 52 : 62;

readonly static double _circleImageHeight = IsSmallScreen ? 48 : 62;

readonly static AsyncAwaitBestPractices.WeakEventManager _tappedWeakEventManager = new();

Expand Down Expand Up @@ -112,8 +113,8 @@ public ContentGrid(in IEnumerable<View> dataTemplateChildren, in Repository repo
(Row.Statistics, _statisticsRowHeight));

ColumnDefinitions = Columns.Define(
(Column.Avatar, IsSmallScreen ? _circleImageHeight - 4 : _circleImageHeight),
(Column.AvatarPadding, IsSmallScreen ? 4 : 16),
(Column.Avatar, _circleImageHeight),
(Column.AvatarPadding, IsSmallScreen ? 4 : 8),
(Column.Trending, Star),
(Column.Emoji1, _emojiColumnSize),
(Column.Statistic1, _statsColumnSize),
Expand Down
4 changes: 1 addition & 3 deletions GitTrends/Views/Settings/GitHubUserView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ public GitHubAvatarImage()
{
this.Center();

HeightRequest = _imageHeight;
WidthRequest = _imageHeight;
Aspect = Aspect.AspectFit;
HeightRequest = WidthRequest = _imageHeight;

AutomationId = SettingsPageAutomationIds.GitHubAvatarImage;

Expand Down

0 comments on commit e6996f9

Please sign in to comment.