import 'package:flutter/material.dart'; import '../state/models.dart'; import '../theme.dart'; class BrandMark extends StatelessWidget { const BrandMark({super.key, this.size = 40}); final double size; @override Widget build(BuildContext context) { return Container( width: size, height: size, decoration: BoxDecoration( gradient: brandGradient, borderRadius: BorderRadius.circular(size * 0.3), boxShadow: [ BoxShadow( color: brandOrange.withValues(alpha: 0.35), blurRadius: size * 0.5, offset: Offset(0, size * 0.12), ), ], ), child: Icon(Icons.download_rounded, size: size * 0.6, color: const Color(0xFF1A1600)), ); } } class PlusBadge extends StatelessWidget { const PlusBadge({super.key, this.label = 'Плюс'}); final String label; @override Widget build(BuildContext context) { return Container( padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2), decoration: BoxDecoration(gradient: plusGradient, borderRadius: BorderRadius.circular(20)), child: Text( label, style: const TextStyle( color: Colors.white, fontSize: 11, fontWeight: FontWeight.w700, letterSpacing: 0.2, ), ), ); } } class AccountAvatar extends StatelessWidget { const AccountAvatar({super.key, required this.account, this.size = 32}); final Account account; final double size; @override Widget build(BuildContext context) { final scheme = Theme.of(context).colorScheme; return Container( width: size, height: size, alignment: Alignment.center, decoration: BoxDecoration( shape: BoxShape.circle, gradient: account.hasPlus ? plusGradient : null, color: account.hasPlus ? null : scheme.surfaceContainerHighest, ), child: Text( account.initial, style: TextStyle( color: account.hasPlus ? Colors.white : scheme.onSurface, fontWeight: FontWeight.w700, fontSize: size * 0.42, ), ), ); } } class Cover extends StatelessWidget { const Cover({ super.key, required this.url, required this.size, this.kind = ReleaseKind.album, this.radius, }); final String url; final double size; final ReleaseKind kind; final double? radius; IconData get _icon => switch (kind) { ReleaseKind.track => Icons.music_note_rounded, ReleaseKind.album => Icons.album_rounded, ReleaseKind.playlist => Icons.queue_music_rounded, ReleaseKind.artist => Icons.person_rounded, }; @override Widget build(BuildContext context) { final scheme = Theme.of(context).colorScheme; final r = radius ?? size * 0.14; final placeholder = Container( width: size, height: size, decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [scheme.surfaceContainerHighest, scheme.surfaceContainerHigh], ), ), child: Icon(_icon, size: size * 0.42, color: scheme.onSurfaceVariant), ); final dpr = MediaQuery.devicePixelRatioOf(context); return ClipRRect( borderRadius: BorderRadius.circular(kind == ReleaseKind.artist ? size : r), child: SizedBox( width: size, height: size, child: url.isEmpty ? placeholder : Image.network( url, width: size, height: size, fit: BoxFit.cover, cacheWidth: (size * dpr).round(), errorBuilder: (_, _, _) => placeholder, frameBuilder: (context, child, frame, sync) => sync ? child : AnimatedSwitcher( duration: const Duration(milliseconds: 250), child: frame == null ? placeholder : child, ), ), ), ); } } class Panel extends StatelessWidget { const Panel({super.key, required this.child, this.padding = const EdgeInsets.all(20)}); final Widget child; final EdgeInsetsGeometry padding; @override Widget build(BuildContext context) { final scheme = Theme.of(context).colorScheme; return Container( padding: padding, decoration: BoxDecoration( color: scheme.surfaceContainerLow, borderRadius: BorderRadius.circular(24), border: Border.all(color: scheme.outlineVariant.withValues(alpha: 0.6)), ), child: child, ); } } class Tag extends StatelessWidget { const Tag(this.label, {super.key, this.icon, this.color}); final String label; final IconData? icon; final Color? color; @override Widget build(BuildContext context) { final scheme = Theme.of(context).colorScheme; final fg = color ?? scheme.onSurfaceVariant; return Container( padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3), decoration: BoxDecoration( color: (color ?? scheme.onSurfaceVariant).withValues(alpha: 0.12), borderRadius: BorderRadius.circular(8), ), child: Row( mainAxisSize: MainAxisSize.min, children: [ if (icon != null) ...[Icon(icon, size: 13, color: fg), const SizedBox(width: 4)], Text( label, style: TextStyle(fontSize: 11.5, fontWeight: FontWeight.w600, color: fg), ), ], ), ); } } class ExplicitBadge extends StatelessWidget { const ExplicitBadge({super.key, this.size = 15}); final double size; @override Widget build(BuildContext context) { final scheme = Theme.of(context).colorScheme; return Tooltip( message: 'Содержит ненормативную лексику (18+)', child: Container( width: size, height: size, alignment: Alignment.center, decoration: BoxDecoration( color: scheme.onSurfaceVariant.withValues(alpha: 0.85), borderRadius: BorderRadius.circular(size * 0.22), ), child: Text( 'E', style: TextStyle(fontSize: size * 0.68, height: 1, fontWeight: FontWeight.w800, color: scheme.surface), ), ), ); } } class TitleWithBadge extends StatelessWidget { const TitleWithBadge(this.title, {super.key, required this.explicit, this.style}); final String title; final bool explicit; final TextStyle? style; @override Widget build(BuildContext context) { return Row( children: [ Flexible(child: Text(title, maxLines: 1, overflow: TextOverflow.ellipsis, style: style)), if (explicit) ...[const SizedBox(width: 6), const ExplicitBadge()], ], ); } }