From 8cd90f4a5f36bd63c77a7c3613f68d831efa41f8 Mon Sep 17 00:00:00 2001 From: Amirmahdi Nourkazemi Date: Fri, 10 Jul 2026 12:39:10 +0330 Subject: [PATCH] feat: update device info plus --- .../presentation/screen/lobby_screen.dart | 34 ++++++++- .../screen/lobby_screen.parts.dart | 74 +++++++++++++++++++ pubspec.lock | 16 ++++ pubspec.yaml | 3 +- 4 files changed, 122 insertions(+), 5 deletions(-) diff --git a/lib/feature/wallet/presentation/screen/lobby_screen.dart b/lib/feature/wallet/presentation/screen/lobby_screen.dart index 22a8f09..46d6147 100644 --- a/lib/feature/wallet/presentation/screen/lobby_screen.dart +++ b/lib/feature/wallet/presentation/screen/lobby_screen.dart @@ -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 { final _coinKey = GlobalKey(); // چیپِ سکه (مقصدِ پروازِ سکه‌ها) final _dailyKey = GlobalKey(); // کارتِ هدیه‌ی روزانه (مبدأ) + String _version = ''; // نسخه‌ی اپ (زیرِ دکمه‌ی خروج) @override void initState() { super.initState(); context.read().add(LoadWalletEvent()); + PackageInfo.fromPlatform().then((info) { + if (mounted) setState(() => _version = 'نسخه ${info.version}'); + }); } void _reload() => context.read().add(LoadWalletEvent()); + /// خروج از حساب با تأیید در بتم‌شیت. + Future _confirmLogout(BuildContext context) async { + final yes = await showModalBottomSheet( + context: context, + backgroundColor: Colors.transparent, + builder: (_) => const _LogoutSheet(), + ); + if (yes == true && context.mounted) { + context.read().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 { ), ), TextButton.icon( - onPressed: () { - context.read().add(LogoutEvent()); - context.go('/login'); - }, + onPressed: () => _confirmLogout(context), icon: const Icon( Icons.logout, color: Colors.white38, @@ -179,6 +194,17 @@ class _LobbyScreenState extends State { 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, + ), + ), + ), ], ), ); diff --git a/lib/feature/wallet/presentation/screen/lobby_screen.parts.dart b/lib/feature/wallet/presentation/screen/lobby_screen.parts.dart index 095e9ae..5765c2e 100644 --- a/lib/feature/wallet/presentation/screen/lobby_screen.parts.dart +++ b/lib/feature/wallet/presentation/screen/lobby_screen.parts.dart @@ -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), + ), + ), + ], + ), + ), + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index 496ea22..146c0d1 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -536,6 +536,22 @@ packages: url: "https://pub.myket.ir" source: hosted version: "8.0.0" + package_info_plus: + dependency: "direct main" + description: + name: package_info_plus + sha256: "16eee997588c60225bda0488b6dcfac69280a6b7a3cf02c741895dd370a02968" + url: "https://pub.myket.ir" + source: hosted + version: "8.3.1" + package_info_plus_platform_interface: + dependency: transitive + description: + name: package_info_plus_platform_interface + sha256: "202a487f08836a592a6bd4f901ac69b3a8f146af552bbd14407b6b41e1c3f086" + url: "https://pub.myket.ir" + source: hosted + version: "3.2.1" path: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index e8e296e..fb1426c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.0.0+1 +version: 1.0.2+2 environment: sdk: ^3.7.2 @@ -47,6 +47,7 @@ dependencies: random_avatar: ^0.0.8 flutter_svg: ^2.3.0 # نمایشِ شخصیتِ آواتارِ svg (و png با Image.network) connectivity_plus: ^6.1.0 # تشخیصِ قطعِ اینترنت برای نمایشِ اوورلیِ «اتصال نیست» + package_info_plus: ^8.1.1 # نمایشِ نسخه‌ی اپ در لابی # خرید درون‌برنامه‌ای: هر flavor یکی را استفاده می‌کند (مایکت/کافه‌بازار). myket_iap: ^1.1.11 flutter_poolakey: ^2.2.0