Implement BmcSupporterService to verify supporters via BMC API with configurable caching. Add SupporterEmail and HideIfSupporter properties to all controls to automatically hide donation prompts for existing supporters. Replace PNG logo with SVG for crisp rendering at all scales. Add BmcOptions and BmcConfiguration for library-wide settings. Bump version to 1.1.0.
46 lines
1.4 KiB
C#
46 lines
1.4 KiB
C#
using BuyMeCofee.Maui.Services;
|
|
using SkiaSharp.Views.Maui.Controls.Hosting;
|
|
|
|
namespace BuyMeCofee.Maui;
|
|
|
|
public static class BuyMeACoffeeExtensions
|
|
{
|
|
/// <summary>
|
|
/// Registers Buy Me a Coffee controls and their dependencies (SkiaSharp).
|
|
/// Call this in your MauiProgram.cs CreateMauiApp() builder.
|
|
/// </summary>
|
|
public static MauiAppBuilder UseBuyMeACoffee(this MauiAppBuilder builder)
|
|
{
|
|
builder.UseSkiaSharp();
|
|
return builder;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Registers Buy Me a Coffee controls with optional supporter verification.
|
|
/// When an AccessToken is provided, controls with HideIfSupporter=true
|
|
/// will auto-hide for verified supporters.
|
|
/// </summary>
|
|
/// <example>
|
|
/// builder.UseBuyMeACoffee(options =>
|
|
/// {
|
|
/// options.AccessToken = "your-bmc-api-token";
|
|
/// options.CacheDuration = TimeSpan.FromHours(2);
|
|
/// });
|
|
/// </example>
|
|
public static MauiAppBuilder UseBuyMeACoffee(this MauiAppBuilder builder, Action<BmcOptions> configure)
|
|
{
|
|
builder.UseSkiaSharp();
|
|
|
|
var options = new BmcOptions();
|
|
configure(options);
|
|
|
|
if (!string.IsNullOrWhiteSpace(options.AccessToken))
|
|
{
|
|
BmcConfiguration.SupporterService = new BmcSupporterService(
|
|
options.AccessToken, options.CacheDuration);
|
|
}
|
|
|
|
return builder;
|
|
}
|
|
}
|