import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import '../../../core/theme/halo_tokens.dart'; /// Slugs we ship SVGs for. Keep this in sync with `assets/payment_icons/`. /// When a brand mark is added to the bundle (drop the SVG into the asset /// dir), add its slug here. Anything not in this set renders the placeholder. /// /// Source: idn-finlogos (github.com/hafidznoor/idn-finlogos) — see /// `assets/payment_icons/NOTICE_IDN_FINLOGOS.txt` for licensing terms. const Set _kBundledSlugs = { 'qris', 'ovo', 'dana', 'shopeepay', 'gopay', 'bca', 'mandiri', 'bni', 'bri', 'permata', }; /// Renders a payment-method brand mark by slug (`payment_methods.icon`). /// Falls back to a generic credit-card placeholder when the slug isn't /// bundled. Slugs are kept lower-case by convention. class PaymentIcon extends StatelessWidget { final String? slug; final double size; final Color color; const PaymentIcon({ super.key, required this.slug, this.size = 24, this.color = HaloTokens.brandDark, }); @override Widget build(BuildContext context) { final isBundled = slug != null && _kBundledSlugs.contains(slug); final asset = isBundled ? 'assets/payment_icons/$slug.svg' : 'assets/payment_icons/placeholder.svg'; // Brand SVGs ship with their canonical colors and must NOT be tinted; // the placeholder is mono-color and DOES want the brand-dark tint. return SvgPicture.asset( asset, width: size, height: size, colorFilter: isBundled ? null : ColorFilter.mode(color, BlendMode.srcIn), ); } }