feat: update device info plus

This commit is contained in:
2026-07-10 12:39:10 +03:30
parent f13b196971
commit 8cd90f4a5f
4 changed files with 122 additions and 5 deletions
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
import 'package:package_info_plus/package_info_plus.dart';
import '../../../../core/theme/app_theme.dart';
import '../../../../core/widgets/game_ui.dart';
@@ -29,15 +30,32 @@ class LobbyScreen extends StatefulWidget {
class _LobbyScreenState extends State<LobbyScreen> {
final _coinKey = GlobalKey(); // چیپِ سکه (مقصدِ پروازِ سکه‌ها)
final _dailyKey = GlobalKey(); // کارتِ هدیه‌ی روزانه (مبدأ)
String _version = ''; // نسخه‌ی اپ (زیرِ دکمه‌ی خروج)
@override
void initState() {
super.initState();
context.read<WalletBloc>().add(LoadWalletEvent());
PackageInfo.fromPlatform().then((info) {
if (mounted) setState(() => _version = 'نسخه ${info.version}');
});
}
void _reload() => context.read<WalletBloc>().add(LoadWalletEvent());
/// خروج از حساب با تأیید در بتم‌شیت.
Future<void> _confirmLogout(BuildContext context) async {
final yes = await showModalBottomSheet<bool>(
context: context,
backgroundColor: Colors.transparent,
builder: (_) => const _LogoutSheet(),
);
if (yes == true && context.mounted) {
context.read<AuthBloc>().add(LogoutEvent());
context.go('/login');
}
}
Offset? _center(GlobalKey k) {
final box = k.currentContext?.findRenderObject() as RenderBox?;
if (box == null || !box.attached) return null;
@@ -165,10 +183,7 @@ class _LobbyScreenState extends State<LobbyScreen> {
),
),
TextButton.icon(
onPressed: () {
context.read<AuthBloc>().add(LogoutEvent());
context.go('/login');
},
onPressed: () => _confirmLogout(context),
icon: const Icon(
Icons.logout,
color: Colors.white38,
@@ -179,6 +194,17 @@ class _LobbyScreenState extends State<LobbyScreen> {
style: TextStyle(color: Colors.white38, fontSize: 13),
),
),
if (_version.isNotEmpty)
Padding(
padding: const EdgeInsets.only(bottom: 8),
child: Text(
_version,
style: const TextStyle(
color: Colors.white24,
fontSize: 11,
),
),
),
],
),
);
@@ -451,3 +451,77 @@ class _VipTag extends StatelessWidget {
);
}
}
/// بتم‌شیتِ تأییدِ خروج از حساب (خروج ⇒ true، انصراف ⇒ false).
class _LogoutSheet extends StatelessWidget {
const _LogoutSheet();
@override
Widget build(BuildContext context) {
return SafeArea(
top: false,
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.fromLTRB(20, 12, 20, 20),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: 42,
height: 4,
margin: const EdgeInsets.only(bottom: 18),
decoration: BoxDecoration(
color: Colors.white24,
borderRadius: BorderRadius.circular(2),
),
),
Container(
width: 60,
height: 60,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: AppColors.accent.withValues(alpha: 0.15),
border: Border.all(color: AppColors.accent),
),
child:
const Icon(Icons.logout, color: AppColors.accent, size: 30),
),
const SizedBox(height: 14),
const Text(
'خروج از حساب؟',
style: TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 8),
const Text(
'برای ورودِ دوباره باید با شماره‌ات کدِ تأیید بگیری.',
textAlign: TextAlign.center,
style: TextStyle(color: Colors.white54, fontSize: 13),
),
const SizedBox(height: 22),
GameButton(
label: 'خروج از حساب',
icon: Icons.logout,
width: double.infinity,
onTap: () => Navigator.pop(context, true),
),
const SizedBox(height: 8),
TextButton(
onPressed: () => Navigator.pop(context, false),
child: const Text(
'انصراف',
style: TextStyle(color: Colors.white70, fontSize: 14),
),
),
],
),
),
);
}
}