feat: rotate table players

This commit is contained in:
2026-06-19 23:18:51 +03:30
parent 04b97ca163
commit 0c8fd22264
5 changed files with 540 additions and 297 deletions
@@ -30,28 +30,38 @@ class ProfileScreen extends StatelessWidget {
if (s is ProfileSaveSuccess) {
context.read<WalletBloc>().add(LoadWalletEvent());
} else if (s is ProfileSaveError) {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text(s.message)));
ScaffoldMessenger.of(
context,
).showSnackBar(SnackBar(content: Text(s.message)));
}
},
builder: (context, state) {
final st = state.loadStatus;
if (st is ProfileLoadError) {
return Center(
child: Column(mainAxisSize: MainAxisSize.min, children: [
Text(st.message,
style: const TextStyle(color: Colors.white70)),
const SizedBox(height: 12),
GameButton(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
st.message,
style: const TextStyle(color: Colors.white70),
),
const SizedBox(height: 12),
GameButton(
label: 'تلاش دوباره',
onTap: () =>
context.read<ProfileBloc>().add(LoadProfileEvent())),
]),
onTap:
() => context.read<ProfileBloc>().add(
LoadProfileEvent(),
),
),
],
),
);
}
if (st is! ProfileLoadLoaded) {
return const Center(
child: CircularProgressIndicator(color: AppColors.gold));
child: CircularProgressIndicator(color: AppColors.gold),
);
}
return _content(context, st.profile);
},
@@ -69,9 +79,9 @@ class ProfileScreen extends StatelessWidget {
builder: (_) => _EditProfileSheet(name: d.name, avatar: d.avatar),
);
if (result == null || !context.mounted) return;
context
.read<ProfileBloc>()
.add(SaveProfileEvent(result['name']!, result['avatar']!));
context.read<ProfileBloc>().add(
SaveProfileEvent(result['name']!, result['avatar']!),
);
}
Widget _content(BuildContext context, ProfileEntity d) {
@@ -79,87 +89,112 @@ class ProfileScreen extends StatelessWidget {
padding: const EdgeInsets.all(16),
child: Column(
children: [
Row(children: [
IconButton(
onPressed: () => context.pop(),
icon: const Icon(Icons.arrow_back, color: AppColors.gold),
),
const Spacer(),
const GlowText('پروفایل', size: 24),
const Spacer(),
const SizedBox(width: 48),
]),
Row(
children: [
IconButton(
onPressed: () => context.pop(),
icon: const Icon(Icons.arrow_back, color: AppColors.gold),
),
const Spacer(),
const GlowText('پروفایل', size: 24),
const Spacer(),
const SizedBox(width: 48),
],
),
const SizedBox(height: 8),
GamePanel(
child: Column(children: [
Stack(children: [
Container(
padding: const EdgeInsets.all(6),
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(color: AppColors.gold, width: 2.5),
),
child: RandomAvatar(d.avatar, height: 92, width: 92),
),
Positioned(
bottom: 0,
right: 0,
child: GestureDetector(
onTap: () => _editProfile(context, d),
child: Container(
child: Column(
children: [
Stack(
children: [
Container(
padding: const EdgeInsets.all(6),
decoration: const BoxDecoration(
decoration: BoxDecoration(
shape: BoxShape.circle,
gradient: LinearGradient(
colors: [Color(0xFFFFD54F), Color(0xFFB8860B)]),
border: Border.all(color: AppColors.gold, width: 2.5),
),
child: const Icon(Icons.edit,
color: Color(0xFF3A0A12), size: 18),
child: RandomAvatar(d.avatar, height: 92, width: 92),
),
),
Positioned(
bottom: 0,
right: 0,
child: GestureDetector(
onTap: () => _editProfile(context, d),
child: Container(
padding: const EdgeInsets.all(6),
decoration: const BoxDecoration(
shape: BoxShape.circle,
gradient: LinearGradient(
colors: [Color(0xFFFFD54F), Color(0xFFB8860B)],
),
),
child: const Icon(
Icons.edit,
color: Color(0xFF3A0A12),
size: 18,
),
),
),
),
],
),
]),
const SizedBox(height: 10),
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
Flexible(child: GlowText(d.name, size: 22)),
if (d.vip) ...[const SizedBox(width: 8), const _VipBadge()],
]),
if (d.mobile.isNotEmpty)
Text(d.mobile,
style:
const TextStyle(color: Colors.white38, fontSize: 12)),
const SizedBox(height: 14),
Row(children: [
Expanded(
child: _MiniStat(
icon: Icons.star, label: 'سطح', value: '${d.level}')),
Expanded(
child: _MiniStat(
const SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Flexible(child: GlowText(d.name, size: 22)),
if (d.vip) ...[const SizedBox(width: 8), const _VipBadge()],
],
),
if (d.mobile.isNotEmpty)
Text(
d.mobile,
style: const TextStyle(color: Colors.white38, fontSize: 12),
),
const SizedBox(height: 14),
Row(
children: [
Expanded(
child: _MiniStat(
icon: Icons.star,
label: 'سطح',
value: '${d.level}',
),
),
Expanded(
child: _MiniStat(
icon: Icons.emoji_events,
label: 'جام',
value: '${d.trophies}')),
]),
const SizedBox(height: 10),
ClipRRect(
borderRadius: BorderRadius.circular(5),
child: LinearProgressIndicator(
value: d.xpNext == 0 ? 0 : d.xpInto / d.xpNext,
minHeight: 8,
backgroundColor: Colors.white10,
valueColor: const AlwaysStoppedAnimation(AppColors.gold),
value: '${d.trophies}',
),
),
],
),
),
Padding(
padding: const EdgeInsets.only(top: 4),
child: Text('${d.xpInto} / ${d.xpNext} XP',
style: const TextStyle(color: Colors.white38, fontSize: 11)),
),
]),
const SizedBox(height: 10),
ClipRRect(
borderRadius: BorderRadius.circular(5),
child: LinearProgressIndicator(
value: d.xpNext == 0 ? 0 : d.xpInto / d.xpNext,
minHeight: 8,
backgroundColor: Colors.white10,
valueColor: const AlwaysStoppedAnimation(AppColors.gold),
),
),
Padding(
padding: const EdgeInsets.only(top: 4),
child: Text(
'${d.xpInto} / ${d.xpNext} XP',
style: const TextStyle(color: Colors.white38, fontSize: 11),
),
),
],
),
),
const SizedBox(height: 16),
const Align(
alignment: Alignment.centerRight,
child: GlowText('آمار بازی', size: 18)),
alignment: Alignment.centerRight,
child: GlowText('آمار بازی', size: 18),
),
const SizedBox(height: 8),
_statsSection(context, d),
],
@@ -181,43 +216,47 @@ class ProfileScreen extends StatelessWidget {
final panel = GamePanel(child: Column(children: rows));
if (d.vip) return panel;
return Stack(children: [
Opacity(opacity: 0.35, child: IgnorePointer(child: panel)),
Positioned.fill(
child: Container(
decoration: BoxDecoration(
color: Colors.black.withValues(alpha: 0.45),
borderRadius: BorderRadius.circular(16),
border: Border.all(color: AppColors.goldDark),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.lock, color: AppColors.gold, size: 36),
const SizedBox(height: 8),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 24),
child: Text('مشاهده‌ی آمار ویژه‌ی کاربران VIP است',
return Stack(
children: [
Opacity(opacity: 0.35, child: IgnorePointer(child: panel)),
Positioned.fill(
child: Container(
decoration: BoxDecoration(
color: Colors.black.withValues(alpha: 0.45),
borderRadius: BorderRadius.circular(16),
border: Border.all(color: AppColors.goldDark),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.lock, color: AppColors.gold, size: 36),
const SizedBox(height: 8),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 24),
child: Text(
'مشاهده‌ی آمار ویژه‌ی کاربران VIP است',
textAlign: TextAlign.center,
style: TextStyle(color: Colors.white, fontSize: 14)),
),
const SizedBox(height: 12),
GameButton(
label: 'تهیه اشتراک VIP',
icon: Icons.workspace_premium,
colors: const [Color(0xFFFFC107), Color(0xFFB8860B)],
onTap: () async {
await context.push('/vip');
if (context.mounted) {
context.read<ProfileBloc>().add(LoadProfileEvent());
}
},
),
],
style: TextStyle(color: Colors.white, fontSize: 14),
),
),
const SizedBox(height: 12),
GameButton(
label: 'تهیه اشتراک VIP',
icon: Icons.workspace_premium,
colors: const [Color(0xFFFFC107), Color(0xFFB8860B)],
onTap: () async {
await context.push('/vip');
if (context.mounted) {
context.read<ProfileBloc>().add(LoadProfileEvent());
}
},
),
],
),
),
),
),
]);
],
);
}
}
@@ -230,17 +269,25 @@ class _StatRow extends StatelessWidget {
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 7),
child: Row(children: [
Icon(icon, color: AppColors.gold, size: 20),
const SizedBox(width: 10),
Text(label, style: const TextStyle(color: Colors.white, fontSize: 15)),
const Spacer(),
Text('${value ?? ''}',
child: Row(
children: [
Icon(icon, color: AppColors.gold, size: 20),
const SizedBox(width: 10),
Text(
label,
style: const TextStyle(color: Colors.white, fontSize: 15),
),
const Spacer(),
Text(
'${value ?? ''}',
style: const TextStyle(
color: AppColors.gold,
fontSize: 16,
fontWeight: FontWeight.bold)),
]),
color: AppColors.gold,
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
],
),
);
}
}
@@ -249,18 +296,31 @@ class _MiniStat extends StatelessWidget {
final IconData icon;
final String label;
final String value;
const _MiniStat(
{required this.icon, required this.label, required this.value});
const _MiniStat({
required this.icon,
required this.label,
required this.value,
});
@override
Widget build(BuildContext context) {
return Column(children: [
Icon(icon, color: AppColors.gold, size: 22),
const SizedBox(height: 2),
Text(value,
return Column(
children: [
Icon(icon, color: AppColors.gold, size: 22),
const SizedBox(height: 2),
Text(
value,
style: const TextStyle(
color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold)),
Text(label, style: const TextStyle(color: Colors.white54, fontSize: 12)),
]);
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
Text(
label,
style: const TextStyle(color: Colors.white54, fontSize: 12),
),
],
);
}
}
@@ -271,15 +331,19 @@ class _VipBadge extends StatelessWidget {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
decoration: BoxDecoration(
gradient:
const LinearGradient(colors: [Color(0xFFFFD54F), Color(0xFFB8860B)]),
gradient: const LinearGradient(
colors: [Color(0xFFFFD54F), Color(0xFFB8860B)],
),
borderRadius: BorderRadius.circular(8),
),
child: const Text('VIP',
style: TextStyle(
color: Color(0xFF3A0A12),
fontWeight: FontWeight.bold,
fontSize: 12)),
child: const Text(
'VIP',
style: TextStyle(
color: Color(0xFF3A0A12),
fontWeight: FontWeight.bold,
fontSize: 12,
),
),
);
}
}
@@ -318,81 +382,97 @@ class _EditProfileSheetState extends State<_EditProfileSheet> {
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: Container(
decoration: const BoxDecoration(
color: AppColors.bgDark,
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
border: Border(top: BorderSide(color: AppColors.gold, width: 2)),
return SafeArea(
top: false,
child: Padding(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom,
),
padding: const EdgeInsets.all(18),
child: SingleChildScrollView(
child: Column(mainAxisSize: MainAxisSize.min, children: [
const GlowText('ویرایش پروفایل', size: 20),
const SizedBox(height: 14),
Container(
padding: const EdgeInsets.all(4),
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(color: AppColors.gold, width: 2),
),
child: RandomAvatar(_selected, height: 72, width: 72),
),
const SizedBox(height: 12),
TextField(
controller: _name,
textAlign: TextAlign.center,
maxLength: 20,
inputFormatters: [LengthLimitingTextInputFormatter(20)],
decoration: const InputDecoration(
hintText: 'نام نمایشی (۲ تا ۲۰ حرف)', counterText: ''),
onChanged: (_) => setState(() {}),
),
const SizedBox(height: 10),
const Align(
alignment: Alignment.centerRight,
child:
Text('انتخاب آواتار', style: TextStyle(color: AppColors.gold)),
),
const SizedBox(height: 8),
GridView.count(
crossAxisCount: 4,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
mainAxisSpacing: 10,
crossAxisSpacing: 10,
child: Container(
decoration: const BoxDecoration(
color: AppColors.bgDark,
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
border: Border(top: BorderSide(color: AppColors.gold, width: 2)),
),
padding: const EdgeInsets.all(18),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
for (final s in _seeds)
GestureDetector(
onTap: () => setState(() => _selected = s),
child: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: AppColors.panel,
border: Border.all(
color: _selected == s
? AppColors.gold
: Colors.transparent,
width: 2.5,
const GlowText('ویرایش پروفایل', size: 20),
const SizedBox(height: 14),
Container(
padding: const EdgeInsets.all(4),
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(color: AppColors.gold, width: 2),
),
child: RandomAvatar(_selected, height: 72, width: 72),
),
const SizedBox(height: 12),
TextField(
controller: _name,
textAlign: TextAlign.center,
maxLength: 20,
inputFormatters: [LengthLimitingTextInputFormatter(20)],
decoration: const InputDecoration(
hintText: 'نام نمایشی (۲ تا ۲۰ حرف)',
counterText: '',
),
onChanged: (_) => setState(() {}),
),
const SizedBox(height: 10),
const Align(
alignment: Alignment.centerRight,
child: Text(
'انتخاب آواتار',
style: TextStyle(color: AppColors.gold),
),
),
const SizedBox(height: 8),
GridView.count(
crossAxisCount: 4,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
mainAxisSpacing: 10,
crossAxisSpacing: 10,
children: [
for (final s in _seeds)
GestureDetector(
onTap: () => setState(() => _selected = s),
child: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: AppColors.panel,
border: Border.all(
color:
_selected == s
? AppColors.gold
: Colors.transparent,
width: 2.5,
),
),
child: RandomAvatar(s),
),
),
child: RandomAvatar(s),
),
),
],
),
const SizedBox(height: 16),
GameButton(
label: 'تأیید',
width: double.infinity,
colors: const [Color(0xFF3FA34D), Color(0xFF1B5E20)],
onTap:
_valid
? () => Navigator.pop(context, {
'name': _name.text.trim(),
'avatar': _selected,
})
: null,
),
],
),
const SizedBox(height: 16),
GameButton(
label: 'تأیید',
width: double.infinity,
colors: const [Color(0xFF3FA34D), Color(0xFF1B5E20)],
onTap: _valid
? () => Navigator.pop(
context, {'name': _name.text.trim(), 'avatar': _selected})
: null,
),
]),
),
),
),
);