play_ui_kit 0.1.0
play_ui_kit: ^0.1.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 PlayWidgetsShowcaseApp());
}
class PlayWidgetsShowcaseApp extends StatefulWidget {
const PlayWidgetsShowcaseApp({super.key});
@override
State<PlayWidgetsShowcaseApp> createState() => _PlayWidgetsShowcaseAppState();
}
class _PlayWidgetsShowcaseAppState extends State<PlayWidgetsShowcaseApp> {
ThemeMode _themeMode = ThemeMode.dark;
void _toggleTheme() {
setState(() {
_themeMode = _themeMode == ThemeMode.dark ? ThemeMode.light : ThemeMode.dark;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'PlayWidgets - Midnight & Sapphire Design System',
debugShowCheckedModeBanner: false,
themeMode: _themeMode,
theme: ThemeData(
useMaterial3: true,
scaffoldBackgroundColor: PlayColors.lightScaffold,
colorScheme: ColorScheme.fromSeed(
seedColor: PlayColors.midnight900,
primary: PlayColors.midnight900,
secondary: PlayColors.sapphire500,
brightness: Brightness.light,
),
appBarTheme: const AppBarTheme(
backgroundColor: Colors.white,
foregroundColor: PlayColors.midnight900,
elevation: 0,
),
cardTheme: CardThemeData(
color: PlayColors.lightCard,
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
side: const BorderSide(color: PlayColors.lightBorder),
),
),
),
darkTheme: ThemeData(
useMaterial3: true,
scaffoldBackgroundColor: PlayColors.midnight950,
colorScheme: ColorScheme.fromSeed(
seedColor: PlayColors.sapphire500,
primary: PlayColors.sapphire500,
secondary: PlayColors.champagne500,
surface: PlayColors.midnight900,
brightness: Brightness.dark,
),
appBarTheme: const AppBarTheme(
backgroundColor: PlayColors.midnight900,
foregroundColor: Colors.white,
elevation: 0,
),
cardTheme: CardThemeData(
color: PlayColors.midnight850,
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
side: const BorderSide(color: PlayColors.darkCardBorder, width: 0.8),
),
),
),
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 = 480;
int _currentScore = 2450;
@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.sapphireGradient,
borderRadius: BorderRadius.circular(10),
),
child: const Icon(
Icons.sports_esports_rounded,
color: Colors.white,
size: 20,
),
),
const SizedBox(width: 12),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'PlayWidgets Kit',
style: TextStyle(fontWeight: FontWeight.w900, fontSize: 16),
),
Text(
'Midnight Navy & Sapphire Design System',
style: TextStyle(
fontSize: 10,
color: isDark ? PlayColors.midnight400 : PlayColors.lightTextSecondary,
),
),
],
),
],
),
actions: [
IconButton(
icon: Icon(isDark ? Icons.light_mode_rounded : Icons.dark_mode_rounded),
tooltip: 'Basculer Thème Clair/Sombre',
onPressed: widget.onToggleTheme,
),
],
bottom: TabBar(
isScrollable: true,
tabAlignment: TabAlignment.start,
indicatorColor: PlayColors.sapphire500,
labelColor: isDark ? PlayColors.sapphire400 : PlayColors.sapphire500,
unselectedLabelColor: isDark ? Colors.white60 : Colors.black54,
tabs: const [
Tab(icon: Icon(Icons.touch_app_rounded), text: 'Boutons Signature'),
Tab(icon: Icon(Icons.verified_rounded), text: 'Paiement Réussi'),
Tab(icon: Icon(Icons.bar_chart_rounded), text: 'Gauges & HUD'),
Tab(icon: Icon(Icons.emoji_events_rounded), text: 'Célébrations'),
],
),
),
body: TabBarView(
children: [
_buildButtonsTab(isDark),
_buildPaymentTab(isDark),
_buildGamingTab(isDark),
_buildCelebrationTab(isDark),
],
),
),
);
}
// --- TAB 1: BOUTONS ---
Widget _buildButtonsTab(bool isDark) {
return ListView(
padding: const EdgeInsets.all(20),
children: [
_buildSectionHeader('1. PlayBouncyButton (Élastique & Retour Haptique)'),
const SizedBox(height: 12),
Wrap(
spacing: 12,
runSpacing: 12,
children: [
PlayBouncyButton(
gradient: PlayColors.sapphireGradient,
borderRadius: BorderRadius.circular(16),
boxShadow: PlayColors.glowSapphire,
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Sapphire Bouncy Tap !')),
);
},
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.bolt_rounded, color: Colors.white),
SizedBox(width: 8),
Text(
'Sapphire Action',
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
),
],
),
),
PlayBouncyButton(
gradient: PlayColors.champagneGradient,
borderRadius: BorderRadius.circular(16),
boxShadow: PlayColors.glowChampagne,
onPressed: () {},
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.star_rounded, color: Colors.white),
SizedBox(width: 8),
Text(
'Champagne Gold',
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
),
],
),
),
],
),
const SizedBox(height: 30),
_buildSectionHeader('2. PlayArcade3DButton (Bouton Dépressible 3D)'),
const SizedBox(height: 12),
PlayArcade3DButton(
frontColor: PlayColors.sapphire500,
depth: 6.0,
borderRadius: 16.0,
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Arcade Button Click !')),
);
},
child: const Text(
'LANCER L\'EXPÉRIENCE',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w900,
fontSize: 15,
letterSpacing: 1.0,
),
),
),
const SizedBox(height: 30),
_buildSectionHeader('3. PlayShimmerGlowButton (Shimmer Sweep & Pulsation)'),
const SizedBox(height: 12),
PlayShimmerGlowButton(
gradient: const LinearGradient(
colors: [PlayColors.sapphire500, PlayColors.sapphire700, PlayColors.midnight900],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
glowColor: PlayColors.midnight500,
borderRadius: BorderRadius.circular(16),
onPressed: () {},
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.workspace_premium_rounded, color: Colors.white),
SizedBox(width: 10),
Text(
'ACTIVER ABONNEMENT PRESTIGE',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
letterSpacing: 0.8,
),
),
],
),
),
const SizedBox(height: 30),
_buildSectionHeader('4. PlayHoldProgressButton (Maintien pour Confirmer)'),
const SizedBox(height: 12),
PlayHoldProgressButton(
backgroundColor: isDark ? PlayColors.midnight850 : const Color(0xFFE2E8F0),
progressColor: PlayColors.sapphire500,
holdDuration: const Duration(milliseconds: 1600),
borderRadius: BorderRadius.circular(16),
onCompleted: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Transaction confirmée avec succès !')),
);
},
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.touch_app_rounded, color: isDark ? Colors.white : PlayColors.midnight900),
const SizedBox(width: 10),
Text(
'Maintenir pour valider le virement',
style: TextStyle(
color: isDark ? Colors.white : PlayColors.midnight900,
fontWeight: FontWeight.bold,
),
),
],
),
),
],
);
}
// --- TAB 2: PAIEMENT ---
Widget _buildPaymentTab(bool isDark) {
return PlayPaymentSuccessView(
amount: '50 000',
currency: 'FCFA',
title: 'Paiement Réussi !',
subtitle: 'Votre transaction sécurisée a été confirmée.',
primaryColor: PlayColors.emerald500,
cardBackgroundColor: isDark ? PlayColors.midnight850 : Colors.white,
isDark: isDark,
details: const [
PlayPaymentDetailRow(label: 'Référence Transaction', value: 'TX-8923481'),
PlayPaymentDetailRow(label: 'Moyen de règlement', value: 'Mobile Money / Wave'),
PlayPaymentDetailRow(label: 'Date & Heure', value: '17 Nov 2026 • 08:45'),
PlayPaymentDetailRow(label: 'Frais de transaction', value: '0 FCFA'),
PlayPaymentDetailRow(label: 'Statut bancaire', value: 'Succès Immédiat ⚡', isHighlighted: true),
],
primaryButtonText: 'Accéder à mes services',
onPrimaryPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Redirection vers le tableau de bord')),
);
},
secondaryButtonText: 'Télécharger le reçu PDF',
onSecondaryPressed: () {},
);
}
// --- TAB 3: GAMING ---
Widget _buildGamingTab(bool isDark) {
final cardBg = isDark ? PlayColors.midnight850 : Colors.white;
final borderColor = isDark ? PlayColors.darkCardBorder : PlayColors.lightBorder;
return ListView(
padding: const EdgeInsets.all(20),
children: [
_buildSectionHeader('Barre de Vies / Cœurs (PlayHeartLifeBar)'),
const SizedBox(height: 12),
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: cardBg,
borderRadius: BorderRadius.circular(16),
border: Border.all(color: borderColor, width: 0.8),
),
child: Column(
children: [
PlayHeartLifeBar(
maxHearts: 5,
currentHearts: _currentHearts,
heartSize: 34,
activeHeartColor: PlayColors.coralHeart,
emptyHeartColor: isDark ? PlayColors.coralHeartEmpty : const Color(0xFFCBD5E1),
),
const SizedBox(height: 18),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
PlayBouncyButton(
backgroundColor: PlayColors.coralHeart,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
onPressed: _currentHearts > 0 ? () => setState(() => _currentHearts--) : null,
child: const Text(
'-1 Cœur (Impact)',
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, 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 Cœur (Soin)',
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 13),
),
),
],
),
],
),
),
const SizedBox(height: 30),
_buildSectionHeader('Jauge de Progression XP (PlayXpProgressBar)'),
const SizedBox(height: 12),
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: cardBg,
borderRadius: BorderRadius.circular(16),
border: Border.all(color: borderColor, width: 0.8),
),
child: Column(
children: [
PlayXpProgressBar(
current: _currentXp,
max: 1000,
currentLevel: 18,
height: 20,
gradient: PlayColors.electricSapphireGradient,
backgroundColor: isDark ? PlayColors.midnight950 : const Color(0xFFE2E8F0),
glowColor: PlayColors.sapphire500,
),
const SizedBox(height: 18),
PlayBouncyButton(
gradient: PlayColors.sapphireGradient,
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
onPressed: () {
setState(() {
_currentXp = (_currentXp + 200 > 1000) ? 150 : _currentXp + 200;
});
},
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.keyboard_double_arrow_up_rounded, color: Colors.white, size: 20),
SizedBox(width: 6),
Text(
'Gagner +200 XP',
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
),
],
),
),
],
),
),
const SizedBox(height: 30),
_buildSectionHeader('Compteur Animé / Odomètre (PlayRollingCounter)'),
const SizedBox(height: 12),
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: cardBg,
borderRadius: BorderRadius.circular(16),
border: Border.all(color: borderColor, width: 0.8),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Jetons accumulés',
style: TextStyle(
color: isDark ? PlayColors.darkTextSecondary : PlayColors.lightTextSecondary,
fontSize: 13,
),
),
const SizedBox(height: 4),
PlayRollingCounter(
value: _currentScore,
suffix: ' 💎',
textStyle: const TextStyle(
fontSize: 32,
fontWeight: FontWeight.w900,
color: PlayColors.champagne500,
),
),
],
),
PlayBouncyButton(
backgroundColor: PlayColors.sapphire500,
padding: const EdgeInsets.all(12),
borderRadius: BorderRadius.circular(14),
onPressed: () {
setState(() => _currentScore += 750);
},
child: const Icon(Icons.add_rounded, color: Colors.white),
),
],
),
),
],
);
}
// --- TAB 4: CÉLÉBRATIONS ---
Widget _buildCelebrationTab(bool isDark) {
return ListView(
padding: const EdgeInsets.all(20),
children: [
_buildSectionHeader('Modal de Célébration (PlayRewardModal)'),
const SizedBox(height: 12),
PlayBouncyButton(
gradient: PlayColors.champagneGradient,
boxShadow: PlayColors.glowChampagne,
onPressed: () {
PlayRewardModal.show(
context: context,
rewardValue: '+5 000 POINTS VIP',
title: 'RÉCOMPENSE MAJEURE !',
subtitle: 'Vous avez atteint le rang Prestige dans le programme fidélité.',
primaryColor: PlayColors.champagne500,
backgroundColor: PlayColors.midnight900,
onClaim: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Points VIP crédités au portefeuille !')),
);
},
);
},
child: const Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.emoji_events_rounded, color: Colors.white),
SizedBox(width: 8),
Text(
'Afficher Modal Récompense Champagne',
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
),
],
),
),
const SizedBox(height: 30),
_buildSectionHeader('Toast Notification (PlayAchievementToast)'),
const SizedBox(height: 12),
PlayBouncyButton(
backgroundColor: isDark ? PlayColors.midnight850 : Colors.white,
border: Border.all(color: PlayColors.sapphire500, width: 1.5),
boxShadow: PlayColors.glowSapphire,
onPressed: () {
PlayAchievementToast.show(
context: context,
title: 'Nouvelle Étape Franchie !',
description: 'Votre profil a débloqué l\'accès aux fonctionnalités exclusives.',
icon: Icons.verified_user_rounded,
iconColor: PlayColors.sapphire400,
backgroundColor: PlayColors.midnight900,
);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.notifications_active_rounded, color: PlayColors.sapphire500),
const SizedBox(width: 8),
Text(
'Déclencher Toast Sapphire',
style: TextStyle(
color: isDark ? Colors.white : PlayColors.midnight900,
fontWeight: FontWeight.bold,
),
),
],
),
),
],
);
}
Widget _buildSectionHeader(String title) {
return Text(
title,
style: const TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
letterSpacing: -0.2,
),
);
}
}