2026-03-04 00:35:05 -05:00
|
|
|
using BuyMeCofee.Maui.Services;
|
feat(scenarios): add buy me a coffee maui library
Create a .NET MAUI library for Buy Me a Coffee integration with branded button, QR code, and widget controls. Includes 8 theme presets (yellow, black, white, blue, violet, orange, red, green), customizable styling, and SkiaSharp-based rendering. Supports opening BMC pages in browser and generating QR codes for donations.
2026-03-03 23:19:45 -05:00
|
|
|
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;
|
|
|
|
|
}
|
2026-03-04 00:35:05 -05:00
|
|
|
|
|
|
|
|
/// <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;
|
|
|
|
|
}
|
feat(scenarios): add buy me a coffee maui library
Create a .NET MAUI library for Buy Me a Coffee integration with branded button, QR code, and widget controls. Includes 8 theme presets (yellow, black, white, blue, violet, orange, red, green), customizable styling, and SkiaSharp-based rendering. Supports opening BMC pages in browser and generating QR codes for donations.
2026-03-03 23:19:45 -05:00
|
|
|
}
|