play_ui_kit 0.2.0
play_ui_kit: ^0.2.0 copied to clipboard
A suite of vibrant, engaging, and animated Flutter widgets for mobile apps and casual games with zero external dependencies.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:play_ui_kit/play_ui_kit.dart';
void main() {
runApp(const PlayUiKitShowcaseApp());
}
class PlayUiKitShowcaseApp extends StatefulWidget {
const PlayUiKitShowcaseApp({super.key});
@override
State<PlayUiKitShowcaseApp> createState() => _PlayUiKitShowcaseAppState();
}
class _PlayUiKitShowcaseAppState extends State<PlayUiKitShowcaseApp> {
ThemeMode _themeMode = ThemeMode.dark;
void _toggleTheme() {
setState(() {
_themeMode = _themeMode == ThemeMode.dark ? ThemeMode.light : ThemeMode.dark;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'PlayUIKit - World-Class Mobile & Game UI',
debugShowCheckedModeBanner: false,
themeMode: _themeMode,
theme: ThemeData(
useMaterial3: true,
scaffoldBackgroundColor: PlayColors.lightCanvas,
colorScheme: ColorScheme.fromSeed(
seedColor: PlayColors.indigo600,
primary: PlayColors.indigo600,
secondary: PlayColors.emerald500,
brightness: Brightness.light,
),
appBarTheme: const AppBarTheme(
backgroundColor: Colors.white,
foregroundColor: PlayColors.lightTextPrimary,
elevation: 0,
),
),
darkTheme: ThemeData(
useMaterial3: true,
scaffoldBackgroundColor: PlayColors.obsidian950,
colorScheme: ColorScheme.fromSeed(
seedColor: PlayColors.indigo600,
primary: PlayColors.indigo500,
secondary: PlayColors.gold500,
surface: PlayColors.obsidian900,
brightness: Brightness.dark,
),
appBarTheme: const AppBarTheme(
backgroundColor: PlayColors.obsidian900,
foregroundColor: Colors.white,
elevation: 0,
),
),
home: ShowcaseScreen(
onToggleTheme: _toggleTheme,
isDark: _themeMode == ThemeMode.dark,
),
);
}
}
class ShowcaseScreen extends StatefulWidget {
final VoidCallback onToggleTheme;
final bool isDark;
const ShowcaseScreen({
super.key,
required this.onToggleTheme,
required this.isDark,
});
@override
State<ShowcaseScreen> createState() => _ShowcaseScreenState();
}
class _ShowcaseScreenState extends State<ShowcaseScreen> {
int _currentHearts = 4;
double _currentXp = 540;
int _currentScore = 24500;
@override
Widget build(BuildContext context) {
final isDark = widget.isDark;
return DefaultTabController(
length: 4,
child: Scaffold(
appBar: AppBar(
title: Row(
children: [
Container(
width: 36,
height: 36,
decoration: BoxDecoration(
gradient: PlayColors.indigoGradient,
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(
color: PlayColors.indigo500.withValues(alpha: 0.35),
blurRadius: 10,
offset: const Offset(0, 3),
),
],
),
child: const Icon(
Icons.auto_awesome_rounded,
color: Colors.white,
size: 20,
),
),
const SizedBox(width: 12),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'PlayUIKit',
style: TextStyle(fontWeight: FontWeight.w800, fontSize: 16),
),
Text(
'Design System & Micro-Interactions',
style: TextStyle(
fontSize: 11,
color: isDark ? const Color(0xFF94A3B8) : PlayColors.lightTextSecondary,
),
),
],
),
],
),
actions: [
IconButton(
icon: Icon(isDark ? Icons.light_mode_rounded : Icons.dark_mode_rounded),
tooltip: 'Basculer Thème',
onPressed: widget.onToggleTheme,
),
],
bottom: TabBar(
isScrollable: true,
tabAlignment: TabAlignment.start,
indicatorColor: PlayColors.indigo500,
indicatorWeight: 2.5,
labelColor: isDark ? Colors.white : PlayColors.indigo600,
unselectedLabelColor: isDark ? Colors.white54 : Colors.black45,
labelStyle: const TextStyle(fontWeight: FontWeight.w700, fontSize: 13),
tabs: const [
Tab(icon: Icon(Icons.touch_app_rounded, size: 20), text: 'Boutons Tactiles'),
Tab(icon: Icon(Icons.receipt_long_rounded, size: 20), text: 'Paiement & Reçu'),
Tab(icon: Icon(Icons.sports_esports_rounded, size: 20), text: 'Gaming & HUD'),
Tab(icon: Icon(Icons.auto_awesome_motion_rounded, size: 20), text: 'Cartes & Modales'),
],
),
),
body: TabBarView(
children: [
_buildButtonsTab(isDark),
_buildPaymentTab(isDark),
_buildGamingTab(isDark),
_buildCardsAndCelebrationTab(isDark),
],
),
),
);
}
// --- TAB 1: BOUTONS TACTILES ---
Widget _buildButtonsTab(bool isDark) {
return ListView(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 24),
children: [
_buildSectionTitle('1. PlayBouncyButton', 'Micro-ressort physique et biseau supérieur spéculaire'),
const SizedBox(height: 12),
Wrap(
spacing: 12,
runSpacing: 12,
children: [
PlayBouncyButton(
gradient: PlayColors.indigoGradient,
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Clic Bouncy Indigo')),
);
},
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.bolt_rounded, size: 18, color: Colors.white),
SizedBox(width: 8),
Text(
'Action Principale',
style: TextStyle(color: Colors.white, fontWeight: FontWeight.w700, fontSize: 14),
),
],
),
),
PlayBouncyButton(
backgroundColor: isDark ? PlayColors.obsidian800 : Colors.white,
border: Border.all(
color: isDark ? PlayColors.obsidianBorder : PlayColors.lightBorder,
width: 1.0,
),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.08),
blurRadius: 10,
offset: const Offset(0, 4),
),
],
onPressed: () {},
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.tune_rounded, size: 18, color: isDark ? Colors.white : PlayColors.lightTextPrimary),
const SizedBox(width: 8),
Text(
'Bouton Secondaire',
style: TextStyle(
color: isDark ? Colors.white : PlayColors.lightTextPrimary,
fontWeight: FontWeight.w600,
fontSize: 14,
),
),
],
),
),
],
),
const SizedBox(height: 32),
_buildSectionTitle('2. PlayArcade3DButton', 'Pression mécanique physique façon Nintendo Switch / Duolingo'),
const SizedBox(height: 12),
PlayArcade3DButton(
frontColor: PlayColors.indigo600,
depth: 4.5,
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Bouton 3D Enfoncé !')),
);
},
child: const Text(
'LANCER L\'EXPÉRIENCE',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w800,
fontSize: 14,
letterSpacing: 0.8,
),
),
),
const SizedBox(height: 32),
_buildSectionTitle('3. PlayShimmerGlowButton', 'Reflet de soie balayant la surface et halo ambiant doux'),
const SizedBox(height: 12),
PlayShimmerGlowButton(
gradient: PlayColors.indigoGradient,
glowColor: PlayColors.indigo500,
onPressed: () {},
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.workspace_premium_rounded, size: 18, color: Colors.white),
SizedBox(width: 8),
Text(
'DÉBLOQUER VIP PASS',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize: 14,
letterSpacing: 0.4,
),
),
],
),
),
const SizedBox(height: 32),
_buildSectionTitle('4. PlayHoldProgressButton', 'Maintien continu pour validation d\'actions critiques'),
const SizedBox(height: 12),
PlayHoldProgressButton(
backgroundColor: isDark ? PlayColors.obsidian800 : const Color(0xFFF1F5F9),
progressColor: PlayColors.indigo600,
progressGradient: PlayColors.indigoGradient,
holdDuration: const Duration(milliseconds: 1500),
onCompleted: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Action confirmée avec succès !')),
);
},
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.fingerprint_rounded, size: 20, color: isDark ? Colors.white : PlayColors.lightTextPrimary),
const SizedBox(width: 10),
Text(
'Maintenir pour transférer 25 000 FCFA',
style: TextStyle(
color: isDark ? Colors.white : PlayColors.lightTextPrimary,
fontWeight: FontWeight.w700,
fontSize: 14,
),
),
],
),
),
],
);
}
// --- TAB 2: PAIEMENT & REÇU ---
Widget _buildPaymentTab(bool isDark) {
return PlayPaymentSuccessView(
amount: '50 000',
currency: 'FCFA',
title: 'Paiement Validé',
subtitle: 'Votre abonnement a été activé en toute sécurité.',
primaryColor: PlayColors.emerald500,
cardBackgroundColor: isDark ? PlayColors.obsidian900 : Colors.white,
isDark: isDark,
details: const [
PlayPaymentDetailRow(label: 'Numéro de Référence', value: 'TX-984201'),
PlayPaymentDetailRow(label: 'Moyen de règlement', value: 'Mobile Money'),
PlayPaymentDetailRow(label: 'Date & Heure', value: '21 Nov 2026 • 09:15'),
PlayPaymentDetailRow(label: 'Frais de transfert', value: '0 FCFA'),
PlayPaymentDetailRow(label: 'Statut du service', value: 'Actif Immédiat ⚡', isHighlighted: true),
],
primaryButtonText: 'Accéder à mes services',
onPrimaryPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Navigation vers le dashboard')),
);
},
);
}
// --- TAB 3: GAMING & HUD ---
Widget _buildGamingTab(bool isDark) {
final cardBg = isDark ? PlayColors.obsidian900 : Colors.white;
final borderColor = isDark ? PlayColors.obsidianBorder : PlayColors.lightBorder;
return ListView(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 24),
children: [
_buildSectionTitle('Barre de Vies Réactive', 'Secousse mécanique à l\'impact et alerte critique'),
const SizedBox(height: 12),
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: cardBg,
borderRadius: BorderRadius.circular(16),
border: Border.all(color: borderColor, width: 1.0),
),
child: Column(
children: [
PlayHeartLifeBar(
maxHearts: 5,
currentHearts: _currentHearts,
heartSize: 30,
activeHeartColor: PlayColors.coral500,
emptyHeartColor: isDark ? const Color(0xFF263045) : const Color(0xFFCBD5E1),
),
const SizedBox(height: 18),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
PlayBouncyButton(
backgroundColor: PlayColors.coral500,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
onPressed: _currentHearts > 0 ? () => setState(() => _currentHearts--) : null,
child: const Text(
'-1 Dégât',
style: TextStyle(color: Colors.white, fontWeight: FontWeight.w700, fontSize: 13),
),
),
const SizedBox(width: 12),
PlayBouncyButton(
backgroundColor: PlayColors.emerald500,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
onPressed: _currentHearts < 5 ? () => setState(() => _currentHearts++) : null,
child: const Text(
'+1 Soin',
style: TextStyle(color: Colors.white, fontWeight: FontWeight.w700, fontSize: 13),
),
),
],
),
],
),
),
const SizedBox(height: 32),
_buildSectionTitle('Jauge d\'Expérience XP', 'Capsule fluide avec reflet de verre et étiquette de niveau'),
const SizedBox(height: 12),
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: cardBg,
borderRadius: BorderRadius.circular(16),
border: Border.all(color: borderColor, width: 1.0),
),
child: Column(
children: [
PlayXpProgressBar(
current: _currentXp,
max: 1000,
currentLevel: 14,
height: 16,
gradient: PlayColors.indigoGradient,
backgroundColor: isDark ? PlayColors.obsidian800 : const Color(0xFFE2E8F0),
glowColor: PlayColors.indigo500,
),
const SizedBox(height: 18),
PlayBouncyButton(
gradient: PlayColors.indigoGradient,
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
onPressed: () {
setState(() {
_currentXp = (_currentXp + 200 > 1000) ? 180 : _currentXp + 200;
});
},
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.keyboard_double_arrow_up_rounded, size: 18, color: Colors.white),
SizedBox(width: 6),
Text(
'Gagner +200 XP',
style: TextStyle(color: Colors.white, fontWeight: FontWeight.w700, fontSize: 13),
),
],
),
),
],
),
),
const SizedBox(height: 32),
_buildSectionTitle('Compteur Odomètre sans Saut', 'Chiffres tabulaires stables avec formatage de milliers'),
const SizedBox(height: 12),
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: cardBg,
borderRadius: BorderRadius.circular(16),
border: Border.all(color: borderColor, width: 1.0),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Jetons accumulés',
style: TextStyle(
color: isDark ? const Color(0xFF94A3B8) : PlayColors.lightTextSecondary,
fontSize: 13,
),
),
const SizedBox(height: 4),
PlayRollingCounter(
value: _currentScore,
suffix: ' 💎',
textStyle: const TextStyle(
fontSize: 28,
fontWeight: FontWeight.w800,
color: PlayColors.gold500,
),
),
],
),
PlayBouncyButton(
backgroundColor: PlayColors.indigo600,
padding: const EdgeInsets.all(12),
borderRadius: BorderRadius.circular(12),
onPressed: () {
setState(() => _currentScore += 1250);
},
child: const Icon(Icons.add_rounded, color: Colors.white),
),
],
),
),
],
);
}
// --- TAB 4: CARTES & MODALES ---
Widget _buildCardsAndCelebrationTab(bool isDark) {
return ListView(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 24),
children: [
_buildSectionTitle('Glassmorphism & Badges Fluo', 'Flou d\'arrière-plan en temps réel et pastilles animées'),
const SizedBox(height: 12),
PlayGlassCard(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const PlayAnimatedAvatar(
radius: 24,
ringThickness: 2.5,
showStatus: true,
),
Row(
children: const [
PlayNeonBadge.live(),
SizedBox(width: 8),
PlayNeonBadge.vip(),
],
),
],
),
const SizedBox(height: 16),
const Text(
'Tournoi Maître en Direct',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize: 16,
),
),
const SizedBox(height: 4),
const Text(
'Carte glassmorphism avec flou GPU et pastille clignotante.',
style: TextStyle(
color: Color(0xFF94A3B8),
fontSize: 13,
height: 1.4,
),
),
],
),
),
const SizedBox(height: 32),
_buildSectionTitle('Modal Célébration & Toasts', 'Rayons ambiants rotatifs et bannière flottante'),
const SizedBox(height: 12),
Wrap(
spacing: 12,
runSpacing: 12,
children: [
PlayBouncyButton(
backgroundColor: PlayColors.gold500,
onPressed: () {
PlayRewardModal.show(
context: context,
rewardValue: '+5 000 POINTS VIP',
title: 'RÉCOMPENSE MAJEURE',
subtitle: 'Vous avez atteint le rang Prestige dans le club privilège.',
primaryColor: PlayColors.gold500,
backgroundColor: PlayColors.obsidian900,
onClaim: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Points crédités au compte !')),
);
},
);
},
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.emoji_events_rounded, size: 18, color: Colors.black),
SizedBox(width: 8),
Text(
'Afficher Modal Récompense',
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w800, fontSize: 14),
),
],
),
),
PlayBouncyButton(
backgroundColor: isDark ? PlayColors.obsidian800 : Colors.white,
border: Border.all(
color: isDark ? PlayColors.obsidianBorder : PlayColors.lightBorder,
width: 1.0,
),
onPressed: () {
PlayAchievementToast.show(
context: context,
title: 'Nouveau Trophée Débloqué !',
description: 'Vous avez complété l\'intégration avec un design soigné.',
icon: Icons.military_tech_rounded,
iconColor: PlayColors.gold500,
);
},
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.notifications_active_rounded, size: 18, color: isDark ? Colors.white : PlayColors.lightTextPrimary),
const SizedBox(width: 8),
Text(
'Déclencher Toast',
style: TextStyle(
color: isDark ? Colors.white : PlayColors.lightTextPrimary,
fontWeight: FontWeight.w600,
fontSize: 14,
),
),
],
),
),
],
),
],
);
}
Widget _buildSectionTitle(String title, String subtitle) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: const TextStyle(
fontSize: 15,
fontWeight: FontWeight.w700,
letterSpacing: -0.2,
),
),
const SizedBox(height: 2),
Text(
subtitle,
style: const TextStyle(
fontSize: 12,
color: Color(0xFF64748B),
),
),
],
);
}
}