fix(ci): load cup logo from embedded resource instead of maui asset
Replace MAUI asset pipeline logo loading with embedded resource stream to fix logo not appearing in consuming NuGet projects. Add CustomLogoSource property to Button and Widget controls for custom branding. Update logo to higher resolution PNG. Bump version to 1.1.2.
This commit is contained in:
51
.notes/series-1772600279146-8a63f2.json
Normal file
51
.notes/series-1772600279146-8a63f2.json
Normal file
File diff suppressed because one or more lines are too long
55
.notes/series-1772600391995-ae1f6e.json
Normal file
55
.notes/series-1772600391995-ae1f6e.json
Normal file
File diff suppressed because one or more lines are too long
@@ -31,8 +31,8 @@
|
|||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
<PackageTags>maui;buymeacoffee;bmc;donation;tip;controls</PackageTags>
|
<PackageTags>maui;buymeacoffee;bmc;donation;tip;controls</PackageTags>
|
||||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||||
<Version>1.1.0</Version>
|
<Version>1.1.2</Version>
|
||||||
<PackageReleaseNotes>v1.1.0: Crisp SVG branding via MAUI asset pipeline, supporter verification API (auto-hide controls for existing supporters), SupporterEmail/HideIfSupporter properties on all controls.</PackageReleaseNotes>
|
<PackageReleaseNotes>v1.1.2: Fix cup logo not showing in consuming projects (load from embedded high-res PNG instead of MAUI asset pipeline). Added CustomLogoSource property on Button and Widget to allow developers to override the default logo.</PackageReleaseNotes>
|
||||||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
||||||
|
|
||||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.0</SupportedOSPlatformVersion>
|
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.0</SupportedOSPlatformVersion>
|
||||||
|
|||||||
@@ -45,6 +45,10 @@ public class BuyMeACoffeeButton : ContentView
|
|||||||
BindableProperty.Create(nameof(CupSize), typeof(double), typeof(BuyMeACoffeeButton),
|
BindableProperty.Create(nameof(CupSize), typeof(double), typeof(BuyMeACoffeeButton),
|
||||||
28.0, propertyChanged: OnVisualPropertyChanged);
|
28.0, propertyChanged: OnVisualPropertyChanged);
|
||||||
|
|
||||||
|
public static readonly BindableProperty CustomLogoSourceProperty =
|
||||||
|
BindableProperty.Create(nameof(CustomLogoSource), typeof(ImageSource), typeof(BuyMeACoffeeButton),
|
||||||
|
null, propertyChanged: OnVisualPropertyChanged);
|
||||||
|
|
||||||
public static readonly BindableProperty SupporterEmailProperty =
|
public static readonly BindableProperty SupporterEmailProperty =
|
||||||
BindableProperty.Create(nameof(SupporterEmail), typeof(string), typeof(BuyMeACoffeeButton),
|
BindableProperty.Create(nameof(SupporterEmail), typeof(string), typeof(BuyMeACoffeeButton),
|
||||||
null, propertyChanged: OnSupporterPropertyChanged);
|
null, propertyChanged: OnSupporterPropertyChanged);
|
||||||
@@ -113,6 +117,13 @@ public class BuyMeACoffeeButton : ContentView
|
|||||||
set => SetValue(CupSizeProperty, value);
|
set => SetValue(CupSizeProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Optional custom logo ImageSource. When set, replaces the default BMC cup logo.</summary>
|
||||||
|
public ImageSource? CustomLogoSource
|
||||||
|
{
|
||||||
|
get => (ImageSource?)GetValue(CustomLogoSourceProperty);
|
||||||
|
set => SetValue(CustomLogoSourceProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Email address to check against your BMC supporters list.
|
/// Email address to check against your BMC supporters list.
|
||||||
/// Requires AccessToken configured via UseBuyMeACoffee(options => ...).
|
/// Requires AccessToken configured via UseBuyMeACoffee(options => ...).
|
||||||
@@ -229,6 +240,7 @@ public class BuyMeACoffeeButton : ContentView
|
|||||||
_textLabel.Text = ButtonText;
|
_textLabel.Text = ButtonText;
|
||||||
_textLabel.FontSize = FontSize;
|
_textLabel.FontSize = FontSize;
|
||||||
_cupImage.HeightRequest = CupSize;
|
_cupImage.HeightRequest = CupSize;
|
||||||
|
_cupImage.Source = CustomLogoSource ?? BmcBrandAssets.GetCupLogo();
|
||||||
|
|
||||||
if (_border.StrokeShape is RoundRectangle rr)
|
if (_border.StrokeShape is RoundRectangle rr)
|
||||||
rr.CornerRadius = new Microsoft.Maui.CornerRadius(CornerRadius);
|
rr.CornerRadius = new Microsoft.Maui.CornerRadius(CornerRadius);
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ public class BuyMeACoffeeWidget : ContentView
|
|||||||
BindableProperty.Create(nameof(SupportButtonText), typeof(string), typeof(BuyMeACoffeeWidget),
|
BindableProperty.Create(nameof(SupportButtonText), typeof(string), typeof(BuyMeACoffeeWidget),
|
||||||
BmcConstants.DefaultSupportButtonText);
|
BmcConstants.DefaultSupportButtonText);
|
||||||
|
|
||||||
|
public static readonly BindableProperty CustomLogoSourceProperty =
|
||||||
|
BindableProperty.Create(nameof(CustomLogoSource), typeof(ImageSource), typeof(BuyMeACoffeeWidget),
|
||||||
|
null, propertyChanged: OnLogoChanged);
|
||||||
|
|
||||||
public static readonly BindableProperty SupporterEmailProperty =
|
public static readonly BindableProperty SupporterEmailProperty =
|
||||||
BindableProperty.Create(nameof(SupporterEmail), typeof(string), typeof(BuyMeACoffeeWidget),
|
BindableProperty.Create(nameof(SupporterEmail), typeof(string), typeof(BuyMeACoffeeWidget),
|
||||||
null, propertyChanged: OnSupporterPropertyChanged);
|
null, propertyChanged: OnSupporterPropertyChanged);
|
||||||
@@ -102,6 +106,13 @@ public class BuyMeACoffeeWidget : ContentView
|
|||||||
set => SetValue(SupportButtonTextProperty, value);
|
set => SetValue(SupportButtonTextProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Optional custom logo ImageSource. When set, replaces the default BMC cup logo in the footer.</summary>
|
||||||
|
public ImageSource? CustomLogoSource
|
||||||
|
{
|
||||||
|
get => (ImageSource?)GetValue(CustomLogoSourceProperty);
|
||||||
|
set => SetValue(CustomLogoSourceProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Email address to check against your BMC supporters list.
|
/// Email address to check against your BMC supporters list.
|
||||||
/// Requires AccessToken configured via UseBuyMeACoffee(options => ...).
|
/// Requires AccessToken configured via UseBuyMeACoffee(options => ...).
|
||||||
@@ -137,6 +148,7 @@ public class BuyMeACoffeeWidget : ContentView
|
|||||||
private Border _supportButton = null!;
|
private Border _supportButton = null!;
|
||||||
private Label _supportButtonLabel = null!;
|
private Label _supportButtonLabel = null!;
|
||||||
private Label _footerLabel = null!;
|
private Label _footerLabel = null!;
|
||||||
|
private Image _footerCup = null!;
|
||||||
|
|
||||||
private int _currentAmount;
|
private int _currentAmount;
|
||||||
|
|
||||||
@@ -274,9 +286,9 @@ public class BuyMeACoffeeWidget : ContentView
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Footer
|
// Footer
|
||||||
var footerCup = new Image
|
_footerCup = new Image
|
||||||
{
|
{
|
||||||
Source = BmcBrandAssets.GetCupLogo(),
|
Source = CustomLogoSource ?? BmcBrandAssets.GetCupLogo(),
|
||||||
HeightRequest = 16,
|
HeightRequest = 16,
|
||||||
Aspect = Aspect.AspectFit,
|
Aspect = Aspect.AspectFit,
|
||||||
VerticalOptions = LayoutOptions.Center,
|
VerticalOptions = LayoutOptions.Center,
|
||||||
@@ -293,7 +305,7 @@ public class BuyMeACoffeeWidget : ContentView
|
|||||||
{
|
{
|
||||||
Spacing = 4,
|
Spacing = 4,
|
||||||
HorizontalOptions = LayoutOptions.Center,
|
HorizontalOptions = LayoutOptions.Center,
|
||||||
Children = { footerCup, _footerLabel }
|
Children = { _footerCup, _footerLabel }
|
||||||
};
|
};
|
||||||
var footerTap = new TapGestureRecognizer();
|
var footerTap = new TapGestureRecognizer();
|
||||||
footerTap.Tapped += OnFooterTapped;
|
footerTap.Tapped += OnFooterTapped;
|
||||||
@@ -465,6 +477,12 @@ public class BuyMeACoffeeWidget : ContentView
|
|||||||
widget._monthlyRow.IsVisible = (bool)newValue;
|
widget._monthlyRow.IsVisible = (bool)newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void OnLogoChanged(BindableObject bindable, object oldValue, object newValue)
|
||||||
|
{
|
||||||
|
if (bindable is BuyMeACoffeeWidget widget)
|
||||||
|
widget._footerCup.Source = (ImageSource?)newValue ?? BmcBrandAssets.GetCupLogo();
|
||||||
|
}
|
||||||
|
|
||||||
private static void OnSupporterPropertyChanged(BindableObject bindable, object oldValue, object newValue)
|
private static void OnSupporterPropertyChanged(BindableObject bindable, object oldValue, object newValue)
|
||||||
{
|
{
|
||||||
if (bindable is BuyMeACoffeeWidget widget)
|
if (bindable is BuyMeACoffeeWidget widget)
|
||||||
|
|||||||
@@ -1,22 +1,21 @@
|
|||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace BuyMeCofee.Maui.Helpers;
|
namespace BuyMeCofee.Maui.Helpers;
|
||||||
|
|
||||||
internal static class BmcBrandAssets
|
internal static class BmcBrandAssets
|
||||||
{
|
{
|
||||||
// MAUI converts bmc_logo.svg → bmc_logo.png at build time with proper DPI scaling
|
// Embedded PNG resource name — travels with the NuGet package assembly
|
||||||
private const string LogoFileName = "bmc_logo.png";
|
|
||||||
|
|
||||||
// Fallback: embedded PNG for QR code overlay (SkiaSharp needs a raw stream)
|
|
||||||
private const string EmbeddedLogoName = "BuyMeCofee.Maui.Resources.Images.bmc_logo.png";
|
private const string EmbeddedLogoName = "BuyMeCofee.Maui.Resources.Images.bmc_logo.png";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the cup logo as an ImageSource for MAUI Image controls.
|
/// Returns the cup logo as an ImageSource for MAUI Image controls.
|
||||||
/// Uses the MAUI asset pipeline (SVG → crisp multi-DPI PNG).
|
/// Loads from embedded PNG resource so it works in consuming NuGet projects.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static ImageSource GetCupLogo()
|
internal static ImageSource GetCupLogo()
|
||||||
{
|
{
|
||||||
return ImageSource.FromFile(LogoFileName);
|
return ImageSource.FromStream(() =>
|
||||||
|
{
|
||||||
|
var assembly = typeof(BmcBrandAssets).Assembly;
|
||||||
|
return assembly.GetManifestResourceStream(EmbeddedLogoName)!;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 97 KiB After Width: | Height: | Size: 95 KiB |
Reference in New Issue
Block a user