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:
@@ -31,8 +31,8 @@
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<PackageTags>maui;buymeacoffee;bmc;donation;tip;controls</PackageTags>
|
||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||
<Version>1.1.0</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>
|
||||
<Version>1.1.2</Version>
|
||||
<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>
|
||||
|
||||
<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),
|
||||
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 =
|
||||
BindableProperty.Create(nameof(SupporterEmail), typeof(string), typeof(BuyMeACoffeeButton),
|
||||
null, propertyChanged: OnSupporterPropertyChanged);
|
||||
@@ -113,6 +117,13 @@ public class BuyMeACoffeeButton : ContentView
|
||||
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>
|
||||
/// Email address to check against your BMC supporters list.
|
||||
/// Requires AccessToken configured via UseBuyMeACoffee(options => ...).
|
||||
@@ -229,6 +240,7 @@ public class BuyMeACoffeeButton : ContentView
|
||||
_textLabel.Text = ButtonText;
|
||||
_textLabel.FontSize = FontSize;
|
||||
_cupImage.HeightRequest = CupSize;
|
||||
_cupImage.Source = CustomLogoSource ?? BmcBrandAssets.GetCupLogo();
|
||||
|
||||
if (_border.StrokeShape is RoundRectangle rr)
|
||||
rr.CornerRadius = new Microsoft.Maui.CornerRadius(CornerRadius);
|
||||
|
||||
@@ -41,6 +41,10 @@ public class BuyMeACoffeeWidget : ContentView
|
||||
BindableProperty.Create(nameof(SupportButtonText), typeof(string), typeof(BuyMeACoffeeWidget),
|
||||
BmcConstants.DefaultSupportButtonText);
|
||||
|
||||
public static readonly BindableProperty CustomLogoSourceProperty =
|
||||
BindableProperty.Create(nameof(CustomLogoSource), typeof(ImageSource), typeof(BuyMeACoffeeWidget),
|
||||
null, propertyChanged: OnLogoChanged);
|
||||
|
||||
public static readonly BindableProperty SupporterEmailProperty =
|
||||
BindableProperty.Create(nameof(SupporterEmail), typeof(string), typeof(BuyMeACoffeeWidget),
|
||||
null, propertyChanged: OnSupporterPropertyChanged);
|
||||
@@ -102,6 +106,13 @@ public class BuyMeACoffeeWidget : ContentView
|
||||
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>
|
||||
/// Email address to check against your BMC supporters list.
|
||||
/// Requires AccessToken configured via UseBuyMeACoffee(options => ...).
|
||||
@@ -137,6 +148,7 @@ public class BuyMeACoffeeWidget : ContentView
|
||||
private Border _supportButton = null!;
|
||||
private Label _supportButtonLabel = null!;
|
||||
private Label _footerLabel = null!;
|
||||
private Image _footerCup = null!;
|
||||
|
||||
private int _currentAmount;
|
||||
|
||||
@@ -274,9 +286,9 @@ public class BuyMeACoffeeWidget : ContentView
|
||||
};
|
||||
|
||||
// Footer
|
||||
var footerCup = new Image
|
||||
_footerCup = new Image
|
||||
{
|
||||
Source = BmcBrandAssets.GetCupLogo(),
|
||||
Source = CustomLogoSource ?? BmcBrandAssets.GetCupLogo(),
|
||||
HeightRequest = 16,
|
||||
Aspect = Aspect.AspectFit,
|
||||
VerticalOptions = LayoutOptions.Center,
|
||||
@@ -293,7 +305,7 @@ public class BuyMeACoffeeWidget : ContentView
|
||||
{
|
||||
Spacing = 4,
|
||||
HorizontalOptions = LayoutOptions.Center,
|
||||
Children = { footerCup, _footerLabel }
|
||||
Children = { _footerCup, _footerLabel }
|
||||
};
|
||||
var footerTap = new TapGestureRecognizer();
|
||||
footerTap.Tapped += OnFooterTapped;
|
||||
@@ -465,6 +477,12 @@ public class BuyMeACoffeeWidget : ContentView
|
||||
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)
|
||||
{
|
||||
if (bindable is BuyMeACoffeeWidget widget)
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
using System.Reflection;
|
||||
|
||||
namespace BuyMeCofee.Maui.Helpers;
|
||||
|
||||
internal static class BmcBrandAssets
|
||||
{
|
||||
// MAUI converts bmc_logo.svg → bmc_logo.png at build time with proper DPI scaling
|
||||
private const string LogoFileName = "bmc_logo.png";
|
||||
|
||||
// Fallback: embedded PNG for QR code overlay (SkiaSharp needs a raw stream)
|
||||
// Embedded PNG resource name — travels with the NuGet package assembly
|
||||
private const string EmbeddedLogoName = "BuyMeCofee.Maui.Resources.Images.bmc_logo.png";
|
||||
|
||||
/// <summary>
|
||||
/// 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>
|
||||
internal static ImageSource GetCupLogo()
|
||||
{
|
||||
return ImageSource.FromFile(LogoFileName);
|
||||
return ImageSource.FromStream(() =>
|
||||
{
|
||||
var assembly = typeof(BmcBrandAssets).Assembly;
|
||||
return assembly.GetManifestResourceStream(EmbeddedLogoName)!;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 97 KiB After Width: | Height: | Size: 95 KiB |
Reference in New Issue
Block a user