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,
),
),
),
],
),
);