diff --git a/lib/home_screen.dart b/lib/home_screen.dart index 534077b..9dcf28b 100644 --- a/lib/home_screen.dart +++ b/lib/home_screen.dart @@ -53,7 +53,7 @@ class _HomeScreenState extends State { _checkVersionInBackground(); _initDeepLinking(); - + _showSpoofUpdateDialogIfNeeded(); _connectionSubscription = ApiService.instance.connectionStatus.listen(( status, @@ -68,7 +68,6 @@ class _HomeScreenState extends State { } }); - _messageSubscription = ApiService.instance.messages.listen((message) { if (message['type'] == 'session_terminated' && mounted) { _handleSessionTerminated(message['message']); @@ -86,7 +85,6 @@ class _HomeScreenState extends State { if (!mounted) return; setState(() => _isProfileLoading = true); try { - final cachedProfile = ApiService.instance.lastChatsPayload?['profile']; if (cachedProfile != null) { if (mounted) { @@ -96,7 +94,6 @@ class _HomeScreenState extends State { }); } } else { - final result = await ApiService.instance.getChatsAndContacts( force: false, ); @@ -124,7 +121,7 @@ class _HomeScreenState extends State { ) async { await showDialog( context: context, - barrierDismissible: false, // Пользователь должен сделать выбор + barrierDismissible: false, // Зачем давать им выбор оло builder: (BuildContext dialogContext) { return AlertDialog( title: const Text('Доступно обновление'), @@ -135,7 +132,7 @@ class _HomeScreenState extends State { TextButton( child: const Text('Отменить'), onPressed: () { - Navigator.of(dialogContext).pop(); // Просто закрыть диалог + Navigator.of(dialogContext).pop(); }, ), FilledButton( @@ -151,12 +148,10 @@ class _HomeScreenState extends State { print("Ошибка переподключения: $e"); } - if (mounted) { Navigator.of(dialogContext).pop(); } - if (mounted) { ScaffoldMessenger.of(context).showSnackBar( SnackBar( @@ -177,11 +172,9 @@ class _HomeScreenState extends State { try { final prefs = await SharedPreferences.getInstance(); - final isWebVersionCheckEnabled = prefs.getBool('enable_web_version_check') ?? false; - if (!isWebVersionCheckEnabled) { print("Web version checking is disabled, skipping check"); return; @@ -196,7 +189,6 @@ class _HomeScreenState extends State { if (latestVersion != currentVersion) { if (isAutoUpdateEnabled) { - await prefs.setString('spoof_appversion', latestVersion); print("Версия сессии автоматически обновлена до $latestVersion"); @@ -223,7 +215,6 @@ class _HomeScreenState extends State { ); } } else if (showUpdateNotification) { - if (mounted) { _showUpdateDialog(context, latestVersion); } @@ -574,6 +565,148 @@ class _HomeScreenState extends State { ); } + Future _showSpoofUpdateDialogIfNeeded() async { + final prefs = await SharedPreferences.getInstance(); + final shouldShow = prefs.getBool('show_spoof_update_dialog') ?? true; + + if (!shouldShow || !mounted) return; + + Future.delayed(const Duration(milliseconds: 500), () { + if (!mounted) return; + + showDialog( + context: context, + barrierDismissible: false, + builder: (BuildContext context) { + bool dontShowAgain = false; + + return StatefulBuilder( + builder: (context, setState) { + return AlertDialog( + title: const Text('Проверка обновлений'), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text('Хотите проверить обновления спуфа?'), + const SizedBox(height: 16), + Row( + children: [ + Checkbox( + value: dontShowAgain, + onChanged: (value) { + setState(() { + dontShowAgain = value ?? false; + }); + }, + ), + const Expanded(child: Text('Больше не показывать')), + ], + ), + ], + ), + actions: [ + TextButton( + onPressed: () async { + if (dontShowAgain) { + final prefs = await SharedPreferences.getInstance(); + await prefs.setBool('show_spoof_update_dialog', false); + } + Navigator.of(context).pop(); + }, + child: const Text('Нет'), + ), + TextButton( + onPressed: () async { + if (dontShowAgain) { + final prefs = await SharedPreferences.getInstance(); + await prefs.setBool('show_spoof_update_dialog', false); + } + Navigator.of(context).pop(); + await _checkSpoofUpdateManually(); + }, + child: const Text('Ок!'), + ), + ], + ); + }, + ); + }, + ); + }); + } + + Future _checkSpoofUpdateManually() async { + try { + final prefs = await SharedPreferences.getInstance(); + + final isAutoUpdateEnabled = prefs.getBool('auto_update_enabled') ?? true; + final currentVersion = prefs.getString('spoof_appversion') ?? '0.0.0'; + final latestVersion = await VersionChecker.getLatestVersion(); + + if (latestVersion != currentVersion) { + if (isAutoUpdateEnabled) { + await prefs.setString('spoof_appversion', latestVersion); + print("Версия сессии обновлена до $latestVersion"); + + try { + await ApiService.instance.performFullReconnection(); + print("Переподключение выполнено успешно"); + } catch (e) { + print("Ошибка переподключения: $e"); + } + + if (mounted) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text('Спуф сессии обновлен до версии $latestVersion'), + backgroundColor: Colors.green.shade700, + behavior: SnackBarBehavior.floating, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + margin: const EdgeInsets.all(10), + ), + ); + } + } else { + if (mounted) { + _showUpdateDialog(context, latestVersion); + } + } + } else { + if (mounted) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: const Text('Версия спуфа актуальна'), + backgroundColor: Colors.blue.shade700, + behavior: SnackBarBehavior.floating, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + margin: const EdgeInsets.all(10), + ), + ); + } + } + } catch (e) { + print("Проверка версии спуфа не удалась: $e"); + if (mounted) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text('Ошибка проверки обновлений: $e'), + backgroundColor: Colors.red.shade700, + behavior: SnackBarBehavior.floating, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + margin: const EdgeInsets.all(10), + ), + ); + } + } + } + void _handleGroupJoinError(Map message) { final errorPayload = message['payload']; String errorMessage = 'Неизвестная ошибка'; @@ -730,7 +863,6 @@ class _DesktopLayoutState extends State<_DesktopLayout> { _loadMyProfile(); } - Future _loadMyProfile() async { if (!mounted) return; setState(() => _isProfileLoading = true); @@ -753,7 +885,6 @@ class _DesktopLayoutState extends State<_DesktopLayout> { } } - void _onChatSelected( Chat chat, Contact contact, diff --git a/lib/screens/settings/bypass_screen.dart b/lib/screens/settings/bypass_screen.dart index 94e7530..6f786b9 100644 --- a/lib/screens/settings/bypass_screen.dart +++ b/lib/screens/settings/bypass_screen.dart @@ -4,7 +4,7 @@ import 'package:gwid/theme_provider.dart'; class BypassScreen extends StatelessWidget { final bool isModal; - + const BypassScreen({super.key, this.isModal = false}); @override @@ -44,8 +44,8 @@ class BypassScreen extends StatelessWidget { ), const SizedBox(height: 8), Text( - "Эта функция позволяет отправлять сообщения заблокированным пользователям, " - "даже если они заблокировали вас. Включите эту опцию, если хотите обойти " + "Эта функция позволяет отправлять сообщения заблокированным пользователям. " + "Включите эту опцию, если хотите обойти " "стандартные ограничения мессенджера.", style: TextStyle(color: colors.onSurfaceVariant), ), @@ -104,7 +104,7 @@ class BypassScreen extends StatelessWidget { ), const SizedBox(width: 8), Text( - "Важно знать", + "ВНИМНИЕ🚨🚨🚨", style: TextStyle( fontWeight: FontWeight.w600, color: colors.primary, @@ -114,7 +114,7 @@ class BypassScreen extends StatelessWidget { ), const SizedBox(height: 8), Text( - "Используя любую из bypass функций мы не несем ответственности за ваш аккаунт", + "Используя любую из bypass функций, вас возможно накажут", style: TextStyle( color: colors.onSurfaceVariant, fontSize: 14, @@ -133,7 +133,6 @@ class BypassScreen extends StatelessWidget { backgroundColor: Colors.transparent, body: Stack( children: [ - GestureDetector( onTap: () => Navigator.of(context).pop(), child: Container( @@ -142,7 +141,6 @@ class BypassScreen extends StatelessWidget { color: Colors.black.withOpacity(0.3), ), ), - Center( child: Container( @@ -162,7 +160,6 @@ class BypassScreen extends StatelessWidget { ), child: Column( children: [ - Container( padding: const EdgeInsets.all(16), decoration: BoxDecoration( @@ -196,7 +193,6 @@ class BypassScreen extends StatelessWidget { ], ), ), - Expanded( child: ListView( @@ -247,11 +243,11 @@ class BypassScreen extends StatelessWidget { builder: (context, themeProvider, child) { return SwitchListTile( title: const Text("Включить обход"), - subtitle: const Text("Активировать функции обхода ограничений"), + subtitle: const Text( + "Активировать функции обхода ограничений", + ), value: false, // Временно отключено - onChanged: (value) { - - }, + onChanged: (value) {}, ); }, ), @@ -277,20 +273,14 @@ class BypassScreen extends StatelessWidget { decoration: BoxDecoration( color: colors.primaryContainer.withOpacity(0.3), borderRadius: BorderRadius.circular(12), - border: Border.all( - color: colors.outline.withOpacity(0.3), - ), + border: Border.all(color: colors.outline.withOpacity(0.3)), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ - Icon( - Icons.info_outline, - color: colors.primary, - size: 20, - ), + Icon(Icons.info_outline, color: colors.primary, size: 20), const SizedBox(width: 8), Text( "Информация", diff --git a/lib/screens/settings/komet_misc_screen.dart b/lib/screens/settings/komet_misc_screen.dart index dd3ea54..b61676d 100644 --- a/lib/screens/settings/komet_misc_screen.dart +++ b/lib/screens/settings/komet_misc_screen.dart @@ -17,6 +17,7 @@ class _KometMiscScreenState extends State { bool _isAutoUpdateEnabled = true; bool _showUpdateNotification = true; bool _enableWebVersionCheck = false; + bool _showSpoofUpdateDialog = true; @override void initState() { @@ -28,12 +29,13 @@ class _KometMiscScreenState extends State { Future _loadUpdateSettings() async { final prefs = await SharedPreferences.getInstance(); setState(() { - _isAutoUpdateEnabled = prefs.getBool('auto_update_enabled') ?? true; _showUpdateNotification = prefs.getBool('show_update_notification') ?? true; _enableWebVersionCheck = prefs.getBool('enable_web_version_check') ?? false; + _showSpoofUpdateDialog = + prefs.getBool('show_spoof_update_dialog') ?? true; }); } @@ -65,7 +67,6 @@ class _KometMiscScreenState extends State { Color statusColor; final defaultTextColor = Theme.of(context).textTheme.bodyMedium?.color; - final isDesktopOrIOS = Platform.isWindows || Platform.isMacOS || @@ -206,6 +207,24 @@ class _KometMiscScreenState extends State { _updateSettings('show_update_notification', value); }, ), + const Divider(height: 1), + SwitchListTile( + secondary: Icon( + Icons.sync_problem_outlined, + color: Theme.of(context).colorScheme.primary, + ), + title: const Text("Диалог обновлений спуфа"), + subtitle: const Text( + "Показывать диалог проверки обновлений спуфа при запуске", + ), + value: _showSpoofUpdateDialog, + onChanged: (bool value) { + setState(() { + _showSpoofUpdateDialog = value; + }); + _updateSettings('show_spoof_update_dialog', value); + }, + ), ], ), ), @@ -239,7 +258,6 @@ class _KometMiscScreenState extends State { backgroundColor: Colors.transparent, body: Stack( children: [ - GestureDetector( onTap: () => Navigator.of(context).pop(), child: Container( @@ -249,7 +267,6 @@ class _KometMiscScreenState extends State { ), ), - Center( child: Container( width: 400, @@ -268,7 +285,6 @@ class _KometMiscScreenState extends State { ), child: Column( children: [ - Container( padding: const EdgeInsets.all(16), decoration: BoxDecoration( @@ -303,7 +319,6 @@ class _KometMiscScreenState extends State { ), ), - Expanded( child: ListView( padding: const EdgeInsets.all(16.0), @@ -367,6 +382,22 @@ class _KometMiscScreenState extends State { ); }, ), + SwitchListTile( + title: const Text("Диалог обновлений спуфа"), + subtitle: const Text( + "Показывать диалог проверки обновлений спуфа при запуске", + ), + value: _showSpoofUpdateDialog, + onChanged: (value) { + setState(() { + _showSpoofUpdateDialog = value; + }); + _updateSettings( + 'show_spoof_update_dialog', + value, + ); + }, + ), SwitchListTile( title: const Text("Проверка веб-версии"), subtitle: const Text( @@ -403,7 +434,6 @@ class _KometMiscScreenState extends State { Color statusColor; final defaultTextColor = Theme.of(context).textTheme.bodyMedium?.color; - final isDesktopOrIOS = Platform.isWindows || Platform.isMacOS || @@ -494,6 +524,24 @@ class _KometMiscScreenState extends State { _updateSettings('show_update_notification', value); }, ), + SwitchListTile( + contentPadding: const EdgeInsets.symmetric(horizontal: 16), + secondary: Icon( + Icons.sync_problem_rounded, + color: Theme.of(context).colorScheme.primary, + ), + title: const Text("Диалог обновлений спуфа"), + subtitle: const Text( + "Показывать диалог проверки обновлений спуфа при запуске", + ), + value: _showSpoofUpdateDialog, + onChanged: (value) { + setState(() { + _showSpoofUpdateDialog = value; + }); + _updateSettings('show_spoof_update_dialog', value); + }, + ), SwitchListTile( contentPadding: const EdgeInsets.symmetric(horizontal: 16), secondary: Icon(